';
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\_%'");
wp_cache_flush();
do_action('wp_reset_delete_transients', $count);
return $count;
} // do_delete_transients
/**
* 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;
$count = $wpdb->query("DELETE FROM $wpdb->options WHERE option_name LIKE 'theme_mods\_%' OR option_name LIKE 'mods\_%'");
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 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));
}
do_action('wp_reset_delete_plugins', $all_plugins, $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', '');
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->query('TRUNCATE TABLE ' . $tbl['name']);
} // 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->query('DROP TABLE IF EXISTS ' . $tbl['name']);
} // 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('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 == 'reset_theme_options') {
$cnt = $this->do_reset_theme_options(true);
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 == 'download_backup') {
$res = $this->do_create_backup();
if (is_wp_error($res)) {
wp_send_json_error($res->get_error_message());
} else {
$url = content_url() . '/' . $this->backups_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 . '. 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;
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
/**
* Generates a button that initiates backup creation and download
*
* @return string
*/
function get_backup_button($tool_id = '')
{
$out = '';
$out .= 'Create & download backup';
return $out;
} // get_backup_button
/**
* Outputs complete plugin's admin page
*
* @return null
*/
function plugin_page()
{
// double check for admin privileges
if (!current_user_can('administrator')) {
wp_die(__('Sorry, you are not allowed to access this page.', 'wp-reset'));
}
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;' .
'
';
}
} // plugin_page
/**
* Echoes all custom plugin notitications
*
* @return null
*/
private function custom_notifications()
{
$notice_shown = false;
$meta = $this->get_meta();
$snapshots = $this->get_snapshots();
// warn that WPR is not WPMU compatible
if (false === $notice_shown && is_multisite()) {
echo '
';
echo '
' . __('WP Reset is not compatible with multisite!', 'wp-reset') . '
';
echo '
' . __('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') . '
' . __('Please help us spread the word & keep the plugin up-to-date', 'wp-reset') . '
';
echo '
' . __('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') . '
' . sprintf(__('all custom database tables that have the same prefix "%s" as default tables in this installation', 'wp-reset'), $wpdb->prefix) . '
';
echo '
' . __('always make a backup first', 'wp-reset') . '
';
echo '
';
echo '
' . __('Resetting will not delete:', 'wp-reset') . '
';
echo '
';
echo '
' . __('media files - they\'ll remain in the wp-uploads folder but will no longer be listed under Media', 'wp-reset');
echo __('; use the Clean Uploads Folder tool to remove media files', 'wp-reset') . '
';
echo '
' . __('no files are touched; plugins, themes, uploads - everything stays', 'wp-reset');
echo __('; if needed use the Delete Themes & Delete Plugins tools', 'wp-reset') . '
';
echo '
' . __('site title, WordPress address, site address, site language and search engine visibility settings', 'wp-reset') . '
';
echo '
' . sprintf(__('logged in user "%s" will be restored with the current password', 'wp-reset'), $current_user->user_login) . '
';
echo '
';
echo '
' . __('What happens when I click the Reset button?', 'wp-reset') . '
';
echo '
';
echo '
' . __('remember, always make a backup first', 'wp-reset') . '
';
echo '
' . __('you will have to confirm the action one more time because there is NO UNDO', 'wp-reset') . '
';
echo '
' . __('everything will be reset; see bullets above for details', 'wp-reset') . '
';
echo '
' . __('site title, WordPress address, site address, site language, search engine visibility and current user will be restored', 'wp-reset') . '
';
echo '
' . __('you will be logged out, automatically logged in and taken to the admin dashboard', 'wp-reset') . '
';
echo '
' . __('WP Reset plugin will be reactivated if that option is chosen in the post-reset options', 'wp-reset') . '
';
echo '
';
echo '
' . __('WP-CLI Support', 'wp-reset') . ' ';
echo '' . 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 careful - there is NO UNDO.', 'wp-reset'), '--yes') . '
';
echo '
' . __('WP Webhooks Support', 'wp-reset') . ' ';
echo '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 '
To run additional actions after reset or automate a complex workflow install WP Webhooks & WPR addon. It\'s a standard, platform-independent way of connecting WordPress to any web app. This short video explains it well.
';
}
echo '
' . __('Type reset in the confirmation field to confirm the reset and then click the "Reset WordPress" button. There is NO UNDO. Always create a backup before deleting anything.', 'wp-reset') . '
All transient related database entries will be deleted. Including expired and non-expired transients, and orphaned transient timeout entries. There is NO UNDO. Always create a backup before deleting anything.
';
echo '
create a backup') . '." 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' . $this->get_backup_button('delete-transients') . '
' . __('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 file 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 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. There is NO UNDO. Always create a backup before deleting anything.', 'wp-reset') . '
';
echo '
create a backup') . '." 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' . $this->get_backup_button('reset-theme-options') . '
';
echo '
';
$theme = wp_get_theme();
echo '
';
echo '
' . __('Delete Themes', 'wp-reset') . '
';
echo '
' . __('All themes will be deleted. Including the currently active theme - ' . $theme->get('Name') . '. There is NO UNDO. WP Reset does not make any file 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 file backups.', 'wp-reset') . '
';
global $wpdb;
$custom_tables = $this->get_custom_tables();
echo '
';
echo '
' . __('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. Always create a backup before deleting anything.
', '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') . '
';
$custom_tables_btns = ' disabled';
}
echo '
create a backup') . '." data-text-done="%n custom tables have been emptied." data-text-done-singular="One custom table has been emptied." class="button button-delete' . $custom_tables_btns . '" href="#" id="truncate-custom-tables">Empty (truncate) custom tables';
echo 'create a backup') . '." data-text-done="%n custom tables have been deleted." data-text-done-singular="One custom table has been deleted." class="button button-delete' . $custom_tables_btns . '" href="#" id="drop-custom-tables">Delete (drop) custom tables' . $this->get_backup_button('drop-custom-tables') . '
';
echo '
';
echo '
';
echo '
' . __('Delete .htaccess File', 'wp-reset') . '
';
echo '
' . __('This action deletes the .htaccess file located in ' . $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.
' . __('A tool that\'s coming with WP Reset PRO that will save hours & hours of your precious time! Have a set of plugins (and themes) that you install and activate after every reset? Or on every fresh WP 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') . '
';
} // tab_collections
/**
* Echoes content for support tab
*
* @return null
*/
private function tab_support()
{
echo '
';
echo '
' . __('Documentation', 'wp-reset') . '
';
echo '
' . __('All tools and functions 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 '
';
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. A public mention @webfactoryltd also does wonders. 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. Watch a short video overview and tutorial about Snapshots.
';
echo '
Snapshots are primarily a development tool. Although they can be used for backups (and downloaded), when using various reset tools we advise using our 1-click backup tool available in every tool\'s confirmation dialog. If you need a full backup that includes files, use something like UpdraftPlus.
';
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.
' . $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 .= '