예제 #1
0
 /**
  * Plugin Activation
  *
  */
 public function activate()
 {
     if (!class_exists('\\WP_CRM_F')) {
         include_once ud_get_wp_crm()->path("lib/class_functions.php", 'dir');
     }
     \WP_CRM_F::maybe_install_tables();
     \WP_CRM_F::manual_activation('auto_redirect=false&update_caps=true');
 }
예제 #2
0
 /**
  * Installs tables and runs WP_CRM_F::manual_activation() which actually handles the upgrades
  *
  * @since 0.01
  *
  */
 static function activation()
 {
     WP_CRM_F::maybe_install_tables();
     WP_CRM_F::manual_activation('auto_redirect=false&update_caps=true');
 }
 /**
  * Primary init of WP_CRM_Core, gets called by after_setup_theme.
  *
  * Register scripts.
  * Register styles.
  * Load premium features.
  *
  * @since 0.01
  *
  * @uses $wp_crm WP-CRM configuration array
  *
  */
 function init()
 {
     global $wpdb, $wp_crm, $wp_roles;
     /** Loads all the class for handling all plugin tables */
     include_once WP_CRM_Path . '/core/class_list_table.php';
     if ($wp_crm['configuration']['track_detailed_user_activity'] == 'true') {
         WP_CRM_F::track_detailed_user_activity();
     }
     wp_register_script('google-jsapi', 'https://www.google.com/jsapi');
     wp_register_script('jquery-cookie', WP_CRM_URL . '/third-party/jquery.smookie.js', array('jquery'), '1.7.3');
     wp_register_script('swfobject', WP_CRM_URL . '/third-party/swfobject.js', array('jquery'));
     wp_register_script('jquery-uploadify', WP_CRM_URL . '/third-party/uploadify/jquery.uploadify.v2.1.4.min.js', array('jquery', 'swfobject'));
     wp_register_script('jquery-position', WP_CRM_URL . '/third-party/jquery.ui.position.min.js', array('jquery-ui-core'));
     wp_register_script('jquery-slider', WP_CRM_URL . '/third-party/jquery.ui.slider.min.js', array('jquery-ui-core'));
     wp_register_script('jquery-widget', WP_CRM_URL . '/third-party/jquery.ui.widget.min.js', array('jquery-ui-core'));
     wp_register_script('jquery-datepicker', WP_CRM_URL . '/third-party/jquery.ui.datepicker.js', array('jquery-ui-core'));
     wp_register_script('jquery-autocomplete', WP_CRM_URL . '/third-party/jquery.ui.autocomplete.min.js', array('jquery-widget', 'jquery-position'));
     wp_register_script('wp-crm-data-tables', WP_CRM_URL . '/third-party/dataTables/jquery.dataTables.min.js', array('jquery'));
     wp_register_script('wp_crm_global', WP_CRM_URL . '/js/wp_crm_global.js', array('jquery'), WP_CRM_Version, true);
     wp_register_script('wp_crm_profile_editor', WP_CRM_URL . '/js/wp_crm_profile_editor.js', array('wp_crm_global'), WP_CRM_Version, true);
     // Find and register theme-specific style if a custom wp_properties.css does not exist in theme
     $theme_slug = get_option('stylesheet');
     if (file_exists(WP_CRM_Templates . "/theme-specific/{$theme_slug}.css")) {
         wp_register_style('wp-crm-theme-specific', WP_CRM_URL . "/templates/theme-specific/{$theme_slug}.css", array('wp-crm-default-styles'), WP_CRM_Version);
     }
     //** Load default styles */
     if (file_exists(WP_CRM_Path . "/templates/wp-crm-default-styles.css")) {
         wp_register_style('wp-crm-default-styles', WP_CRM_URL . "/templates/wp-crm-default-styles.css", array(), WP_CRM_Version);
     }
     if (file_exists(WP_CRM_Path . "/css/wp_crm_global.css")) {
         wp_register_style('wp_crm_global', WP_CRM_URL . "/css/wp_crm_global.css", array(), WP_CRM_Version);
     }
     wp_register_style('wp-crm-data-tables', WP_CRM_URL . "/css/crm-data-tables.css", array(), WP_CRM_Version);
     // Plug page actions -> Add Settings Link to plugin overview page
     add_filter('plugin_action_links', array('WP_CRM_Core', 'plugin_action_links'), 10, 2);
     // Setup pages and overview columns
     add_action("admin_menu", array('WP_CRM_Core', "admin_menu"), 100);
     add_filter("retrieve_password_message", array('WP_CRM_F', "retrieve_password_message"));
     //** Modify default WP password reset message */
     add_filter("admin_body_class", create_function('', "return WP_CRM_Core::admin_body_class(); "));
     //** Load back-end scripts */
     add_action("admin_enqueue_scripts", array('WP_CRM_Core', "admin_enqueue_scripts"));
     add_action("wp_ajax_wp_crm_csv_export", create_function('', ' WP_CRM_F::csv_export($_REQUEST["wp_crm_search"]); die();'));
     add_action("wp_ajax_wp_crm_visualize_results", create_function('', ' WP_CRM_F::visualize_results($_REQUEST["filters"]); die();'));
     add_action('wp_ajax_wp_crm_check_plugin_updates', create_function("", '  echo WP_CRM_F::check_plugin_updates(); die();'));
     add_action("wp_ajax_wp_crm_user_object", create_function('', ' echo "CRM Object Report: \\n" . print_r(wp_crm_get_user($_REQUEST[user_id]), true) . "\\nRaw Meta Report: \\n" .  print_r(WP_CRM_F::show_user_meta_report($_REQUEST[user_id]), true); '));
     add_action("wp_ajax_wp_crm_show_meta_report", create_function('', ' die(print_r(WP_CRM_F::show_user_meta_report(), true)); '));
     add_action("wp_ajax_wp_crm_get_user_activity_stream", create_function('', ' echo WP_CRM_F::get_user_activity_stream("user_id={$_REQUEST[user_id]}"); die; '));
     add_action("wp_ajax_wp_crm_insert_activity_message", create_function('', ' echo WP_CRM_F::insert_event("time={$_REQUEST[time]}&attribute=note&object_id={$_REQUEST[user_id]}&text={$_REQUEST[content]}&ajax=true"); die; '));
     add_action("wp_ajax_wp_crm_get_notification_template", create_function('', ' echo WP_CRM_F::get_notification_template($_REQUEST["template_slug"]); die; '));
     add_action("wp_ajax_wp_crm_do_fake_users", create_function('', ' echo WP_CRM_F::do_fake_users("number={$_REQUEST[number]}&do_what={$_REQUEST[do_what]}"); die; '));
     add_action("wp_ajax_wp_crm_list_table", create_function('', ' echo WP_CRM_F::ajax_table_rows(); die; '));
     add_action("wp_ajax_wp_crm_quick_action", create_function('', ' echo WP_CRM_F::quick_action(); die; '));
     add_action("admin_init", array('WP_CRM_Core', "admin_init"));
     add_action("admin_head", array('WP_CRM_Core', "admin_head"));
     //* Init action hook */
     do_action('wp_crm_init');
     add_action('load-toplevel_page_wp_crm', array('WP_CRM_Core', 'toplevel_page_wp_crm'));
     add_action('load-crm_page_wp_crm_settings', array('WP_CRM_Core', 'crm_page_wp_crm_settings'));
     add_action('load-crm_page_wp_crm_add_new', array('WP_CRM_Core', 'crm_page_wp_crm_add_new'));
     //** Take over traditional user pages if option is enabled */
     add_action('load-user-edit.php', array('WP_CRM_Core', 'crm_page_traditional_user_page'));
     add_action('load-users.php', array('WP_CRM_Core', 'crm_page_traditional_user_page'));
     add_action('load-user-new.php', array('WP_CRM_Core', 'crm_page_traditional_user_page'));
     add_action("template_redirect", array('WP_CRM_Core', "template_redirect"));
     add_action("deleted_user", array('WP_CRM_F', "deleted_user"));
     //** Check if installed DB version is older than THIS version */
     if (is_admin()) {
         if (!get_option('wp_crm_caps_set')) {
             WP_CRM_F::manual_activation('update_caps=true&auto_redirect=true');
         }
         //** Load defaults */
         WP_CRM_F::manual_activation();
     }
 }
 /**
  * Installs tables and runs WP_CRM_F::manual_activation() which actually handles the upgrades
  *
  * @since 0.01
  *
  */
 function activation()
 {
     global $current_user, $wp_crm, $wp_roles;
     WP_CRM_F::maybe_install_tables();
     WP_CRM_F::manual_activation('auto_redirect=false&update_caps=true');
 }
