Version Description
- 23/02/2022 =
- New: feature to clean up 'uploads' folder
- New: feature to delete all themes
- New: feature to delete all plugins
- New: feature to clean up 'wp-content' folder
- New: feature to delete MU plugins
- New: feature to delete the '.htaccess' file
- New: feature to delete all comments
- New: feature to delete pending comments
- New: feature to delete spam comments
- New: feature to delete trashed comments
- New: feature to delete pingbacks
- New: feature to delete trackbacks
- Tweak: completely rewriting the JavaScript code
- Tweak: enhancing the CSS code
- Tweak: enhancing the PHP code
- Tested with WordPress 5.9
Download this release
Release Info
Developer | symptote |
Plugin | Advanced WordPress Reset |
Version | 1.5 |
Comparing to | |
See all releases |
Code changes from version 1.1.1 to 1.5
- README.txt +57 -18
- advanced-wp-reset.php +218 -143
- css/admin.css +350 -76
- images/donate.gif +0 -0
- images/help.svg +70 -0
- images/icon-128x128.png +0 -0
- images/info.png +0 -0
- images/information2.svg +19 -0
- images/warning.png +0 -0
- includes/custom_reset.php +156 -0
- includes/functions.php +772 -35
- includes/reset.php +46 -41
- includes/settings.php +8 -0
- js/admin.js +558 -11
- screenshot-1.png +0 -0
README.txt
CHANGED
@@ -3,30 +3,49 @@ Contributors: symptote
|
|
3 |
Donate Link: http://www.sigmaplugin.com/donation
|
4 |
Tags: database, reset database, reset, clean, restore
|
5 |
Requires at least: 4.0
|
6 |
-
Tested up to:
|
7 |
-
Stable tag: 1.
|
8 |
License: GPLv2 or later
|
9 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
|
11 |
-
Reset and restore your WordPress database
|
12 |
|
13 |
== Description ==
|
14 |
|
15 |
-
Notice: If you are looking for cleaning up your database, use instead our plugin: <a href="https://wordpress.org/plugins/advanced-database-cleaner" target="_blank">Advanced Database Cleaner</a>
|
16 |
|
17 |
-
'Advanced WordPress reset' plugin will reset
|
18 |
|
19 |
-
|
20 |
-
|
21 |
-
|
|
|
|
|
|
|
|
|
22 |
* Deletes all database customizations made by plugins and themes
|
23 |
-
* Deletes all content including
|
24 |
-
* Detects the Admin user and
|
25 |
* Keeps the blog name after the reset
|
26 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
27 |
|
28 |
= Multisite Support =
|
29 |
-
*
|
30 |
|
31 |
== Installation ==
|
32 |
|
@@ -39,10 +58,30 @@ This section describes how to install the plugin and get it working.
|
|
39 |
|
40 |
== Screenshots ==
|
41 |
|
42 |
-
1.
|
|
|
|
|
43 |
|
44 |
== Changelog ==
|
45 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
46 |
= 1.1.1 - 17/09/2020 =
|
47 |
- Tweak: enhancing the JavaScript code
|
48 |
- Tweak: we are now using SweetAlert for all popup boxes
|
@@ -69,14 +108,14 @@ This option will reset your WordPress database back to its first original status
|
|
69 |
= Is it safe to reset my database? =
|
70 |
Yes, it is safe since you have no important content to lose. If there are any issues, we will support you :)
|
71 |
|
72 |
-
=
|
73 |
No. All files are kept as they are. The plugin does not delete or modify any of your files.
|
74 |
|
75 |
-
=
|
76 |
-
No. All your plugins and themes will be kept. However you will lose any settings in database of those plugins/themes.
|
77 |
|
78 |
= Is this plugin compatible with multisite? =
|
79 |
No, it is not compatible with multisite. We will try to fix this compatibility as soon as possible.
|
80 |
|
81 |
-
= Is this plugin compatible with SharDB, HyperDB or Multi-DB? =
|
82 |
-
|
3 |
Donate Link: http://www.sigmaplugin.com/donation
|
4 |
Tags: database, reset database, reset, clean, restore
|
5 |
Requires at least: 4.0
|
6 |
+
Tested up to: 6.0
|
7 |
+
Stable tag: 1.5
|
8 |
License: GPLv2 or later
|
9 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
|
11 |
+
Reset and restore your WordPress database to its first original status, just like if you make a fresh installation.
|
12 |
|
13 |
== Description ==
|
14 |
|
15 |
+
Notice: If you are looking for cleaning up your database and delete orphaned items, use instead our plugin: <a href="https://wordpress.org/plugins/advanced-database-cleaner" target="_blank">Advanced Database Cleaner</a>
|
16 |
|
17 |
+
'Advanced WordPress reset' plugin will reset and restore your WordPress Database to its first original status in order to make a fresh installation without going through WordPress traditional installation. You can also reset specific items by executing tools such as: clean up the "uploads" folder, delete all comments, remove all plugins, etc.
|
18 |
|
19 |
+
This plugin will help you save time especially if you are a developer and you have to install WordPress from scratch every time after testing some plugins/themes.
|
20 |
+
|
21 |
+
The plugin provides two main features categories:
|
22 |
+
|
23 |
+
= Main reset (Reset all) =
|
24 |
+
* Runs a new installation without going through the 5 minutes WordPress installation
|
25 |
+
* Resets the database without deleting or modifying any of your files (all your WordPress, plugins, and themes files are kept as they are without modifying them in any way)
|
26 |
* Deletes all database customizations made by plugins and themes
|
27 |
+
* Deletes all content including posts, pages, options, menus, etc.
|
28 |
+
* Detects the Admin user and recreates it with its saved password. If the Admin user does not exist, the current logged in user will be recreated with its current password with wp_user_level 10
|
29 |
* Keeps the blog name after the reset
|
30 |
+
|
31 |
+
= Custom reset tools =
|
32 |
+
* Clean up 'uploads' folder (/wp-content/uploads) by deleting all its content. This includes images, videos, music, documents, subfolders, etc.
|
33 |
+
* Delete all themes (the plugin uses WordPress core functions to delete themes). You have the possibility to keep the currently active theme or delete it as well
|
34 |
+
* Delete all plugins (the plugin will deactivate them first then uninstall them using WordPress core functions)
|
35 |
+
* Clean up "wp-content" folder. All files and folders inside '/wp-content' directory will be deleted, except 'index.php' and the following folders: 'plugins', 'themes', 'uploads' and 'mu-plugins'
|
36 |
+
* Delete Must-use plugins. All MU plugins in '/wp-content/mu-plugins' will be deleted. These are plugins that cannot be disabled except by removing their files from the must-use directory
|
37 |
+
* Delete ".htaccess" file. This is a critical WordPress core file used to enable or disable features of websites hosted on Apache. In some cases, you may need to delete it to do some tests
|
38 |
+
* Delete all comments. All types of comments will be deleted. Comments meta will also be deleted
|
39 |
+
* Delete pending comments. These are the comments that are awaiting moderation
|
40 |
+
* Delete spam comments
|
41 |
+
* Delete trashed comments. These are comments that you have deleted and sent to the Trash
|
42 |
+
* Delete pingbacks. Pingbacks allow you to notify other website owners that you have linked to their article on your website
|
43 |
+
* Delete trackbacks. Although there are some minor technical differences, a trackback is basically the same things as a pingback
|
44 |
+
|
45 |
+
The use of the plugin is quick, convenient, and safe. It is impossible to accidentally click on the reset buttons without your permission. You are always invited to confirm your actions.
|
46 |
|
47 |
= Multisite Support =
|
48 |
+
* The plugin does not support Multisite installation for now. We will add compatibility as soon as possible.
|
49 |
|
50 |
== Installation ==
|
51 |
|
58 |
|
59 |
== Screenshots ==
|
60 |
|
61 |
+
1. Reset all - main reset feature
|
62 |
+
2. Custom reset tools
|
63 |
+
2. You are invited to confirm the reset for all tools
|
64 |
|
65 |
== Changelog ==
|
66 |
|
67 |
+
= 1.5 - 23/02/2022 =
|
68 |
+
- New: feature to clean up 'uploads' folder
|
69 |
+
- New: feature to delete all themes
|
70 |
+
- New: feature to delete all plugins
|
71 |
+
- New: feature to clean up 'wp-content' folder
|
72 |
+
- New: feature to delete MU plugins
|
73 |
+
- New: feature to delete the '.htaccess' file
|
74 |
+
- New: feature to delete all comments
|
75 |
+
- New: feature to delete pending comments
|
76 |
+
- New: feature to delete spam comments
|
77 |
+
- New: feature to delete trashed comments
|
78 |
+
- New: feature to delete pingbacks
|
79 |
+
- New: feature to delete trackbacks
|
80 |
+
- Tweak: completely rewriting the JavaScript code
|
81 |
+
- Tweak: enhancing the CSS code
|
82 |
+
- Tweak: enhancing the PHP code
|
83 |
+
- Tested with WordPress 5.9
|
84 |
+
|
85 |
= 1.1.1 - 17/09/2020 =
|
86 |
- Tweak: enhancing the JavaScript code
|
87 |
- Tweak: we are now using SweetAlert for all popup boxes
|
108 |
= Is it safe to reset my database? =
|
109 |
Yes, it is safe since you have no important content to lose. If there are any issues, we will support you :)
|
110 |
|
111 |
+
= Are there any files that will be deleted after the reset? =
|
112 |
No. All files are kept as they are. The plugin does not delete or modify any of your files.
|
113 |
|
114 |
+
= Are there any plugins or themes that will be deleted after the reset? =
|
115 |
+
No. All your plugins and themes will be kept. However, you will lose any settings in the database of those plugins/themes.
|
116 |
|
117 |
= Is this plugin compatible with multisite? =
|
118 |
No, it is not compatible with multisite. We will try to fix this compatibility as soon as possible.
|
119 |
|
120 |
+
= Is this plugin compatible with SharDB, HyperDB, or Multi-DB? =
|
121 |
+
The plugin is not supposed to be compatible with SharDB, HyperDB, or Multi-DB for now.
|
advanced-wp-reset.php
CHANGED
@@ -4,8 +4,8 @@ if (!defined('ABSPATH') || !is_main_site()) return;
|
|
4 |
/*
|
5 |
Plugin Name: Advanced WordPress Reset
|
6 |
Plugin URI: http://sigmaplugin.com/downloads/advanced-wordpress-reset
|
7 |
-
Description: Reset your WordPress database
|
8 |
-
Version: 1.
|
9 |
Author: Younes JFR.
|
10 |
Author URI: http://www.sigmaplugin.com
|
11 |
Contributors: symptote
|
@@ -15,169 +15,244 @@ License: GPLv2 or later
|
|
15 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
16 |
*/
|
17 |
|
18 |
-
|
19 |
-
* Define common constants
|
20 |
-
********************************************************************/
|
21 |
-
if (!defined("DBR_PLUGIN_VERSION")) define("DBR_PLUGIN_VERSION", "1.1.1");
|
22 |
-
if (!defined("DBR_PLUGIN_DIR_PATH")) define("DBR_PLUGIN_DIR_PATH", plugins_url('' , __FILE__));
|
23 |
-
if (!defined("DBR_PLUGIN_BASENAME")) define("DBR_PLUGIN_BASENAME", plugin_basename(__FILE__));
|
24 |
-
|
25 |
-
/********************************************************************
|
26 |
-
* Load language
|
27 |
-
********************************************************************/
|
28 |
-
add_action('plugins_loaded', 'DBR_load_textdomain');
|
29 |
-
function DBR_load_textdomain() {
|
30 |
-
load_plugin_textdomain('advanced-wp-reset', false, plugin_basename(dirname(__FILE__)) . '/languages');
|
31 |
-
}
|
32 |
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
41 |
|
42 |
-
/********************************************************************
|
43 |
-
* Add actions for ajax
|
44 |
-
********************************************************************/
|
45 |
-
add_action('wp_ajax_DBR_wp_reset', 'DBR_wp_reset');
|
46 |
-
|
47 |
-
/********************************************************************
|
48 |
-
* Load CSS and JS
|
49 |
-
********************************************************************/
|
50 |
-
add_action('admin_enqueue_scripts', 'DBR_load_styles_and_scripts');
|
51 |
-
function DBR_load_styles_and_scripts($hook) {
|
52 |
-
|
53 |
-
// Enqueue our js and css in the plugin pages only
|
54 |
-
global $DBR_tool_submenu;
|
55 |
-
if($hook != $DBR_tool_submenu){
|
56 |
-
return;
|
57 |
}
|
58 |
|
59 |
-
|
60 |
-
|
61 |
|
62 |
-
|
63 |
-
|
64 |
|
65 |
-
|
66 |
-
|
|
|
|
|
67 |
|
68 |
-
|
69 |
-
'
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
'processing' => __('Processing...', 'advanced-wp-reset'),
|
74 |
-
'done' => __('Done!', 'advanced-wp-reset'),
|
75 |
-
'cancel' => __('Cancel', 'advanced-wp-reset'),
|
76 |
-
'Continue' => __('Continue', 'advanced-wp-reset'),
|
77 |
-
'ajax_nonce' => wp_create_nonce('DBR_nonce'),
|
78 |
|
79 |
-
|
|
|
80 |
|
81 |
-
|
82 |
-
//wp_enqueue_script('jquery-ui-dialog');
|
83 |
-
//wp_enqueue_style('wp-jquery-ui-dialog');
|
84 |
-
}
|
85 |
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
|
94 |
-
/********************************************************************
|
95 |
-
* Add rating box to the top of wordpress admin panel
|
96 |
-
********************************************************************/
|
97 |
-
$aDBc_upload_dir = wp_upload_dir();
|
98 |
-
$aDBc_file_path = str_replace('\\' ,'/', $aDBc_upload_dir['basedir']) . "/DBR.txt";
|
99 |
-
if(isset($_GET['DBR_rate']) && $_GET['DBR_rate'] == "0"){
|
100 |
-
$handle = fopen($aDBc_file_path, "w");
|
101 |
-
if($handle){
|
102 |
-
fwrite($handle, "0");
|
103 |
}
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
|
|
|
|
|
|
109 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
110 |
}
|
111 |
-
}
|
112 |
-
function DBR_show_rate_box(){
|
113 |
-
$aDBc_new_URI = $_SERVER['REQUEST_URI'];
|
114 |
-
$aDBc_new_URI = add_query_arg('DBR_rate', "0", $aDBc_new_URI);
|
115 |
-
$style_botton = "background: #f0f5fa;padding: 4px !important;text-decoration: none;margin-right:10px;border-radius: 5px;-moz-border-radius: 5px;-webkit-border-radius: 5px; box-shadow: 0 0 0 1px #5b9dd9, 0 0 2px 1px rgba(30,140,190,.8); ";
|
116 |
-
?>
|
117 |
-
<div style="padding:15px !important;" class="updated DBR-top-main-msg">
|
118 |
-
<span style="font-size:16px;color:green;font-weight:bold;"><?php _e('Awesome!', 'advanced-wp-reset'); ?></span>
|
119 |
-
<p style="font-size:14px;line-height:30px">
|
120 |
-
<?php _e('The plugin "Advanced DB Reset" just helped you reset your database to a fresh installation with success!', 'advanced-wp-reset'); ?>
|
121 |
-
<br/>
|
122 |
-
<?php _e('Could you please kindly help the plugin in your turn by giving it 5 stars rating? (Thank you in advance)', 'advanced-wp-reset'); ?>
|
123 |
-
<div style="font-size:14px;margin-top:10px">
|
124 |
-
<a style="<?php echo $style_botton ?>" target="_blank" href="https://wordpress.org/support/plugin/advanced-wp-reset/reviews/?filter=5">
|
125 |
-
<?php _e('Ok, you deserved it', 'advanced-wp-reset'); ?></a>
|
126 |
-
<form method="post" action="" style="display:inline">
|
127 |
-
<input type="hidden" name="dont_show_rate" value=""/>
|
128 |
-
<a style="<?php echo $style_botton ?>" href="<?php echo $aDBc_new_URI; ?>"><?php _e('I already did', 'advanced-wp-reset'); ?></a>
|
129 |
-
<a style="<?php echo $style_botton ?>" href="<?php echo $aDBc_new_URI; ?>"><?php _e('Please don\'t show this again', 'advanced-wp-reset'); ?></a>
|
130 |
-
</form>
|
131 |
-
</div>
|
132 |
-
</p>
|
133 |
-
</div>
|
134 |
-
<?php
|
135 |
-
}
|
136 |
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
function DBR_deactivate_plugin(){
|
142 |
-
// Anything to do on deactivation? Maybe later...
|
143 |
-
}
|
144 |
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
//
|
151 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
152 |
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
|
158 |
-
|
159 |
-
|
160 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
161 |
}
|
162 |
|
163 |
-
|
164 |
-
|
165 |
-
<
|
166 |
-
|
167 |
-
<div
|
168 |
-
<
|
169 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
170 |
</div>
|
|
|
|
|
|
|
171 |
</div>
|
172 |
-
<div class="DBR-sidebar"><?php include_once 'includes/sidebar.php'; ?></div>
|
173 |
</div>
|
174 |
-
|
175 |
-
|
176 |
}
|
177 |
|
178 |
-
|
179 |
-
|
180 |
-
***************************************************************/
|
181 |
-
include_once 'includes/functions.php';
|
182 |
-
|
183 |
-
?>
|
4 |
/*
|
5 |
Plugin Name: Advanced WordPress Reset
|
6 |
Plugin URI: http://sigmaplugin.com/downloads/advanced-wordpress-reset
|
7 |
+
Description: Reset your WordPress database to its first original status, just like if you make a fresh installation.
|
8 |
+
Version: 1.5
|
9 |
Author: Younes JFR.
|
10 |
Author URI: http://www.sigmaplugin.com
|
11 |
Contributors: symptote
|
15 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
16 |
*/
|
17 |
|
18 |
+
class DBR_Advanced_DB_Reset {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
19 |
|
20 |
+
public function __construct(){
|
21 |
+
|
22 |
+
// Define common constants that should be modified in each version
|
23 |
+
if(!defined("DBR_PLUGIN_VERSION")) define("DBR_PLUGIN_VERSION", "1.5");
|
24 |
+
|
25 |
+
// Load text-domain, ajax functions...
|
26 |
+
add_action('plugins_loaded', array($this, 'plugins_loaded'));
|
27 |
+
|
28 |
+
// Load CSS and JS
|
29 |
+
add_action('admin_enqueue_scripts', array($this, 'DBR_load_styles_and_scripts'));
|
30 |
+
|
31 |
+
// Register activation, deactivation and uninstall hooks of the plugin
|
32 |
+
register_activation_hook (__FILE__, array($this, 'DBR_activate_plugin'));
|
33 |
+
register_deactivation_hook (__FILE__, array($this, 'DBR_deactivate_plugin'));
|
34 |
+
register_uninstall_hook (__FILE__, array('DBR_Advanced_DB_Reset', 'DBR_uninstall'));
|
35 |
+
|
36 |
+
// Add admin notice to rate plugin
|
37 |
+
add_action('admin_notices', array($this, 'DBR_rate_notice'));
|
38 |
+
add_action('admin_init', array($this, 'DBR_ignore_notice'));
|
39 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
40 |
}
|
41 |
|
42 |
+
// Do this on plugins loded : prevent conflict between free and pro, load text-domain and check if we should update settings in DB
|
43 |
+
public function plugins_loaded(){
|
44 |
|
45 |
+
// Include functions
|
46 |
+
include_once 'includes/functions.php';
|
47 |
|
48 |
+
// Add actions for Ajax
|
49 |
+
add_action('wp_ajax_DBR_wp_reset', 'DBR_wp_reset');
|
50 |
+
add_action('wp_ajax_DBR_calculate_number_items_to_reset', 'DBR_calculate_number_items_to_reset');
|
51 |
+
add_action('wp_ajax_DBR_execute_called_tool', 'DBR_execute_called_tool');
|
52 |
|
53 |
+
// Define other variables
|
54 |
+
if(!defined("DBR_PLUGIN_DIR_PATH")) define("DBR_PLUGIN_DIR_PATH", plugins_url('' , __FILE__));
|
55 |
+
if(!defined("DBR_PLUGIN_BASENAME")) define("DBR_PLUGIN_BASENAME", plugin_basename(__FILE__));
|
56 |
+
if(!defined("WP_CONTENT_DIR")) define("WP_CONTENT_DIR", ABSPATH . 'wp-content');
|
57 |
+
if(!defined("WPMU_PLUGIN_DIR")) define("WPMU_PLUGIN_DIR", WP_CONTENT_DIR . 'mu-plugins');
|
|
|
|
|
|
|
|
|
|
|
58 |
|
59 |
+
// Add submenu under tools
|
60 |
+
add_action('admin_menu', array($this, 'DBR_add_admin_menu'));
|
61 |
|
62 |
+
load_plugin_textdomain('advanced-wp-reset', false, dirname(plugin_basename(__FILE__)) . '/languages');
|
|
|
|
|
|
|
63 |
|
64 |
+
}
|
65 |
+
|
66 |
+
/// Function to add submenu under tools
|
67 |
+
function DBR_add_admin_menu(){
|
68 |
+
|
69 |
+
global $DBR_tool_submenu;
|
70 |
+
$DBR_tool_submenu = add_submenu_page('tools.php', 'Advanced WP Reset', 'Advanced WP Reset', 'manage_options', 'advanced_wp_reset', array($this, 'DBR_main_page_callback'));
|
71 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
72 |
}
|
73 |
+
|
74 |
+
// Load CSS and JS
|
75 |
+
function DBR_load_styles_and_scripts($hook){
|
76 |
+
|
77 |
+
// Enqueue our js and css in the plugin pages only
|
78 |
+
global $DBR_tool_submenu;
|
79 |
+
if($hook != $DBR_tool_submenu){
|
80 |
+
return;
|
81 |
}
|
82 |
+
|
83 |
+
wp_enqueue_style('DBR_css', DBR_PLUGIN_DIR_PATH . '/css/admin.css');
|
84 |
+
wp_enqueue_script('DBR_js', DBR_PLUGIN_DIR_PATH . '/js/admin.js');
|
85 |
+
|
86 |
+
wp_enqueue_style('sweet2_css', DBR_PLUGIN_DIR_PATH . '/css/sweetalert2.min.css');
|
87 |
+
wp_enqueue_script('sweet2_js', DBR_PLUGIN_DIR_PATH . '/js/sweetalert2.min.js');
|
88 |
+
|
89 |
+
// The wp_localize_script allows us to output the ajax_url path for our script to use.
|
90 |
+
wp_localize_script('DBR_js', 'DBR_ajax_obj', array(
|
91 |
+
|
92 |
+
'ajaxurl' => admin_url('admin-ajax.php'),
|
93 |
+
'images_path' => DBR_PLUGIN_DIR_PATH . "/images/",
|
94 |
+
'are_you_sure' => __('Are you sure to continue?', 'advanced-wp-reset'),
|
95 |
+
'warning_msg' => __('You are about to reset your database. Any content will be lost!', 'advanced-wp-reset'),
|
96 |
+
'irreversible_msg' => __('This operation is irreversible!', 'advanced-wp-reset'),
|
97 |
+
'custom_warning' => __('You are about to perform the following action:', 'advanced-wp-reset'),
|
98 |
+
'type_reset' => sprintf(__('Please type the word "<b>%s</b>" correctly in the text box','advanced-wp-reset'), "reset"),
|
99 |
+
'processing' => __('Processing...', 'advanced-wp-reset'),
|
100 |
+
'done' => __('Done!', 'advanced-wp-reset'),
|
101 |
+
'cancel' => __('Cancel', 'advanced-wp-reset'),
|
102 |
+
'Continue' => __('Continue', 'advanced-wp-reset'),
|
103 |
+
'keep_active_theme' => __('Keep active theme', 'advanced-wp-reset'),
|
104 |
+
'keep_this_plugin' => __('Keep current plugin', 'advanced-wp-reset'),
|
105 |
+
'unknown_error' => __('Unknown error!', 'advanced-wp-reset'),
|
106 |
+
'ajax_nonce' => wp_create_nonce('DBR_nonce'),
|
107 |
+
|
108 |
+
));
|
109 |
+
|
110 |
+
//wp_enqueue_script('jquery');
|
111 |
+
//wp_enqueue_script('jquery-ui-dialog');
|
112 |
+
//wp_enqueue_style('wp-jquery-ui-dialog');
|
113 |
+
wp_enqueue_script( 'jquery-ui-sortable' );
|
114 |
+
|
115 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
116 |
|
117 |
+
// Register activation of the plugin
|
118 |
+
function DBR_activate_plugin(){
|
119 |
+
// Anything to do on deactivation? Maybe later...
|
120 |
+
}
|
|
|
|
|
|
|
121 |
|
122 |
+
// Register deactivation hook
|
123 |
+
function DBR_deactivate_plugin($network_wide){
|
124 |
+
// Anything to do on deactivation? Maybe later...
|
125 |
+
}
|
126 |
+
|
127 |
+
// Register UNINSTALL hook
|
128 |
+
public static function DBR_uninstall(){
|
129 |
+
// Anything to do on uninstall? Maybe later...
|
130 |
+
}
|
131 |
+
|
132 |
+
// Add admin notice to rate plugin
|
133 |
+
function DBR_rate_notice(){
|
134 |
+
|
135 |
+
$DBR_upload_dir = wp_upload_dir();
|
136 |
+
$DBR_file_path = str_replace('\\' ,'/', $DBR_upload_dir['basedir']) . "/DBR.txt";
|
137 |
+
|
138 |
+
if(file_exists($DBR_file_path)){
|
139 |
+
$content = file_get_contents($DBR_file_path);
|
140 |
+
// Return in case the file contains 0
|
141 |
+
if($content != "1")
|
142 |
+
return;
|
143 |
+
}else{
|
144 |
+
// Return in case the file does not exist
|
145 |
+
return;
|
146 |
+
}
|
147 |
|
148 |
+
$DBR_new_URI = $_SERVER['REQUEST_URI'];
|
149 |
+
$DBR_new_URI = add_query_arg('DBR_rate', "0", $DBR_new_URI);
|
150 |
+
// Style should be done here because it is not loaded outside the plugin admin panel
|
151 |
+
$style_botton = "background:#f0f5fa;padding:5px;text-decoration:none;margin-right:10px;border:1px solid #999;border-radius:4px"; ?>
|
152 |
|
153 |
+
<div style="padding:15px !important;" class="updated DBR-top-main-msg">
|
154 |
+
<span style="font-size:16px;color:green;font-weight:bold;"><?php _e('Awesome!', 'advanced-wp-reset'); ?></span>
|
155 |
+
<p style="font-size:14px;line-height:30px">
|
156 |
+
<?php _e('The plugin "Advanced DB Reset" just helped you reset your database to a fresh installation with success!', 'advanced-wp-reset'); ?>
|
157 |
+
<br/>
|
158 |
+
<?php _e('Could you please kindly help the plugin in your turn by giving it 5 stars rating? (Thank you in advance)', 'advanced-wp-reset'); ?>
|
159 |
+
<div style="font-size:14px;margin-top:10px">
|
160 |
+
<a style="<?php echo $style_botton ?>" target="_blank" href="https://wordpress.org/support/plugin/advanced-wp-reset/reviews/?filter=5">
|
161 |
+
<?php _e('Ok, you deserved it', 'advanced-wp-reset'); ?></a>
|
162 |
+
<form method="post" action="" style="display:inline">
|
163 |
+
<input type="hidden" name="dont_show_rate" value=""/>
|
164 |
+
<a style="<?php echo $style_botton ?>" href="<?php echo $DBR_new_URI; ?>"><?php _e('I already did', 'advanced-wp-reset'); ?></a>
|
165 |
+
<a style="<?php echo $style_botton ?>" href="<?php echo $DBR_new_URI; ?>"><?php _e('Please don\'t show this again', 'advanced-wp-reset'); ?></a>
|
166 |
+
</form>
|
167 |
+
</div>
|
168 |
+
</p>
|
169 |
+
</div>
|
170 |
+
<?php
|
171 |
+
}
|
172 |
+
|
173 |
+
// Hide rating msg box if the user clicked on the button to hide it
|
174 |
+
function DBR_ignore_notice(){
|
175 |
+
|
176 |
+
if(isset($_GET['DBR_rate']) && $_GET['DBR_rate'] == "0"){
|
177 |
+
|
178 |
+
$DBR_upload_dir = wp_upload_dir();
|
179 |
+
$DBR_file_path = str_replace('\\' ,'/', $DBR_upload_dir['basedir']) . "/DBR.txt";
|
180 |
+
|
181 |
+
$handle = fopen($DBR_file_path, "w");
|
182 |
+
if($handle){
|
183 |
+
fwrite($handle, "0");
|
184 |
+
}
|
185 |
+
}
|
186 |
}
|
187 |
|
188 |
+
// The admin page of the plugin
|
189 |
+
function DBR_main_page_callback(){ ?>
|
190 |
+
<div class="wrap">
|
191 |
+
|
192 |
+
<div>
|
193 |
+
<table width="100%" cellspacing="0">
|
194 |
+
<tr style="background:#fff;border:0px solid #eee;">
|
195 |
+
|
196 |
+
<td style="padding:10px 10px 10px 20px">
|
197 |
+
<img style="width:50px" src="<?php echo DBR_PLUGIN_DIR_PATH; ?>/images/icon-128x128.png"/>
|
198 |
+
</td>
|
199 |
+
|
200 |
+
<td width="100%">
|
201 |
+
<div style="background:#fff;padding:10px;margin-bottom:10px;">
|
202 |
+
<?php
|
203 |
+
$DBR_plugin_title = "Advanced WP Reset '" . DBR_PLUGIN_VERSION . "'";
|
204 |
+
?>
|
205 |
+
<div style="font-size: 20px;font-weight: 400;margin-bottom:10px"><?php echo $DBR_plugin_title; ?></div>
|
206 |
+
<div style="border-top:1px dashed #eee;padding-top:4px">
|
207 |
+
<span class="DBR-row-text"><?php _e('By', 'advanced-wp-reset'); ?></span>
|
208 |
+
<a class="DBR-sidebar-link" href="https://profiles.wordpress.org/symptote/" target="_blank">Younes JFR.</a>
|
209 |
+
|
|
210 |
+
<span class="DBR-row-text"><?php _e('Need help?', 'advanced-wp-reset'); ?></span>
|
211 |
+
<a class="DBR-sidebar-link" href="http://sigmaplugin.com/contact" target="_blank"><?php _e('Contact me', 'advanced-wp-reset'); ?></a>
|
212 |
+
</div>
|
213 |
+
</div>
|
214 |
+
</td>
|
215 |
+
|
216 |
+
<td style="text-align:center">
|
217 |
+
<div style="background:#fff;padding:10px;margin-bottom:10px;">
|
218 |
+
<a class="DBR-sidebar-link" href="http://sigmaplugin.com/contact" target="_blank">
|
219 |
+
<img style="width:50px" src="<?php echo DBR_PLUGIN_DIR_PATH; ?>/images/help.svg"/>
|
220 |
+
<br/>
|
221 |
+
<span><?php _e('Support', 'advanced-wp-reset'); ?></span>
|
222 |
+
</a>
|
223 |
+
</div>
|
224 |
+
</td>
|
225 |
+
</tr>
|
226 |
+
</table>
|
227 |
+
</div>
|
228 |
+
|
229 |
+
<h1 style="font-size:10px"></h1>
|
230 |
+
|
231 |
+
<div class="DBR-margin-r-300" style="margin-top:30px">
|
232 |
+
<div class="DBR-tab-box">
|
233 |
+
|
234 |
+
<a id="reset_all_tab" class="DBR-tablinks"><?php _e('Reset all', 'advanced-wp-reset') ?></a>
|
235 |
+
<a id="custom_reset_tab" class="DBR-tablinks"><?php _e('Custom reset', 'advanced-wp-reset') ?></a>
|
236 |
+
<!--<a id="reset_tables_tab" class="DBR-tablinks"><?php //_e('Reset tables', 'advanced-wp-reset') ?></a>
|
237 |
+
<a id="profiles_tab" class="DBR-tablinks"><?php //_e('Profiles', 'advanced-wp-reset') ?></a>
|
238 |
+
<a id="collections_tab" class="DBR-tablinks"><?php //_e('Collections', 'advanced-wp-reset') ?></a>
|
239 |
+
<a id="settings_tab" class="DBR-tablinks"><?php //_e('Settings', 'advanced-wp-reset') ?></a>-->
|
240 |
+
|
241 |
+
<div class="DBR-tab-box-div"> <?php
|
242 |
+
include_once 'includes/reset.php';
|
243 |
+
include_once 'includes/custom_reset.php';
|
244 |
+
include_once 'includes/settings.php'; ?>
|
245 |
+
</div>
|
246 |
+
|
247 |
</div>
|
248 |
+
|
249 |
+
<div class="DBR-sidebar"><?php include_once 'includes/sidebar.php'; ?></div>
|
250 |
+
|
251 |
</div>
|
|
|
252 |
</div>
|
253 |
+
<?php
|
254 |
+
}
|
255 |
}
|
256 |
|
257 |
+
// Get instance
|
258 |
+
new DBR_Advanced_DB_Reset();
|
|
|
|
|
|
|
|
css/admin.css
CHANGED
@@ -1,114 +1,388 @@
|
|
1 |
/*---------------------------------------------------------------------------------------------
|
2 |
* Global styles
|
3 |
*---------------------------------------------------------------------------------------------*/
|
4 |
-
html
|
5 |
overflow-y: scroll;
|
6 |
}
|
7 |
-
.DBR-margin-r-300
|
8 |
-
margin-top:
|
9 |
-
margin-right:
|
10 |
}
|
11 |
.DBR-float-left{
|
12 |
-
float:
|
13 |
}
|
14 |
.DBR-float-right{
|
15 |
-
float:
|
16 |
}
|
17 |
.DBR-button-reset{
|
18 |
-
width:
|
19 |
-
height:
|
20 |
-
text-align:
|
21 |
}
|
22 |
-
.DBR-
|
23 |
-
|
24 |
-
|
|
|
|
|
25 |
}
|
26 |
|
27 |
/*---------------------------------------------------------------------------------------------
|
28 |
* Tabs
|
29 |
*---------------------------------------------------------------------------------------------*/
|
30 |
-
.DBR-tab-box
|
31 |
-
|
32 |
-
width:
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
42 |
}
|
43 |
|
44 |
/*---------------------------------------------------------------------------------------------
|
45 |
* Sidebar
|
46 |
*---------------------------------------------------------------------------------------------*/
|
47 |
-
.DBR-sidebar
|
48 |
-
float:
|
49 |
-
border:
|
50 |
-
background
|
51 |
-
margin-right
|
52 |
-
width:
|
53 |
-
border-radius:
|
54 |
-
-moz-border-radius:
|
55 |
-
-webkit-border-radius:
|
56 |
-
}
|
57 |
-
.DBR-sidebar > div{
|
58 |
-
padding: 15px;
|
59 |
-
}
|
60 |
-
.DBR-sidebar h2{
|
61 |
-
font-size: 16px;
|
62 |
-
text-align: center;
|
63 |
-
color: #888;
|
64 |
-
line-height: 24px;
|
65 |
-
}
|
66 |
-
.DBR-donation-text{
|
67 |
-
text-align:center;
|
68 |
-
color: #555
|
69 |
}
|
70 |
-
.DBR-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
|
|
|
|
|
|
75 |
}
|
76 |
.DBR-grey-row{
|
77 |
-
height:
|
78 |
-
background-color
|
79 |
}
|
80 |
.DBR-white-row{
|
81 |
-
height:
|
82 |
-
background-color
|
83 |
}
|
84 |
.DBR-row-text{
|
85 |
-
font-size:
|
86 |
-
color
|
87 |
}
|
88 |
.DBR-sidebar-link{
|
89 |
-
text-decoration:
|
90 |
}
|
91 |
.DBR-support-us{
|
92 |
-
background:
|
93 |
-
width:
|
94 |
-
height:
|
95 |
-
margin-top:
|
96 |
}
|
97 |
|
98 |
/*---------------------------------------------------------------------------------------------
|
99 |
* Box messages
|
100 |
*---------------------------------------------------------------------------------------------*/
|
101 |
-
.DBR-box-warning
|
102 |
-
|
103 |
-
border
|
104 |
-
color
|
105 |
-
padding: 10px 10px 10px
|
106 |
-
margin-bottom:
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
border-bottom:
|
111 |
-
color
|
112 |
-
padding: 10px 10px 10px
|
113 |
-
margin-bottom:
|
114 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
/*---------------------------------------------------------------------------------------------
|
2 |
* Global styles
|
3 |
*---------------------------------------------------------------------------------------------*/
|
4 |
+
html{
|
5 |
overflow-y: scroll;
|
6 |
}
|
7 |
+
.DBR-margin-r-300{
|
8 |
+
margin-top:10px;
|
9 |
+
margin-right:260px;
|
10 |
}
|
11 |
.DBR-float-left{
|
12 |
+
float:left;
|
13 |
}
|
14 |
.DBR-float-right{
|
15 |
+
float:right;
|
16 |
}
|
17 |
.DBR-button-reset{
|
18 |
+
width:150px !important;
|
19 |
+
height:40px !important;
|
20 |
+
text-align:center;
|
21 |
}
|
22 |
+
.DBR-path-style{
|
23 |
+
color:#000;
|
24 |
+
background:#e9e9e9;
|
25 |
+
padding:1px 3px;
|
26 |
+
|
27 |
}
|
28 |
|
29 |
/*---------------------------------------------------------------------------------------------
|
30 |
* Tabs
|
31 |
*---------------------------------------------------------------------------------------------*/
|
32 |
+
.DBR-tab-box{
|
33 |
+
float:left;
|
34 |
+
width:100%;
|
35 |
+
overflow:hidden;
|
36 |
+
}
|
37 |
+
.DBR-tab-box a{
|
38 |
+
float:left;
|
39 |
+
background:none;
|
40 |
+
border:none;
|
41 |
+
outline:none;
|
42 |
+
cursor:pointer;
|
43 |
+
padding:14px;
|
44 |
+
font-size:14px;
|
45 |
+
font-weight:600;
|
46 |
+
border-top:3px solid transparent;
|
47 |
+
}
|
48 |
+
.DBR-tab-box a:hover{
|
49 |
+
color:#024f72;
|
50 |
+
}
|
51 |
+
/* Create an active/current tablink class */
|
52 |
+
.DBR-tab-box a.active{
|
53 |
+
border-top:3px solid #0073aa;
|
54 |
+
background:#fff;
|
55 |
+
}
|
56 |
+
.DBR-tab-box-div{
|
57 |
+
clear:both;
|
58 |
+
min-height:400px;
|
59 |
+
background:#fff;
|
60 |
+
padding:35px 25px;
|
61 |
}
|
62 |
|
63 |
/*---------------------------------------------------------------------------------------------
|
64 |
* Sidebar
|
65 |
*---------------------------------------------------------------------------------------------*/
|
66 |
+
.DBR-sidebar{
|
67 |
+
float:right;
|
68 |
+
border:1px solid #ccc;
|
69 |
+
background:#fff;
|
70 |
+
margin-right:-260px;
|
71 |
+
width:240px;
|
72 |
+
border-radius:5px 5px 0 0;
|
73 |
+
-moz-border-radius:5px 5px 0 0;
|
74 |
+
-webkit-border-radius:5px 5px 0 0;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
75 |
}
|
76 |
+
.DBR-sidebar > div{
|
77 |
+
padding:15px;
|
78 |
+
}
|
79 |
+
.DBR-sidebar h2{
|
80 |
+
font-size:16px;
|
81 |
+
text-align:center;
|
82 |
+
color:#888;
|
83 |
+
line-height:24px;
|
84 |
}
|
85 |
.DBR-grey-row{
|
86 |
+
height:20px;
|
87 |
+
background-color:#fff;
|
88 |
}
|
89 |
.DBR-white-row{
|
90 |
+
height:20px;
|
91 |
+
background-color:#fff;
|
92 |
}
|
93 |
.DBR-row-text{
|
94 |
+
font-size:13px;
|
95 |
+
color:#555;
|
96 |
}
|
97 |
.DBR-sidebar-link{
|
98 |
+
text-decoration:none;
|
99 |
}
|
100 |
.DBR-support-us{
|
101 |
+
background:url("../images/rate.png") no-repeat center right;
|
102 |
+
width:88px;
|
103 |
+
height:18px;
|
104 |
+
margin-top:0px;
|
105 |
}
|
106 |
|
107 |
/*---------------------------------------------------------------------------------------------
|
108 |
* Box messages
|
109 |
*---------------------------------------------------------------------------------------------*/
|
110 |
+
.DBR-box-warning{
|
111 |
+
background: #fff7db;
|
112 |
+
border:1px dashed #FFB900;
|
113 |
+
color:#404040;
|
114 |
+
padding:10px 10px 10px 10px;
|
115 |
+
margin-bottom:20px;
|
116 |
+
border-radius: 4px;
|
117 |
+
}
|
118 |
+
.DBR-box-info{
|
119 |
+
border-bottom:1px dashed #ccc;
|
120 |
+
color:#404040;
|
121 |
+
padding:10px 10px 10px 10px;
|
122 |
+
margin-bottom:20px;
|
123 |
+
}
|
124 |
+
|
125 |
+
/*---------------------------------------------------------------------------------------------
|
126 |
+
* Tool tip for info
|
127 |
+
*---------------------------------------------------------------------------------------------*/
|
128 |
+
span.DBR-tooltips-headers {
|
129 |
+
position: relative;
|
130 |
+
display: inline;
|
131 |
+
cursor: pointer;
|
132 |
+
color: #000;
|
133 |
+
}
|
134 |
+
span.DBR-tooltips-headers span {
|
135 |
+
position: absolute;
|
136 |
+
text-align: left;
|
137 |
+
line-height: 22px;
|
138 |
+
color: #fff;
|
139 |
+
background: #555;
|
140 |
+
opacity: 1 !important;
|
141 |
+
font-size: 13px;
|
142 |
+
font-weight: normal;
|
143 |
+
padding: 10px;
|
144 |
+
visibility: hidden;
|
145 |
+
width: 240px;
|
146 |
+
border: 1px solid #222;
|
147 |
+
border-radius: 4px;
|
148 |
+
-moz-border-radius: 4px;
|
149 |
+
-webkit-border-radius: 4px;
|
150 |
+
}
|
151 |
+
span.DBR-tooltips-headers span:after {
|
152 |
+
content: '';
|
153 |
+
position: absolute;
|
154 |
+
top: 18px;
|
155 |
+
right: 100%;
|
156 |
+
margin-top: -8px;
|
157 |
+
width: 0;
|
158 |
+
height: 0;
|
159 |
+
border-right: 8px solid #555;
|
160 |
+
border-top: 8px solid transparent;
|
161 |
+
border-bottom: 8px solid transparent;
|
162 |
+
}
|
163 |
+
span:hover.DBR-tooltips-headers span {
|
164 |
+
visibility: visible;
|
165 |
+
left: 100%;
|
166 |
+
top: 50%;
|
167 |
+
margin-top: -18px;
|
168 |
+
margin-left: 8px;
|
169 |
+
z-index: 999;
|
170 |
+
}
|
171 |
+
.DBR-info-image {
|
172 |
+
width: 15px;
|
173 |
+
vertical-align: middle;
|
174 |
+
margin-left: 2px;
|
175 |
+
margin-bottom: 4px;
|
176 |
+
}
|
177 |
+
|
178 |
+
/*---------------------------------------------------------------------------------------------
|
179 |
+
* 'Custom reset' tab css
|
180 |
+
*---------------------------------------------------------------------------------------------*/
|
181 |
+
.DBR-header-box-msg{
|
182 |
+
margin-bottom:40px;
|
183 |
+
padding:30px;
|
184 |
+
background:#f0f5fa;
|
185 |
+
border:1px solid #ccc;
|
186 |
+
border-radius:5px;
|
187 |
+
}
|
188 |
+
.DBR-sortable-highlight{
|
189 |
+
border:2px dashed #999;
|
190 |
+
height:50px;
|
191 |
+
}
|
192 |
+
.DBR-custom-reset-table{
|
193 |
+
border-collapse: collapse;
|
194 |
+
margin-bottom:30px;
|
195 |
+
border: 1px solid #f0f0f0 !important;
|
196 |
+
}
|
197 |
+
.DBR-item-to-reset-title{
|
198 |
+
cursor:pointer;
|
199 |
+
font-weight:600;
|
200 |
+
}
|
201 |
+
.DBR-item-to-reset-exclude{
|
202 |
+
font-size:12px;
|
203 |
+
color:grey;
|
204 |
+
}
|
205 |
+
.DBR-table-header-title{
|
206 |
+
background:#fff;
|
207 |
+
padding:15px 0px;
|
208 |
+
font-size:14px;
|
209 |
+
vertical-align:top;
|
210 |
+
border-bottom:2px solid #e9e9e9;
|
211 |
+
}
|
212 |
+
.DBR-item-to-reset-total{
|
213 |
+
color:grey;
|
214 |
+
}
|
215 |
+
.DBR-dashicons-warning{
|
216 |
+
color:#EB7F63;
|
217 |
+
font-size:18px;
|
218 |
+
margin-right:2px;
|
219 |
+
vertical-align:middle;
|
220 |
+
}
|
221 |
+
.DBR-deselect-all{
|
222 |
+
width:75px;
|
223 |
+
cursor:pointer;
|
224 |
+
margin-bottom:10px;
|
225 |
+
color:#0073aa;
|
226 |
+
font-weight:600;
|
227 |
+
display:none;
|
228 |
+
}
|
229 |
+
.DBR_tabcontent {
|
230 |
+
display:none;
|
231 |
+
}
|
232 |
+
.DBR-accordion{
|
233 |
+
float:right;
|
234 |
+
cursor:pointer;
|
235 |
+
border:1px solid #ccc;
|
236 |
+
border-radius:4px;
|
237 |
+
}
|
238 |
+
.DBR-spinning-checkbox{
|
239 |
+
vertical-align:middle;
|
240 |
+
width:22px;
|
241 |
+
display:none;
|
242 |
+
}
|
243 |
+
.DBR-reorder-tables{
|
244 |
+
float:right;
|
245 |
+
padding-top:10px;
|
246 |
+
cursor:pointer;
|
247 |
+
}
|
248 |
+
.DBR-save-order-tables{
|
249 |
+
float:right;
|
250 |
+
color:#fff;
|
251 |
+
padding:8px;
|
252 |
+
border-radius:3px;
|
253 |
+
cursor:pointer;
|
254 |
+
background:#2BC48A;
|
255 |
+
display:none;
|
256 |
+
}
|
257 |
+
.DBR-collapse-expand-all-tables{
|
258 |
+
float:right;
|
259 |
+
padding-top:10px;
|
260 |
+
cursor:pointer;
|
261 |
+
}
|
262 |
+
.DBR-hor-divider{
|
263 |
+
padding-left:10px;
|
264 |
+
padding-right:10px;
|
265 |
+
color:grey;
|
266 |
+
cursor:default;
|
267 |
+
}
|
268 |
+
.DBR-save-order-tables:hover{
|
269 |
+
background:#1ab278;
|
270 |
+
}
|
271 |
+
.DBR-order-li-element{
|
272 |
+
list-style-type:none;
|
273 |
+
}
|
274 |
+
.DBR-only-in-mobile{
|
275 |
+
display:none !important;
|
276 |
+
}
|
277 |
+
.DBR-only-in-desktop{
|
278 |
+
display:inline-block !important;
|
279 |
+
}
|
280 |
+
.DBR-custom-reset-button{
|
281 |
+
border:1px solid grey !important;
|
282 |
+
padding:5px 12px !important;
|
283 |
+
font-weight:600 !important;
|
284 |
+
border-radius:16px !important;
|
285 |
+
vertical-align:bottom !important;
|
286 |
+
}
|
287 |
+
|
288 |
+
/*---------------------------------------------------------------------------------------------
|
289 |
+
* Override css of WP tables
|
290 |
+
*---------------------------------------------------------------------------------------------*/
|
291 |
+
|
292 |
+
.widefat tr.DBR-custom-reset-tr{
|
293 |
+
background:#f5f5f5;
|
294 |
+
border-bottom:2px solid #fff;
|
295 |
+
}
|
296 |
+
.widefat tr.DBR-custom-reset-tr:hover{
|
297 |
+
background:#e5e5e5;
|
298 |
+
}
|
299 |
+
.widefat th{
|
300 |
+
vertical-align:top !important;
|
301 |
+
}
|
302 |
+
.widefat td{
|
303 |
+
padding:10px 10px;
|
304 |
+
vertical-align:top !important;
|
305 |
+
color:#111 !important;
|
306 |
+
min-height:51px !important;
|
307 |
+
}
|
308 |
+
|
309 |
+
/*---------------------------------------------------------------------------------------------
|
310 |
+
* ON/OFF switch - the box around the slider
|
311 |
+
*---------------------------------------------------------------------------------------------*/
|
312 |
+
.DBR-switch{
|
313 |
+
position:relative;
|
314 |
+
display:inline-block;
|
315 |
+
width:25px;
|
316 |
+
height:15px;
|
317 |
+
}
|
318 |
+
.DBR-switch input{
|
319 |
+
opacity:0;
|
320 |
+
width:0;
|
321 |
+
height:0;
|
322 |
+
}
|
323 |
+
.DBR-slider{
|
324 |
+
position:absolute;
|
325 |
+
cursor:pointer;
|
326 |
+
top:0;
|
327 |
+
left:0;
|
328 |
+
right:0;
|
329 |
+
bottom:0;
|
330 |
+
background-color:#ccc;
|
331 |
+
-webkit-transition:.4s;
|
332 |
+
transition:.4s;
|
333 |
+
}
|
334 |
+
.DBR-slider:before{
|
335 |
+
position:absolute;
|
336 |
+
content:"";
|
337 |
+
height:13px;
|
338 |
+
width:13px;
|
339 |
+
left:1px;
|
340 |
+
bottom:1px;
|
341 |
+
background-color:white;
|
342 |
+
-webkit-transition:.4s;
|
343 |
+
transition:.4s;
|
344 |
+
}
|
345 |
+
input:checked + .DBR-slider{
|
346 |
+
background-color:green;
|
347 |
+
}
|
348 |
+
input:checked + .DBR-slider:before{
|
349 |
+
-webkit-transform:translateX(10px);
|
350 |
+
-ms-transform:translateX(10px);
|
351 |
+
transform:translateX(10px);
|
352 |
+
}
|
353 |
+
/* Rounded sliders */
|
354 |
+
.DBR-slider.round{
|
355 |
+
border-radius:34px;
|
356 |
+
}
|
357 |
+
.DBR-slider.round:before{
|
358 |
+
border-radius:50%;
|
359 |
+
}
|
360 |
+
|
361 |
+
/*---------------------------------------------------------------------------------------------
|
362 |
+
* Style for mobile
|
363 |
+
*---------------------------------------------------------------------------------------------*/
|
364 |
+
@media only screen and (max-width: 600px){
|
365 |
+
.DBR-only-in-mobile{
|
366 |
+
display:inline-block !important;
|
367 |
+
}
|
368 |
+
.DBR-only-in-desktop{
|
369 |
+
display:none !important;
|
370 |
+
}
|
371 |
+
.DBR-margin-r-300{
|
372 |
+
margin-top:10px;
|
373 |
+
margin-right:0px;
|
374 |
+
}
|
375 |
+
.DBR-sidebar {
|
376 |
+
clear:both;
|
377 |
+
border:1px solid #ccc;
|
378 |
+
background:#fff;
|
379 |
+
margin:0px;
|
380 |
+
width:100%;
|
381 |
+
border-radius:0px;
|
382 |
+
-moz-border-radius:0px;
|
383 |
+
-webkit-border-radius:0px;
|
384 |
+
}
|
385 |
+
span.DBR-tooltips-headers span {
|
386 |
+
width: 150px;
|
387 |
+
}
|
388 |
+
}
|
images/donate.gif
DELETED
Binary file
|
images/help.svg
ADDED
@@ -0,0 +1,70 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0" encoding="iso-8859-1"?>
|
2 |
+
<!-- Generator: Adobe Illustrator 19.0.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
|
3 |
+
<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
|
4 |
+
viewBox="0 0 504.124 504.124" style="enable-background:new 0 0 504.124 504.124;" xml:space="preserve">
|
5 |
+
<path style="fill:#E4E7E7;" d="M441.108,244.578l-1.182-16.148l10.24-10.24c45.292-45.292,45.292-119.335,0-164.234
|
6 |
+
c-45.292-45.292-118.942-45.292-164.234,0l-10.24,10.24c-5.12-0.788-10.634-1.182-16.148-1.182l17.723-17.723
|
7 |
+
c50.018-50.018,131.545-50.412,181.563,0c50.018,50.018,50.018,131.545,0,181.563C458.831,226.855,441.108,244.578,441.108,244.578z
|
8 |
+
M228.825,64.591l-10.24-10.24c-45.292-45.292-119.335-45.292-164.234,0c-45.686,44.898-45.686,118.942,0,164.234l10.24,10.24
|
9 |
+
c-0.788,5.12-1.182,10.634-1.182,16.148L45.686,227.25c-50.018-50.018-50.412-131.545,0-181.563
|
10 |
+
c50.018-50.018,131.545-50.018,181.563,0l17.723,17.723C239.458,63.409,233.945,63.803,228.825,64.591z M63.015,259.545
|
11 |
+
l1.182,16.148l-10.24,10.24C8.665,331.225,8.665,405.268,53.563,450.166c45.292,45.292,118.942,45.292,164.234,0l10.24-10.24
|
12 |
+
c5.12,0.788,10.634,1.182,16.148,1.182l-17.723,17.723c-50.018,50.018-131.545,50.412-181.563,0.394S-5.12,327.68,45.292,277.661
|
13 |
+
L63.015,259.545z M275.298,439.532l10.24,10.24c45.292,45.292,119.335,45.292,164.234,0c45.292-45.292,45.292-118.942-0.394-164.234
|
14 |
+
l-10.24-10.24c0.788-5.12,1.182-10.634,1.182-16.148l17.723,17.723c50.018,50.018,50.412,131.545,0.394,181.563
|
15 |
+
s-131.545,50.018-181.563-0.394l-17.723-17.723C264.665,440.714,270.178,440.32,275.298,439.532z"/>
|
16 |
+
<path style="fill:#E2574C;" d="M252.062,0C113.034,0,0,113.034,0,252.062s112.64,252.062,252.062,252.062
|
17 |
+
c139.028,0,252.062-113.034,252.062-252.062S391.089,0,252.062,0z M252.062,378.092c-69.711,0-126.031-56.32-126.031-126.031
|
18 |
+
s56.32-126.031,126.031-126.031s126.031,56.32,126.031,126.031S321.772,378.092,252.062,378.092z"/>
|
19 |
+
<path style="fill:#D95449;" d="M252.062,95.705c-86.252,0-156.357,70.105-156.357,156.357s70.105,156.357,156.357,156.357
|
20 |
+
s156.357-70.105,156.357-156.357S338.314,95.705,252.062,95.705z M252.062,378.092c-69.711,0-126.031-56.32-126.031-126.031
|
21 |
+
s56.32-126.031,126.031-126.031s126.031,56.32,126.031,126.031S321.772,378.092,252.062,378.092z"/>
|
22 |
+
<path style="fill:#E5685E;" d="M252.062,35.446c-119.729,0-216.615,96.886-216.615,216.615s96.886,216.615,216.615,216.615
|
23 |
+
s216.615-96.886,216.615-216.615S371.791,35.446,252.062,35.446z M252.062,452.923c-111.065,0-200.862-89.797-200.862-200.862
|
24 |
+
S140.997,51.2,252.062,51.2s200.862,89.797,200.862,200.862S363.126,452.923,252.062,452.923z"/>
|
25 |
+
<path style="fill:#EFEFEF;" d="M193.378,363.52c-22.843-11.815-41.354-30.72-53.169-53.169l-90.978,91.372
|
26 |
+
c14.966,20.086,32.689,38.203,53.169,53.169L193.378,363.52z M310.351,140.209c22.843,11.815,41.354,30.326,53.169,53.169
|
27 |
+
l91.372-90.978c-14.966-20.086-33.083-38.203-53.169-53.169L310.351,140.209z M49.231,102.4l90.978,90.978
|
28 |
+
c11.815-22.843,30.326-41.354,53.169-53.169L102.4,49.231C82.314,64.197,64.197,82.314,49.231,102.4z M454.892,401.723
|
29 |
+
l-90.978-90.978c-11.815,22.843-30.326,41.354-53.169,53.169l90.978,90.978C421.809,439.926,439.926,421.809,454.892,401.723z"/>
|
30 |
+
<path style="fill:#E6E6E6;" d="M332.8,118.154l-22.055,22.055c22.843,11.815,41.354,30.326,53.169,53.169l22.055-22.055
|
31 |
+
C372.578,149.662,354.462,131.151,332.8,118.154z M140.209,310.351L118.154,332.8c12.997,21.662,31.508,39.778,53.169,53.169
|
32 |
+
l22.055-22.055C170.929,351.705,152.418,333.194,140.209,310.351z M310.745,363.914l22.055,22.055
|
33 |
+
c21.662-12.997,39.778-31.508,53.169-53.169l-22.055-22.055C351.705,333.194,333.194,351.705,310.745,363.914z M193.772,140.603
|
34 |
+
l-22.449-22.449c-21.662,13.391-39.778,31.508-53.169,53.169l22.055,22.055C152.418,170.929,170.929,152.418,193.772,140.603z"/>
|
35 |
+
<path style="fill:#F1F1F1;" d="M85.858,365.095l-11.422,11.422c14.572,20.48,32.295,38.597,53.169,53.169l11.422-11.422
|
36 |
+
C118.154,403.692,100.037,385.969,85.858,365.095z M418.265,365.095c-14.178,20.874-32.295,38.991-53.169,53.169l11.422,11.422
|
37 |
+
c20.48-14.572,38.597-32.689,53.169-53.169L418.265,365.095z M85.858,139.028c14.178-20.874,32.295-38.991,53.169-53.169L128,74.831
|
38 |
+
C107.52,89.403,89.403,107.52,74.831,128L85.858,139.028z M418.265,139.028l11.422-11.422
|
39 |
+
c-14.572-20.48-32.689-38.597-53.169-53.169l-11.422,11.422C385.969,100.037,403.692,118.154,418.265,139.028z"/>
|
40 |
+
<g>
|
41 |
+
</g>
|
42 |
+
<g>
|
43 |
+
</g>
|
44 |
+
<g>
|
45 |
+
</g>
|
46 |
+
<g>
|
47 |
+
</g>
|
48 |
+
<g>
|
49 |
+
</g>
|
50 |
+
<g>
|
51 |
+
</g>
|
52 |
+
<g>
|
53 |
+
</g>
|
54 |
+
<g>
|
55 |
+
</g>
|
56 |
+
<g>
|
57 |
+
</g>
|
58 |
+
<g>
|
59 |
+
</g>
|
60 |
+
<g>
|
61 |
+
</g>
|
62 |
+
<g>
|
63 |
+
</g>
|
64 |
+
<g>
|
65 |
+
</g>
|
66 |
+
<g>
|
67 |
+
</g>
|
68 |
+
<g>
|
69 |
+
</g>
|
70 |
+
</svg>
|
images/icon-128x128.png
ADDED
Binary file
|
images/info.png
DELETED
Binary file
|
images/information2.svg
ADDED
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0" encoding="iso-8859-1"?>
|
2 |
+
<!-- Generator: Adobe Illustrator 19.0.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
|
3 |
+
<svg version="1.1" id="Capa_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
|
4 |
+
viewBox="0 0 512 512" style="enable-background:new 0 0 512 512;" xml:space="preserve">
|
5 |
+
<g>
|
6 |
+
<g>
|
7 |
+
<g fill="#666">
|
8 |
+
<circle cx="256" cy="378.5" r="25"/>/>
|
9 |
+
<path d="M256,0C114.516,0,0,114.497,0,256c0,141.484,114.497,256,256,256c141.484,0,256-114.497,256-256
|
10 |
+
C512,114.516,397.503,0,256,0z M256,472c-119.377,0-216-96.607-216-216c0-119.377,96.607-216,216-216
|
11 |
+
c119.377,0,216,96.607,216,216C472,375.377,375.393,472,256,472z"/>
|
12 |
+
<path d="M256,128.5c-44.112,0-80,35.888-80,80c0,11.046,8.954,20,20,20s20-8.954,20-20c0-22.056,17.944-40,40-40
|
13 |
+
c22.056,0,40,17.944,40,40c0,22.056-17.944,40-40,40c-11.046,0-20,8.954-20,20v50c0,11.046,8.954,20,20,20
|
14 |
+
c11.046,0,20-8.954,20-20v-32.531c34.466-8.903,60-40.26,60-77.469C336,164.388,300.112,128.5,256,128.5z"/>/>
|
15 |
+
</g>
|
16 |
+
</g>
|
17 |
+
</g>
|
18 |
+
|
19 |
+
</svg>
|
images/warning.png
DELETED
Binary file
|
includes/custom_reset.php
ADDED
@@ -0,0 +1,156 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
|
2 |
+
<div id="custom_reset_tab_content" class="DBR_tabcontent">
|
3 |
+
|
4 |
+
<div class="DBR-box-warning" style="">
|
5 |
+
<span class="dashicons dashicons-warning DBR-dashicons-warning" style="color:red"></span>
|
6 |
+
<span style="color:red"><strong><?php _e('WARNING','advanced-wp-reset'); ?></strong></span>:
|
7 |
+
<?php _e('The plugin does not backup your database and files before the rest. Please don\'t forget to make a backup in case you think you will need it.','advanced-wp-reset'); ?>
|
8 |
+
</div>
|
9 |
+
|
10 |
+
<div style="display:none">
|
11 |
+
|
12 |
+
<input id="" class="button button-primary button-large" type="submit" value="Reset all selected items">
|
13 |
+
<input id="" class="button button-primary button-large" type="submit" value="Create new profile">
|
14 |
+
|
15 |
+
<div id="DBR_reorder_tables" class="DBR-reorder-tables">
|
16 |
+
<span><?php _e('Reorder tables', 'advanced-wp-reset')?></span>
|
17 |
+
<span class="dashicons dashicons-editor-ul"></span>
|
18 |
+
</div>
|
19 |
+
|
20 |
+
<div id="DBR_save_order_tables" class="DBR-save-order-tables">
|
21 |
+
<span><?php _e('Save the new order', 'advanced-wp-reset')?></span>
|
22 |
+
<span class="dashicons dashicons-saved"></span>
|
23 |
+
</div>
|
24 |
+
|
25 |
+
<div id="DBR_collapse_all_tables" class="DBR-collapse-expand-all-tables">
|
26 |
+
<span class=""><?php _e('Collapse all', 'advanced-wp-reset')?></span>
|
27 |
+
<span class="DBR-hor-divider">|</span>
|
28 |
+
</div>
|
29 |
+
|
30 |
+
<div id="DBR_expand_all_tables" class="DBR-collapse-expand-all-tables">
|
31 |
+
<span class=""><?php _e('Expand all', 'advanced-wp-reset')?></span>
|
32 |
+
<span class="DBR-hor-divider">|</span>
|
33 |
+
</div>
|
34 |
+
|
35 |
+
</div>
|
36 |
+
|
37 |
+
<ul id="my_sortable">
|
38 |
+
|
39 |
+
<?php
|
40 |
+
|
41 |
+
// Prepare the list of items to reset with their explanations
|
42 |
+
$all_items_array = DBR_prepare_custom_reset_items();
|
43 |
+
$all_explanations = DBR_prepare_explanations_for_custom_reset_items();
|
44 |
+
|
45 |
+
foreach($all_items_array as $item_type => $item_info){ ?>
|
46 |
+
|
47 |
+
<li id="order_<?php echo $item_type?>" value="<?php echo $item_type?>" class="DBR-order-li-element">
|
48 |
+
|
49 |
+
<div id="DBR_accordion_div_<?php echo $item_type?>" class="DBR-table-header-title">
|
50 |
+
|
51 |
+
<?php echo '<span style="color:#EB7F63;font-size:1.2em;font-weight:700;padding-bottom:10px">' . $item_info['table_title'] . '</span>'?>
|
52 |
+
|
53 |
+
<span id="DBR_accordion_link_<?php echo $item_type?>" class="dashicons dashicons-arrow-up DBR-accordion" style="display:none"></span>
|
54 |
+
|
55 |
+
</div>
|
56 |
+
|
57 |
+
<table id="DBR_table_custom_reset_<?php echo $item_type?>" class="wp-list-table widefat DBR-custom-reset-table">
|
58 |
+
<tbody>
|
59 |
+
|
60 |
+
<?php
|
61 |
+
|
62 |
+
foreach($item_info['table_rows'] as $row_info){ ?>
|
63 |
+
|
64 |
+
<tr class="DBR-custom-reset-tr">
|
65 |
+
|
66 |
+
<!--<th style="width:4%;padding-top:19px">
|
67 |
+
<input id="DBR_checkbox_<?php //echo $row_info['type'] ?>" type="checkbox" value="true">
|
68 |
+
</th>-->
|
69 |
+
|
70 |
+
<td style="width:20%;padding-top:15px">
|
71 |
+
|
72 |
+
<span value="<?php echo $row_info['type'] ?>" class="DBR-item-to-reset-title">
|
73 |
+
<?php echo $row_info['title'] ?>
|
74 |
+
</span>
|
75 |
+
<?php echo $row_info['deals_with'] ?>
|
76 |
+
|
77 |
+
<?php
|
78 |
+
// Add checkbox in case of themes-files and plugins-files to keep active theme and DBR plugin
|
79 |
+
if($row_info['type'] == 'themes-files'){ ?>
|
80 |
+
<div style="margin:3px 0px">
|
81 |
+
<label class="DBR-switch">
|
82 |
+
<input id="DBR_keep_active_theme" type="checkbox" checked>
|
83 |
+
<span class="DBR-slider round"></span>
|
84 |
+
</label>
|
85 |
+
<?php _e('Keep active theme', 'advanced-wp-reset') ?>
|
86 |
+
</div>
|
87 |
+
<?php
|
88 |
+
}
|
89 |
+
//if($row_info['type'] == 'plugins-files'){ ?>
|
90 |
+
<!--<div style="margin:3px 0px">
|
91 |
+
<label class="DBR-switch">
|
92 |
+
<input id="DBR_keep_this_plugin" type="checkbox" checked>
|
93 |
+
<span class="DBR-slider round"></span>
|
94 |
+
</label>
|
95 |
+
<?php //_e('Keep current plugin', 'advanced-wp-reset') ?>
|
96 |
+
</div>-->
|
97 |
+
<?php
|
98 |
+
//}
|
99 |
+
?>
|
100 |
+
|
101 |
+
<div id="" class="DBR-item-to-reset-exclude">
|
102 |
+
|
103 |
+
<?php _e('Total', 'advanced-wp-reset')?>
|
104 |
+
|
105 |
+
<span id="DBR_total_<?php echo $row_info['type']?>" class="DBR-item-to-reset-total">-</span>
|
106 |
+
|
107 |
+
<img id="DBR_spinning_checkbox_<?php echo $row_info['type']?>" class="DBR-spinning-checkbox" src="<?php echo DBR_PLUGIN_DIR_PATH; ?>/images/loading20px.svg"/>
|
108 |
+
|
109 |
+
</div>
|
110 |
+
|
111 |
+
</td>
|
112 |
+
|
113 |
+
<td style="width:20%;padding-top:15px">
|
114 |
+
|
115 |
+
<div style="text-align:center">
|
116 |
+
<button name="<?php echo $row_info['type']?>" value="<?php echo $row_info['title']?>" class="button button-secondary DBR-only-in-desktop DBR-custom-reset-button" type="button">
|
117 |
+
|
118 |
+
<?php _e('Run reset now', 'advanced-wp-reset')?>
|
119 |
+
|
120 |
+
</button>
|
121 |
+
|
122 |
+
<button name="<?php echo $row_info['type']?>" value="<?php echo $row_info['title']?>" class="button button-secondary DBR-only-in-mobile DBR-custom-reset-button" type="button">
|
123 |
+
|
124 |
+
<?php _e('Reset', 'advanced-wp-reset')?>
|
125 |
+
|
126 |
+
</button>
|
127 |
+
</div>
|
128 |
+
|
129 |
+
</td>
|
130 |
+
<td class="DBR-only-in-desktop">
|
131 |
+
<?php echo $all_explanations[$row_info['type']]?>
|
132 |
+
</td>
|
133 |
+
|
134 |
+
</tr>
|
135 |
+
|
136 |
+
<?php
|
137 |
+
}
|
138 |
+
?>
|
139 |
+
|
140 |
+
</tbody>
|
141 |
+
|
142 |
+
</table>
|
143 |
+
|
144 |
+
</li>
|
145 |
+
|
146 |
+
<?php
|
147 |
+
}
|
148 |
+
?>
|
149 |
+
</ul>
|
150 |
+
|
151 |
+
<!--<div style="margin-top:15px">
|
152 |
+
<input id="" class="button button-primary button-large" type="submit" value="Reset all selected items">
|
153 |
+
<input id="" class="button button-primary button-large" type="submit" value="Create new profile">
|
154 |
+
</div>-->
|
155 |
+
|
156 |
+
</div>
|
includes/functions.php
CHANGED
@@ -1,44 +1,187 @@
|
|
1 |
<?php
|
2 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
3 |
* Resets the database back to its initial status just like a fresh installation
|
4 |
-
|
|
|
|
|
5 |
function DBR_wp_reset(){
|
6 |
|
7 |
// Verify ajax nonce before doing anything
|
8 |
check_ajax_referer('DBR_nonce', 'security');
|
9 |
|
10 |
-
require_once(
|
11 |
global $current_user, $wpdb;
|
12 |
-
|
13 |
-
$
|
14 |
-
$
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
|
|
|
|
19 |
$user = $current_user;
|
|
|
|
|
|
|
|
|
|
|
|
|
20 |
}
|
21 |
-
|
22 |
-
$tables = $wpdb->get_col( "SHOW TABLES LIKE '{$prefix}%'" );
|
23 |
-
foreach ( $tables as $table ) {
|
24 |
-
$wpdb->query( "DROP TABLE $table" );
|
25 |
-
}
|
26 |
// Install wordpress
|
27 |
-
$result
|
28 |
-
|
|
|
29 |
// Set user password
|
30 |
-
$query = $wpdb->prepare(
|
31 |
-
$wpdb->query(
|
32 |
-
|
33 |
-
$get_user_meta = function_exists( 'get_user_meta' ) ? 'get_user_meta' : 'get_usermeta';
|
34 |
-
$update_user_meta = function_exists( 'update_user_meta' ) ? 'update_user_meta' : 'update_usermeta';
|
35 |
// Say to wordpress that we will not use generated password
|
36 |
-
if
|
37 |
-
|
38 |
-
|
39 |
-
if
|
40 |
-
|
41 |
-
|
42 |
// Add a small file to invite users rate the plugin
|
43 |
$aDBc_upload_dir = wp_upload_dir();
|
44 |
$aDBc_file_path = str_replace('\\' ,'/', $aDBc_upload_dir['basedir']) . "/DBR.txt";
|
@@ -49,16 +192,610 @@ function DBR_wp_reset(){
|
|
49 |
}
|
50 |
}
|
51 |
|
52 |
-
// Reactivate the plugin
|
53 |
@activate_plugin(DBR_PLUGIN_BASENAME);
|
54 |
-
// Clear all cookies associated with authentication
|
55 |
-
//wp_clear_auth_cookie();
|
56 |
-
// Set the authentication cookies based User ID
|
57 |
-
//wp_set_auth_cookie( $user_id );
|
58 |
-
// Redirect user to admin pannel
|
59 |
-
//wp_redirect( admin_url()."tools.php?page=advanced_wp_reset&reset-db=done");
|
60 |
|
61 |
wp_die(); // Always die after ajax call
|
62 |
}
|
63 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
64 |
?>
|
1 |
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Execute the called tool. This function is called via ajax
|
5 |
+
*
|
6 |
+
* @return null
|
7 |
+
*/
|
8 |
+
function DBR_execute_called_tool(){
|
9 |
+
|
10 |
+
// Security and role check
|
11 |
+
check_ajax_referer('DBR_nonce', 'security');
|
12 |
+
|
13 |
+
if(!current_user_can('administrator')){
|
14 |
+
wp_send_json_error(__('Not sufficient permissions!', 'advanced-wp-reset'));
|
15 |
+
}
|
16 |
+
|
17 |
+
// Sanitize $_REQUEST['DBR_tool']
|
18 |
+
$item_to_reset = sanitize_html_class($_REQUEST['DBR_item_to_reset']);
|
19 |
+
|
20 |
+
switch($item_to_reset){
|
21 |
+
|
22 |
+
case 'uploads-files':
|
23 |
+
DBR_reset_uploads_dir();
|
24 |
+
break;
|
25 |
+
|
26 |
+
case 'themes-files' :
|
27 |
+
$keep_active_theme = $_REQUEST['DBR_keep_active_theme'] == 0 ? false : true;
|
28 |
+
DBR_delete_all_themes($keep_active_theme);
|
29 |
+
break;
|
30 |
+
|
31 |
+
case 'plugins-files' :
|
32 |
+
DBR_delete_all_plugins(true);
|
33 |
+
break;
|
34 |
+
|
35 |
+
case 'wp-content-files' :
|
36 |
+
|
37 |
+
DBR_reset_wp_content_dir();
|
38 |
+
break;
|
39 |
+
|
40 |
+
case 'mu-plugins-files' :
|
41 |
+
DBR_reset_mu_plugins_dir();
|
42 |
+
break;
|
43 |
+
|
44 |
+
case 'htaccess-files' :
|
45 |
+
DBR_delete_htaccess_file();
|
46 |
+
break;
|
47 |
+
|
48 |
+
case 'nav-menus' :
|
49 |
+
// TODO
|
50 |
+
break;
|
51 |
+
|
52 |
+
case 'widgets' :
|
53 |
+
// TODO
|
54 |
+
break;
|
55 |
+
|
56 |
+
case 'transients' :
|
57 |
+
// TODO
|
58 |
+
break;
|
59 |
+
|
60 |
+
case 'themes-options' :
|
61 |
+
// TODO
|
62 |
+
break;
|
63 |
+
|
64 |
+
case 'posts' :
|
65 |
+
// TODO
|
66 |
+
break;
|
67 |
+
|
68 |
+
case 'pages' :
|
69 |
+
// TODO
|
70 |
+
break;
|
71 |
+
|
72 |
+
case 'media' :
|
73 |
+
// TODO
|
74 |
+
break;
|
75 |
+
|
76 |
+
case 'revisions' :
|
77 |
+
// TODO
|
78 |
+
break;
|
79 |
+
|
80 |
+
case 'drafts' :
|
81 |
+
// TODO
|
82 |
+
break;
|
83 |
+
|
84 |
+
case 'auto-drafts' :
|
85 |
+
// TODO
|
86 |
+
break;
|
87 |
+
|
88 |
+
case 'trash-posts' :
|
89 |
+
// TODO
|
90 |
+
break;
|
91 |
+
|
92 |
+
case 'categories' :
|
93 |
+
// TODO
|
94 |
+
break;
|
95 |
+
|
96 |
+
case 'tags' :
|
97 |
+
// TODO
|
98 |
+
break;
|
99 |
+
|
100 |
+
case 'all-comments' :
|
101 |
+
DBR_delete_comments("all-comments");
|
102 |
+
break;
|
103 |
+
|
104 |
+
case 'pending-comments' :
|
105 |
+
DBR_delete_comments("pending-comments");
|
106 |
+
break;
|
107 |
+
|
108 |
+
case 'spam-comments' :
|
109 |
+
DBR_delete_comments("spam-comments");
|
110 |
+
break;
|
111 |
+
|
112 |
+
case 'trashed-comments' :
|
113 |
+
DBR_delete_comments("trashed-comments");
|
114 |
+
break;
|
115 |
+
|
116 |
+
case 'pingbacks' :
|
117 |
+
DBR_delete_comments("pingbacks");
|
118 |
+
break;
|
119 |
+
|
120 |
+
case 'trackbacks' :
|
121 |
+
DBR_delete_comments("trackbacks");
|
122 |
+
break;
|
123 |
+
|
124 |
+
case 'users' :
|
125 |
+
// TODO
|
126 |
+
break;
|
127 |
+
|
128 |
+
case 'user-roles' :
|
129 |
+
// TODO
|
130 |
+
break;
|
131 |
+
|
132 |
+
default:
|
133 |
+
wp_send_json_error(__('Cannot find this tool!', 'advanced-wp-reset'));
|
134 |
+
}
|
135 |
+
|
136 |
+
// If no error reported before, success and die
|
137 |
+
wp_send_json_success();
|
138 |
+
}
|
139 |
+
|
140 |
+
/**
|
141 |
* Resets the database back to its initial status just like a fresh installation
|
142 |
+
*
|
143 |
+
* @return null
|
144 |
+
*/
|
145 |
function DBR_wp_reset(){
|
146 |
|
147 |
// Verify ajax nonce before doing anything
|
148 |
check_ajax_referer('DBR_nonce', 'security');
|
149 |
|
150 |
+
require_once(ABSPATH . '/wp-admin/includes/upgrade.php');
|
151 |
global $current_user, $wpdb;
|
152 |
+
|
153 |
+
$blogname = get_option('blogname');
|
154 |
+
$admin_email = get_option('admin_email');
|
155 |
+
$blog_public = get_option('blog_public');
|
156 |
+
|
157 |
+
if($current_user->user_login != 'admin')
|
158 |
+
$user = get_user_by('login', 'admin');
|
159 |
+
|
160 |
+
if(empty($user->user_level ) || $user->user_level < 10)
|
161 |
$user = $current_user;
|
162 |
+
|
163 |
+
$prefix = str_replace('_', '\_', $wpdb->prefix );
|
164 |
+
$tables = $wpdb->get_col("SHOW TABLES LIKE '{$prefix}%'" );
|
165 |
+
|
166 |
+
foreach($tables as $table){
|
167 |
+
$wpdb->query("DROP TABLE $table");
|
168 |
}
|
169 |
+
|
|
|
|
|
|
|
|
|
170 |
// Install wordpress
|
171 |
+
$result = wp_install($blogname, $user->user_login, $user->user_email, $blog_public);
|
172 |
+
$user_id = $result['user_id'];
|
173 |
+
|
174 |
// Set user password
|
175 |
+
$query = $wpdb->prepare("UPDATE $wpdb->users SET user_pass = %s, user_activation_key = '' WHERE ID = %d", $user->user_pass, $user_id);
|
176 |
+
$wpdb->query($query);
|
177 |
+
|
|
|
|
|
178 |
// Say to wordpress that we will not use generated password
|
179 |
+
if(get_user_meta($user_id, 'default_password_nag'))
|
180 |
+
update_user_meta($user_id, 'default_password_nag', false);
|
181 |
+
|
182 |
+
if(get_user_meta($user_id, $wpdb->prefix . 'default_password_nag'))
|
183 |
+
update_user_meta($user_id, $wpdb->prefix . 'default_password_nag', false);
|
184 |
+
|
185 |
// Add a small file to invite users rate the plugin
|
186 |
$aDBc_upload_dir = wp_upload_dir();
|
187 |
$aDBc_file_path = str_replace('\\' ,'/', $aDBc_upload_dir['basedir']) . "/DBR.txt";
|
192 |
}
|
193 |
}
|
194 |
|
195 |
+
// Reactivate the current plugin
|
196 |
@activate_plugin(DBR_PLUGIN_BASENAME);
|
|
|
|
|
|
|
|
|
|
|
|
|
197 |
|
198 |
wp_die(); // Always die after ajax call
|
199 |
}
|
200 |
|
201 |
+
/**
|
202 |
+
* Prepares an array with all elements to reset in "Custom reset" tab
|
203 |
+
*
|
204 |
+
* @return array Array of elements to reset
|
205 |
+
*/
|
206 |
+
function DBR_prepare_custom_reset_items(){
|
207 |
+
|
208 |
+
$all_items_array = array();
|
209 |
+
|
210 |
+
$deals_with_db = __('This tool modifies only the database. Files are not modified', 'advanced-wp-reset');
|
211 |
+
$deals_with_files = __('This tool modifies only files. Database is not modified', 'advanced-wp-reset');
|
212 |
+
$deals_with_db_and_files = __('This tool modifies both the database and files', 'advanced-wp-reset');
|
213 |
+
$deals_with_nothing = __('This tool does not modify either the files or the database', 'advanced-wp-reset');
|
214 |
+
|
215 |
+
// Add items related to files
|
216 |
+
$all_items_array['files'] = array(
|
217 |
+
|
218 |
+
'table_title' => __('Reset Files', 'advanced-wp-reset'),
|
219 |
+
'table_rows' => array(
|
220 |
+
array('type' => 'uploads-files', 'title' => __("Clean 'uploads' folder", "advanced-wp-reset"), 'deals_with' => DBR_generate_tooltip($deals_with_files)),
|
221 |
+
array('type' => 'themes-files', 'title' => __("Delete all themes", "advanced-wp-reset"), 'deals_with' => DBR_generate_tooltip($deals_with_db_and_files)),
|
222 |
+
array('type' => 'plugins-files', 'title' => __("Delete all plugins", "advanced-wp-reset"), 'deals_with' => DBR_generate_tooltip($deals_with_db_and_files)),
|
223 |
+
array('type' => 'wp-content-files', 'title' => __("Clean 'wp-content' folder", "advanced-wp-reset"),'deals_with' => DBR_generate_tooltip($deals_with_files)),
|
224 |
+
array('type' => 'mu-plugins-files', 'title' => __("Delete MU plugins", "advanced-wp-reset"), 'deals_with' => DBR_generate_tooltip($deals_with_files)),
|
225 |
+
array('type' => 'htaccess-files', 'title' => __("Delete '.htaccess' file", "advanced-wp-reset"), 'deals_with' => DBR_generate_tooltip($deals_with_files))
|
226 |
+
));
|
227 |
+
|
228 |
+
// Add items related to options
|
229 |
+
/*$all_items_array['options'] = array(
|
230 |
+
|
231 |
+
'table_title' => __('Reset DB Options', 'advanced-wp-reset'),
|
232 |
+
'table_rows' => array(
|
233 |
+
array('type' => 'nav-menus', 'title' => __('Delete navigation menus', 'advanced-wp-reset')),
|
234 |
+
array('type' => 'widgets', 'title' => __('Delete widgets', 'advanced-wp-reset')),
|
235 |
+
array('type' => 'transients', 'title' => __('Delete transients', 'advanced-wp-reset')),
|
236 |
+
array('type' => 'themes-options','title' => __('Delete theme options', 'advanced-wp-reset')),
|
237 |
+
));*/
|
238 |
+
|
239 |
+
// Add items related to posts
|
240 |
+
/*$all_items_array['posts'] = array(
|
241 |
+
|
242 |
+
'table_title' => __('Reset Posts', 'advanced-wp-reset'),
|
243 |
+
'table_rows' => array(
|
244 |
+
array('type' => 'posts', 'title' => __('Delete posts', 'advanced-wp-reset')),
|
245 |
+
array('type' => 'pages', 'title' => __('Delete pages', 'advanced-wp-reset')),
|
246 |
+
array('type' => 'media', 'title' => __('Delete media', 'advanced-wp-reset')),
|
247 |
+
array('type' => 'revisions', 'title' => __('Delete revisions', 'advanced-wp-reset')),
|
248 |
+
array('type' => 'drafts', 'title' => __('Delete drafts', 'advanced-wp-reset')),
|
249 |
+
array('type' => 'auto-drafts', 'title' => __('Delete auto-drafts', 'advanced-wp-reset')),
|
250 |
+
array('type' => 'trash-posts', 'title' => __('Delete trashed posts', 'advanced-wp-reset')),
|
251 |
+
));*/
|
252 |
+
|
253 |
+
// Add items related to taxonomies
|
254 |
+
/*$all_items_array['taxonomies'] = array(
|
255 |
+
|
256 |
+
'table_title' => __('Reset Taxonomies', 'advanced-wp-reset'),
|
257 |
+
'table_rows' => array(
|
258 |
+
array('type' => 'categories', 'title' => __('Delete categories', 'advanced-wp-reset')),
|
259 |
+
array('type' => 'tags', 'title' => __('Delete tags', 'advanced-wp-reset')),
|
260 |
+
));*/
|
261 |
+
|
262 |
+
// Add items related to comments
|
263 |
+
$all_items_array['comments'] = array(
|
264 |
+
|
265 |
+
'table_title' => __('Reset Comments', 'advanced-wp-reset'),
|
266 |
+
'table_rows' => array(
|
267 |
+
array('type' => 'all-comments', 'title' => __('Delete all comments', 'advanced-wp-reset'), 'deals_with' => DBR_generate_tooltip($deals_with_db)),
|
268 |
+
array('type' => 'pending-comments', 'title' => __('Delete pending comments', 'advanced-wp-reset'), 'deals_with' => DBR_generate_tooltip($deals_with_db)),
|
269 |
+
array('type' => 'spam-comments', 'title' => __('Delete spam comments', 'advanced-wp-reset'), 'deals_with' => DBR_generate_tooltip($deals_with_db)),
|
270 |
+
array('type' => 'trashed-comments', 'title' => __('Delete trashed comments', 'advanced-wp-reset'), 'deals_with' => DBR_generate_tooltip($deals_with_db)),
|
271 |
+
array('type' => 'pingbacks', 'title' => __('Delete pingbacks', 'advanced-wp-reset'), 'deals_with' => DBR_generate_tooltip($deals_with_db)),
|
272 |
+
array('type' => 'trackbacks', 'title' => __('Delete trackbacks', 'advanced-wp-reset'), 'deals_with' => DBR_generate_tooltip($deals_with_db)),
|
273 |
+
));
|
274 |
+
|
275 |
+
// Add items related to users
|
276 |
+
/*$all_items_array['users'] = array(
|
277 |
+
|
278 |
+
'table_title' => __('Reset Users', 'advanced-wp-reset'),
|
279 |
+
'table_rows' => array(
|
280 |
+
array('type' => 'users', 'title' => __('Delete all users', 'advanced-wp-reset')),
|
281 |
+
array('type' => 'user-roles', 'title' => __('Reset user roles', 'advanced-wp-reset')),
|
282 |
+
));*/
|
283 |
+
|
284 |
+
// Add items related to local data
|
285 |
+
/*$all_items_array['local-data'] = array(
|
286 |
+
|
287 |
+
'table_title' => __('Local Data', 'advanced-wp-reset'),
|
288 |
+
'table_rows' => array(
|
289 |
+
array('type' => 'cookies', 'title' => __("Delete cookies", "advanced-wp-reset"), 'deals_with' => DBR_generate_tooltip($deals_with_nothing)),
|
290 |
+
array('type' => 'local-storage', 'title' => __('Delete local storage', 'advanced-wp-reset'), 'deals_with' => DBR_generate_tooltip($deals_with_nothing)),
|
291 |
+
array('type' => 'session-storage', 'title' => __('Delete session storage', 'advanced-wp-reset'), 'deals_with' => DBR_generate_tooltip($deals_with_nothing)),
|
292 |
+
));*/
|
293 |
+
|
294 |
+
return $all_items_array;
|
295 |
+
}
|
296 |
+
|
297 |
+
/**
|
298 |
+
* Generate a tooltip with a specific content
|
299 |
+
*
|
300 |
+
* @return String tooltip info
|
301 |
+
*/
|
302 |
+
function DBR_generate_tooltip($text_inside){
|
303 |
+
|
304 |
+
$tooltip = "<span class='DBR-tooltips-headers'>
|
305 |
+
<img style='width:15px' class='DBR-info-image' src='". DBR_PLUGIN_DIR_PATH . '/images/information2.svg' . "'/>
|
306 |
+
<span>" . $text_inside ." </span>
|
307 |
+
</span>";
|
308 |
+
|
309 |
+
return $tooltip;
|
310 |
+
}
|
311 |
+
|
312 |
+
|
313 |
+
/**
|
314 |
+
* Prepares an array with explanations for all elements to reset in "Custom reset" tab
|
315 |
+
*
|
316 |
+
* @return array Array of explanations
|
317 |
+
*/
|
318 |
+
function DBR_prepare_explanations_for_custom_reset_items(){
|
319 |
+
|
320 |
+
$all_explanations_array = array();
|
321 |
+
$uploads_dir = wp_upload_dir(null, false);
|
322 |
+
$uploads_dir_path = "<span class='DBR-path-style'>/wp-content/uploads</span>";
|
323 |
+
$must_use_path = "<span class='DBR-path-style'>/wp-content/mu-plugins</span>";
|
324 |
+
$wp_content_path = "<span class='DBR-path-style'>/wp-content</span>";
|
325 |
+
|
326 |
+
$all_explanations_array['uploads-files'] = __("All media uploads inside $uploads_dir_path directory will be deleted! This includes images, videos, music, documents, subfolders, etc.", 'advanced-wp-reset');
|
327 |
+
|
328 |
+
$all_explanations_array['themes-files'] = __("All themes will be deleted. If you want to keep the current active theme, check the 'Keep active theme' checkbox, otherwise, it will be deleted too.", 'advanced-wp-reset');
|
329 |
+
|
330 |
+
$all_explanations_array['plugins-files'] = __("All plugins will be deleted except the current plugin, it will still be active after the reset.", 'advanced-wp-reset');
|
331 |
+
|
332 |
+
$all_explanations_array['wp-content-files'] = __("All files and folders inside $wp_content_path directory will be deleted, except 'index.php' and the following folders: 'plugins', 'themes', 'uploads' and 'mu-plugins'.", 'advanced-wp-reset');
|
333 |
+
|
334 |
+
$all_explanations_array['mu-plugins-files'] = __("All Must-use plugins in $must_use_path will be deleted. These are plugins that cannot be disabled except by removing their files from the must-use directory.", 'advanced-wp-reset');
|
335 |
+
|
336 |
+
$all_explanations_array['htaccess-files'] = __("The .htaccess file will be deleted. This is a critical WordPress core file used to enable or disable features of websites hosted on Apache.", 'advanced-wp-reset');
|
337 |
+
|
338 |
+
$all_explanations_array['nav-menus'] = "";
|
339 |
+
|
340 |
+
$all_explanations_array['widgets'] = "";
|
341 |
+
|
342 |
+
$all_explanations_array['user-roles'] = "";
|
343 |
+
|
344 |
+
$all_explanations_array['transients'] = "";
|
345 |
+
|
346 |
+
$all_explanations_array['themes-options'] = "";
|
347 |
+
|
348 |
+
$all_explanations_array['users'] = "";
|
349 |
+
|
350 |
+
$all_explanations_array['posts'] = "";
|
351 |
+
|
352 |
+
$all_explanations_array['pages'] = "";
|
353 |
+
|
354 |
+
$all_explanations_array['media'] = "";
|
355 |
+
|
356 |
+
$all_explanations_array['revisions'] = "";
|
357 |
+
|
358 |
+
$all_explanations_array['categories'] = "";
|
359 |
+
|
360 |
+
$all_explanations_array['tags'] = "";
|
361 |
+
|
362 |
+
$all_explanations_array['drafts'] = "";
|
363 |
+
|
364 |
+
$all_explanations_array['auto-drafts'] = "";
|
365 |
+
|
366 |
+
$all_explanations_array['trash-posts'] = "";
|
367 |
+
|
368 |
+
$all_explanations_array['all-comments'] = __('All types of comments will be deleted. Comments meta will also be deleted.', 'advanced-wp-reset');
|
369 |
+
|
370 |
+
$all_explanations_array['pending-comments'] = __('Pending comments will be deleted. These are the comments that are awaiting moderation.', 'advanced-wp-reset');
|
371 |
+
|
372 |
+
$all_explanations_array['spam-comments'] = __('Spam comments will be deleted.', 'advanced-wp-reset');
|
373 |
+
|
374 |
+
$all_explanations_array['trashed-comments'] = __('Trashed comments will be deleted. These are comments that you have deleted and sent to the Trash', 'advanced-wp-reset');
|
375 |
+
|
376 |
+
$all_explanations_array['pingbacks'] = __('All Pingbacks will be deleted. Pingbacks allow you to notify other website owners that you have linked to their article on your website.', 'advanced-wp-reset');
|
377 |
+
|
378 |
+
$all_explanations_array['trackbacks'] = __('All Trackbacks will be deleted. Although there are some minor technical differences, a trackback is basically the same things as a pingback. ', 'advanced-wp-reset');
|
379 |
+
|
380 |
+
$all_explanations_array['cookies'] = __('WordPress cookies associated with authentication will be deleted. After running this tool, you will be logged out.', 'advanced-wp-reset');
|
381 |
+
|
382 |
+
$all_explanations_array['local-storage'] = __('Local storage data will be deleted. These are a key-value pairs stored in your browser. They help to save data even after closing the browser.', 'advanced-wp-reset');
|
383 |
+
|
384 |
+
$all_explanations_array['session-storage'] = __('Session storage data will be delete. These are a key-value pairs stored in your browser. They help to maintain data while the browser is open and will be automatically deleted when the browser is closed.', 'advanced-wp-reset');
|
385 |
+
|
386 |
+
return $all_explanations_array;
|
387 |
+
}
|
388 |
+
|
389 |
+
/**
|
390 |
+
* Calculates the number of items to reset
|
391 |
+
*
|
392 |
+
* @return int|string The number of items
|
393 |
+
*/
|
394 |
+
function DBR_calculate_number_items_to_reset(){
|
395 |
+
|
396 |
+
// Security and role check
|
397 |
+
check_ajax_referer('DBR_nonce', 'security');
|
398 |
+
|
399 |
+
if(!current_user_can('administrator')){
|
400 |
+
wp_send_json_error ('Not sufficient permissions!');
|
401 |
+
}
|
402 |
+
|
403 |
+
// Sanitize $_REQUEST['DBR_item_type']
|
404 |
+
$item_type = sanitize_html_class($_REQUEST['DBR_item_type']);
|
405 |
+
|
406 |
+
switch($item_type){
|
407 |
+
|
408 |
+
case 'uploads-files' :
|
409 |
+
|
410 |
+
// Get uploads dir path
|
411 |
+
$uploads_dir = wp_upload_dir(null, false);
|
412 |
+
$total_items = DBR_calculate_items_in_folder($uploads_dir['basedir'], array('.', '..', 'DBR.txt'));
|
413 |
+
break;
|
414 |
+
|
415 |
+
case 'themes-files' :
|
416 |
+
|
417 |
+
$total_items = count(wp_get_themes(array('errors' => null)));
|
418 |
+
if($total_items > 0){
|
419 |
+
$keep_active_theme = $_REQUEST['DBR_keep_active_theme'] == 0 ? false : true;
|
420 |
+
if($keep_active_theme){
|
421 |
+
$total_items = $total_items - 1;
|
422 |
+
}
|
423 |
+
}
|
424 |
+
break;
|
425 |
+
|
426 |
+
case 'plugins-files' :
|
427 |
+
|
428 |
+
$plugins_list = get_plugins();
|
429 |
+
unset($plugins_list[DBR_PLUGIN_BASENAME]);
|
430 |
+
$total_items = count($plugins_list);
|
431 |
+
break;
|
432 |
+
|
433 |
+
case 'wp-content-files' :
|
434 |
+
|
435 |
+
$total_items = DBR_calculate_items_in_folder(WP_CONTENT_DIR, array('.', '..', 'plugins', 'themes', 'uploads', 'mu-plugins', 'index.php'));
|
436 |
+
break;
|
437 |
+
|
438 |
+
case 'mu-plugins-files' :
|
439 |
+
|
440 |
+
$total_items = DBR_calculate_items_in_folder(WPMU_PLUGIN_DIR, array('.', '..', 'index.php'));
|
441 |
+
break;
|
442 |
+
|
443 |
+
case 'htaccess-files' :
|
444 |
+
|
445 |
+
clearstatcache();
|
446 |
+
if(file_exists(get_home_path() . '.htaccess')){
|
447 |
+
$total_items = 1;
|
448 |
+
}else{
|
449 |
+
$total_items = 0;
|
450 |
+
}
|
451 |
+
break;
|
452 |
+
|
453 |
+
case 'nav-menus' :
|
454 |
+
$total_items = "-";
|
455 |
+
break;
|
456 |
+
case 'widgets' :
|
457 |
+
$total_items = "-";
|
458 |
+
break;
|
459 |
+
case 'transients' :
|
460 |
+
$total_items = "-";
|
461 |
+
break;
|
462 |
+
case 'themes-options' :
|
463 |
+
$total_items = "-";
|
464 |
+
break;
|
465 |
+
case 'posts' :
|
466 |
+
$total_items = "-";
|
467 |
+
break;
|
468 |
+
case 'pages' :
|
469 |
+
$total_items = "-";
|
470 |
+
break;
|
471 |
+
case 'media' :
|
472 |
+
$total_items = "-";
|
473 |
+
break;
|
474 |
+
case 'revisions' :
|
475 |
+
$total_items = "-";
|
476 |
+
break;
|
477 |
+
case 'drafts' :
|
478 |
+
$total_items = "-";
|
479 |
+
break;
|
480 |
+
case 'auto-drafts' :
|
481 |
+
$total_items = "-";
|
482 |
+
break;
|
483 |
+
case 'trash-posts' :
|
484 |
+
$total_items = "-";
|
485 |
+
break;
|
486 |
+
case 'categories' :
|
487 |
+
$total_items = "-";
|
488 |
+
break;
|
489 |
+
case 'tags' :
|
490 |
+
$total_items = "-";
|
491 |
+
break;
|
492 |
+
case 'all-comments' :
|
493 |
+
$total_items = DBR_calculate_comments("all-comments");
|
494 |
+
break;
|
495 |
+
case 'pending-comments' :
|
496 |
+
$total_items = DBR_calculate_comments("pending-comments");
|
497 |
+
break;
|
498 |
+
case 'spam-comments' :
|
499 |
+
$total_items = DBR_calculate_comments("spam-comments");
|
500 |
+
break;
|
501 |
+
case 'trashed-comments' :
|
502 |
+
$total_items = DBR_calculate_comments("trashed-comments");
|
503 |
+
break;
|
504 |
+
case 'pingbacks' :
|
505 |
+
$total_items = DBR_calculate_comments("pingbacks");
|
506 |
+
break;
|
507 |
+
case 'trackbacks' :
|
508 |
+
$total_items = DBR_calculate_comments("trackbacks");
|
509 |
+
break;
|
510 |
+
case 'users' :
|
511 |
+
$total_items = "-";
|
512 |
+
break;
|
513 |
+
case 'user-roles' :
|
514 |
+
$total_items = "-";
|
515 |
+
break;
|
516 |
+
default:
|
517 |
+
// Default to show
|
518 |
+
$total_items = " - ";
|
519 |
+
}
|
520 |
+
|
521 |
+
echo $total_items;
|
522 |
+
|
523 |
+
wp_die(); // Always die after ajax call
|
524 |
+
}
|
525 |
+
|
526 |
+
/**
|
527 |
+
* Calculates the number of files/folders in a folder
|
528 |
+
*
|
529 |
+
* @param string $folder Folder to start from
|
530 |
+
* @param array $except Array of names to excludes from the count
|
531 |
+
*
|
532 |
+
* @return int The number of files and folders
|
533 |
+
*/
|
534 |
+
function DBR_calculate_items_in_folder($folder, $except = array()){
|
535 |
+
|
536 |
+
if(!file_exists($folder))
|
537 |
+
return 0;
|
538 |
+
|
539 |
+
// Get all files and folders names exluding . and .. in $except param
|
540 |
+
if(is_dir($folder)){
|
541 |
+
$all_files = array_diff(scandir($folder), $except);
|
542 |
+
return count($all_files);
|
543 |
+
}else{
|
544 |
+
return 0;
|
545 |
+
}
|
546 |
+
}
|
547 |
+
|
548 |
+
/**
|
549 |
+
* Calculates the number of comments according to their type (all comment, pending, spam, trash, pingback, trackback)
|
550 |
+
*
|
551 |
+
* @param string $comment_type the comment type to count
|
552 |
+
*
|
553 |
+
* @return int The number of comments
|
554 |
+
*/
|
555 |
+
function DBR_calculate_comments($comment_type){
|
556 |
+
|
557 |
+
global $wpdb;
|
558 |
+
$sql_query = "";
|
559 |
+
|
560 |
+
switch($comment_type){
|
561 |
+
case 'all-comments' :
|
562 |
+
$sql_query = "SELECT COUNT(*) from $wpdb->comments";
|
563 |
+
break;
|
564 |
+
case 'pending-comments' :
|
565 |
+
$sql_query = "SELECT COUNT(*) from $wpdb->comments WHERE comment_approved = '0'";
|
566 |
+
break;
|
567 |
+
case 'spam-comments' :
|
568 |
+
$sql_query = "SELECT COUNT(*) from $wpdb->comments WHERE comment_approved = 'spam'";
|
569 |
+
break;
|
570 |
+
case 'trashed-comments' :
|
571 |
+
$sql_query = "SELECT COUNT(*) from $wpdb->comments WHERE comment_approved = 'trash'";
|
572 |
+
break;
|
573 |
+
case 'pingbacks' :
|
574 |
+
$sql_query = "SELECT COUNT(*) from $wpdb->comments WHERE comment_type = 'pingback'";
|
575 |
+
break;
|
576 |
+
case 'trackbacks' :
|
577 |
+
$sql_query = "SELECT COUNT(*) from $wpdb->comments WHERE comment_type = 'trackback'";
|
578 |
+
break;
|
579 |
+
default:
|
580 |
+
return " - ";
|
581 |
+
}
|
582 |
+
|
583 |
+
$total = $wpdb->get_var($sql_query);
|
584 |
+
return $total;
|
585 |
+
}
|
586 |
+
|
587 |
+
/**
|
588 |
+
* Deletes all files and folders in "uploads" directory
|
589 |
+
*
|
590 |
+
* @return null
|
591 |
+
*/
|
592 |
+
function DBR_reset_uploads_dir(){
|
593 |
+
|
594 |
+
// Get uploads dir path
|
595 |
+
$uploads_dir = wp_upload_dir(null, false);
|
596 |
+
|
597 |
+
clearstatcache();
|
598 |
+
|
599 |
+
if(file_exists($uploads_dir['basedir']))
|
600 |
+
DBR_delete_folder($uploads_dir['basedir'], $uploads_dir['basedir'], false);
|
601 |
+
|
602 |
+
}
|
603 |
+
|
604 |
+
/**
|
605 |
+
* Deletes all content in a folder without deleting the folder itself
|
606 |
+
*
|
607 |
+
* @param string $folder current folder
|
608 |
+
* @param string $original_folder original folder
|
609 |
+
* @param bool $delete_original_folder Either to delete or no the original folder
|
610 |
+
*
|
611 |
+
* @return bool
|
612 |
+
*/
|
613 |
+
function DBR_delete_folder($folder, $original_folder, $delete_original_folder = false){
|
614 |
+
|
615 |
+
// Get all files and folders names exluding . and .. and "DBR.txt"
|
616 |
+
$all_files = array_diff(scandir($folder), array('.', '..', 'DBR.txt'));
|
617 |
+
|
618 |
+
foreach($all_files as $file){
|
619 |
+
if(is_dir($folder . DIRECTORY_SEPARATOR . $file)){
|
620 |
+
DBR_delete_folder($folder . DIRECTORY_SEPARATOR . $file, $original_folder, $delete_original_folder);
|
621 |
+
}else{
|
622 |
+
@unlink($folder . DIRECTORY_SEPARATOR . $file);
|
623 |
+
}
|
624 |
+
}
|
625 |
+
|
626 |
+
// Delete the original folder if $delete_original_folder == true, otherwise keep it. Delete all other content folders
|
627 |
+
if($delete_original_folder == true || $folder != $original_folder){
|
628 |
+
$result = @rmdir($folder);
|
629 |
+
return $result;
|
630 |
+
}else{
|
631 |
+
return true;
|
632 |
+
}
|
633 |
+
}
|
634 |
+
|
635 |
+
/**
|
636 |
+
* Deletes all themes
|
637 |
+
*
|
638 |
+
* @param bool $keep_active_theme Keep default theme
|
639 |
+
*
|
640 |
+
* @return null
|
641 |
+
*/
|
642 |
+
function DBR_delete_all_themes($keep_active_theme){
|
643 |
+
|
644 |
+
// Return all themes
|
645 |
+
$all_themes = wp_get_themes(array('errors' => null));
|
646 |
+
|
647 |
+
$active_theme = get_template();
|
648 |
+
$active_child = get_stylesheet();
|
649 |
+
|
650 |
+
if($keep_active_theme == true){
|
651 |
+
unset($all_themes[$active_theme]);
|
652 |
+
unset($all_themes[$active_child]);
|
653 |
+
}
|
654 |
+
|
655 |
+
foreach($all_themes as $name_slug => $info){
|
656 |
+
delete_theme($name_slug);
|
657 |
+
}
|
658 |
+
|
659 |
+
// After deleting all themes, update DB option
|
660 |
+
if($keep_active_theme == false){
|
661 |
+
update_option('template', '');
|
662 |
+
update_option('stylesheet', '');
|
663 |
+
update_option('current_theme', '');
|
664 |
+
}
|
665 |
+
}
|
666 |
+
|
667 |
+
/**
|
668 |
+
* Deletes all plugins
|
669 |
+
*
|
670 |
+
* @param bool $keep_this_plugin Keep 'Advanced WP Reset' plugin or not
|
671 |
+
*
|
672 |
+
* @return null
|
673 |
+
*/
|
674 |
+
function DBR_delete_all_plugins($keep_this_plugin){
|
675 |
+
|
676 |
+
$plugins_list = get_plugins();
|
677 |
+
|
678 |
+
if($keep_this_plugin == true){
|
679 |
+
unset($plugins_list[DBR_PLUGIN_BASENAME]);
|
680 |
+
}
|
681 |
+
|
682 |
+
if(!empty($plugins_list)){
|
683 |
+
deactivate_plugins(array_keys($plugins_list));
|
684 |
+
delete_plugins(array_keys($plugins_list));
|
685 |
+
}
|
686 |
+
}
|
687 |
+
|
688 |
+
/**
|
689 |
+
* Deletes all 'wp-content' folder content except these folders: 'plugins', 'themes', 'uploads', 'mu-plugins' and 'index.php'
|
690 |
+
*
|
691 |
+
* @return null
|
692 |
+
*/
|
693 |
+
function DBR_reset_wp_content_dir(){
|
694 |
+
|
695 |
+
if(!file_exists(WP_CONTENT_DIR))
|
696 |
+
return;
|
697 |
+
|
698 |
+
// Get all folders and files in 'wp-content' except the array in prameter.
|
699 |
+
$all_files = array_diff(scandir(WP_CONTENT_DIR), array('.', '..', 'plugins', 'themes', 'uploads', 'mu-plugins', 'index.php'));
|
700 |
+
|
701 |
+
// Delete
|
702 |
+
foreach($all_files as $file){
|
703 |
+
if(is_dir(WP_CONTENT_DIR . DIRECTORY_SEPARATOR . $file)){
|
704 |
+
DBR_delete_folder(WP_CONTENT_DIR . DIRECTORY_SEPARATOR . $file, "", true);
|
705 |
+
}else{
|
706 |
+
@unlink(WP_CONTENT_DIR . DIRECTORY_SEPARATOR . $file);
|
707 |
+
}
|
708 |
+
}
|
709 |
+
}
|
710 |
+
|
711 |
+
/**
|
712 |
+
* Deletes all 'mu-plugins' content
|
713 |
+
*
|
714 |
+
* @return null
|
715 |
+
*/
|
716 |
+
function DBR_reset_mu_plugins_dir(){
|
717 |
+
|
718 |
+
if(!file_exists(WPMU_PLUGIN_DIR))
|
719 |
+
return;
|
720 |
+
|
721 |
+
// Get all folders and files in 'mu-plugins' except the array in prameter
|
722 |
+
$all_files = array_diff(scandir(WPMU_PLUGIN_DIR), array('.', '..', 'index.php'));
|
723 |
+
|
724 |
+
// Delete
|
725 |
+
foreach($all_files as $file){
|
726 |
+
if(is_dir(WPMU_PLUGIN_DIR . DIRECTORY_SEPARATOR . $file)){
|
727 |
+
DBR_delete_folder(WPMU_PLUGIN_DIR . DIRECTORY_SEPARATOR . $file, "", true);
|
728 |
+
}else{
|
729 |
+
@unlink(WPMU_PLUGIN_DIR . DIRECTORY_SEPARATOR . $file);
|
730 |
+
}
|
731 |
+
}
|
732 |
+
}
|
733 |
+
|
734 |
+
/**
|
735 |
+
* Deletes .htaccess file
|
736 |
+
*
|
737 |
+
* @return null
|
738 |
+
*/
|
739 |
+
function DBR_delete_htaccess_file(){
|
740 |
+
|
741 |
+
$htaccess_file = get_home_path() . '.htaccess';
|
742 |
+
|
743 |
+
clearstatcache();
|
744 |
+
|
745 |
+
if(!is_readable($htaccess_file)){
|
746 |
+
wp_send_json_error(__('Cannot be deleted! The Htaccess file does not exist!', 'advanced-wp-reset'));
|
747 |
+
}
|
748 |
+
|
749 |
+
if(!is_writable($htaccess_file)){
|
750 |
+
wp_send_json_error(__('Cannot be deleted! Htaccess file is not writable!', 'advanced-wp-reset'));
|
751 |
+
}
|
752 |
+
|
753 |
+
if(unlink($htaccess_file)){
|
754 |
+
wp_send_json_success();
|
755 |
+
}else{
|
756 |
+
wp_send_json_error(__('Cannot be deleted! Unknown error!', 'advanced-wp-reset'));
|
757 |
+
}
|
758 |
+
}
|
759 |
+
|
760 |
+
/**
|
761 |
+
* Deletes the type of comments in parameter
|
762 |
+
*
|
763 |
+
* @param string $comment_type the comment type to delete
|
764 |
+
*
|
765 |
+
* @return null
|
766 |
+
*/
|
767 |
+
function DBR_delete_comments($comment_type){
|
768 |
+
|
769 |
+
global $wpdb;
|
770 |
+
$sql_query = "";
|
771 |
+
|
772 |
+
switch($comment_type){
|
773 |
+
case 'all-comments' :
|
774 |
+
$sql_query = "DELETE from $wpdb->comments";
|
775 |
+
$wpdb->query("TRUNCATE TABLE $wpdb->commentmeta");
|
776 |
+
break;
|
777 |
+
case 'pending-comments' :
|
778 |
+
$sql_query = "DELETE from $wpdb->comments WHERE comment_approved = '0'";
|
779 |
+
break;
|
780 |
+
case 'spam-comments' :
|
781 |
+
$sql_query = "DELETE from $wpdb->comments WHERE comment_approved = 'spam'";
|
782 |
+
break;
|
783 |
+
case 'trashed-comments' :
|
784 |
+
$sql_query = "DELETE from $wpdb->comments WHERE comment_approved = 'trash'";
|
785 |
+
break;
|
786 |
+
case 'pingbacks' :
|
787 |
+
$sql_query = "DELETE from $wpdb->comments WHERE comment_type = 'pingback'";
|
788 |
+
break;
|
789 |
+
case 'trackbacks' :
|
790 |
+
$sql_query = "DELETE from $wpdb->comments WHERE comment_type = 'trackback'";
|
791 |
+
break;
|
792 |
+
default:
|
793 |
+
return " - ";
|
794 |
+
}
|
795 |
+
|
796 |
+
$total = $wpdb->get_var($sql_query);
|
797 |
+
return $total;
|
798 |
+
}
|
799 |
+
|
800 |
+
|
801 |
?>
|
includes/reset.php
CHANGED
@@ -1,49 +1,54 @@
|
|
1 |
<?php
|
2 |
-
|
3 |
-
|
4 |
-
$
|
5 |
-
$
|
6 |
-
|
7 |
-
|
8 |
-
}
|
9 |
-
|
10 |
?>
|
11 |
|
12 |
-
<div class="
|
13 |
-
<span style="color:red"><strong><?php _e('WARNING:','advanced-wp-reset'); ?></strong></span>
|
14 |
-
<br/>
|
15 |
-
<?php _e('The reset makes a fresh installation of your database. Therefore, ANY data in your database will be lost.','advanced-wp-reset'); ?>
|
16 |
-
<br/>
|
17 |
-
<?php _e('Please do not use this option if you want to keep your posts and pages.','advanced-wp-reset'); ?>
|
18 |
-
</div>
|
19 |
|
20 |
-
<div class="DBR-box-
|
21 |
-
|
22 |
-
<
|
23 |
-
<
|
24 |
-
|
25 |
-
|
26 |
-
if
|
27 |
-
|
28 |
-
}else{
|
29 |
-
printf(__('The <b>%s</b> user does not exist. The user <b>%s</b> will be recreated with its current password with user level 10.','advanced-wp-reset'), "admin", esc_html($current_user->user_login));
|
30 |
-
}?>
|
31 |
-
</li>
|
32 |
-
<li><?php _e('After the reset, you will be redirected to the admin login page.','advanced-wp-reset'); ?></li>
|
33 |
-
</ul>
|
34 |
-
</div>
|
35 |
|
36 |
-
<
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
37 |
|
38 |
-
<
|
39 |
-
<?php
|
40 |
-
printf(__('Please type "<b>%s</b>" in the confirmation field below to confirm the reset and then click the reset button.','advanced-wp-reset'), "reset" );
|
41 |
-
?>
|
42 |
-
</p>
|
43 |
|
44 |
-
<
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
</p>
|
49 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
<?php
|
2 |
+
global $current_user;
|
3 |
+
$DBR_admin = get_user_by('login', 'admin');
|
4 |
+
$DBR_admin_exists = 1;
|
5 |
+
if(!isset($DBR_admin->user_login ) || $DBR_admin->user_level < 10 ){
|
6 |
+
$DBR_admin_exists = 0;
|
7 |
+
}
|
|
|
|
|
8 |
?>
|
9 |
|
10 |
+
<div id="reset_all_tab_content" class="DBR_tabcontent">
|
|
|
|
|
|
|
|
|
|
|
|
|
11 |
|
12 |
+
<div class="DBR-box-warning">
|
13 |
+
<span class="dashicons dashicons-warning DBR-dashicons-warning" style="color:red"></span>
|
14 |
+
<span style="color:red"><strong><?php _e('WARNING','advanced-wp-reset'); ?></strong></span>
|
15 |
+
<br/>-
|
16 |
+
<?php _e('The reset makes a fresh installation of your database. Therefore, ANY data in your database will be lost.','advanced-wp-reset'); ?>
|
17 |
+
<br/>-
|
18 |
+
<?php _e('Please do not use this option if you want to keep your posts, pages, etc.','advanced-wp-reset'); ?>
|
19 |
+
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
20 |
|
21 |
+
<div class="DBR-box-info">
|
22 |
+
<span class="dashicons dashicons-info DBR-dashicons-info" style="color:#0073AA"></span>
|
23 |
+
<span><strong><?php _e('What will be done','advanced-wp-reset'); ?></strong></span>
|
24 |
+
<ul>
|
25 |
+
<li>- <?php _e('The reset does not delete or modify any of your plugins/themes files or server files.','advanced-wp-reset'); ?></li>
|
26 |
+
<li>- <?php _e('All your plugins will be deactivated except this one. You should activate them manually after the reset.','advanced-wp-reset'); ?></li>
|
27 |
+
<li>-
|
28 |
+
<?php
|
29 |
+
if($DBR_admin_exists){
|
30 |
+
printf(__('The plugin has detected that the <b>%s</b> user exists. It will be recreated with its current password.','advanced-wp-reset'), "admin");
|
31 |
+
}else{
|
32 |
+
printf(__('The <b>%s</b> user does not exist. The user <b>%s</b> will be recreated with its current password with user level 10.','advanced-wp-reset'), "admin", esc_html($current_user->user_login));
|
33 |
+
}?>
|
34 |
+
</li>
|
35 |
+
<li>- <?php _e('After the reset, you will be redirected to the admin login page.','advanced-wp-reset'); ?></li>
|
36 |
+
</ul>
|
37 |
+
</div>
|
38 |
|
39 |
+
<h3 style="padding-top: 10px"><?php _e('Reset database','advanced-wp-reset'); ?></h3>
|
|
|
|
|
|
|
|
|
40 |
|
41 |
+
<p>
|
42 |
+
<?php
|
43 |
+
printf(__('Please type "<b>%s</b>" in the confirmation field below to confirm the reset and then click the reset button.','advanced-wp-reset'), "reset" );
|
44 |
+
?>
|
45 |
</p>
|
46 |
+
|
47 |
+
<form id="DBR_form" action="" method="post">
|
48 |
+
<input id="DBR_reset_comfirmation" type="text" name="DBR_reset_comfirmation" value="" style="width:150px"/>
|
49 |
+
<p class="submit">
|
50 |
+
<input id="DBR_reset_button" name="DBR_reset_button" type="submit" class="button-primary DBR-button-reset" value="<?php _e("Reset database","advanced-wp-reset"); ?>"/>
|
51 |
+
</p>
|
52 |
+
</form>
|
53 |
+
|
54 |
+
</div>
|
includes/settings.php
ADDED
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
|
2 |
+
|
3 |
+
<div id="settings_tab_content" class="DBR_tabcontent">
|
4 |
+
|
5 |
+
Settings
|
6 |
+
|
7 |
+
|
8 |
+
</div>
|
js/admin.js
CHANGED
@@ -1,5 +1,136 @@
|
|
1 |
jQuery(document).ready(function(){
|
2 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
3 |
jQuery('#DBR_reset_button').on('click', function(e){
|
4 |
|
5 |
// Prevent doaction button from its default behaviour
|
@@ -21,7 +152,7 @@ jQuery(document).ready(function(){
|
|
21 |
|
22 |
Swal.fire({
|
23 |
title : '<font size="4px" color="red">' + DBR_ajax_obj.are_you_sure + '</font>',
|
24 |
-
text : DBR_ajax_obj.warning_msg,
|
25 |
imageUrl : DBR_ajax_obj.images_path + 'alert_delete.svg',
|
26 |
imageWidth : 60,
|
27 |
imageHeight : 60,
|
@@ -38,16 +169,8 @@ jQuery(document).ready(function(){
|
|
38 |
// If the user clicked on "confirm", call reset function
|
39 |
if(result.value){
|
40 |
|
41 |
-
// Show processing
|
42 |
-
|
43 |
-
imageUrl : DBR_ajax_obj.images_path + 'loading20px.svg',
|
44 |
-
imageWidth : 60,
|
45 |
-
imageHeight : 60,
|
46 |
-
showCloseButton : false,
|
47 |
-
showConfirmButton : false,
|
48 |
-
allowOutsideClick : false,
|
49 |
-
text : DBR_ajax_obj.processing
|
50 |
-
})
|
51 |
|
52 |
jQuery.ajax({
|
53 |
type : "post",
|
@@ -69,4 +192,428 @@ jQuery(document).ready(function(){
|
|
69 |
})
|
70 |
}
|
71 |
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
72 |
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
jQuery(document).ready(function(){
|
2 |
|
3 |
+
|
4 |
+
/******************************************************************************
|
5 |
+
*
|
6 |
+
* When the page is loaded/refreshed, test if we should load the last active tab
|
7 |
+
*
|
8 |
+
******************************************************************************/
|
9 |
+
|
10 |
+
var current_tab_id = localStorage.getItem("DBR_current_tab");
|
11 |
+
if(current_tab_id != '' && current_tab_id != null){
|
12 |
+
|
13 |
+
// Add class 'active' to the current active tab and show its contents
|
14 |
+
showCurrentTabAndContent(jQuery("#" + current_tab_id));
|
15 |
+
|
16 |
+
}else{
|
17 |
+
// If not tab is saved in the browser, show the first tab
|
18 |
+
showCurrentTabAndContent(jQuery("#reset_all_tab"));
|
19 |
+
}
|
20 |
+
|
21 |
+
/**********************************************************************************************
|
22 |
+
*
|
23 |
+
* When the page is loaded/refreshed, test which tables (in 'custom reset' tab) should be hidden
|
24 |
+
*
|
25 |
+
***********************************************************************************************/
|
26 |
+
|
27 |
+
whichTablesShouldBeHidden();
|
28 |
+
|
29 |
+
// This function hides tables that should be hidden
|
30 |
+
function whichTablesShouldBeHidden(){
|
31 |
+
|
32 |
+
var hidden_tables = localStorage.getItem("DBR_hidden_tables");
|
33 |
+
if(hidden_tables != '' && hidden_tables != null){
|
34 |
+
|
35 |
+
// Get array with tables names that should be hidden
|
36 |
+
var items_array = hidden_tables.split(":");
|
37 |
+
|
38 |
+
for(var i = 0; i < items_array.length; i++ ){
|
39 |
+
var name = items_array[i];
|
40 |
+
if(name != ""){
|
41 |
+
// Hide the table
|
42 |
+
jQuery('#DBR_table_custom_reset_' + name).hide();
|
43 |
+
// Change arrow class
|
44 |
+
jQuery('#DBR_accordion_link_' + name).removeClass('dashicons-arrow-up');
|
45 |
+
jQuery('#DBR_accordion_link_' + name).addClass('dashicons-arrow-down');
|
46 |
+
}
|
47 |
+
}
|
48 |
+
}
|
49 |
+
}
|
50 |
+
|
51 |
+
/**********************************************************************************************
|
52 |
+
*
|
53 |
+
* When the page is loaded/refreshed, reorder the tables order in "custom reset" tab if needed
|
54 |
+
*
|
55 |
+
**********************************************************************************************/
|
56 |
+
var tables_order = localStorage.getItem("DBR_tables_order");
|
57 |
+
if(tables_order != '' && tables_order != null){
|
58 |
+
|
59 |
+
// Get array with tables names that should be ordered
|
60 |
+
var items_array = tables_order.split(":");
|
61 |
+
|
62 |
+
for(var i = 0; i < items_array.length; i++ ){
|
63 |
+
var name = items_array[i];
|
64 |
+
if(name != ""){
|
65 |
+
jQuery("#order_" + name).remove().appendTo("#my_sortable");
|
66 |
+
}
|
67 |
+
}
|
68 |
+
}
|
69 |
+
|
70 |
+
/********************************************************************************************
|
71 |
+
*
|
72 |
+
* When the page is loaded/refreshed, calculate number of items to reset in "custom reset" tab
|
73 |
+
*
|
74 |
+
********************************************************************************************/
|
75 |
+
|
76 |
+
// Loop over all tables items titles and calculate
|
77 |
+
jQuery('.DBR-item-to-reset-total').each(function(i, obj){
|
78 |
+
|
79 |
+
// Get name
|
80 |
+
var accordion_id = jQuery(obj).attr('id');
|
81 |
+
var names_array = accordion_id.split("_");
|
82 |
+
var item_name = names_array[names_array.length-1];
|
83 |
+
|
84 |
+
// If we are calculating local data items:
|
85 |
+
if(item_name == "cookies" || item_name == "local-storage" || item_name == "session-storage"){
|
86 |
+
|
87 |
+
if(item_name == "cookies"){
|
88 |
+
var total = DBR_count_cookies();
|
89 |
+
}else if(item_name == "local-storage"){
|
90 |
+
var total = DBR_count_local_storage();
|
91 |
+
}else if(item_name == "session-storage"){
|
92 |
+
var total = DBR_count_session_storage();
|
93 |
+
}
|
94 |
+
|
95 |
+
jQuery('#DBR_spinning_checkbox_' + item_name).hide();
|
96 |
+
jQuery('#DBR_total_' + item_name).show();
|
97 |
+
jQuery('#DBR_total_' + item_name).text('(' + total + ')');
|
98 |
+
|
99 |
+
return;
|
100 |
+
}
|
101 |
+
|
102 |
+
calculateTotalItems(item_name);
|
103 |
+
|
104 |
+
});
|
105 |
+
|
106 |
+
// Processing tabs clicks
|
107 |
+
jQuery('.DBR-tablinks').on('click', function(e){
|
108 |
+
|
109 |
+
// Prevent button from its default behaviour
|
110 |
+
e.preventDefault();
|
111 |
+
|
112 |
+
// Add class 'active' to the current active tab and show its contents
|
113 |
+
showCurrentTabAndContent(jQuery(this));
|
114 |
+
|
115 |
+
// Save the current tab in the browser
|
116 |
+
localStorage.setItem("DBR_current_tab", jQuery(this).attr("id"));
|
117 |
+
|
118 |
+
});
|
119 |
+
|
120 |
+
// This function shows the current tab and its content and hides all other contents
|
121 |
+
function showCurrentTabAndContent(my_jquery_object){
|
122 |
+
|
123 |
+
// Add class 'active' to the current active tab
|
124 |
+
jQuery('.DBR-tablinks').removeClass('active');
|
125 |
+
my_jquery_object.addClass('active');
|
126 |
+
|
127 |
+
// Show corresponding content to the current tab
|
128 |
+
jQuery('.DBR_tabcontent').hide();
|
129 |
+
var content_to_show = my_jquery_object.attr("id") + "_content";
|
130 |
+
jQuery('#'+content_to_show).show();
|
131 |
+
}
|
132 |
+
|
133 |
+
// Reset wordpress back to its first status
|
134 |
jQuery('#DBR_reset_button').on('click', function(e){
|
135 |
|
136 |
// Prevent doaction button from its default behaviour
|
152 |
|
153 |
Swal.fire({
|
154 |
title : '<font size="4px" color="red">' + DBR_ajax_obj.are_you_sure + '</font>',
|
155 |
+
text : DBR_ajax_obj.warning_msg + " " + DBR_ajax_obj.irreversible_msg,
|
156 |
imageUrl : DBR_ajax_obj.images_path + 'alert_delete.svg',
|
157 |
imageWidth : 60,
|
158 |
imageHeight : 60,
|
169 |
// If the user clicked on "confirm", call reset function
|
170 |
if(result.value){
|
171 |
|
172 |
+
// Show processing msg box
|
173 |
+
showProcessingMsgBox();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
174 |
|
175 |
jQuery.ajax({
|
176 |
type : "post",
|
192 |
})
|
193 |
}
|
194 |
});
|
195 |
+
|
196 |
+
// Check/uncheck the checkbox in custom reset Tab when clicking on the title of the item to reset
|
197 |
+
jQuery('.DBR-item-to-reset-title').on('click', function(e){
|
198 |
+
|
199 |
+
// Get the id of the clicked title
|
200 |
+
var title_type = jQuery(this).attr("value");
|
201 |
+
|
202 |
+
// Get the checkbox object in the same line
|
203 |
+
var current_checkbox = jQuery("#DBR_checkbox_" + title_type);
|
204 |
+
|
205 |
+
if(current_checkbox.prop("checked") == true){
|
206 |
+
current_checkbox.prop("checked", false);
|
207 |
+
}else{
|
208 |
+
current_checkbox.prop("checked", true);
|
209 |
+
}
|
210 |
+
});
|
211 |
+
|
212 |
+
// Hide/show tables when clicking on accordion right arrow (in custom reset tab)
|
213 |
+
jQuery('.DBR-accordion').on('click', function(e){
|
214 |
+
|
215 |
+
// Get the id of the clicked arrow
|
216 |
+
var my_id = jQuery(this).attr("id");
|
217 |
+
var items_array = my_id.split("_");
|
218 |
+
var itemname = items_array[items_array.length-1];
|
219 |
+
var my_table = jQuery('#DBR_table_custom_reset_' + itemname);
|
220 |
+
var accordion_icon = jQuery('#DBR_accordion_link_' + itemname);
|
221 |
+
|
222 |
+
// If the table is visible/shown
|
223 |
+
if(my_table.is(":visible")){
|
224 |
+
|
225 |
+
// Change arrow class
|
226 |
+
accordion_icon.removeClass('dashicons-arrow-up');
|
227 |
+
accordion_icon.addClass('dashicons-arrow-down');
|
228 |
+
// Hide the table
|
229 |
+
my_table.fadeOut("fast");
|
230 |
+
|
231 |
+
}else{
|
232 |
+
|
233 |
+
// Change arrow class
|
234 |
+
accordion_icon.removeClass('dashicons-arrow-down');
|
235 |
+
accordion_icon.addClass('dashicons-arrow-up');
|
236 |
+
// Show the table
|
237 |
+
my_table.fadeIn("fast");
|
238 |
+
}
|
239 |
+
|
240 |
+
// When hiding a table, save its ID in localStorage to hide it again if the page is reloaded
|
241 |
+
var list_of_tables = "";
|
242 |
+
jQuery('.dashicons-arrow-down').each(function(i, obj){
|
243 |
+
|
244 |
+
// Get name
|
245 |
+
var accordion_id = jQuery(obj).attr('id');
|
246 |
+
var names_array = accordion_id.split("_");
|
247 |
+
var name = names_array[names_array.length-1];
|
248 |
+
|
249 |
+
list_of_tables = name + ":" + list_of_tables;
|
250 |
+
});
|
251 |
+
|
252 |
+
// If all tables are shown, save empty string
|
253 |
+
if(list_of_tables == ""){
|
254 |
+
localStorage.setItem("DBR_hidden_tables", "");
|
255 |
+
}else{
|
256 |
+
localStorage.setItem("DBR_hidden_tables", list_of_tables);
|
257 |
+
}
|
258 |
+
|
259 |
+
});
|
260 |
+
|
261 |
+
/*****************************************************************************
|
262 |
+
*
|
263 |
+
* When clicking on "Keep active theme", recalculate the total themes to delete
|
264 |
+
*
|
265 |
+
******************************************************************************/
|
266 |
+
jQuery('#DBR_keep_active_theme').on('click', function(){
|
267 |
+
calculateTotalItems("themes-files");
|
268 |
+
});
|
269 |
+
|
270 |
+
/*****************************************************************************
|
271 |
+
*
|
272 |
+
* Reset items when clicking on "Run reset now" button in "Custom reset" tab
|
273 |
+
*
|
274 |
+
******************************************************************************/
|
275 |
+
jQuery('.DBR-custom-reset-button').on('click', function(){
|
276 |
+
|
277 |
+
// Get item name and title to delete
|
278 |
+
var item_name = jQuery(this).attr('name');
|
279 |
+
var item_title = jQuery(this).attr('value');
|
280 |
+
|
281 |
+
// When clicking on 'Delete themes' button, check if keep active theme and keep current plugin are checked
|
282 |
+
var keep_current = "";
|
283 |
+
if(item_name == "themes-files" && jQuery("#DBR_keep_active_theme").prop("checked") == true){
|
284 |
+
keep_current = " + <b>" + DBR_ajax_obj.keep_active_theme + "</b>";
|
285 |
+
}
|
286 |
+
|
287 |
+
Swal.fire({
|
288 |
+
title : '<font size="4px" color="red">' + DBR_ajax_obj.are_you_sure + '</font>',
|
289 |
+
html : DBR_ajax_obj.custom_warning + "<br><br><b>" + item_title + "</b>" + keep_current,
|
290 |
+
footer : "<font color='red'>" + DBR_ajax_obj.irreversible_msg + "</font>",
|
291 |
+
imageUrl : DBR_ajax_obj.images_path + 'alert_delete.svg',
|
292 |
+
imageWidth : 60,
|
293 |
+
imageHeight : 60,
|
294 |
+
showCancelButton : true,
|
295 |
+
showCloseButton : true,
|
296 |
+
cancelButtonText : DBR_ajax_obj.cancel,
|
297 |
+
cancelButtonColor : '#555',
|
298 |
+
confirmButtonText : DBR_ajax_obj.Continue,
|
299 |
+
confirmButtonColor : '#0085ba',
|
300 |
+
focusCancel : true,
|
301 |
+
|
302 |
+
}).then((result) => {
|
303 |
+
|
304 |
+
// If the user clicked on "confirm", call reset function
|
305 |
+
if(result.value){
|
306 |
+
|
307 |
+
// Show processing icon
|
308 |
+
showProcessingMsgBox();
|
309 |
+
|
310 |
+
// If the user clicked on "Reset Local Data" tools
|
311 |
+
if(item_name == "cookies" || item_name == "local-storage" || item_name == "session-storage"){
|
312 |
+
|
313 |
+
// Show spinning
|
314 |
+
jQuery('#DBR_total_' + item_name).hide();
|
315 |
+
jQuery('#DBR_spinning_checkbox_' + item_name).show();
|
316 |
+
|
317 |
+
if(item_name == "cookies"){
|
318 |
+
|
319 |
+
DBR_clear_local_data(true, false, false);
|
320 |
+
var total = DBR_count_cookies();
|
321 |
+
|
322 |
+
}else if(item_name == "local-storage"){
|
323 |
+
|
324 |
+
DBR_clear_local_data(false, true, false);
|
325 |
+
var total = DBR_count_local_storage();
|
326 |
+
|
327 |
+
}else if(item_name == "session-storage"){
|
328 |
+
|
329 |
+
DBR_clear_local_data(false, false, true);
|
330 |
+
var total = DBR_count_session_storage();
|
331 |
+
|
332 |
+
}
|
333 |
+
|
334 |
+
jQuery('#DBR_spinning_checkbox_' + item_name).hide();
|
335 |
+
jQuery('#DBR_total_' + item_name).show();
|
336 |
+
jQuery('#DBR_total_' + item_name).text('(' + total + ')');
|
337 |
+
|
338 |
+
Swal.fire({
|
339 |
+
title : '<font size="4px">' + DBR_ajax_obj.done + '</font>',
|
340 |
+
icon : 'success',
|
341 |
+
showConfirmButton : false,
|
342 |
+
timer : 1000,
|
343 |
+
timerProgressBar : true,
|
344 |
+
});
|
345 |
+
|
346 |
+
// Return here and prevent calling code bellow
|
347 |
+
return;
|
348 |
+
}
|
349 |
+
|
350 |
+
// If the user clicked on all other reset tools except "Reset Local Data"
|
351 |
+
// Get "keep active theme" checkbox value
|
352 |
+
var DBR_keep_active_theme = 0;
|
353 |
+
if(jQuery("#DBR_keep_active_theme").prop("checked") == true){
|
354 |
+
DBR_keep_active_theme = 1;
|
355 |
+
}
|
356 |
+
|
357 |
+
jQuery.ajax({
|
358 |
+
type : "post",
|
359 |
+
url : DBR_ajax_obj.ajaxurl,
|
360 |
+
cache : false,
|
361 |
+
data: {
|
362 |
+
'action' : 'DBR_execute_called_tool',
|
363 |
+
'security' : DBR_ajax_obj.ajax_nonce,
|
364 |
+
'DBR_item_to_reset' : item_name,
|
365 |
+
'DBR_keep_active_theme' : DBR_keep_active_theme,
|
366 |
+
},
|
367 |
+
success: function(result){
|
368 |
+
|
369 |
+
// Show success/error message
|
370 |
+
if(true === result.success){
|
371 |
+
|
372 |
+
Swal.fire({
|
373 |
+
title : '<font size="4px">' + DBR_ajax_obj.done + '</font>',
|
374 |
+
icon : 'success',
|
375 |
+
showConfirmButton : false,
|
376 |
+
timer : 1000,
|
377 |
+
timerProgressBar : true,
|
378 |
+
});
|
379 |
+
|
380 |
+
}else{
|
381 |
+
Swal.fire({
|
382 |
+
html : '<font size="4px">' + result.data + '</font>',
|
383 |
+
icon : 'error'
|
384 |
+
});
|
385 |
+
}
|
386 |
+
|
387 |
+
// Recalculate the corresponding remaining number of items
|
388 |
+
calculateTotalItems(item_name);
|
389 |
+
|
390 |
+
// If we have deleted a specific type of comments, recalculate the "AlL comments" section as well
|
391 |
+
var comments_types = ["pending-comments", "spam-comments", "trashed-comments", "pingbacks", "trackbacks"];
|
392 |
+
if(jQuery.inArray(item_name, comments_types) != -1){
|
393 |
+
calculateTotalItems("all-comments");
|
394 |
+
}
|
395 |
+
|
396 |
+
},
|
397 |
+
error: function(){
|
398 |
+
Swal.fire({
|
399 |
+
html : '<font size="4px">' + DBR_ajax_obj.unknown_error + '</font>',
|
400 |
+
icon : 'error'
|
401 |
+
});
|
402 |
+
}
|
403 |
+
|
404 |
+
});
|
405 |
+
}
|
406 |
+
})
|
407 |
+
});
|
408 |
+
|
409 |
+
|
410 |
+
/*****************************************************************************
|
411 |
+
*
|
412 |
+
* This function calculates the total number of items for specific tools
|
413 |
+
*
|
414 |
+
******************************************************************************/
|
415 |
+
function calculateTotalItems(item_name){
|
416 |
+
|
417 |
+
// Get "keep active theme" checkbox value
|
418 |
+
var DBR_keep_active_theme = 0;
|
419 |
+
if(jQuery("#DBR_keep_active_theme").prop("checked") == true){
|
420 |
+
DBR_keep_active_theme = 1;
|
421 |
+
}
|
422 |
+
|
423 |
+
jQuery('#DBR_total_' + item_name).hide();
|
424 |
+
jQuery('#DBR_spinning_checkbox_' + item_name).show();
|
425 |
+
|
426 |
+
jQuery.ajax({
|
427 |
+
type : "post",
|
428 |
+
url : DBR_ajax_obj.ajaxurl,
|
429 |
+
cache : false,
|
430 |
+
data: {
|
431 |
+
'action' : 'DBR_calculate_number_items_to_reset',
|
432 |
+
'security' : DBR_ajax_obj.ajax_nonce,
|
433 |
+
'DBR_item_type' : item_name,
|
434 |
+
'DBR_keep_active_theme' : DBR_keep_active_theme,
|
435 |
+
},
|
436 |
+
success: function(result){
|
437 |
+
jQuery('#DBR_spinning_checkbox_' + item_name).hide();
|
438 |
+
jQuery('#DBR_total_' + item_name).show();
|
439 |
+
if(jQuery.isNumeric(result)){
|
440 |
+
jQuery('#DBR_total_' + item_name).text('(' + result + ')');
|
441 |
+
}else{
|
442 |
+
jQuery('#DBR_total_' + item_name).text('(' + 'NaN' + ')');
|
443 |
+
}
|
444 |
+
},
|
445 |
+
complete: function(){}
|
446 |
+
});
|
447 |
+
}
|
448 |
+
|
449 |
+
/*****************************************************************************
|
450 |
+
*
|
451 |
+
* This function shows a "processing" msg box when performing an action
|
452 |
+
*
|
453 |
+
******************************************************************************/
|
454 |
+
function showProcessingMsgBox(){
|
455 |
+
|
456 |
+
Swal.fire({
|
457 |
+
imageUrl : DBR_ajax_obj.images_path + 'loading20px.svg',
|
458 |
+
imageWidth : 60,
|
459 |
+
imageHeight : 60,
|
460 |
+
showCloseButton : false,
|
461 |
+
showConfirmButton : false,
|
462 |
+
allowOutsideClick : false,
|
463 |
+
text : DBR_ajax_obj.processing
|
464 |
+
})
|
465 |
+
}
|
466 |
+
|
467 |
+
/***********************************************************************************
|
468 |
+
*
|
469 |
+
* When clicking on "Reorder tables"/"Save order" links, prepare tables to be ordered
|
470 |
+
*
|
471 |
+
***********************************************************************************/
|
472 |
+
jQuery('#DBR_reorder_tables, #DBR_save_order_tables').on('click', function(){
|
473 |
+
|
474 |
+
var my_id = jQuery(this).attr("id");
|
475 |
+
|
476 |
+
// If the user clicked on "Reorder tables" link
|
477 |
+
if(my_id == "DBR_reorder_tables"){
|
478 |
+
|
479 |
+
// Hide current link and show save link
|
480 |
+
jQuery("#DBR_reorder_tables").hide();
|
481 |
+
jQuery("#DBR_save_order_tables").show();
|
482 |
+
|
483 |
+
// Hide all accordion icons
|
484 |
+
jQuery(".DBR-accordion").hide();
|
485 |
+
|
486 |
+
// Hide collapse all and expand all links
|
487 |
+
jQuery(".DBR-collapse-expand-all-tables").hide();
|
488 |
+
|
489 |
+
// Make cursor pointer for tables header
|
490 |
+
jQuery(".DBR-table-header-title").css("cursor", "move");
|
491 |
+
|
492 |
+
// When changing places of custom reset tables, hide all tables so that dragging will be easy for the user
|
493 |
+
jQuery(".DBR-custom-reset-table").hide();
|
494 |
+
|
495 |
+
// Make the UL elements sortable
|
496 |
+
jQuery("#my_sortable").sortable({
|
497 |
+
|
498 |
+
placeholder: "DBR-sortable-highlight",
|
499 |
+
//scroll: false,
|
500 |
+
appendTo: document.body,
|
501 |
+
helper: "clone",
|
502 |
+
|
503 |
+
});
|
504 |
+
// If we are saving the new order
|
505 |
+
}else if(my_id == "DBR_save_order_tables"){
|
506 |
+
|
507 |
+
// Hide current link and show order link
|
508 |
+
jQuery("#DBR_reorder_tables").show();
|
509 |
+
jQuery("#DBR_save_order_tables").hide();
|
510 |
+
|
511 |
+
// Show all accordion icons
|
512 |
+
jQuery(".DBR-accordion").show();
|
513 |
+
|
514 |
+
// Show collapse all and expand all links
|
515 |
+
jQuery(".DBR-collapse-expand-all-tables").show();
|
516 |
+
|
517 |
+
// Make cursor default for tables header
|
518 |
+
jQuery(".DBR-table-header-title").css("cursor", "default");
|
519 |
+
|
520 |
+
// After changing places of custom reset tables, show tables that should be shown; because we hided them in "start"
|
521 |
+
jQuery(".DBR-custom-reset-table").show();
|
522 |
+
whichTablesShouldBeHidden();
|
523 |
+
|
524 |
+
// Save new order in localStorage
|
525 |
+
// Loop over all tables items titles and save them in their order
|
526 |
+
var li_order = "";
|
527 |
+
jQuery('.DBR-order-li-element').each(function(i, obj){
|
528 |
+
if(li_order == ""){
|
529 |
+
li_order = jQuery(obj).attr('value');
|
530 |
+
}else{
|
531 |
+
li_order = li_order + ":" + jQuery(obj).attr('value');
|
532 |
+
}
|
533 |
+
});
|
534 |
+
|
535 |
+
// Save order in localStorage
|
536 |
+
localStorage.setItem("DBR_tables_order", li_order);
|
537 |
+
|
538 |
+
// Delete sortable from the UL element
|
539 |
+
jQuery("#my_sortable").sortable("destroy");
|
540 |
+
|
541 |
+
}
|
542 |
+
});
|
543 |
+
|
544 |
+
/***********************************************************************************
|
545 |
+
*
|
546 |
+
* When clicking on "Expand all" / "Collapse all" links, show/hide all tables
|
547 |
+
*
|
548 |
+
***********************************************************************************/
|
549 |
+
jQuery('#DBR_collapse_all_tables').on('click', function(){
|
550 |
+
|
551 |
+
// Hide all tables
|
552 |
+
jQuery('.DBR-custom-reset-table').hide();
|
553 |
+
|
554 |
+
// Loop over all tables items titles and save them in their names
|
555 |
+
var list_of_tables = "";
|
556 |
+
jQuery('.DBR-order-li-element').each(function(i, obj){
|
557 |
+
if(list_of_tables == ""){
|
558 |
+
list_of_tables = jQuery(obj).attr('value');
|
559 |
+
}else{
|
560 |
+
list_of_tables = list_of_tables + ":" + jQuery(obj).attr('value');
|
561 |
+
}
|
562 |
+
});
|
563 |
+
|
564 |
+
// Update tables that should be hidden to "all tables"
|
565 |
+
localStorage.setItem("DBR_hidden_tables", list_of_tables);
|
566 |
+
|
567 |
+
});
|
568 |
+
|
569 |
+
jQuery('#DBR_expand_all_tables').on('click', function(){
|
570 |
+
|
571 |
+
// Show all tables
|
572 |
+
jQuery('.DBR-custom-reset-table').show();
|
573 |
+
|
574 |
+
// Update tables that should be hidden to "empty"
|
575 |
+
localStorage.setItem("DBR_hidden_tables", "");
|
576 |
+
|
577 |
+
});
|
578 |
+
|
579 |
+
|
580 |
});
|
581 |
+
|
582 |
+
// Clear Local Data
|
583 |
+
function DBR_clear_local_data(clean_cookies, clean_local, clean_session){
|
584 |
+
|
585 |
+
if(clean_cookies){
|
586 |
+
var cookies = Cookies.get();
|
587 |
+
for(cookie in cookies){
|
588 |
+
Cookies.remove(cookie);
|
589 |
+
}
|
590 |
+
}
|
591 |
+
|
592 |
+
if(clean_local){
|
593 |
+
localStorage.clear();
|
594 |
+
}
|
595 |
+
|
596 |
+
if(clean_session){
|
597 |
+
sessionStorage.clear();
|
598 |
+
}
|
599 |
+
}
|
600 |
+
|
601 |
+
function DBR_count_cookies(){
|
602 |
+
|
603 |
+
var total = 0;
|
604 |
+
var cookies = Cookies.get();
|
605 |
+
total = Object.keys(cookies).length;
|
606 |
+
return total;
|
607 |
+
}
|
608 |
+
|
609 |
+
function DBR_count_local_storage(){
|
610 |
+
|
611 |
+
var total = localStorage.length;
|
612 |
+
return total;
|
613 |
+
}
|
614 |
+
|
615 |
+
function DBR_count_session_storage(){
|
616 |
+
|
617 |
+
var total = sessionStorage.length;
|
618 |
+
return total;
|
619 |
+
}
|
screenshot-1.png
DELETED
Binary file
|