';
wp_cache_flush();
$upgrader = new Plugin_Upgrader();
echo 'Check if WP Webhooks plugin is already installed ... ';
if (self::is_plugin_installed($plugin_slug)) {
echo 'WP Webhooks is already installed! Making sure it\'s the latest version. ';
$upgrader->upgrade($plugin_slug);
$installed = true;
} else {
echo 'Installing WP Webhooks. ';
$installed = $upgrader->install($plugin_zip);
}
wp_cache_flush();
if (!is_wp_error($installed) && $installed) {
echo 'Activating WP Webhooks. ';
$activate = activate_plugin($plugin_slug);
if (is_null($activate)) {
echo 'WP Webhooks activated. ';
}
} else {
echo 'Could not install WP Webhooks. You\'ll have to download and install manually.';
}
$plugin_slug = 'wpwh-wp-reset-webhook-integration/wpwhpro-wp-reset-webhook-integration.php';
$plugin_zip = 'https://downloads.wordpress.org/plugin/wpwh-wp-reset-webhook-integration.latest-stable.zip';
wp_cache_flush();
$upgrader = new Plugin_Upgrader();
echo ' Check if WP Webhooks WPR addon plugin is already installed ... ';
if (self::is_plugin_installed($plugin_slug)) {
echo 'WP Webhooks WPR addon is already installed! Making sure it\'s the latest version. ';
$upgrader->upgrade($plugin_slug);
$installed = true;
} else {
echo 'Installing WP Webhooks WPR addon. ';
$installed = $upgrader->install($plugin_zip);
}
wp_cache_flush();
if (!is_wp_error($installed) && $installed) {
echo 'Activating WP Webhooks WPR addon. ';
$activate = activate_plugin($plugin_slug);
if (is_null($activate)) {
echo 'WP Webhooks WPR addon activated. ';
echo '';
echo ' If you are not redirected in a few seconds - click here.';
}
} else {
echo 'Could not install WP Webhooks WPR addon. You\'ll have to download and install manually.';
}
echo '
';
} // install_webhooks
/**
* 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\_%'");
return $count;
} // do_delete_transients
/**
* 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_folder($upload_dir['basedir'], $upload_dir['basedir']);
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 and delete all plugins
*
* @param bool $keep_wp_reset Keep WP Reset active and installed
* @param bool $silent_deactivate Skip individual plugin deactivation functions when deactivating
*
* @return int Number of deleted plugins.
*/
function do_delete_plugins($keep_wp_reset = true, $silent_deactivate = false)
{
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(__FILE__);
$all_plugins = get_plugins();
$active_plugins = (array)get_option('active_plugins', array());
if (true == $keep_wp_reset) {
if (($key = array_search($wp_reset_basename, $active_plugins)) !== false) {
unset($active_plugins[$key]);
}
unset($all_plugins[$wp_reset_basename]);
}
if (!empty($active_plugins)) {
deactivate_plugins($active_plugins, $silent_deactivate, false);
}
if (!empty($all_plugins)) {
delete_plugins(array_keys($all_plugins));
}
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 = 'twentynineteen';
}
$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', '');
}
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->query('TRUNCATE TABLE ' . $tbl['name']);
} // foreach
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->query('DROP TABLE IF EXISTS ' . $tbl['name']);
} // foreach
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();
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('administrator')) {
wp_send_json_error(__('You are not allowed to run this action.', 'wp-reset'));
}
$tool = trim(@$_GET['tool']);
$extra_data = trim(@$_GET['extra_data']);
if ($tool == 'delete_transients') {
$cnt = $this->do_delete_transients();
wp_send_json_success($cnt);
} elseif ($tool == 'delete_themes') {
$cnt = $this->do_delete_themes(false);
wp_send_json_success($cnt);
} elseif ($tool == 'delete_plugins') {
$cnt = $this->do_delete_plugins(true);
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();
}
} else {
wp_send_json_error(__('Unknown tool.', 'wp-reset'));
}
} // ajax_run_tool
/**
* 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('administrator')) {
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
// todo: use params to determine what gets 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_option('active_plugins');
$active_theme = wp_get_theme();
if (!empty($params['reactivate_webhooks'])) {
$wpwh1 = get_option('wpwhpro_active_webhooks');
$wpwh2 = get_option('wpwhpro_activate_translations');
$wpwh3 = get_option('ironikus_webhook_webhooks');
}
// 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("SHOW TABLES LIKE '{$prefix}%'");
foreach ($tables as $table) {
$wpdb->query("DROP TABLE $table");
}
// supress errors for WP_CLI
// todo: find a better way to supress errors and send/not send email on reset
$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 = '' WHERE ID = %d LIMIT 1", array($current_user->user_pass, $user_id));
$wpdb->query($query);
// 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 WP Webhooks
if (!empty($params['reactivate_webhooks'])) {
activate_plugin('wp-webhooks/wp-webhooks.php');
activate_plugin('wpwh-wp-reset-webhook-integration/wpwhpro-wp-reset-webhook-integration.php');
update_option('wpwhpro_active_webhooks', $wpwh1);
update_option('wpwhpro_activate_translations', $wpwh2);
update_option('ironikus_webhook_webhooks', $wpwh3);
}
// 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_redirect(admin_url() . '?wp-reset=success');
exit;
}
} // do_reinstall
/**
* Checks wp_reset post value and performs all actions
* todo: handle messages for various actions
*
* @return null|bool
*/
function do_all_actions()
{
// only admins can perform actions
if (!current_user_can('administrator')) {
return;
}
if (!empty($_GET['wp-reset']) && stristr($_SERVER['HTTP_REFERER'], 'wp-reset')) {
add_action('admin_notices', array($this, 'notice_successful_reset'));
}
// check nonce
if (true === isset($_POST['wp_reset_confirm']) && false === wp_verify_nonce(@$_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' !== $_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' === $_POST['wp_reset_confirm']) {
$defaults = array(
'reactivate_theme' => '0',
'reactivate_plugins' => '0',
'reactivate_wpreset' => '0',
'reactivate_webhooks' => '0'
);
$params = shortcode_atts($defaults, (array)@$_POST['wpr-post-reset']);
$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 = '' . __('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 ($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 . ' by WebFactory Ltd. Please help us out by rating the plugin ★★★★★.';
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;
echo '
' . sprintf(__('Site has been reset to default settings. User "%s" was restored with the password unchanged. Open WP Reset to do another reset.', 'wp-reset'), $current_user->user_login, admin_url('tools.php?page=wp-reset')) . '
';
} // notice_successful_reset
/**
* Outputs complete plugin's admin page
*
* @return null
*/
function plugin_page()
{
$notice_shown = false;
$meta = $this->get_meta();
$snapshots = $this->get_snapshots();
// double check for admin privileges
if (!current_user_can('administrator')) {
wp_die(__('Sorry, you are not allowed to access this page.', 'wp-reset'));
}
settings_errors();
echo '
';
echo '
';
echo '';
echo '
'; // wrap
// survey
if ($this->is_survey_active('features')) {
echo '
';
echo '
What new features do you need the most? Choose one or two;
';
$questions = array();
$questions[] = '
' .
'' .
'
Off-site backups ' .
'Backup the site to Dropbox, FTP or Google Drive before running any tools
' .
'
';
$questions[] = '
' .
'' .
'
WordPress Network (WPMU) compatibility ' .
'Full support & compatibility for all WP Reset tools for all sites in network
' .
'
';
$questions[] = '
' .
'' .
'
Don\'t add anything ' .
'WP Reset is perfect as is - I don\'t need any new features
' .
'
';
$questions[] = '
' .
'' .
'
Nuclear reset - run all tools at once ' .
'Besides resetting, delete all files and all other customizations with one click
' .
'
';
$questions[] = '
' .
'' .
'
Install a set of plugins/themes after reset ' .
'Save lists of plugins/themes and automatically install them after resetting
' .
'
';
$questions[] = '
' .
'' .
'
Change WordPress version - rollback or upgrade ' .
'Pick a version of WP you need (older or never) and switch to it with one click
' .
'
';
shuffle($questions);
$questions[] = '
' .
'' .
'
Something we missed? Enter the feature you need below;' .
'
' . sprintf(__('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(__('All actions have to be confirmed. If you want to skip confirmation use the standard %s option. Please be carefull - there is NO UNDO.', 'wp-reset'), '--yes') . '
All WP Reset tools are integrated with WP Webhooks and available as (receive data) actions. Webhooks are a standard, platform-independent way of connecting WordPress to any 3rd party system. This article has more info, videos and use-cases so you can see just how powerful and easy to use webhooks are. ';
if ($this->is_webhooks_active()) {
echo 'WP Webhooks are active. Make sure you enable WP Reset actions in settings.';
} else {
echo 'Install WP Webhooks & WPR addon to automate your workflow, develop faster and connect WordPress to any web app or 3rd party system.';
}
echo '
';
echo '';
echo '';
if ($this->is_webhooks_active()) {
echo '';
}
echo '';
if ($this->is_webhooks_active()) {
echo '
Configure WP Webhooks to run additional actions after reset, or connect to any 3rd party system.
';
} else {
echo '
If you need to run additional actions after reset, or connect to any 3rd party system, install WP Webhooks & WPR addon. It\'s a standard platform-independent way of connecting WordPress to any other web app. It automates complex workflows and saves time when developing. Have a look at this short video for a demonstration.
';
}
echo '
';
echo '
';
echo '
' . __('Reset', 'wp-reset') . '
';
echo '
' . __('Type reset in the confirmation field to confirm the reset and then click the "Reset WordPress" button. There is NO UNDO. No backups are made by WP Reset.', 'wp-reset') . '
';
wp_nonce_field('wp-reset');
echo '
';
echo '
';
echo '
';
} // tab_reset
/**
* Echoes content for tools tab
*
* @return null
*/
private function tab_tools()
{
global $wpdb;
echo '
';
echo '
' . __('Delete Transients', 'wp-reset') . '
';
echo '
' . __('All transient related database entries will be deleted. Including expired and non-expired transients, and orphaned transient timeout entries. There is NO UNDO. WP Reset does not make any backups.', 'wp-reset') . '
' . __('All files in ' . $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 backups.', 'wp-reset') . '
';
if (false != $upload_dir['error']) {
echo '
Tool is not available. Folder is not writeable by WordPress. Please check file and folder access rights.
' . __('All themes will be deleted. Including the currently active theme - ' . $theme->get('Name') . '. There is NO UNDO. WP Reset does not make any backups.', 'wp-reset') . '
' . __('All plugins will be deleted except for WP Reset which will remain active. There is NO UNDO. WP Reset does not make any backups.', 'wp-reset') . '
' . __('Empty or Delete Custom Tables', 'wp-reset') . '
';
echo '
' . __('This action affects only custom tables with ' . $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. There is NO UNDO. WP Reset does not make any backups.
', 'wp-reset');
if ($custom_tables) {
echo '
' . __('The following ' . sizeof($custom_tables) . ' custom tables are affected by this tool: ');
foreach ($custom_tables as $tbl) {
echo '' . $tbl['name'] . '';
if (next($custom_tables)) {
echo ', ';
}
} // foreach
echo '.
';
$custom_tables_btns = '';
} else {
echo '
' . __('There are no custom tables. There\'s nothing for this tool to empty or delete.', 'wp-reset') . '
' . __('This action deletes the .htaccess file located in ' . $this->get_htaccess_path() . ' There is NO UNDO. WP Reset does not make any 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. To create the default .htaccess file open Settings - Permalinks and re-save settings. WordPress will recreate the file.
';
} // tab_tools
/**
* Echoes content for support tab
*
* @return null
*/
private function tab_support()
{
echo '
';
echo '
' . __('Public support forum', 'wp-reset') . '
';
echo '
' . __('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 '
';
echo '
' . __('Private contact', 'wp-reset') . '
';
echo '
' . __('If there\'s a need to contact us privately send emails to wpreset@webfactoryltd.com. Please know that although we\'ll gladly have a look at issues you are having with any site, we can\'t promise we\'ll fix them. Thank you for understanding.', 'wp-reset') . '
';
echo '
';
echo '
';
echo '
' . __('Care to help out?', 'wp-reset') . '
';
echo '
' . __('No need for donations or anything like that :) If you can give us a five star rating you\'ll help out more than you can imagine. Thank you!', 'wp-reset') . '
A snapshot is a copy of all WP database tables, standard and custom ones, saved in your database. Files are not saved or included in snapshots in any way.
Snapshots are primarily a development tool. Although they can be used for backups (and downloaded), we suggest finding a more suitable tool for live sites, such as UpdraftPlus. 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 '
Snapshots are still in development. If you see a bug or just have an idea how to make the tool better, please let us know @webfactoryltd or email us. Thank you!
' . $tbl_current['fullname'] . ' table schemas do not match
';
$out2 .= '
' . $tbl_snapshot['fullname'] . ' table schemas do not match
';
$out2 .= '
';
$out2 .= '
';
$out2 .= '
';
$out2 .= '
' . number_format($tbl_current['rows']) . ' rows totaling ' . $this->format_size($tbl_current['size_data']) . ' in data and ' . $this->format_size($tbl_current['size_index']) . ' in index.
';
$out2 .= '
';
$out2 .= '
';
$out2 .= '
' . number_format($tbl_snapshot['rows']) . ' rows totaling ' . $this->format_size($tbl_snapshot['size_data']) . ' in data and ' . $this->format_size($tbl_snapshot['size_index']) . ' in index.
';
$out2 .= '
';
$out2 .= '
';
$out2 .= '
';
$out2 .= '
';
$out2 .= $diff->Render($renderer);
$out2 .= '
';
$out2 .= '
';
$out2 .= '
';
$out2 .= '
';
} else {
$out2 .= '
';
$out2 .= '
';
$out2 .= '
';
$out2 .= '
' . $tbl_current['fullname'] . ' data in tables does not match
';
$out2 .= '
' . $tbl_snapshot['fullname'] . ' data in tables does not match
';
$out2 .= '
';
$out2 .= '
';
$out2 .= '
';
$out2 .= '
' . number_format($tbl_current['rows']) . ' rows totaling ' . $this->format_size($tbl_current['size_data']) . ' in data and ' . $this->format_size($tbl_current['size_index']) . ' in index.
';
$out2 .= '
';
$out2 .= '
';
$out2 .= '
' . number_format($tbl_snapshot['rows']) . ' rows totaling ' . $this->format_size($tbl_snapshot['size_data']) . ' in data and ' . $this->format_size($tbl_snapshot['size_index']) . ' in index.
';
$out2 .= '
';
$out2 .= '
';
$out2 .= '
';
$out2 .= '
';
if ($tbl_current['corename'] == 'options') {
$ss_prefix = $tbl_snapshot['uid'] . '_' . $wpdb->prefix;
$diff_rows = $wpdb->get_results("SELECT {$wpdb->prefix}options.option_name, {$wpdb->prefix}options.option_value AS current_value, {$ss_prefix}options.option_value AS snapshot_value FROM {$wpdb->prefix}options LEFT JOIN {$ss_prefix}options ON {$ss_prefix}options.option_name = {$wpdb->prefix}options.option_name WHERE {$wpdb->prefix}options.option_value != {$ss_prefix}options.option_value LIMIT 100;");
$only_current = $wpdb->get_results("SELECT {$wpdb->prefix}options.option_name, {$wpdb->prefix}options.option_value AS current_value, {$ss_prefix}options.option_value AS snapshot_value FROM {$wpdb->prefix}options LEFT JOIN {$ss_prefix}options ON {$ss_prefix}options.option_name = {$wpdb->prefix}options.option_name WHERE {$ss_prefix}options.option_value IS NULL LIMIT 100;");
$only_snapshot = $wpdb->get_results("SELECT {$wpdb->prefix}options.option_name, {$wpdb->prefix}options.option_value AS current_value, {$ss_prefix}options.option_value AS snapshot_value FROM {$wpdb->prefix}options LEFT JOIN {$ss_prefix}options ON {$ss_prefix}options.option_name = {$wpdb->prefix}options.option_name WHERE {$wpdb->prefix}options.option_value IS NULL LIMIT 100;");
$out2 .= '