-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrand-ide.php
More file actions
98 lines (88 loc) · 3.62 KB
/
Copy pathrand-ide.php
File metadata and controls
98 lines (88 loc) · 3.62 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
<?php
/*
Plugin Name: Rand IgnitionDeck Customization
URI:
Description: An IgnitionDeck customization for Rand
Version: 1.0
Author: IgnitionDeck
Author URI: http://IgnitionDeck.com
License: GPL2
*/
include_once 'rand-ide-admin.php';
function randide_activate() {
// If class ID_Member doesn't exist, deactivate the plugin
if (!class_exists('ID_Member')) {
deactivate_plugins($plugins_path.'rand-ide/rand-ide.php');
}
}
register_activation_hook( __FILE__, 'randide_activate' );
/**
* Hook to check ID_Member class exists, if yes then activate this plugin
* randide_activate_check()
*/
function randide_activate_check() {
// If class ID_Member doesn't exist, deactivate the plugin
if (!class_exists('ID_Member')) {
deactivate_plugins(plugin_basename(__FILE__));
}
}
add_action( 'admin_init', 'randide_activate_check' );
/**
* Deactivate this plugin if IDCommerce plugin is deactivated
* detect_plugin_deactivation()
*/
function detect_plugin_deactivation( $plugin, $network_activation ) {
if ($plugin == "idcommerce/idcommerce.php" ) {
deactivate_plugins( plugin_basename(__FILE__) );
}
}
add_action( 'deactivated_plugin', 'detect_plugin_deactivation', 10, 2 );
/**
* Action to store the default project end date in case of Rand customization, called on Project Creation
* It's a hook function called from ignitiondeck-enterprise.php
*/
function rand_set_project_end_date($user_id, $project_id, $post_id, $proj_args, $saved_levels, $project_fund_type) {
// Getting the default end date from the options
$default_proj_end_date = get_option( "ign_default_project_end_date" );
// If date is not null, then update the meta to store that date
if ($default_proj_end_date != "") {
update_post_meta($post_id, 'ign_fund_end', $default_proj_end_date);
}
}
//add_action('ide_fes_create', 'rand_set_project_end_date');
/**
* Action to store the default project end date in case of Rand customization, called on Project Updation
* It's a hook function called from ignitiondeck-enterprise.php
* Though this action is not needed, but in case the user (creator) has tried to change it forcefully.
*/
function rand_update_project_end_date($user_id, $project_id, $post_id, $proj_args, $saved_levels, $project_fund_type) {
// Getting the default end date from the options
$default_proj_end_date = get_option( "ign_default_project_end_date" );
// If date is not null, then update the meta to store that date
if ($default_proj_end_date != "") {
update_post_meta($post_id, 'ign_fund_end', $default_proj_end_date);
}
}
//add_action('ide_fes_update', 'rand_update_project_end_date');
function rand_enqueue_scripts() {
// If we are on the create_project page (FES form), then hide project end date field
if ( (isset($_GET['create_project']) || isset($_GET['edit_project'])) && is_user_logged_in() ) {
// Check if default project end date is set and not Null
$default_proj_end_date = get_option( "ign_default_project_end_date" );
if (!empty($default_proj_end_date)) {
// Hiding project end date field using jQuery
wp_register_script('rand-ide', plugins_url('js/rand-ide.js', __FILE__));
wp_enqueue_script('jquery');
wp_enqueue_script( 'rand-ide');
$default_proj_end_date = get_option( "ign_default_project_end_date" );
wp_localize_script('rand-ide', 'randEndDate', $default_proj_end_date);
}
}
}
add_action( 'wp_enqueue_scripts', 'rand_enqueue_scripts' );
function rand_fes_creation_actions($user_id, $project_id, $post_id, $proj_args, $saved_levels, $project_fund_type) {
// Publish the post directly in Rand plugin
wp_publish_post( $post_id );
}
add_action('ide_fes_create', 'rand_fes_creation_actions', 10, 6);
?>