public function set_license($key = NULL, $product = NULL)
 {
     if ($key === NULL && $this->license_key_k === NULL) {
         return;
     }
     if ($key !== NULL) {
         $this->slug = $key;
         $this->need_license = TRUE;
         $this->license_key_k = $key . '-license-key';
         $this->product = $product;
     }
     if (is_multisite()) {
         $options = new WPFront_User_Role_Editor_Options($this->main);
         switch_to_blog($options->ms_options_blog_id());
     }
     $entity = new WPFront_User_Role_Editor_Entity_Options();
     $this->license_key = $entity->get_option($this->license_key_k);
     if ($this->license_key !== NULL) {
         $last_checked = $entity->get_option($this->license_key_k . '-last-checked');
         if ($last_checked < time() - 24 * 3600) {
             $entity->update_option($this->license_key_k . '-last-checked', time());
             $result = $this->remote_get('check_license', $this->license_key);
             if (!empty($result)) {
                 if (($result->activations_left === 'unlimited' || $result->activations_left >= 0) && ($result->license === 'valid' || $result->license === 'expired')) {
                     $entity->update_option($this->license_key_k . '-status', $result->license);
                     $entity->update_option($this->license_key_k . '-expires', $result->expires);
                     $entity->update_option($this->license_key_k . '-invalid-count', 0);
                 } else {
                     $invalid_count = $entity->get_option($this->license_key_k . '-invalid-count');
                     if (empty($invalid_count)) {
                         $invalid_count = 0;
                     }
                     $invalid_count = $invalid_count + 1;
                     $entity->update_option($this->license_key_k . '-invalid-count', $invalid_count);
                     $this->license_status = 'invalid';
                     if ($invalid_count === 1) {
                         $this->send_mail('invalid', $result, 'wpfront.com');
                     } else {
                         if ($invalid_count > 7) {
                             $this->deactivate_license(TRUE);
                             $this->send_mail('deactivated', $result, 'wpfront.com');
                             return;
                         }
                     }
                 }
             }
         }
         $this->has_license = TRUE;
         $this->license_expired = $entity->get_option($this->license_key_k . '-status') === 'expired';
         $this->license_expires = date('F d, Y', strtotime($entity->get_option($this->license_key_k . '-expires')));
         $invalid_count = $entity->get_option($this->license_key_k . '-invalid-count');
         if ($invalid_count > 0) {
             $this->license_status = 'invalid';
         }
         if ($this->license_status === NULL) {
             if ($this->license_expired) {
                 $this->license_status = 'expired';
             } else {
                 $this->license_status = 'valid';
             }
         }
         $this->license_key = str_repeat('X', strlen($this->license_key) - 4) . substr($this->license_key, strlen($this->license_key) - 4, 4);
         //Software licensing change
         $this->edd_plugin_update();
         //add_action('admin_init', array($this, 'edd_plugin_update'));
     } else {
         $this->license_key = '';
         $this->has_license = FALSE;
         $this->license_expires = NULL;
     }
     if (is_multisite()) {
         restore_current_blog();
     }
 }
Beispiel #2
0
    switch_to_blog(WPFront_User_Role_Editor_Options::get_ms_options_blog_id());
    $entity = new WPFront_User_Role_Editor_Options(NULL);
    if ($entity->remove_data_on_uninstall()) {
        foreach ($blogids as $blogid) {
            switch_to_blog($blogid);
            WPFront_User_Role_Editor_Entity_Options::uninstall();
            WPFront_User_Role_Editor_Entity_Menu_Editor::uninstall();
            WPFront_User_Role_Editor_Entity_Post_Type_Permissions::uninstall();
            WPFront_User_Role_Editor_Entity_Content_Shortcodes::uninstall();
            WPFront_User_Role_Editor_Entity_Login_Redirect::uninstall();
            WPFront_User_Role_Editor_Nav_Menu::uninstall();
        }
    }
    restore_current_blog();
} else {
    $entity = new WPFront_User_Role_Editor_Options(NULL);
    if ($entity->remove_data_on_uninstall()) {
        if (class_exists('WPFront_User_Role_Editor_Entity_Options')) {
            WPFront_User_Role_Editor_Entity_Options::uninstall();
        }
        if (class_exists('WPFront_User_Role_Editor_Entity_Menu_Editor')) {
            WPFront_User_Role_Editor_Entity_Menu_Editor::uninstall();
        }
        if (class_exists('WPFront_User_Role_Editor_Entity_Post_Type_Permissions')) {
            WPFront_User_Role_Editor_Entity_Post_Type_Permissions::uninstall();
        }
        if (class_exists('WPFront_User_Role_Editor_Entity_Content_Shortcodes')) {
            WPFront_User_Role_Editor_Entity_Content_Shortcodes::uninstall();
        }
        if (class_exists('WPFront_User_Role_Editor_Entity_Login_Redirect')) {
            WPFront_User_Role_Editor_Entity_Login_Redirect::uninstall();
 public function set_license($key = NULL, $product = NULL)
 {
     if ($key === NULL && $this->license_key_k === NULL) {
         return;
     }
     if ($key !== NULL) {
         $this->need_license = TRUE;
         $this->license_key_k = $key . '-license-key';
         $this->product = $product;
     }
     if (is_multisite()) {
         $options = new WPFront_User_Role_Editor_Options($this->main);
         switch_to_blog($options->ms_options_blog_id());
     }
     $entity = new WPFront_User_Role_Editor_Entity_Options();
     $this->license_key = $entity->get_option($this->license_key_k);
     if ($this->license_key !== NULL) {
         $last_checked = $entity->get_option($this->license_key_k . '-last-checked');
         if ($last_checked < time() - 24 * 3600) {
             $entity->update_option($this->license_key_k . '-last-checked', time());
             $result = $this->remote_get('check_license', $this->license_key);
             if (($result->activations_left === 'unlimited' || $result->activations_left >= 0) && ($result->license === 'valid' || $result->license === 'expired')) {
                 $entity->update_option($this->license_key_k . '-status', $result->license);
                 $entity->update_option($this->license_key_k . '-expires', $result->expires);
             } else {
                 $this->deactivate_license(TRUE);
                 return;
             }
         }
         $this->has_license = TRUE;
         $this->license_expired = $entity->get_option($this->license_key_k . '-status') === 'expired';
         $this->license_expires = date('F d, Y', strtotime($entity->get_option($this->license_key_k . '-expires')));
         for ($i = 0; $i < strlen($this->license_key) - 4; $i++) {
             $this->license_key = substr_replace($this->license_key, 'X', $i, 1);
         }
         //Software licensing change
         $this->edd_plugin_update();
         //add_action('admin_init', array($this, 'edd_plugin_update'));
     } else {
         $this->license_key = '';
         $this->has_license = FALSE;
         $this->license_expires = NULL;
     }
     if (is_multisite()) {
         restore_current_blog();
     }
 }