예제 #5
0
 /**
  * Runs pre-header functions on admin-side only - ran on ALL admin pages
  *
  * Checks if plugin has been updated.
  *
  * @since 0.1
  *
  */
 static function admin_init()
 {
     global $wp_crm, $wpdb, $current_user;
     //** Check if current page is profile page, and load global variable */
     WP_CRM_F::maybe_load_profile();
     do_action('wp_crm_metaboxes');
     //** Add overview table rows. Static because admin_menu is not loaded on ajax calls. */
     add_filter("manage_toplevel_page_wp_crm_columns", array('WP_CRM_Core', "overview_columns"));
     if (!empty($wp_crm['system']['pages']['settings'])) {
         add_action('admin_print_scripts-' . $wp_crm['system']['pages']['settings'], create_function('', "wp_enqueue_script('jquery-ui-tabs');wp_enqueue_script('jquery-cookie');"));
     }
     add_action('load-crm_page_wp_crm_add_new', array('WP_CRM_Core', 'wp_crm_save_user_data'));
     // Add metaboxes
     if (!empty($wp_crm['system']['pages']) && is_array($wp_crm['system']['pages'])) {
         $sidebar_boxes = array('special_actions');
         foreach ($wp_crm['system']['pages'] as $screen) {
             if (!class_exists($screen)) {
                 continue;
             }
             $location_prefixes = array('side_', 'normal_', 'advanced_');
             foreach (get_class_methods($screen) as $box) {
                 // Set context and priority if specified for box
                 $context = 'normal';
                 if (strpos($box, "side_") === 0 || in_array($box, $sidebar_boxes)) {
                     $context = 'side';
                 }
                 if (strpos($box, "advanced_") === 0) {
                     $context = 'advanced';
                 }
                 // Get name from slug
                 $label = CRM_UD_F::slug_to_label(str_replace($location_prefixes, '', $box));
                 add_meta_box($box, $label, array($screen, $box), $screen, $context, 'default');
             }
         }
     }
     //** Handle actions */
     if (isset($_REQUEST['wp_crm_action'])) {
         $_wpnonce = $_REQUEST['_wpnonce'];
         switch ($_REQUEST['wp_crm_action']) {
             case 'delete_user':
                 $user_id = $_REQUEST['user_id'];
                 if (wp_verify_nonce($_wpnonce, 'wp-crm-delete-user-' . $user_id)) {
                     //** Get IDs of users posts */
                     $post_ids = $wpdb->get_col($wpdb->prepare("SELECT ID FROM {$wpdb->posts} WHERE post_author = %d", $user_id));
                     //** Delete user and reassign all their posts to the current user */
                     if (wp_delete_user($user_id, $current_user->data->ID)) {
                         //** Trash all posts */
                         if (is_array($post_ids)) {
                             foreach ($post_ids as $trash_post) {
                                 wp_trash_post($trash_post);
                             }
                         }
                         wp_redirect(admin_url('admin.php?page=wp_crm&message=user_deleted'));
                     }
                 }
                 break;
         }
     }
     if (!empty($wp_crm['configuration']['replace_default_user_page']) && $wp_crm['configuration']['replace_default_user_page'] == 'true') {
         add_filter('admin_user_info_links', array('WP_CRM_Core', 'admin_user_info_links'), 10, 2);
     }
     add_filter('admin_title', array('WP_CRM_F', 'admin_title'));
     WP_CRM_F::manual_activation();
 }