Reset WP - Version 1.4

Version Description

  • 2018/07/25
  • started moving users to WP Reset - https://wordpress.org/plugins/wp-reset/
Download this release

Release Info

Developer WebFactory
Plugin Icon 128x128 Reset WP
Version 1.4
Comparing to
See all releases

Code changes from version 1.3 to 1.4

Files changed (2) hide show
  1. readme.txt +13 -4
  2. reset-wp.php +100 -27
readme.txt CHANGED
@@ -1,10 +1,10 @@
1
  === Reset WP - Easiest WordPress Reset Plugin ===
2
- Contributors: WebFactory, WPreset
3
  Tags: reset wp, reset wordpress, wordpress reset, wp reset, reset, restart wordpress, clean wordpress, clean database, restart, reset database, default wordpress, developer
4
  Requires at least: 4.0
5
  Tested up to: 4.9
6
  Requires PHP: 5.2
7
- Stable tag: 1.3
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
@@ -12,7 +12,8 @@ Reset WordPress resets the WP database back to the default installation values w
12
 
13
  == Description ==
14
 
15
- **This plugin has a new home in the WordPress repo - <a href="https://wordpress.org/plugins/wp-reset/">wordpress.org/plugins/wp-reset/</a> - Please download it from there. Thank you!**
 
16
 
17
  <a href="https://wpreset.com/?utm_source=wordpressorg&utm_medium=content&utm_campaign=reset-wp&utm_term=reset%20wordpress">Reset WordPress</a> resets the WP database back to the default installation values without deleting or modifying any files. It's fast and safe to use and an ideal tool for testing during WP development.
18
 
@@ -38,7 +39,7 @@ Usage :
38
  Follow the standard routine;
39
 
40
  1. Open WordPress admin, go to Plugins, click Add New
41
- 2. Enter "reset wp" in search and hit Enter
42
  3. Plugin will show up as the first on the list, click "Install Now"
43
  4. Activate & open plugin's settings page located under the Tools menu
44
 
@@ -55,6 +56,10 @@ Or if needed, upload manually;
55
 
56
  == Changelog ==
57
 
 
 
 
 
58
  = 1.3 =
59
  * 2018/06/19
60
  * WebFactory took over development
@@ -76,6 +81,10 @@ Or if needed, upload manually;
76
 
77
  == Frequently Asked Questions ==
78
 
 
 
 
 
79
  = How can I log in after resetting? =
80
 
81
  Use the same username and password you used while doing the reset. Only one user will be restored after resetting. The one you used at that time.
1
  === Reset WP - Easiest WordPress Reset Plugin ===
2
+ Contributors: WebFactory, WPreset, googlemapswidget
3
  Tags: reset wp, reset wordpress, wordpress reset, wp reset, reset, restart wordpress, clean wordpress, clean database, restart, reset database, default wordpress, developer
4
  Requires at least: 4.0
5
  Tested up to: 4.9
6
  Requires PHP: 5.2
7
+ Stable tag: 1.4
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
12
 
13
  == Description ==
14
 
15
+ **This plugin has a new home in the WordPress repo - <a href="https://wordpress.org/plugins/wp-reset/">wordpress.org/plugins/wp-reset/</a> - Please download it from there. Thank you!** More info about this change is available on the <a href="https://wpreset.com/rebranding-reset-wp/?utm_source=wordpressorg&utm_medium=content&utm_campaign=reset-wp&utm_term=wp%20reset%20blog">WP Reset blog</a>.
16
+
17
 
18
  <a href="https://wpreset.com/?utm_source=wordpressorg&utm_medium=content&utm_campaign=reset-wp&utm_term=reset%20wordpress">Reset WordPress</a> resets the WP database back to the default installation values without deleting or modifying any files. It's fast and safe to use and an ideal tool for testing during WP development.
19
 
39
  Follow the standard routine;
40
 
41
  1. Open WordPress admin, go to Plugins, click Add New
42
+ 2. Enter "wp reset" in search and hit Enter
43
  3. Plugin will show up as the first on the list, click "Install Now"
