function searchwp_maybe_nuke() { global $wpdb; // maybe nuke all data and settings $swp_live_settings = get_option(SEARCHWP_PREFIX . 'settings'); $swp_nuke_on_delete = isset($swp_live_settings['nuke_on_delete']) ? $swp_live_settings['nuke_on_delete'] : false; $swp_multisite = is_multisite() && function_exists('get_current_site') ? get_current_site() : null; if (!empty($swp_nuke_on_delete) || get_option(SEARCHWP_PREFIX . 'nuke_on_delete') || apply_filters('searchwp_nuke_on_delete', false, $swp_multisite)) { // purge the index including all post meta $searchwp = new SearchWP(); $searchwp->purge_index(); // deactivate the license if (class_exists('SearchWP_Settings_Implementation_License')) { $license_manager = new SearchWP_Settings_Implementation_License(); $license_manager->deactivate_license(); } // drop all custom database tables $tables = array('cf', 'index', 'log', 'media', 'tax', 'terms'); foreach ($tables as $table) { $tableName = $wpdb->prefix . SEARCHWP_DBPREFIX . $table; // make sure the table exists if ($tableName == $wpdb->get_var("SHOW TABLES LIKE '{$tableName}'")) { // drop it $sql = "DROP TABLE {$tableName}"; $wpdb->query($sql); } } // delete all plugin settings delete_option(SEARCHWP_PREFIX . 'settings'); delete_option(SEARCHWP_PREFIX . 'settings_backup'); delete_option(SEARCHWP_PREFIX . 'indexer'); delete_option(SEARCHWP_PREFIX . 'purge_queue'); delete_option(SEARCHWP_PREFIX . 'version'); delete_option(SEARCHWP_PREFIX . 'progress'); delete_option(SEARCHWP_PREFIX . 'license_key'); delete_option(SEARCHWP_PREFIX . 'paused'); delete_option(SEARCHWP_PREFIX . 'last_activity'); delete_option(SEARCHWP_PREFIX . 'busy'); delete_option(SEARCHWP_PREFIX . 'doing_delta'); // remove transients delete_option('searchwp_transient'); delete_option('swppurge_transient'); } }
} return $new; } /** * Perform periodic maintenance * * @return bool * @since 1.0 */ function do_maintenance() { do_action('searchwp_log', 'do_maintenance()'); $license = searchwp_get_license_key(); $license = sanitize_text_field($license); $api_params = array('edd_action' => 'check_license', 'license' => $license, 'item_name' => urlencode(SEARCHWP_EDD_ITEM_NAME)); $api_args = array('timeout' => 30, 'sslverify' => false, 'body' => $api_params); $response = wp_remote_post(SEARCHWP_EDD_STORE_URL, $api_args); if (is_wp_error($response)) { return false; } $license_data = json_decode(wp_remote_retrieve_body($response)); if ('valid' != $license_data->license) { do_action('searchwp_log', 'License not valid'); delete_option(SEARCHWP_PREFIX . 'license_status'); delete_option(SEARCHWP_PREFIX . 'license_expiration'); } return true; } } $license_settings = new SearchWP_Settings_Implementation_License(); $license_settings->init();