public function check_license($new_license = false, $force_check = false)
 {
     $license = emodal_get_license();
     if ($new_license == '') {
         emodal_delete_option(EMCORE_SLUG . '-license');
         delete_site_transient(EMCORE_SLUG . '-license-check');
         delete_transient(EMCORE_SLUG . '-addon-list');
         return;
     }
     if ($new_license && $new_license != $license['key'] && SHA1($new_license) != $license['key']) {
         $license = array('valid' => false, 'key' => $new_license != '' ? SHA1($new_license) : '', 'status' => array('code' => NULL, 'message' => NULL, 'expires' => NULL, 'domains' => NULL));
         if ($new_license != '') {
             $force_check = true;
         }
         emodal_update_option(EMCORE_SLUG . '-license', $license);
     }
     if ($force_check || $license['valid'] && !get_site_transient(EMCORE_SLUG . '-license-check')) {
         $status = $this->api_request('license_check');
         if (is_array($status) && in_array($status['code'], $this->unactivated_status_codes)) {
             $status = $this->api_request('activate_domain');
             //$this->api_request('license_check');
         }
         if (is_array($status) && in_array($status['code'], $this->valid_status_codes)) {
             $license['valid'] = true;
         } else {
             if ($status instanceof WP_Error) {
                 $status = array('code' => 00, 'message' => $status->error);
             }
         }
         $license['status'] = $status;
         emodal_update_option(EMCORE_SLUG . '-license', $license);
         set_site_transient(EMCORE_SLUG . '-license-check', true, 365 * (60 * 60 * 24) / 12);
         delete_transient(EMCORE_SLUG . '-addon-list');
     }
     return $license;
 }
 public function reset_emodal_db()
 {
     if (isset($_POST['remove_old_emodal_data'])) {
         // run a quick security check
         if (!check_admin_referer(EMCORE_NONCE, EMCORE_NONCE)) {
             return;
         }
         // get out if we didn't click the Activate button
         global $wpdb;
         $wpdb->query("DELETE FROM {$wpdb->options} WHERE `option_name` LIKE 'EasyModal%';");
         do_action('remove_old_emodal_data');
     }
     if (isset($_POST['reset_emodal_db'])) {
         // run a quick security check
         if (!check_admin_referer(EMCORE_NONCE, EMCORE_NONCE)) {
             return;
         }
         // get out if we didn't click the Activate button
         global $wpdb;
         $wpdb->query("DROP TABLE IF EXISTS `{$wpdb->em_modal_metas}`;");
         $wpdb->query("DROP TABLE IF EXISTS `{$wpdb->em_modals}`;");
         $wpdb->query("DROP TABLE IF EXISTS `{$wpdb->em_theme_metas}`;");
         $wpdb->query("DROP TABLE IF EXISTS `{$wpdb->em_themes}`;");
         emodal_delete_option(EMCORE_SLUG . '_db_version');
         do_action('emodal_db_update', false);
         /*
         $wpdb->query( "DELETE FROM $wpdb->em_modal_metas" );
         $wpdb->query( "DELETE FROM $wpdb->em_modals" );
         $wpdb->query( "DELETE FROM $wpdb->em_theme_metas" );
         $wpdb->query( "DELETE FROM $wpdb->em_themes" );
         */
         do_action('emodal_reset_db');
     }
     if (isset($_POST['migrate_emodal_db'])) {
         // run a quick security check
         if (!check_admin_referer(EMCORE_NONCE, EMCORE_NONCE)) {
             return;
         }
         // get out if we didn't click the Activate button
         if (emodal_get_option('EasyModal_Version')) {
             global $wpdb;
             $wpdb->query("DELETE FROM {$wpdb->em_modal_metas}");
             $wpdb->query("DELETE FROM {$wpdb->em_modals}");
             $wpdb->query("DELETE FROM {$wpdb->em_theme_metas}");
             $wpdb->query("DELETE FROM {$wpdb->em_themes}");
             new EModal_Migrate_Pre_V2();
             do_action('emodal_migrate_db');
         }
     }
     if (isset($_POST['uninstall_emodal_db'])) {
         // run a quick security check
         if (!check_admin_referer(EMCORE_NONCE, EMCORE_NONCE)) {
             return;
         }
         // get out if we didn't click the Activate button
         global $wpdb;
         $wpdb->query("DROP TABLE IF EXISTS `{$wpdb->em_modal_metas}`;");
         $wpdb->query("DROP TABLE IF EXISTS `{$wpdb->em_modals}`;");
         $wpdb->query("DROP TABLE IF EXISTS `{$wpdb->em_theme_metas}`;");
         $wpdb->query("DROP TABLE IF EXISTS `{$wpdb->em_themes}`;");
         $wpdb->query("DELETE FROM {$wpdb->options} WHERE `option_name` LIKE 'easy-modal%';");
         do_action('emodal_uninstall');
         emodal_update_option(EMCORE_SLUG . '_uninstalled', true);
     }
 }
 public static function delete_all()
 {
     foreach (self::get_themes() as $theme) {
         delete_option('EasyModal_Theme-' . $theme['id']);
     }
     delete_option('EasyModal_ThemeList');
     foreach (self::get_modals() as $modal) {
         delete_option('EasyModal_Modal-' . $modal['id']);
     }
     delete_option('EasyModal_ModalList');
     delete_option('EasyModal_Settings');
     delete_option('EasyModal_License');
     delete_option('EasyModal_License_Status');
     delete_option('EasyModal_License_LastChecked');
     delete_option('EasyModal_Version');
     emodal_delete_option(EMCORE_SLUG . '_migration_approval');
     emodal_delete_option(EMCORE_SLUG . '_migration_approved');
 }
Exemple #4
0
 public function deactivate()
 {
     emodal_delete_option(EMCORE_SLUG . '_uninstalled');
 }