WP Reset – Fastest WordPress Reset Plugin - Version 1.30

Version Description

Download this release

Release Info

Developer WebFactory
Plugin Icon 128x128 WP Reset – Fastest WordPress Reset Plugin
Version 1.30
Comparing to
See all releases

Code changes from version 1.25 to 1.30

Files changed (6) hide show
  1. css/wp-reset.css +164 -3
  2. js/wp-reset-pointers.js +32 -0
  3. js/wp-reset.js +106 -12
  4. readme.txt +21 -3
  5. wp-reset-cli.php +30 -5
  6. wp-reset.php +234 -11
css/wp-reset.css CHANGED
@@ -8,6 +8,10 @@
8
  vertical-align: middle;
9
  }
10
 
 
 
 
 
11
  .tools_page_wp-reset .plain-list {
12
  margin-top: 5px;
13
  list-style-type: circle;
@@ -91,6 +95,163 @@
91
  display: none;
92
  }
93
 
94
- @-moz-keyframes spin { 100% { -moz-transform: rotate(-360deg); } }
95
- @-webkit-keyframes spin { 100% { -webkit-transform: rotate(-360deg); } }
96
- @keyframes spin { 100% { -webkit-transform: rotate(-360deg); transform:rotate(-360deg); } }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
8
  vertical-align: middle;
9
  }
10
 
11
+ .tools_page_wp-reset.wp-core-ui .button, .tools_page_wp-reset.wp-core-ui .button-primary, .tools_page_wp-reset.wp-core-ui .button-secondary {
12
+ border-radius: 0;
13
+ }
14
+
15
  .tools_page_wp-reset .plain-list {
16
  margin-top: 5px;
17
  list-style-type: circle;
95
  display: none;
96
  }
97
 
98
+ .tools_page_wp-reset .swal2-popup {
99
+ border-radius: 0;
100
+ }
101
+
102
+ @-moz-keyframes spin {
103
+ 100% {
104
+ -moz-transform: rotate(-360deg);
105
+ }
106
+ }
107
+ @-webkit-keyframes spin {
108
+ 100% {
109
+ -webkit-transform: rotate(-360deg);
110
+ }
111
+ }
112
+ @keyframes spin {
113
+ 100% {
114
+ -webkit-transform: rotate(-360deg); transform:rotate(-360deg);
115
+ }
116
+ }
117
+
118
+
119
+ /* tabs */
120
+ .tools_page_wp-reset .ui-tabs {
121
+ max-width: 100%;
122
+ position: relative;
123
+ padding: 0px;
124
+ zoom: 1;
125
+ margin-top: 20px;
126
+ }
127
+
128
+ .tools_page_wp-reset .ui-tabs .ui-tabs-nav {
129
+ margin: 0;
130
+ padding: 0;
131
+ }
132
+
133
+ .tools_page_wp-reset .ui-tabs .ui-tabs-nav li {
134
+ list-style: none;
135
+ position: relative;
136
+ top: 1px;
137
+ margin: 0 .2em 1px 0;
138
+ padding: 0;
139
+ white-space: nowrap;
140
+ }
141
+
142
+ .tools_page_wp-reset .ui-tabs .ui-tabs-nav li a {
143
+ text-decoration: none;
144
+ }
145
+
146
+ .tools_page_wp-reset .ui-tabs .ui-tabs-nav li.ui-tabs-selected {
147
+ margin-bottom: 0;
148
+ border-bottom: 1px solid #F1F1F1 !important;
149
+ }
150
+
151
+ .tools_page_wp-reset ul.ui-tabs-nav.wpr-main-tab li.ui-state-active {
152
+ border-top: 3px solid #666666;
153
+ background: #ffffff;
154
+ transition: all 0.4s ease-out;
155
+ border-bottom: 1px solid #fff;
156
+ }
157
+
158
+ .tools_page_wp-reset .ui-tabs .ui-tabs-nav li.ui-tabs-selected a,
159
+ .tools_page_wp-reset .ui-tabs .ui-tabs-nav li.ui-state-disabled a,
160
+ .tools_page_wp-reset .ui-tabs .ui-tabs-nav li.ui-state-processing a {
161
+ cursor: text;
162
+ }
163
+
164
+ .tools_page_wp-reset .ui-tabs .ui-tabs-nav li a,
165
+ .tools_page_wp-reset .ui-tabs.ui-tabs-collapsible .ui-tabs-nav li.ui-tabs-selected a {
166
+ cursor: pointer;
167
+ }
168
+
169
+
170
+ .tools_page_wp-reset .ui-tabs .ui-tabs-panel {
171
+ display: inline-block;
172
+ border: none;
173
+ padding: 20px;
174
+ background: #ffffff;
175
+ overflow: visible;
176
+ min-width: 520px;
177
+ border-top: 1px solid #e5e5e5;
178
+ }
179
+
180
+ .tools_page_wp-reset .ui-tabs .ui-tabs-hide {
181
+ display: none !important;
182
+ }
183
+
184
+ .tools_page_wp-reset .ui-tabs .ui-tabs-nav li a {
185
+ font-size: 14px;
186
+ font-weight: 600;
187
+ line-height: 32px;
188
+ color: #AAAAAA;
189
+ padding: 10px 25px;
190
+ display: block;
191
+ letter-spacing: 1px;
192
+ }
193
+
194
+ .tools_page_wp-reset .ui-tabs ul.ui-tabs-nav li.ui-state-active .icon {
195
+ color: #666666;
196
+ }
197
+
198
+ .tools_page_wp-reset .ui-tabs-nav:after {
199
+ content: '';
200
+ clear: both;
201
+ display: block;
202
+ }
203
+
204
+ .tools_page_wp-reset .ui-tabs-anchor,
205
+ .nav-tab {
206
+ outline: none !important;
207
+ }
208
+
209
+ .tools_page_wp-reset .ui-tabs ul.ui-tabs-nav li {
210
+ color: #AAAAAA;
211
+ display: inline-block;
212
+ font-size: 12px;
213
+ line-height: 16px;
214
+ margin: 0px 15px 0px 6px;
215
+ text-decoration: none;
216
+ text-shadow: none;
217
+ background: rgba(255, 255, 255, 0.7);
218
+ padding: 0;
219
+ text-align: center;
220
+ letter-spacing: .5px;
221
+ min-width: 100px;
222
+ border-top: 3px solid transparent;
223
+ border-bottom: 1px solid #e5e5e5;
224
+ }
225
+
226
+ .tools_page_wp-reset .ui-tabs ul.ui-tabs-nav li .label {
227
+ display: block;
228
+ margin-top: -10px;
229
+ }
230
+
231
+ .tools_page_wp-reset .ui-tabs ul.ui-tabs-nav li:first-child {
232
+ margin-left: 0;
233
+ }
234
+
235
+ .tools_page_wp-reset ul.ui-tabs-nav.wpr-main-tab {
236
+ padding-bottom: 0;
237
+ width: 100%;
238
+ box-sizing: border-box;
239
+ }
240
+
241
+ .tools_page_wp-reset .ui-state-hover a,
242
+ .tools_page_wp-reset .ui-state-active a,
243
+ .tools_page_wp-reset li.ui-state-hover,
244
+ .tools_page_wp-reset li.ui-state-hover a {
245
+ color: #000000 !important;
246
+ }
247
+
248
+ .tools_page_wp-reset .ui-tabs ul.ui-tabs-nav li.ui-state-hover {
249
+ background-color: #ffffff !important;
250
+ border-bottom: 1px solid #fff;
251
+ }
252
+
253
+ .tools_page_wp-reset .ui-tabs-nav a:focus {
254
+ box-shadow: none;
255
+ -webkit-box-shadow: none;
256
+ }
257
+ /* tabs */
js/wp-reset-pointers.js ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*
2
+ * WP Reset
3
+ * Backend GUI pointers
4
+ * (c) Web factory Ltd, 2017 - 2018
5
+ */
6
+
7
+ jQuery(document).ready(function($){
8
+ if (typeof wp_reset_pointers == 'undefined') {
9
+ return;
10
+ }
11
+
12
+ $.each(wp_reset_pointers, function(index, pointer) {
13
+ if (index.charAt(0) == '_') {
14
+ return true;
15
+ }
16
+ $(pointer.target).pointer({
17
+ content: '<h3>WP Reset</h3><p>' + pointer.content + '</p>',
18
+ pointerWidth: 380,
19
+ position: {
20
+ edge: pointer.edge,
21
+ align: pointer.align
22
+ },
23
+ close: function() {
24
+ $.get(ajaxurl, {
25
+ notice_name: index,
26
+ _ajax_nonce: wp_reset_pointers._nonce_dismiss_pointer,
27
+ action: 'wp_reset_dismiss_notice'
28
+ });
29
+ }
30
+ }).pointer('open');
31
+ });
32
+ });
js/wp-reset.js CHANGED
@@ -6,6 +6,111 @@
6
 
