Esempio n. 1
0
 /**
  * Run manually when a version mismatch is detected.
  *
  * Called in admin_init and on activation hook.
  *
  * @todo Need a better way of handling adding capabilities since this function is not activated when premium features are added.
  * @since 0.1
  *
  */
 static function manual_activation($args = '')
 {
     global $wp_crm, $wp_roles;
     $defaults = array('auto_redirect' => 'false', 'update_caps' => 'true');
     $args = wp_parse_args($args, $defaults);
     $installed_ver = get_option("wp_crm_version");
     if (@version_compare($installed_ver, WP_CRM_Version) == '-1') {
         if (!empty($installed_ver)) {
             //** Handle any updates related to version changes */
             WP_CRM_F::handle_update($installed_ver);
         }
         // Unschedule event
         $timestamp = wp_next_scheduled('wp_crm_premium_feature_check');
         wp_unschedule_event($timestamp, 'wp_crm_premium_feature_check');
         wp_clear_scheduled_hook('wp_crm_premium_feature_check');
         // Schedule event
         wp_schedule_event(time(), 'daily', 'wp_crm_premium_feature_check');
         // Update option to latest version so this isn't run on next admin page load
         update_option("wp_crm_version", WP_CRM_Version);
         //** Get premium features on activation */
         @WP_CRM_F::feature_check();
         $args['update_caps'] = 'true';
         //$args['auto_redirect'] = 'true';
     }
     //** load this here to get the capabilities */
     include_once WP_CRM_Path . '/action_hooks.php';
     //** Add capabilities */
     if ($args['update_caps'] == 'true' && (is_array($wp_crm['capabilities']) && $wp_roles)) {
         if (is_array($wp_crm['capabilities'])) {
             foreach ($wp_crm['capabilities'] as $capability => $description) {
                 $wp_roles->add_cap('administrator', 'WP-CRM: ' . $capability, true);
             }
             update_option('wp_crm_caps_set', true);
         }
     }
     if ($args['auto_redirect'] == 'true') {
         //** Redirect to overview page so all updates take affect on page reload. Not done on activation() */
         die(wp_redirect(admin_url('admin.php?page=wp_crm&message=plugin_updated')));
     }
     return;
 }
Esempio n. 2
0
 /**
  * Run manually when a version mismatch is detected.
  *
  * Called in admin_init and on activation hook.
  * @since 0.1
  *
  */
 static function manual_activation($args = '')
 {
     global $wp_crm, $wp_roles;
     $defaults = array('auto_redirect' => 'false', 'update_caps' => 'true');
     $args = wp_parse_args($args, $defaults);
     $installed_ver = get_option("wp_crm_version");
     if (@version_compare($installed_ver, WP_CRM_Version) == '-1') {
         if (!empty($installed_ver)) {
             //** Handle any updates related to version changes */
             WP_CRM_F::handle_update($installed_ver);
         }
         // Update option to latest version so this isn't run on next admin page load
         update_option("wp_crm_version", WP_CRM_Version);
         $args['update_caps'] = 'true';
         //$args['auto_redirect'] = 'true';
     }
     //** load this here to get the capabilities */
     include_once ud_get_wp_crm()->path("action_hooks.php", 'dir');
     //** Add capabilities */
     if ($args['update_caps'] == 'true' && (!empty($wp_crm['capabilities']) && is_array($wp_crm['capabilities']) && $wp_roles)) {
         if (is_array($wp_crm['capabilities'])) {
             foreach ($wp_crm['capabilities'] as $capability => $description) {
                 $wp_roles->add_cap('administrator', 'WP-CRM: ' . $capability, true);
             }
             update_option('wp_crm_caps_set', true);
         }
     }
     if ($args['auto_redirect'] == 'true') {
         //** Redirect to overview page so all updates take affect on page reload. Not done on activation() */
         die(wp_redirect(admin_url('admin.php?page=wp_crm&message=plugin_updated')));
     }
     return;
 }