44
  4. Activate & open plugin's settings page located under the Tools menu
45
 
56
 
57
  == Changelog ==
58
 
59
+ = 1.4 =
60
+ * 2018/07/25
61
+ * started moving users to WP Reset - https://wordpress.org/plugins/wp-reset/
62
+
63
  = 1.3 =
64
  * 2018/06/19
65
  * WebFactory took over development
81
 
82
  == Frequently Asked Questions ==
83
 
84
+ = Is Reset WP regularly maintained? =
85
+
86
+ Yes, but **it will soon be removed from the repository**. Please install <a href="https://wordpress.org/plugins/wp-reset/">WP Reset</a> instead. It has the same functionality, it's created by the same people. It's free and safe to use. If you need more info about this change visit the <a href="https://wpreset.com/rebranding-reset-wp/?utm_source=wordpressorg&utm_medium=content&utm_campaign=reset-wp&utm_term=wp%20reset%20blog">WP Reset blog</a>.
87
+
88
  = How can I log in after resetting? =
89
 
90
  Use the same username and password you used while doing the reset. Only one user will be restored after resetting. The one you used at that time.
reset-wp.php CHANGED
@@ -2,8 +2,8 @@
2
  /*
3
  Plugin Name: Reset WP
4
  Plugin URI: https://wpreset.com
5
- Description: Reset the WordPress database to the default installation values including all content and customizations. Only the database is reset. No files are modified or deleted.
6
- Version: 1.3
7
  Author: WebFactory Ltd
8
  Author URI: https://www.webfactoryltd.com/
9
  Text Domain: reset-wp
@@ -28,14 +28,13 @@ if ( is_admin() ) {
28
  define( 'REACTIVATE_THE_RESET_WP', true );
29
 
30
  class ResetWP {
31
- static $version = 1.3;
32
 
33
  function __construct() {
34
  add_action( 'admin_menu', array( $this, 'add_page' ) );
35
  add_action( 'admin_init', array( $this, 'admin_init' ) );
36
- add_filter( 'favorite_actions', array( $this, 'add_favorite' ), 100 );
37
- add_action( 'wp_before_admin_bar_render', array( $this, 'admin_bar_link' ) );
38
  add_filter( 'plugin_action_links_' . plugin_basename(__FILE__), array( $this, 'plugin_action_links') );
 
39
  }
40
 
41
  // Checks reset_wp post value and performs an installation, adding the users previous password also
@@ -130,23 +129,6 @@ class ResetWP {
130
  add_action( "admin_footer-{$hook}", array( $this, 'footer_javascript' ) );
131
  }
132
 
133
- function add_favorite( $actions ) {
134
- $reset['tools.php?page=reset-wp'] = array( 'Reset WP', 'level_10' );
135
- return array_merge( $reset, $actions );
136
- }
137
-
138
- function admin_bar_link() {
139
- global $wp_admin_bar;
140
- $wp_admin_bar->add_menu(
141
- array(
142
- 'parent' => 'site-name',
143
- 'id' => 'reset-wp',
144
- 'title' => 'Reset WP',
145
- 'href' => admin_url( 'tools.php?page=reset-wp' )
146
- )
147
- );
148
- }
149
-
150
  // Inform the user that WordPress has been successfully reset
151
  function admin_notices_successfully_reset() {
152
  global $current_user;
@@ -195,6 +177,21 @@ class ResetWP {
195
  <div class="wrap">
196
  <h2>Reset WP</h2>
197
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
198
  <div class="card">
199
  <p><strong>After completing the reset operation, you will be automatically logged in and redirected to the dashboard.</strong></p>
200
 
@@ -210,16 +207,92 @@ class ResetWP {
210
  <input id="reset_wp_confirm" style="vertical-align: middle;" type="text" name="reset_wp_confirm" placeholder="Type in 'reset'">
211
  <input id="reset_wp_submit" style="vertical-align: middle;" type="submit" name="Submit" class="button-primary" value="Reset">
212
  </form>
 
 
213
  </div>
214
  </div>
215
 
216
- <div class="card">
217
- <p><b>Please help us keep the plugin going</b></p>
218
- <p>If you enjoy this plugin, <b>please rate it on WordPress</b>. It only takes a second and helps us keep the plugin free and maintained.
219
- <a title="Reset WP" target="_blank" href="https://wordpress.org/support/plugin/reset-wp/reviews/#new-post">Rate the plugin</a></p>
220
- </div>
221
  <?php
222
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
223
  }
224
 
225
  $ResetWP = new ResetWP();
2
  /*
3
  Plugin Name: Reset WP
4
  Plugin URI: https://wpreset.com
5
+ Description: Reset the WordPress database to the default installation values including all content and customizations. This plugin will soon be removed from the WP repository and replaced with WP Reset.
6
+ Version: 1.4
7
  Author: WebFactory Ltd
8
  Author URI: https://www.webfactoryltd.com/
9
  Text Domain: reset-wp
28
  define( 'REACTIVATE_THE_RESET_WP', true );
29
 
30
  class ResetWP {
31
+ static $version = 1.4;
32
 
33
  function __construct() {
34
  add_action( 'admin_menu', array( $this, 'add_page' ) );
35
  add_action( 'admin_init', array( $this, 'admin_init' ) );
 
 
36
  add_filter( 'plugin_action_links_' . plugin_basename(__FILE__), array( $this, 'plugin_action_links') );
37
+ add_action( 'admin_action_replace_reset_wp', array($this, 'replace_reset_wp'));
38
  }
39
 
40
  // Checks reset_wp post value and performs an installation, adding the users previous password also
129
  add_action( "admin_footer-{$hook}", array( $this, 'footer_javascript' ) );
130
  }
131
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
132
  // Inform the user that WordPress has been successfully reset
133
  function admin_notices_successfully_reset() {
134
  global $current_user;
177
  <div class="wrap">
178
  <h2>Reset WP</h2>
179
 
180
+ <div class="card">
181
+ <p><strong>This plugin will soon be removed from the WP repository &amp; replaced with <a target="_blank" href="https://wordpress.org/plugins/wp-reset/">WP Reset</a></strong></p>
182
+ <p>Except the name and the slug <b>NOTHING CHANGES</b>. Plugin remains simple, fast, free and maintained by the same dedicated developers. You can read more about the change on the <a target="_blank" href="https://wpreset.com/rebranding-reset-wp/?utm_source=reset-wp-free&utm_medium=plugin&utm_content=wp-reset-blog&utm_campaign=reset-wp-free-v<?php echo self::$version; ?>">WP Reset blog</a>.</p>
183
+ <?php
184
+ $replace_url = add_query_arg(array('action' => 'replace_reset_wp'), admin_url('admin.php'));
185
+ echo '<a class="button button-primary" id="upgrade-wp-reset">Replace plugin with the new version - WP Reset</a><br>';
186
+ echo '<p>What happens when I click the button? WP Reset will be downloaded from <a target="_blank" href="https://wordpress.org/plugins/wp-reset/">wordpress.org/plugins/wp-reset/</a> and activated. You\'ll be redirected to its admin page. This plugin will then be deactivated. Nothing is deleted or removed!</p>';
187
+ ?>
188
+ <script>
189
+ jQuery('#upgrade-wp-reset').on('click',function(){
190
+ jQuery('body').append('<div style="width:400px;height:540px; position:absolute;top:10%;left:50%;margin-left:-200px;background:#FFF;border:1px solid #DDD; border-radius:4px;box-shadow: 0px 0px 0px 4000px rgba(0, 0, 0, 0.85);z-index: 9999999;"><iframe src="<?php echo $replace_url; ?>" style="width:100%;height:100%;border:none;" /></div>');
191
+ jQuery('#wpwrap').css('pointer-events', 'none');
192
+ });
193
+ </script>
194
+ </div>
195
  <div class="card">
196
  <p><strong>After completing the reset operation, you will be automatically logged in and redirected to the dashboard.</strong></p>
197
 
207
  <input id="reset_wp_confirm" style="vertical-align: middle;" type="text" name="reset_wp_confirm" placeholder="Type in 'reset'">
208
  <input id="reset_wp_submit" style="vertical-align: middle;" type="submit" name="Submit" class="button-primary" value="Reset">
209
  </form>
210
+
211
+ <p>Something is not right? Let us know in the <a href="https://wordpress.org/support/plugin/reset-wp" target="_blank">forums</a>.
212
  </div>
213
  </div>
214
 
 
 
 
 
 
215
  <?php
216
  }
217
+
218
+ function replace_reset_wp() {
219
+ $plugin_slug = 'wp-reset/wp-reset.php';
220
+ $plugin_zip = 'https://downloads.wordpress.org/plugin/wp-reset.latest-stable.zip';
221
+
222
+ @include_once ABSPATH . 'wp-admin/includes/plugin.php';
223
+ @include_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
224
+ @include_once ABSPATH . 'wp-admin/includes/plugin-install.php';
225
+ @include_once ABSPATH . 'wp-admin/includes/file.php';
226
+ @include_once ABSPATH . 'wp-admin/includes/misc.php';
227
+ echo '<style>
228
+ body{
229
+ font-family: sans-serif;
230
+ font-size: 14px;
231
+ line-height: 1.5;
232
+ color: #444;
233
+ }
234
+
235
+ a{
236
+ color:#0073aa;
237
+ }
238
+
239
+ a:hover{
240
+ color:#00a0d2;
241
+ text-decoration:none;
242
+ }
243
+ </style>';
244
+
245
+ echo '<div style="margin: 30px;">';
246
+ echo 'If things are not done in a minute <a href="plugins.php" target="_parent">click here to return to Plugins page</a><br><br>';
247
+ echo 'Starting ...<br><br>';
248
+
249
+ wp_cache_flush();
250
+ $upgrader = new Plugin_Upgrader();
251
+ echo 'Check if new plugin is already installed - ';
252
+ if ($this->is_plugin_installed($plugin_slug)) {
253
+ echo 'it\'s installed! Making sure it\'s the latest version.';
254
+ $upgrader->upgrade($plugin_slug);
255
+ $installed = true;
256
+ } else {
257
+ echo 'it\'s not installed. Installing.';
258
+ $installed = $upgrader->install($plugin_zip);
259
+ }
260
+ wp_cache_flush();
261
+
262
+ if (!is_wp_error($installed) && $installed) {
263
+ echo 'Activating new plugin.';
264
+ $activate = activate_plugin($plugin_slug);
265
+
266
+ if (is_null($activate)) {
267
+ echo '<br>Deactivating old plugin.<br>';
268
+ deactivate_plugins(array('reset-wp/reset-wp.php'));
269
+
270
+ $options = get_option('wp-reset', array());
271
+ $options['meta']['reset-wp-user'] = true;
272
+ update_option('wp-reset', $options);
273
+
274
+ echo '<script>setTimeout(function() { top.location = "tools.php?page=wp-reset"; }, 1000);</script>';
275
+ echo '<br>If you are not redirected to the new plugin in a few seconds - <a href="tools.php?page=wp-reset" target="_parent">click here</a>.';
276
+ }
277
+ } else {
278
+ echo 'Could not install WP Reset. You\'ll have to <a target="_parent" href="' . admin_url('plugin-install.php?s=wp+reset&tab=search&type=term') .'">download and install manually</a>.';
279
+ }
280
+
281
+ echo '</div>';
282
+ } // replace
283
+
284
+ function is_plugin_installed( $slug ) {
285
+ if ( ! function_exists( 'get_plugins' ) ) {
286
+ require_once ABSPATH . 'wp-admin/includes/plugin.php';
287
+ }
288
+ $all_plugins = get_plugins();
289
+
290
+ if ( !empty( $all_plugins[$slug] ) ) {
291
+ return true;
292
+ } else {
293
+ return false;
294
+ }
295
+ }
296
  }
297
 
298
  $ResetWP = new ResetWP();