7
 
8
  jQuery(document).ready(function($) {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
9
  $('#wp_reset_form').on('submit', function(e, confirmed) {
10
  if (!confirmed) {
11
  $('#wp_reset_submit').trigger('click');
@@ -42,18 +147,7 @@ jQuery(document).ready(function($) {
42
  width: 600
43
  }).then((result) => {
44
  if (result.value === true) {
45
- swal({ text: wp_reset.doing_reset,
46
- type: false,
47
- imageUrl: wp_reset.icon_url,
48
- onOpen: () => { $(swal.getImage()).addClass('rotating'); },
49
- imageWidth: 100,
50
- imageHeight: 100,
51
- imageAlt: wp_reset.doing_reset,
52
- allowOutsideClick: false,
53
- allowEscapeKey: false,
54
- allowEnterKey: false,
55
- showConfirmButton: false,
56
- });
57
  $('#wp_reset_form').trigger('submit', true);
58
  }
59
  });
6
 
7
 
8
  jQuery(document).ready(function($) {
9
+ // init tabs
10
+ $('#wp-reset-tabs').tabs({
11
+ activate: function(event, ui) {
12
+ localStorage.setItem('wp-reset-tabs', $('#wp-reset-tabs').tabs('option', 'active'));
13
+ },
14
+ active: localStorage.getItem('wp-reset-tabs') || 0
15
+ }).show();
16
+
17
+
18
+ // delete transients
19
+ $('.tools_page_wp-reset').on('click', '#delete-transients', 'click', function(e) {
20
+ e.preventDefault();
21
+
22
+ run_tool(this, 'delete_transients');
23
+
24
+ return false;
25
+ }); // delete transients
26
+
27
+
28
+ // delete themes
29
+ $('.tools_page_wp-reset').on('click', '#delete-themes', 'click', function(e) {
30
+ e.preventDefault();
31
+
32
+ run_tool(this, 'delete_themes');
33
+
34
+ return false;
35
+ }); // delete themes
36
+
37
+
38
+ // delete plugins
39
+ $('.tools_page_wp-reset').on('click', '#delete-plugins', 'click', function(e) {
40
+ e.preventDefault();
41
+
42
+ run_tool(this, 'delete_plugins');
43
+
44
+ return false;
45
+ }); // delete plugins
46
+
47
+
48
+ function run_tool(button, tool_name) {
49
+ confirm_action(wp_reset.confirm_title, $(button).data('text-confirm'), $(button).data('btn-confirm'), wp_reset.cancel_button)
50
+ .then((result) => {
51
+ if (result.value) {
52
+ block = block_ui($(button).data('text-wait'));
53
+ $.get({
54
+ url: ajaxurl,
55
+ data: {
56
+ action: 'wp_reset_run_tool',
57
+ _ajax_nonce: wp_reset.nonce_run_tool,
58
+ tool: tool_name
59
+ }
60
+ }).always(function(data) {
61
+ swal.close();
62
+ }).done(function(data) {
63
+ if (data.success) {
64
+ msg = $(button).data('text-done').replace('%n', data.data);
65
+ swal({ type: 'success', title: msg });
66
+ } else {
67
+ swal({ type: 'error', title: wp_reset.undocumented_error });
68
+ }
69
+ }).fail(function(data) {
70
+ swal({ type: 'error', title: wp_reset.undocumented_error });
71
+ });
72
+ } // if confirmed
73
+ }
74
+ );
75
+ } // run_tool
76
+
77
+
78
+ // display a message while an action is performed
79
+ function block_ui(message) {
80
+ tmp = swal({ text: message,
81
+ type: false,
82
+ imageUrl: wp_reset.icon_url,
83
+ onOpen: () => { $(swal.getImage()).addClass('rotating'); },
84
+ imageWidth: 100,
85
+ imageHeight: 100,
86
+ imageAlt: message,
87
+ allowOutsideClick: false,
88
+ allowEscapeKey: false,
89
+ allowEnterKey: false,
90
+ showConfirmButton: false,
91
+ });
92
+
93
+ return tmp;
94
+ } // block_ui
95
+
96
+
97
+ // display dialog to confirm action
98
+ function confirm_action(title, question, btn_confirm, btn_cancel) {
99
+ tmp = swal({ title: title,
100
+ type: 'question',
101
+ html: question,
102
+ showCancelButton: true,
103
+ focusConfirm: false,
104
+ confirmButtonText: btn_confirm,
105
+ cancelButtonText: btn_cancel,
106
+ confirmButtonColor: '#dd3036',
107
+ width: 600
108
+ });
109
+
110
+ return tmp;
111
+ } // confirm_action
112
+
113
+
114
  $('#wp_reset_form').on('submit', function(e, confirmed) {
115
  if (!confirmed) {
116
  $('#wp_reset_submit').trigger('click');
147
  width: 600
148
  }).then((result) => {
149
  if (result.value === true) {
150
+ block_ui(wp_reset.doing_reset);
 
 
 
 
 
 
 
 
 
 
 
151
  $('#wp_reset_form').trigger('submit', true);
152
  }
153
  });
readme.txt CHANGED
@@ -1,10 +1,10 @@
1
  === WP Reset - Fastest WordPress Reset Plugin ===
2
  Tags: wordpress reset, reset wordpress, reset database, reset wordpress database, reset, restart wordpress, clean wordpress, default wp, default wordpress, reset wp, wp reset, developer, wp-cli
3
- Contributors: WebFactory, wpreset
4
  Requires at least: 4.0
5
  Requires PHP: 5.2
6
  Tested up to: 4.9
7
- Stable tag: 1.25
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
@@ -17,6 +17,7 @@ For support please use the <a href="https://wordpress.org/support/plugin/wp-rese
17
 
18
  Access WP Reset admin page via the "Tools" menu.
19
 
 
20
 
21
  **Please read carefully before proceeding to understand what WP Reset does**
22
 
@@ -49,6 +50,15 @@ WP Reset comes with full WP-CLI support. Help on our WP-CLI commands is availabl
49
 
50
  WP Reset has yet to be completely tested with multisite! Please be careful when using it with multisite enabled. We don't recommend to resetting the main site. Sub-sites should be OK. We're working on making WP Reset fully compatible with WP-MU. Till then please be careful. Thank you for understanding.
51
 
 
 
 
 
 
 
 
 
 
52
 
53
  == Installation ==
54
 
@@ -75,8 +85,16 @@ Or if needed, upload manually;
75
 
76
  == Changelog ==
77
 
 
 
 
 
 
 
 
 
78
  = v1.25 =
79
- * 2018/07/31
80
  * code clean-up
81
  * post-reset options - reactivate plugin, themes & WP Reset
82
  * added WP-MU warning till we make WP Reset fully compatible with it
1
  === WP Reset - Fastest WordPress Reset Plugin ===
2
  Tags: wordpress reset, reset wordpress, reset database, reset wordpress database, reset, restart wordpress, clean wordpress, default wp, default wordpress, reset wp, wp reset, developer, wp-cli
3
+ Contributors: WebFactory, wpreset, googlemapswidget
4
  Requires at least: 4.0
5
  Requires PHP: 5.2
6
  Tested up to: 4.9
7
+ Stable tag: 1.30
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
17
 
18
  Access WP Reset admin page via the "Tools" menu.
19
 
20
+ > WP Reset is proudly sponsored by <a target="_blank" href="https://ipgeolocation.io/">IP Geolocation</a>, a **premium GeoIP service for developers**. See how you can use their <a href="https://wpreset.com/geoip-transform-boring-data-better-user-experience/">GeoIP service</a> to make boring IP addresses more interesting for users. They offer <a href="https://ipgeolocation.io/signup">50,000 API requests a month FREE for developers</a>, and keep WP Reset updated, maintained & ad free.
21
 
22
  **Please read carefully before proceeding to understand what WP Reset does**
23
 
50
 
51
  WP Reset has yet to be completely tested with multisite! Please be careful when using it with multisite enabled. We don't recommend to resetting the main site. Sub-sites should be OK. We're working on making WP Reset fully compatible with WP-MU. Till then please be careful. Thank you for understanding.
52
 
53
+ #### Partial Reset Tools
54
+
55
+ Delete transients - deletes all transient related database entries. Including expired and non-expired transients, and orphaned timeout entries.
56
+
57
+ Delete plugins - deletes all plugins except WP Reset which remains active.
58
+
59
+ Delete themes - deletes all themes.
60
+
61
+
62
 
63
  == Installation ==
64
 
85
 
86
  == Changelog ==
87
 
88
+ = v1.30 =
89
+ * 2018/08/27
90
+ * more code clean-up
91
+ * added new reset params to WP-CLI
92
+ * big GUI changes
93
+ * started adding various tools; delete transients, delete all plugins, delete all themes
94
+ * we hit 50,000 installations on 2018/08/11 with 274,000 downloads
95
+
96
  = v1.25 =
97
+ * 2018/07/30
98
  * code clean-up
99
  * post-reset options - reactivate plugin, themes & WP Reset
100
  * added WP-MU warning till we make WP Reset fully compatible with it
wp-reset-cli.php CHANGED
@@ -16,18 +16,28 @@ if (!defined('ABSPATH')) {
16
  * Resets the site to the default values without modifying any files.
17
  */
18
  class WP_Reset_CLI extends WP_CLI_Command {
 
19
  /**
20
  * Reset the site database to default values. No files are modified.
21
  *
22
  * ## OPTIONS
23
- *
 
 
 
 
 
 
 
 
 
24
  * [--yes]
25
  * : Answer yes to the confirmation message.
26
  *
27
  * ## EXAMPLES
28
  *
29
- * $ wp reset reset --yes
30
- * Success: Database has been reset.
31
  *
32
  * @when after_wp_load
33
  */
@@ -35,7 +45,21 @@ class WP_Reset_CLI extends WP_CLI_Command {
35
  WP_CLI::confirm( 'Are you sure you want to do this?', $assoc_args );
36
 
37
  global $wp_reset;
38
- $result = $wp_reset->do_reinstall();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
39
  if (is_wp_error($result)) {
40
  WP_CLI::error( $result->get_error_message );
41
  } else {
@@ -46,12 +70,13 @@ class WP_Reset_CLI extends WP_CLI_Command {
46
 
47
  /**
48
  * Display WP Reset version.
 
49
  * @when after_wp_load
50
  */
51
  function version( $_, $assoc_args ) {
52
  global $wp_reset;
53
 
54
- WP_CLI::line( 'WP Reset ' . $wp_reset->version );
55
  } // version
56
  } // WP_Reset_CLI
57
 
16
  * Resets the site to the default values without modifying any files.
17
  */
18
  class WP_Reset_CLI extends WP_CLI_Command {
19
+
20
  /**
21
  * Reset the site database to default values. No files are modified.
22
  *
23
  * ## OPTIONS
24
+ *
25
+ * [--reactivate-theme]
26
+ * : Reactivate currently active theme after reset.
27
+ *
28
+ * [--reactivate-plugins]
29
+ * : Reactivate all currently active plugins after reset.
30
+ *
31
+ * [--deactivate-wp-reset]
32
+ * : Deactivate WP Reset plugin after reset. By default it will stay active after reset.
33
+ *
34
  * [--yes]
35
  * : Answer yes to the confirmation message.
36
  *
37
  * ## EXAMPLES
38
  *
39
+ * $ wp reset reset --yes
40
+ * Success: Database has been reset.
41
  *
42
  * @when after_wp_load
43
  */
45
  WP_CLI::confirm( 'Are you sure you want to do this?', $assoc_args );
46
 
47
  global $wp_reset;
48
+ $params = array();
49
+
50
+ if ( !empty( $assoc_args['reactivate-theme'] ) ) {
51
+ $params['reactivate_theme'] = true;
52
+ }
53
+ if ( !empty( $assoc_args['disable-wp-reset'] ) ) {
54
+ $params['reactivate_wpreset'] = false;
55
+ } else {
56
+ $params['reactivate_wpreset'] = true;
57
+ }
58
+ if ( !empty( $assoc_args['reactivate-plugins'] ) ) {
59
+ $params['reactivate_plugins'] = true;
60
+ }
61
+
62
+ $result = $wp_reset->do_reinstall( $params );
63
  if (is_wp_error($result)) {
64
  WP_CLI::error( $result->get_error_message );
65
  } else {
70
 
71
  /**
72
  * Display WP Reset version.
73
+ *
74
  * @when after_wp_load
75
  */
76
  function version( $_, $assoc_args ) {
77
  global $wp_reset;
78
 
79
+ WP_CLI::line( 'WP Reset v' . $wp_reset->version );
80
  } // version
81
  } // WP_Reset_CLI
82
 
wp-reset.php CHANGED
@@ -3,7 +3,7 @@
3
  Plugin Name: WP Reset
4
  Plugin URI: https://wpreset.com/
5
  Description: Reset the site to default installation values without modifying any files. Deletes all customizations and content.
6
- Version: 1.25
7
  Author: WebFactory Ltd
8
  Author URI: https://www.webfactoryltd.com/
9
  Text Domain: wp-reset
@@ -73,6 +73,7 @@ class WP_Reset {
73
  add_action('admin_init', array($this, 'do_all_actions'));
74
  add_action('admin_enqueue_scripts', array($this, 'admin_enqueue_scripts'));
75
  add_action('wp_ajax_wp_reset_dismiss_notice', array($this, 'ajax_dismiss_notice'));
 
76
 
77
  add_filter('plugin_action_links_' . plugin_basename(__FILE__), array($this, 'plugin_action_links'));
78
  add_filter('plugin_row_meta', array($this, 'plugin_meta_links'), 10, 2);
@@ -144,7 +145,7 @@ class WP_Reset {
144
  */
145
  function get_dismissed_notices($notice_name = '') {
146
  $notices = $this->options['dismissed_notices'];
147
-
148
  if (empty($notice_name)) {
149
  return $notices;
150
  } else {
@@ -228,12 +229,46 @@ class WP_Reset {
228
  } // dismiss_notice
229
 
230
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
231
  /**
232
  * Enqueue CSS and JS files
233
  *
234
  * @return null
235
  */
236
  function admin_enqueue_scripts($hook) {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
237
  // exit early if not on WP Reset page
238
  if ('tools_page_wp-reset' != $hook) {
239
  return;
@@ -255,11 +290,13 @@ class WP_Reset {
255
  'confirm2' => __('Click "Cancel" to abort.', 'wp-reset'),
256
  'doing_reset' => __('Resetting in progress. Please wait.', 'wp-reset'),
257
  'nonce_dismiss_notice' => wp_create_nonce('wp-reset_dismiss_notice'),
 
258
  'nonce_do_reset' => wp_create_nonce('wp-reset_do_reset'));
259
 
260
  wp_enqueue_style('wp-reset', $this->plugin_url . 'css/wp-reset.css', array(), $this->version);
261
  wp_enqueue_style('wp-reset-sweetalert2', $this->plugin_url . 'css/sweetalert2.min.css', array(), $this->version);
262
 
 
263
  wp_enqueue_script('wp-reset-sweetalert2', $this->plugin_url . 'js/sweetalert2.min.js', array('jquery'), $this->version, true);
264
  wp_enqueue_script('wp-reset', $this->plugin_url . 'js/wp-reset.js', array('jquery'), $this->version, true);
265
  wp_localize_script('wp-reset', 'wp_reset', $js_localize);
@@ -280,6 +317,11 @@ class WP_Reset {
280
  } // admin_enqueue_scripts
281
 
282
 
 
 
 
 
 
283
  function is_cli_running() {
284
  if (defined('WP_CLI') && WP_CLI) {
285
  return true;
@@ -289,6 +331,107 @@ class WP_Reset {
289
  } // is_cli_running
290
 
291
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
292
  /**
293
  * Reinstall / reset the WP site
294
  * There are no failsafes in the function - it reinstalls when called
@@ -392,8 +535,10 @@ class WP_Reset {
392
 
393
 
394
  /**
395
- * checks wp_reset post value and performs all actions
396
  * todo: handle messages for various actions
 
 
397
  */
398
  function do_all_actions() {
399
  // only admins can perform actions
@@ -523,7 +668,6 @@ class WP_Reset {
523
  * @return null
524
  */
525
  function plugin_page() {
526
- global $current_user, $wpdb;
527
  $notice_shown = false;
528
  $meta = $this->get_meta();
529
 
@@ -563,6 +707,42 @@ class WP_Reset {
563
  $notice_shown = true;
564
  }
565
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
566
  echo '<div class="card" id="card-description">';
567
  echo '<a class="toggle-card" href="#" title="' . __('Collapse / expand box', 'wp-reset') . '"><span class="dashicons dashicons-arrow-up-alt2"></span></a>';
568
  echo '<h2>' . __('Please read carefully before proceeding. There is NO UNDO!', 'wp-reset') . '</h2>';
@@ -591,7 +771,7 @@ class WP_Reset {
591
  echo '</ul>';
592
 
593
  echo '<b>' . __('WP-CLI Support', 'wp-reset') . '</b>';
594
- echo '<p>' . sprintf(__('All features available via GUI are available in WP-CLI as well. To get the list of commands run %s. Instead of the active user, the first user with admin privileges found in the database will be restored.', 'wp-reset'), '<code>wp help reset</code>');
595
  echo sprintf(__('All actions have to be confirmed. If you want to skip confirmation use the standard %s option. Please be carefull - there is NO UNDO.', 'wp-reset'), '<code>--yes</code>') . '</p>';
596
  echo '</div>';
597
 
@@ -607,19 +787,62 @@ class WP_Reset {
607
 
608
  echo '<div class="card">';
609
  echo '<h2>' . __('Reset', 'wp-reset') . '</h2>';
610
- echo '<p>' . __('Type <b>reset</b> in the confirmation field to confirm the reset and then click the "Reset WordPress" button. <b>There is NO UNDO. No backups are made by this plugin.</b>', 'wp-reset') . '</p>';
611
 
612
  wp_nonce_field('wp-reset');
613
  echo '<p><input id="wp_reset_confirm" type="text" name="wp_reset_confirm" placeholder="' . esc_attr__('Type in "reset"', 'wp-reset'). '" value="" autocomplete="off"> &nbsp;';
614
  echo '<input id="wp_reset_submit" type="button" class="button-primary" value="' . __('Reset WordPress', 'wp-reset') . '"></p>';
615
  echo '</div>';
 
616
 
617
- echo '<br><br>';
618
- echo '</form>';
619
- echo '</div>'; // wrap
620
- } // plugin_page
621
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
622
 
 
623
  /**
624
  * Helper function for generating UTM tagged links
625
  *
3
  Plugin Name: WP Reset
4
  Plugin URI: https://wpreset.com/
5
  Description: Reset the site to default installation values without modifying any files. Deletes all customizations and content.
6
+ Version: 1.30
7
  Author: WebFactory Ltd
8
  Author URI: https://www.webfactoryltd.com/
9
  Text Domain: wp-reset
73
  add_action('admin_init', array($this, 'do_all_actions'));
74
  add_action('admin_enqueue_scripts', array($this, 'admin_enqueue_scripts'));
75
  add_action('wp_ajax_wp_reset_dismiss_notice', array($this, 'ajax_dismiss_notice'));
76
+ add_action('wp_ajax_wp_reset_run_tool', array($this, 'ajax_run_tool'));
77
 
78
  add_filter('plugin_action_links_' . plugin_basename(__FILE__), array($this, 'plugin_action_links'));
79
  add_filter('plugin_row_meta', array($this, 'plugin_meta_links'), 10, 2);
145
  */
146
  function get_dismissed_notices($notice_name = '') {
147
  $notices = $this->options['dismissed_notices'];
148
+
149
  if (empty($notice_name)) {
150
  return $notices;
151
  } else {
229
  } // dismiss_notice
230
 
231
 
232
+ /**
233
+ * Returns all WP pointers
234
+ *
235
+ * @return array
236
+ */
237
+ function get_pointers() {
238
+ $pointers = array();
239
+
240
+ $pointers['welcome'] = array('target' => '#menu-tools', 'edge' => 'left', 'align' => 'right', 'content' => 'Thank you for installing the <b style="font-weight: 800;">WP Reset</b> plugin!<br>Open <a href="' . admin_url('tools.php?page=wp-reset'). '">Tools - WP Reset</a> to access resetting tools and start developing &amp; debugging faster.');
241
+
242
+ return $pointers;
243
+ } // get_pointers
244
+
245
+
246
  /**
247
  * Enqueue CSS and JS files
248
  *
249
  * @return null
250
  */
251
  function admin_enqueue_scripts($hook) {
252
+ // welcome pointer is shown on all pages except WPR, untill dismissed
253
+ $pointers = $this->get_pointers();
254
+ $dismissed_notices = $this->get_dismissed_notices();
255
+
256
+ foreach ($dismissed_notices as $notice_name => $tmp) {
257
+ if ($tmp) {
258
+ unset($pointers[$notice_name]);
259
+ }
260
+ } // foreach
261
+
262
+ if (!empty($pointers) && 'tools_page_wp-reset' != $hook) {
263
+ $pointers['_nonce_dismiss_pointer'] = wp_create_nonce('wp-reset_dismiss_notice');
264
+
265
+ wp_enqueue_style('wp-pointer');
266
+
267
+ wp_enqueue_script('wp-reset-pointers', $this->plugin_url . 'js/wp-reset-pointers.js', array('jquery'), $this->version, true);
268
+ wp_enqueue_script('wp-pointer');
269
+ wp_localize_script('wp-pointer', 'wp_reset_pointers', $pointers);
270
+ }
271
+
272
  // exit early if not on WP Reset page
273
  if ('tools_page_wp-reset' != $hook) {
274
  return;
290
  'confirm2' => __('Click "Cancel" to abort.', 'wp-reset'),
291
  'doing_reset' => __('Resetting in progress. Please wait.', 'wp-reset'),
292
  'nonce_dismiss_notice' => wp_create_nonce('wp-reset_dismiss_notice'),
293
+ 'nonce_run_tool' => wp_create_nonce('wp-reset_run_tool'),
294
  'nonce_do_reset' => wp_create_nonce('wp-reset_do_reset'));
295
 
296
  wp_enqueue_style('wp-reset', $this->plugin_url . 'css/wp-reset.css', array(), $this->version);
297
  wp_enqueue_style('wp-reset-sweetalert2', $this->plugin_url . 'css/sweetalert2.min.css', array(), $this->version);
298
 
299
+ wp_enqueue_script('jquery-ui-tabs');
300
  wp_enqueue_script('wp-reset-sweetalert2', $this->plugin_url . 'js/sweetalert2.min.js', array('jquery'), $this->version, true);
301
  wp_enqueue_script('wp-reset', $this->plugin_url . 'js/wp-reset.js', array('jquery'), $this->version, true);
302
  wp_localize_script('wp-reset', 'wp_reset', $js_localize);
317
  } // admin_enqueue_scripts
318
 
319
 
320
+ /**
321
+ * Check if WP-CLI is available and running
322
+ *
323
+ * @return bool
324
+ */
325
  function is_cli_running() {
326
  if (defined('WP_CLI') && WP_CLI) {
327
  return true;
331
  } // is_cli_running
332
 
333
 
334
+ /**
335
+ * Deletes all transients.
336
+ *
337
+ * @return int
338
+ */
339
+ function do_delete_transients() {
340
+ global $wpdb;
341
+
342
+ $count = $wpdb->query("DELETE FROM $wpdb->options WHERE option_name LIKE '\_transient\_%' OR option_name LIKE '\_site\_transient\_%'");
343
+
344
+ return $count;
345
+ } // do_delete_transients
346
+
347
+
348
+ /**
349
+ * Deactivate and delete all plugins
350
+ *
351
+ * @param bool Keep WP Reset active and installed
352
+ * @param bool Skip individual plugin deactivation functions when deactivating
353
+ * @return int
354
+ */
355
+ function do_delete_plugins($keep_wp_reset = true, $silent_deactivate = false) {
356
+ if (!function_exists('get_plugins')) {
357
+ require_once ABSPATH . 'wp-admin/includes/plugin.php';
358
+ }
359
+
360
+ $wp_reset_basename = plugin_basename(__FILE__);
361
+
362
+ $all_plugins = get_plugins();
363
+ $active_plugins = (array) get_option('active_plugins', array());
364
+ if (true == $keep_wp_reset) {
365
+ if (($key = array_search($wp_reset_basename, $active_plugins)) !== false) {
366
+ unset($active_plugins[$key]);
367
+ }
368
+ unset($all_plugins[$wp_reset_basename]);
369
+ }
370
+
371
+ if (!empty($active_plugins)) {
372
+ deactivate_plugins($active_plugins, $silent_deactivate, false);
373
+ }
374
+
375
+ if (!empty($all_plugins)) {
376
+ delete_plugins(array_keys($all_plugins));
377
+ }
378
+
379
+ return sizeof($all_plugins);
380
+ } // do_delete_plugins
381
+
382
+
383
+ /**
384
+ * Delete all themes
385
+ *
386
+ * @param bool Keep default theme
387
+ * @return int
388
+ */
389
+ function do_delete_themes($keep_default_theme = true) {
390
+ $default_theme = 'twentyseventeen';
391
+ $all_themes = wp_get_themes(array('errors' => null));
392
+
393
+ if (true == $keep_default_theme) {
394
+ unset($all_themes[$default_theme]);
395
+ }
396
+
397
+ foreach ($all_themes as $theme_slug => $theme_details) {
398
+ $res = delete_theme($theme_slug);
399
+ }
400
+
401
+ if (false == $keep_default_theme) {
402
+ update_option('template', '');
403
+ update_option('stylesheet', '');
404
+ }
405
+
406
+ return sizeof($all_themes);
407
+ } // do_delete_themes
408
+
409
+
410
+ /**
411
+ * Run tool via AJAX call
412
+ *
413
+ * @return null
414
+ */
415
+ function ajax_run_tool() {
416
+ check_ajax_referer('wp-reset_run_tool');
417
+
418
+ $tool = trim(@$_GET['tool']);
419
+
420
+ if ($tool == 'delete_transients') {
421
+ $cnt = $this->do_delete_transients();
422
+ wp_send_json_success($cnt);
423
+ } elseif ($tool == 'delete_themes') {
424
+ $cnt = $this->do_delete_themes(false);
425
+ wp_send_json_success($cnt);
426
+ } elseif ($tool == 'delete_plugins') {
427
+ $cnt = $this->do_delete_plugins(true);
428
+ wp_send_json_success($cnt);
429
+ } else {
430
+ wp_send_json_error(__('Unknown tool.', 'wp-reset'));
431
+ }
432
+ } // ajax_run_tool
433
+
434
+
435
  /**
436
  * Reinstall / reset the WP site
437
  * There are no failsafes in the function - it reinstalls when called
535
 
536
 
537
  /**
538
+ * Checks wp_reset post value and performs all actions
539
  * todo: handle messages for various actions
540
+ *
541
+ * @return null
542
  */
543
  function do_all_actions() {
544
  // only admins can perform actions
668
  * @return null
669
  */
670
  function plugin_page() {
 
671
  $notice_shown = false;
672
  $meta = $this->get_meta();
673
 
707
  $notice_shown = true;
708
  }
709
 
710
+ // tabs
711
+ echo '<div id="wp-reset-tabs" class' . __('="', 'wp-reset') . 'ui-tabs">';
712
+
713
+ echo '<ul class="wpr-main-tab">';
714
+ echo '<li><a href="#tab-reset">' . __('Reset', 'wp-reset') . '</a></li>';
715
+ echo '<li><a href="#tab-tools">' . __('Tools', 'wp-reset') . '</a></li>';
716
+ echo '<li><a href="#tab-support">' . __('Support', 'wp-reset') . '</a></li>';
717
+ echo '</ul>';
718
+
719
+ echo '<div style="display: none;" id="tab-reset">';
720
+ $this->tab_reset();
721
+ echo '</div>';
722
+
723
+ echo '<div style="display: none;" id="tab-tools">';
724
+ $this->tab_tools();
725
+ echo '</div>';
726
+
727
+ echo '<div style="display: none;" id="tab-support">';
728
+ $this->tab_support();
729
+ echo '</div>';
730
+
731
+ echo '</div>'; // tabs
732
+
733
+ echo '</form>';
734
+ echo '</div>'; // wrap
735
+ } // plugin_page
736
+
737
+
738
+ /**
739
+ * Echoes content for reset tab
740
+ *
741
+ * @return null
742
+ */
743
+ private function tab_reset() {
744
+ global $current_user, $wpdb;
745
+
746
  echo '<div class="card" id="card-description">';
747
  echo '<a class="toggle-card" href="#" title="' . __('Collapse / expand box', 'wp-reset') . '"><span class="dashicons dashicons-arrow-up-alt2"></span></a>';
748
  echo '<h2>' . __('Please read carefully before proceeding. There is NO UNDO!', 'wp-reset') . '</h2>';
771
  echo '</ul>';
772
 
773
  echo '<b>' . __('WP-CLI Support', 'wp-reset') . '</b>';
774
+ echo '<p>' . sprintf(__('All features available via GUI are available in WP-CLI as well. To get the list of commands run %s. Instead of the active user, the first user with admin privileges found in the database will be restored. ', 'wp-reset'), '<code>wp help reset</code>');
775
  echo sprintf(__('All actions have to be confirmed. If you want to skip confirmation use the standard %s option. Please be carefull - there is NO UNDO.', 'wp-reset'), '<code>--yes</code>') . '</p>';
776
  echo '</div>';
777
 
787
 
788
  echo '<div class="card">';
789
  echo '<h2>' . __('Reset', 'wp-reset') . '</h2>';
790
+ echo '<p>' . __('Type <b>reset</b> in the confirmation field to confirm the reset and then click the "Reset WordPress" button. <b>There is NO UNDO. No backups are made by WP Reset.</b>', 'wp-reset') . '</p>';
791
 
792
  wp_nonce_field('wp-reset');
793
  echo '<p><input id="wp_reset_confirm" type="text" name="wp_reset_confirm" placeholder="' . esc_attr__('Type in "reset"', 'wp-reset'). '" value="" autocomplete="off"> &nbsp;';
794
  echo '<input id="wp_reset_submit" type="button" class="button-primary" value="' . __('Reset WordPress', 'wp-reset') . '"></p>';
795
  echo '</div>';
796
+ } // tab_reset
797
 
798
+
799
+ /**
800
+ * Echoes content for tools tab
801
+ *
802
+ * @return null
803
+ */
804
+ private function tab_tools() {
805
+ $theme = wp_get_theme();
806
+
807
+ echo '<div class="card">';
808
+ echo '<h2>' . __('Transients', 'wp-reset') . '</h2>';
809
+ echo '<p>' . __('All transient related database entries will be deleted. Including expired and non-expired transients, and orphaned timeout entries. <b>There is NO UNDO. WP Reset will not make any backups.</b>', 'wp-reset') . '</p>';
810
+ echo '<p><a data-btn-confirm="Delete all transients" data-text-wait="Deleting transients. Please wait." data-text-confirm="All database entries related to transients will be deleted. There is NO UNDO. WP Reset will not make any backups." data-text-done="%n transient database entries have been deleted." class="button" href="#" id="delete-transients">Delete all transients</a></p>';
811
+ echo '</div>';
812
+
813
+ echo '<div class="card">';
814
+ echo '<h2>' . __('Themes', 'wp-reset') . '</h2>';
815
+ echo '<p>' . __('All themes will be deleted. Including the currently active theme - ' . $theme->get('Name') . '. <b>There is NO UNDO. WP Reset will not make any backups.</b>', 'wp-reset') . '</p>';
816
+ echo '<p><a data-btn-confirm="Delete all themes" data-text-wait="Deleting all themes. Please wait." data-text-confirm="All themes will be deleted. There is NO UNDO. WP Reset will not make any backups." data-text-done="%n themes have been deleted." class="button" href="#" id="delete-themes">Delete all themes</a></p>';
817
+ echo '</div>';
818
+
819
+ echo '<div class="card">';
820
+ echo '<h2>' . __('Plugins', 'wp-reset') . '</h2>';
821
+ echo '<p>' . __('Type <b>reset</b> in the confirmation field to confirm the reset and then click the "Reset WordPress" button. <b>There is NO UNDO. WP Reset will not make any backups.</b>', 'wp-reset') . '</p>';
822
+ echo '<p>WP Reset plugin will no be deleted or disabled.</p>';
823
+ echo '<p><a data-btn-confirm="Delete plugins" data-text-wait="Deleting plugins. Please wait." data-text-confirm="All plugins except WP Reset will be deleted. There is NO UNDO. WP Reset will not make any backups." data-text-done="%n plugins have been deleted." class="button" href="#" id="delete-plugins">Delete plugins</a></p>';
824
+ echo '</div>';
825
+ } // tab_tools
826
+
827
+
828
+ /**
829
+ * Echoes content for support tab
830
+ *
831
+ * @return null
832
+ */
833
+ private function tab_support() {
834
+ echo '<div class="card">';
835
+ echo '<h2>' . __('Public support forum', 'wp-reset') . '</h2>';
836
+ echo '<p>' . __('We are very active on the <a href="https://wordpress.org/support/plugin/wp-reset" target="_blank">official WP Reset support forum</a>. If you found a bug, have a feature idea or just want to say hi - please drop by. We love to hear back from our users.', 'wp-reset') . '</p>';
837
+ echo '</div>';
838
+
839
+ echo '<div class="card">';
840
+ echo '<h2>' . __('Private contact', 'wp-reset') . '</h2>';
841
+ echo '<p>' . __('If there\'s a need to contact us privately send emails to <a href="mailto:wpreset@webfactoryltd.com">wpreset@webfactoryltd.com</a>. Please know that although we\'ll gladly have a look at issues you are having with any site, we can\'t promise we\'ll fix them. Thank you for understanding.', 'wp-reset') . '</p>';
842
+ echo '</div>';
843
+ } // tab_support
844
 
845
+
846
  /**
847
  * Helper function for generating UTM tagged links
848
  *