Version Description
- 2018/11/13
- dropped to 30k installations on 2018/11/02
- effort to move people to WP Reset continues
Download this release
Release Info
| Developer | WebFactory |
| Plugin | |
| Version | 1.50 |
| Comparing to | |
| See all releases | |
Code changes from version 1.45 to 1.50
- readme.txt +7 -2
- reset-wp.php +89 -49
readme.txt
CHANGED
|
@@ -2,9 +2,9 @@
|
|
| 2 |
Contributors: WebFactory, WPreset, underconstructionpage, googlemapswidget, securityninja
|
| 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:
|
| 6 |
Requires PHP: 5.2
|
| 7 |
-
Stable tag: 1.
|
| 8 |
License: GPLv2 or later
|
| 9 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
| 10 |
|
|
@@ -56,6 +56,11 @@ Or if needed, upload manually;
|
|
| 56 |
|
| 57 |
== Changelog ==
|
| 58 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 59 |
= 1.45 =
|
| 60 |
* 2018/10/02
|
| 61 |
* effort to move people to WP Reset continues
|
| 2 |
Contributors: WebFactory, WPreset, underconstructionpage, googlemapswidget, securityninja
|
| 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: 5.0
|
| 6 |
Requires PHP: 5.2
|
| 7 |
+
Stable tag: 1.50
|
| 8 |
License: GPLv2 or later
|
| 9 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
| 10 |
|
| 56 |
|
| 57 |
== Changelog ==
|
| 58 |
|
| 59 |
+
= 1.50 =
|
| 60 |
+
* 2018/11/13
|
| 61 |
+
* dropped to 30k installations on 2018/11/02
|
| 62 |
+
* effort to move people to WP Reset continues
|
| 63 |
+
|
| 64 |
= 1.45 =
|
| 65 |
* 2018/10/02
|
| 66 |
* effort to move people to WP Reset continues
|
reset-wp.php
CHANGED
|
@@ -3,7 +3,7 @@
|
|
| 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.
|
| 7 |
Author: WebFactory Ltd
|
| 8 |
Author URI: https://www.webfactoryltd.com/
|
| 9 |
Text Domain: reset-wp
|
|
@@ -20,7 +20,7 @@ IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
| 20 |
|
| 21 |
if ( ! defined( 'ABSPATH' ) ){
|
| 22 |
exit; // Exit if accessed this file directly
|
| 23 |
-
}
|
| 24 |
|
| 25 |
if ( is_admin() ) {
|
| 26 |
|
|
@@ -29,14 +29,16 @@ define( 'REACTIVATE_THE_RESET_WP', true );
|
|
| 29 |
|
| 30 |
class ResetWP {
|
| 31 |
static $version = 1.45;
|
| 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
|
| 41 |
function admin_init() {
|
| 42 |
global $current_user, $wpdb;
|
|
@@ -84,10 +86,10 @@ class ResetWP {
|
|
| 84 |
}
|
| 85 |
|
| 86 |
|
| 87 |
-
|
| 88 |
if ( defined( 'REACTIVATE_THE_RESET_WP' ) && REACTIVATE_THE_RESET_WP === true )
|
| 89 |
@activate_plugin( plugin_basename( __FILE__ ) );
|
| 90 |
-
|
| 91 |
|
| 92 |
wp_clear_auth_cookie();
|
| 93 |
wp_set_auth_cookie( $user_id );
|
|
@@ -104,39 +106,69 @@ class ResetWP {
|
|
| 104 |
// add settings link to plugins page
|
| 105 |
static function plugin_action_links($links) {
|
| 106 |
$settings_link = '<a href="' . admin_url('tools.php?page=reset-wp') . '" title="' . __('Reset WordPress', 'reset-wp') . '">' . __('Reset WordPress', 'reset-wp') . '</a>';
|
| 107 |
-
|
| 108 |
array_unshift($links, $settings_link);
|
| 109 |
-
|
| 110 |
return $links;
|
| 111 |
} // plugin_action_links
|
| 112 |
-
|
| 113 |
-
|
| 114 |
-
|
| 115 |
-
|
| 116 |
-
|
| 117 |
-
|
| 118 |
-
|
| 119 |
-
|
| 120 |
-
|
| 121 |
-
|
| 122 |
-
|
| 123 |
-
|
| 124 |
-
|
| 125 |
// admin_menu action hook operations & Add the settings page
|
| 126 |
function add_page() {
|
| 127 |
$hook = add_management_page( 'Reset WP', 'Reset WP', 'administrator', 'reset-wp', array( $this, 'admin_page' ) );
|
| 128 |
add_action( "admin_print_scripts-{$hook}", array( $this, 'admin_javascript' ) );
|
| 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;
|
| 135 |
|
| 136 |
echo '<div id="message" class="updated"><p><strong>WordPress has been reset successfully.</strong> User "' . $current_user->user_login . '" was recreated with its old password.</p></div>';
|
| 137 |
do_action( 'reset_wp_post', $current_user );
|
| 138 |
-
|
| 139 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 140 |
function admin_javascript() {
|
| 141 |
if ( $this->is_plugin_page() ) {
|
| 142 |
wp_enqueue_script( 'jquery' );
|
|
@@ -160,7 +192,7 @@ class ResetWP {
|
|
| 160 |
return false;
|
| 161 |
}
|
| 162 |
});
|
| 163 |
-
</script>
|
| 164 |
<?php
|
| 165 |
}
|
| 166 |
|
|
@@ -172,7 +204,7 @@ class ResetWP {
|
|
| 172 |
echo '<div class="error fade"><p><strong>Invalid confirmation. Please type \'reset-wp\' in the confirmation field.</strong></p></div>';
|
| 173 |
elseif ( isset( $_POST['_wpnonce'] ) )
|
| 174 |
echo '<div class="error fade"><p><strong>Invalid wpnonce. Please try again.</strong></p></div>';
|
| 175 |
-
|
| 176 |
?>
|
| 177 |
<div class="wrap">
|
| 178 |
<h2>Reset WP</h2>
|
|
@@ -271,7 +303,7 @@ class ResetWP {
|
|
| 271 |
</tr>
|
| 272 |
<tr>
|
| 273 |
<td> </td>
|
| 274 |
-
<td><a href="" id="continue-reset-wp">Continue using an unmaintained plugin</a></td>
|
| 275 |
<td><a style="margin-bottom: 8px;" class="button button-primary" id="upgrade-wp-reset">Switch to WP Reset</a><br>1 click & 5 seconds of waiting</td>
|
| 276 |
</tr>
|
| 277 |
</table>
|
|
@@ -279,21 +311,21 @@ class ResetWP {
|
|
| 279 |
<?php
|
| 280 |
$replace_url = add_query_arg(array('action' => 'replace_reset_wp'), admin_url('admin.php'));
|
| 281 |
//echo '<a class="button button-primary" id="upgrade-wp-reset">Replace plugin with the new version - WP Reset</a><br>';
|
| 282 |
-
echo '<p>What happens when I click the "Switch to WP Reset" 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 and this plugin will then be deactivated. Nothing is deleted or removed!</p>';
|
| 283 |
?>
|
| 284 |
<script>
|
| 285 |
jQuery('#upgrade-wp-reset').on('click',function(e){
|
| 286 |
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>');
|
| 287 |
jQuery('#wpwrap').css('pointer-events', 'none');
|
| 288 |
-
|
| 289 |
e.preventDefault();
|
| 290 |
return false;
|
| 291 |
});
|
| 292 |
-
|
| 293 |
jQuery('#continue-reset-wp').on('click',function(e){
|
| 294 |
jQuery('#wp-reset-promo').hide();
|
| 295 |
jQuery('#reset-wp-do').show();
|
| 296 |
-
|
| 297 |
e.preventDefault();
|
| 298 |
return false;
|
| 299 |
});
|
|
@@ -301,12 +333,12 @@ class ResetWP {
|
|
| 301 |
</div>
|
| 302 |
<div id="reset-wp-do" class="card" style="display: none;">
|
| 303 |
<p><strong>After completing the reset operation, you will be automatically logged in and redirected to the dashboard.</strong></p>
|
| 304 |
-
|
| 305 |
-
<?php
|
| 306 |
echo '<p>Current user "' . $current_user->user_login . '" will be recreated after resetting with its current password and admin privileges. Reset WP <strong>will be automatically reactivated</strong> after the reset operation.</p>';
|
| 307 |
?>
|
| 308 |
<hr/>
|
| 309 |
-
|
| 310 |
<p>To confirm the reset operation, type "<strong>reset</strong>" in the confirmation field below and then click the Reset button</p>
|
| 311 |
<form id="reset_wp_form" action="" method="post" autocomplete="off">
|
| 312 |
<?php wp_nonce_field( 'reset_wp' ); ?>
|
|
@@ -314,23 +346,30 @@ class ResetWP {
|
|
| 314 |
<input id="reset_wp_confirm" style="vertical-align: middle;" type="text" name="reset_wp_confirm" placeholder="Type in 'reset'">
|
| 315 |
<input id="reset_wp_submit" style="vertical-align: middle;" type="submit" name="Submit" class="button-primary" value="Reset">
|
| 316 |
</form>
|
| 317 |
-
|
| 318 |
<p>Something is not right? Let us know in the <a href="https://wordpress.org/support/plugin/reset-wp" target="_blank">forums</a>.
|
| 319 |
</div>
|
| 320 |
</div>
|
| 321 |
-
|
| 322 |
<?php
|
| 323 |
}
|
| 324 |
-
|
| 325 |
function replace_reset_wp() {
|
| 326 |
$plugin_slug = 'wp-reset/wp-reset.php';
|
| 327 |
$plugin_zip = 'https://downloads.wordpress.org/plugin/wp-reset.latest-stable.zip';
|
| 328 |
-
|
| 329 |
@include_once ABSPATH . 'wp-admin/includes/plugin.php';
|
| 330 |
@include_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
|
| 331 |
@include_once ABSPATH . 'wp-admin/includes/plugin-install.php';
|
| 332 |
@include_once ABSPATH . 'wp-admin/includes/file.php';
|
| 333 |
@include_once ABSPATH . 'wp-admin/includes/misc.php';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 334 |
echo '<style>
|
| 335 |
body{
|
| 336 |
font-family: sans-serif;
|
|
@@ -352,7 +391,7 @@ class ResetWP {
|
|
| 352 |
echo '<div style="margin: 30px;">';
|
| 353 |
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>';
|
| 354 |
echo 'Starting ...<br><br>';
|
| 355 |
-
|
| 356 |
wp_cache_flush();
|
| 357 |
$upgrader = new Plugin_Upgrader();
|
| 358 |
echo 'Check if new plugin is already installed - ';
|
|
@@ -365,41 +404,42 @@ class ResetWP {
|
|
| 365 |
$installed = $upgrader->install($plugin_zip);
|
| 366 |
}
|
| 367 |
wp_cache_flush();
|
| 368 |
-
|
| 369 |
if (!is_wp_error($installed) && $installed) {
|
| 370 |
echo 'Activating new plugin.';
|
| 371 |
$activate = activate_plugin($plugin_slug);
|
| 372 |
-
|
| 373 |
if (is_null($activate)) {
|
| 374 |
echo '<br>Deactivating old plugin.<br>';
|
| 375 |
deactivate_plugins(array('reset-wp/reset-wp.php'));
|
| 376 |
-
|
| 377 |
$options = get_option('wp-reset', array());
|
| 378 |
$options['meta']['reset-wp-user'] = true;
|
|
|
|
| 379 |
update_option('wp-reset', $options);
|
| 380 |
-
|
| 381 |
-
echo '<script>setTimeout(function() { top.location = "
|
| 382 |
-
echo '<br>If you are not redirected to the new plugin in a few seconds - <a href="
|
| 383 |
}
|
| 384 |
} else {
|
| 385 |
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>.';
|
| 386 |
}
|
| 387 |
-
|
| 388 |
echo '</div>';
|
| 389 |
} // replace
|
| 390 |
-
|
| 391 |
function is_plugin_installed( $slug ) {
|
| 392 |
if ( ! function_exists( 'get_plugins' ) ) {
|
| 393 |
require_once ABSPATH . 'wp-admin/includes/plugin.php';
|
| 394 |
}
|
| 395 |
$all_plugins = get_plugins();
|
| 396 |
-
|
| 397 |
if ( !empty( $all_plugins[$slug] ) ) {
|
| 398 |
return true;
|
| 399 |
} else {
|
| 400 |
return false;
|
| 401 |
}
|
| 402 |
-
}
|
| 403 |
}
|
| 404 |
|
| 405 |
$ResetWP = new ResetWP();
|
| 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.50
|
| 7 |
Author: WebFactory Ltd
|
| 8 |
Author URI: https://www.webfactoryltd.com/
|
| 9 |
Text Domain: reset-wp
|
| 20 |
|
| 21 |
if ( ! defined( 'ABSPATH' ) ){
|
| 22 |
exit; // Exit if accessed this file directly
|
| 23 |
+
}
|
| 24 |
|
| 25 |
if ( is_admin() ) {
|
| 26 |
|
| 29 |
|
| 30 |
class ResetWP {
|
| 31 |
static $version = 1.45;
|
| 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 |
+
add_action( 'admin_notices', array( $this, 'admin_notices_upgrade' ) );
|
| 39 |
+
add_action( 'admin_footer', array( $this, 'upgrade_footer' ) );
|
| 40 |
}
|
| 41 |
+
|
| 42 |
// Checks reset_wp post value and performs an installation, adding the users previous password also
|
| 43 |
function admin_init() {
|
| 44 |
global $current_user, $wpdb;
|
| 86 |
}
|
| 87 |
|
| 88 |
|
| 89 |
+
|
| 90 |
if ( defined( 'REACTIVATE_THE_RESET_WP' ) && REACTIVATE_THE_RESET_WP === true )
|
| 91 |
@activate_plugin( plugin_basename( __FILE__ ) );
|
| 92 |
+
|
| 93 |
|
| 94 |
wp_clear_auth_cookie();
|
| 95 |
wp_set_auth_cookie( $user_id );
|
| 106 |
// add settings link to plugins page
|
| 107 |
static function plugin_action_links($links) {
|
| 108 |
$settings_link = '<a href="' . admin_url('tools.php?page=reset-wp') . '" title="' . __('Reset WordPress', 'reset-wp') . '">' . __('Reset WordPress', 'reset-wp') . '</a>';
|
| 109 |
+
|
| 110 |
array_unshift($links, $settings_link);
|
| 111 |
+
|
| 112 |
return $links;
|
| 113 |
} // plugin_action_links
|
| 114 |
+
|
| 115 |
+
|
| 116 |
+
// test if we're on plugin's page
|
| 117 |
+
function is_plugin_page() {
|
| 118 |
+
$current_screen = get_current_screen();
|
| 119 |
+
|
| 120 |
+
if ($current_screen->id == 'tools_page_reset-wp') {
|
| 121 |
+
return true;
|
| 122 |
+
} else {
|
| 123 |
+
return false;
|
| 124 |
+
}
|
| 125 |
+
} // is_plugin_page
|
| 126 |
+
|
| 127 |
// admin_menu action hook operations & Add the settings page
|
| 128 |
function add_page() {
|
| 129 |
$hook = add_management_page( 'Reset WP', 'Reset WP', 'administrator', 'reset-wp', array( $this, 'admin_page' ) );
|
| 130 |
add_action( "admin_print_scripts-{$hook}", array( $this, 'admin_javascript' ) );
|
| 131 |
add_action( "admin_footer-{$hook}", array( $this, 'footer_javascript' ) );
|
| 132 |
}
|
| 133 |
+
|
| 134 |
// Inform the user that WordPress has been successfully reset
|
| 135 |
function admin_notices_successfully_reset() {
|
| 136 |
global $current_user;
|
| 137 |
|
| 138 |
echo '<div id="message" class="updated"><p><strong>WordPress has been reset successfully.</strong> User "' . $current_user->user_login . '" was recreated with its old password.</p></div>';
|
| 139 |
do_action( 'reset_wp_post', $current_user );
|
| 140 |
+
}
|
| 141 |
+
|
| 142 |
+
// try to get users to switch to WP Reset
|
| 143 |
+
function admin_notices_upgrade() {
|
| 144 |
+
if ($this->is_plugin_page()) {
|
| 145 |
+
return;
|
| 146 |
+
}
|
| 147 |
+
|
| 148 |
+
echo '<div id="message" class="error" style="display: table;"><p><strong>Important! You are using an old & unmaintained plugin - Reset WP</strong><br>';
|
| 149 |
+
echo 'This is not an advertisement, or a pro upgrade nag. We no longer maintain Reset WP and you should stop using it.<br>Please switch to WP Reset which is fully compatible with your version of WP. It is a one-click action, nothing else is required; <a href="' . admin_url( 'tools.php?page=reset-wp' ) . '">read more.</a></p>';
|
| 150 |
+
echo '<p><a href="#" id="upgrade-wp-reset" class="button button-primary">Upgrade & switch to WP Reset now</a> <i>This notice will go away once you stop using Reset WP.</i></p></div>';
|
| 151 |
+
} // admin_notices_upgrade
|
| 152 |
+
|
| 153 |
+
function upgrade_footer() {
|
| 154 |
+
if ($this->is_plugin_page()) {
|
| 155 |
+
return;
|
| 156 |
+
}
|
| 157 |
+
|
| 158 |
+
$replace_url = add_query_arg(array('action' => 'replace_reset_wp', 'redirect' => urlencode($_SERVER['REQUEST_URI'])), admin_url('admin.php'));
|
| 159 |
+
?>
|
| 160 |
+
<script>
|
| 161 |
+
jQuery('#upgrade-wp-reset').on('click',function(e){
|
| 162 |
+
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>');
|
| 163 |
+
jQuery('#wpwrap').css('pointer-events', 'none');
|
| 164 |
+
|
| 165 |
+
e.preventDefault();
|
| 166 |
+
return false;
|
| 167 |
+
});
|
| 168 |
+
</script>
|
| 169 |
+
<?php
|
| 170 |
+
} // upgrade_footer
|
| 171 |
+
|
| 172 |
function admin_javascript() {
|
| 173 |
if ( $this->is_plugin_page() ) {
|
| 174 |
wp_enqueue_script( 'jquery' );
|
| 192 |
return false;
|
| 193 |
}
|
| 194 |
});
|
| 195 |
+
</script>
|
| 196 |
<?php
|
| 197 |
}
|
| 198 |
|
| 204 |
echo '<div class="error fade"><p><strong>Invalid confirmation. Please type \'reset-wp\' in the confirmation field.</strong></p></div>';
|
| 205 |
elseif ( isset( $_POST['_wpnonce'] ) )
|
| 206 |
echo '<div class="error fade"><p><strong>Invalid wpnonce. Please try again.</strong></p></div>';
|
| 207 |
+
|
| 208 |
?>
|
| 209 |
<div class="wrap">
|
| 210 |
<h2>Reset WP</h2>
|
| 303 |
</tr>
|
| 304 |
<tr>
|
| 305 |
<td> </td>
|
| 306 |
+
<td><a style="display: none;" href="" id="continue-reset-wp">Continue using an unmaintained plugin</a></td>
|
| 307 |
<td><a style="margin-bottom: 8px;" class="button button-primary" id="upgrade-wp-reset">Switch to WP Reset</a><br>1 click & 5 seconds of waiting</td>
|
| 308 |
</tr>
|
| 309 |
</table>
|
| 311 |
<?php
|
| 312 |
$replace_url = add_query_arg(array('action' => 'replace_reset_wp'), admin_url('admin.php'));
|
| 313 |
//echo '<a class="button button-primary" id="upgrade-wp-reset">Replace plugin with the new version - WP Reset</a><br>';
|
| 314 |
+
echo '<p>What happens when I click the "Switch to WP Reset" 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 and this plugin will then be deactivated. Nothing is deleted or removed!</p>';
|
| 315 |
?>
|
| 316 |
<script>
|
| 317 |
jQuery('#upgrade-wp-reset').on('click',function(e){
|
| 318 |
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>');
|
| 319 |
jQuery('#wpwrap').css('pointer-events', 'none');
|
| 320 |
+
|
| 321 |
e.preventDefault();
|
| 322 |
return false;
|
| 323 |
});
|
| 324 |
+
|
| 325 |
jQuery('#continue-reset-wp').on('click',function(e){
|
| 326 |
jQuery('#wp-reset-promo').hide();
|
| 327 |
jQuery('#reset-wp-do').show();
|
| 328 |
+
|
| 329 |
e.preventDefault();
|
| 330 |
return false;
|
| 331 |
});
|
| 333 |
</div>
|
| 334 |
<div id="reset-wp-do" class="card" style="display: none;">
|
| 335 |
<p><strong>After completing the reset operation, you will be automatically logged in and redirected to the dashboard.</strong></p>
|
| 336 |
+
|
| 337 |
+
<?php
|
| 338 |
echo '<p>Current user "' . $current_user->user_login . '" will be recreated after resetting with its current password and admin privileges. Reset WP <strong>will be automatically reactivated</strong> after the reset operation.</p>';
|
| 339 |
?>
|
| 340 |
<hr/>
|
| 341 |
+
|
| 342 |
<p>To confirm the reset operation, type "<strong>reset</strong>" in the confirmation field below and then click the Reset button</p>
|
| 343 |
<form id="reset_wp_form" action="" method="post" autocomplete="off">
|
| 344 |
<?php wp_nonce_field( 'reset_wp' ); ?>
|
| 346 |
<input id="reset_wp_confirm" style="vertical-align: middle;" type="text" name="reset_wp_confirm" placeholder="Type in 'reset'">
|
| 347 |
<input id="reset_wp_submit" style="vertical-align: middle;" type="submit" name="Submit" class="button-primary" value="Reset">
|
| 348 |
</form>
|
| 349 |
+
|
| 350 |
<p>Something is not right? Let us know in the <a href="https://wordpress.org/support/plugin/reset-wp" target="_blank">forums</a>.
|
| 351 |
</div>
|
| 352 |
</div>
|
| 353 |
+
|
| 354 |
<?php
|
| 355 |
}
|
| 356 |
+
|
| 357 |
function replace_reset_wp() {
|
| 358 |
$plugin_slug = 'wp-reset/wp-reset.php';
|
| 359 |
$plugin_zip = 'https://downloads.wordpress.org/plugin/wp-reset.latest-stable.zip';
|
| 360 |
+
|
| 361 |
@include_once ABSPATH . 'wp-admin/includes/plugin.php';
|
| 362 |
@include_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
|
| 363 |
@include_once ABSPATH . 'wp-admin/includes/plugin-install.php';
|
| 364 |
@include_once ABSPATH . 'wp-admin/includes/file.php';
|
| 365 |
@include_once ABSPATH . 'wp-admin/includes/misc.php';
|
| 366 |
+
|
| 367 |
+
if (!empty($_GET['redirect'])) {
|
| 368 |
+
$redirect = $_GET['redirect'];
|
| 369 |
+
} else {
|
| 370 |
+
$redirect = admin_url('tools.php?page=wp-reset');
|
| 371 |
+
}
|
| 372 |
+
|
| 373 |
echo '<style>
|
| 374 |
body{
|
| 375 |
font-family: sans-serif;
|
| 391 |
echo '<div style="margin: 30px;">';
|
| 392 |
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>';
|
| 393 |
echo 'Starting ...<br><br>';
|
| 394 |
+
|
| 395 |
wp_cache_flush();
|
| 396 |
$upgrader = new Plugin_Upgrader();
|
| 397 |
echo 'Check if new plugin is already installed - ';
|
| 404 |
$installed = $upgrader->install($plugin_zip);
|
| 405 |
}
|
| 406 |
wp_cache_flush();
|
| 407 |
+
|
| 408 |
if (!is_wp_error($installed) && $installed) {
|
| 409 |
echo 'Activating new plugin.';
|
| 410 |
$activate = activate_plugin($plugin_slug);
|
| 411 |
+
|
| 412 |
if (is_null($activate)) {
|
| 413 |
echo '<br>Deactivating old plugin.<br>';
|
| 414 |
deactivate_plugins(array('reset-wp/reset-wp.php'));
|
| 415 |
+
|
| 416 |
$options = get_option('wp-reset', array());
|
| 417 |
$options['meta']['reset-wp-user'] = true;
|
| 418 |
+
$options['dismissed_notices']['welcome'] = true;
|
| 419 |
update_option('wp-reset', $options);
|
| 420 |
+
|
| 421 |
+
echo '<script>setTimeout(function() { top.location = "' . $redirect . '"; }, 1000);</script>';
|
| 422 |
+
echo '<br>If you are not redirected to the new plugin in a few seconds - <a href="' . $redirect . '" target="_parent">click here</a>.';
|
| 423 |
}
|
| 424 |
} else {
|
| 425 |
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>.';
|
| 426 |
}
|
| 427 |
+
|
| 428 |
echo '</div>';
|
| 429 |
} // replace
|
| 430 |
+
|
| 431 |
function is_plugin_installed( $slug ) {
|
| 432 |
if ( ! function_exists( 'get_plugins' ) ) {
|
| 433 |
require_once ABSPATH . 'wp-admin/includes/plugin.php';
|
| 434 |
}
|
| 435 |
$all_plugins = get_plugins();
|
| 436 |
+
|
| 437 |
if ( !empty( $all_plugins[$slug] ) ) {
|
| 438 |
return true;
|
| 439 |
} else {
|
| 440 |
return false;
|
| 441 |
}
|
| 442 |
+
}
|
| 443 |
}
|
| 444 |
|
| 445 |
$ResetWP = new ResetWP();
|
