Version Description
- Initial release.
=
Download this release
Release Info
Developer | nikunjsoni |
Plugin | Reset WP |
Version | 1.0 |
Comparing to | |
See all releases |
Version 1.0
- readme.txt +59 -0
- reset-wp.php +197 -0
- screenshot-1.png +0 -0
- screenshot-2.png +0 -0
- screenshot-3.png +0 -0
readme.txt
ADDED
@@ -0,0 +1,59 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
=== Reset WP ===
|
2 |
+
Contributors: Nikunj Soni
|
3 |
+
Donate link: http://www.nikunjsoni.co.in/donate
|
4 |
+
Tags: reset wp,reset-wp,reset,wp,wordpress,clean,cleaner,database,mysql,wp-admin,admin,plugin
|
5 |
+
License: GPLv2
|
6 |
+
Requires at least: 3.7
|
7 |
+
Tested up to: 4.4
|
8 |
+
Stable tag: 1.0
|
9 |
+
|
10 |
+
Resets the WP Database to the default installation. It deletes all content and custom changes. Resets only database not modify or delete any files.
|
11 |
+
|
12 |
+
== Description ==
|
13 |
+
|
14 |
+
It resets the WordPress database to the default installation. It deletes all content and custom changes. It will only reset the database. It will not modify or delete any files.
|
15 |
+
|
16 |
+
* It adds a settings page to "Dashboard"->"Tools"->"Reset WP" where you can simply reset your WordPress database.
|
17 |
+
* It adds submenu to the Admin Bar under the site title for quick access of this plugin.
|
18 |
+
* Resets WordPress in quick time.
|
19 |
+
* Handy tool for WordPress Programmers to reset database.
|
20 |
+
|
21 |
+
Usage :
|
22 |
+
|
23 |
+
1. Download and extract this plugin to `wp-content/plugins/`
|
24 |
+
2. Activate the plugin through the 'Plugins' menu in WordPress.
|
25 |
+
3. "Dashboard"->"Tools"->"Reset WP"
|
26 |
+
|
27 |
+
== Installation ==
|
28 |
+
|
29 |
+
1. Download and extract this plugin to `wp-content/plugins/`
|
30 |
+
2. Activate the plugin through the 'Plugins' menu in WordPress.
|
31 |
+
3. "Dashboard"->"Tools"->"Reset WP"
|
32 |
+
|
33 |
+
== Screenshots ==
|
34 |
+
|
35 |
+
1. Admin page screenshot
|
36 |
+
2. Admin page screenshot for reset confirmation.
|
37 |
+
3. Admin page screenshot for reset confirmation.
|
38 |
+
|
39 |
+
== Other Notes ==
|
40 |
+
|
41 |
+
Usage :
|
42 |
+
|
43 |
+
1. Download and extract this plugin to `wp-content/plugins/`
|
44 |
+
2. Activate the plugin through the 'Plugins' menu in WordPress.
|
45 |
+
3. "Dashboard"->"Tools"->"Reset WP"
|
46 |
+
|
47 |
+
== Changelog ==
|
48 |
+
|
49 |
+
= 1.0 =
|
50 |
+
* Initial release.
|
51 |
+
|
52 |
+
== Upgrade Notice ==
|
53 |
+
|
54 |
+
= 1.0 =
|
55 |
+
* Initial release.
|
56 |
+
|
57 |
+
== Frequently Asked Questions ==
|
58 |
+
|
59 |
+
You can submit it in http://www.nikunjsoni.co.in
|
reset-wp.php
ADDED
@@ -0,0 +1,197 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/*
|
3 |
+
Plugin Name: Reset WP
|
4 |
+
Plugin URI: http://www.nikunjsoni.co.in
|
5 |
+
Description: It resets the WordPress database to the default installation. It deletes all content and custom changes. Resets only database not modify or delete any files.
|
6 |
+
Version: 1.0
|
7 |
+
Author: Nikunj Soni
|
8 |
+
Author URI: http://www.nikunjsoni.co.in
|
9 |
+
Text Domain: Reset-WP
|
10 |
+
*/
|
11 |
+
|
12 |
+
/*
|
13 |
+
|
14 |
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
15 |
+
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
16 |
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
|
17 |
+
IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
18 |
+
|
19 |
+
*/
|
20 |
+
|
21 |
+
if ( ! defined( 'ABSPATH' ) ){
|
22 |
+
exit; // Exit if accessed this file directly
|
23 |
+
}
|
24 |
+
|
25 |
+
if ( is_admin() ) {
|
26 |
+
|
27 |
+
define( 'REACTIVATE_THE_RESET_WP', true );
|
28 |
+
|
29 |
+
class ResetWP {
|
30 |
+
|
31 |
+
function ResetWP() {
|
32 |
+
add_action( 'admin_menu', array( &$this, 'add_page' ) );
|
33 |
+
add_action( 'admin_init', array( &$this, 'admin_init' ) );
|
34 |
+
add_filter( 'favorite_actions', array( &$this, 'add_favorite' ), 100 );
|
35 |
+
add_action( 'wp_before_admin_bar_render', array( &$this, 'admin_bar_link' ) );
|
36 |
+
}
|
37 |
+
|
38 |
+
// Checks reset_wp post value and performs an installation, adding the users previous password also
|
39 |
+
function admin_init() {
|
40 |
+
global $current_user;
|
41 |
+
|
42 |
+
$reset_wp = ( isset( $_POST['reset_wp'] ) && $_POST['reset_wp'] == 'true' ) ? true : false;
|
43 |
+
$reset_wp_confirm = ( isset( $_POST['reset_wp_confirm'] ) && $_POST['reset_wp_confirm'] == 'reset-wp' ) ? true : false;
|
44 |
+
$valid_nonce = ( isset( $_POST['_wpnonce'] ) && wp_verify_nonce( $_POST['_wpnonce'], 'reset_wp' ) ) ? true : false;
|
45 |
+
|
46 |
+
if ( $reset_wp && $reset_wp_confirm && $valid_nonce ) {
|
47 |
+
require_once( ABSPATH . '/wp-admin/includes/upgrade.php' );
|
48 |
+
|
49 |
+
$blogname = get_option( 'blogname' );
|
50 |
+
$admin_email = get_option( 'admin_email' );
|
51 |
+
$blog_public = get_option( 'blog_public' );
|
52 |
+
|
53 |
+
if ( $current_user->user_login != 'admin' )
|
54 |
+
$user = get_user_by( 'login', 'admin' );
|
55 |
+
|
56 |
+
if ( empty( $user->user_level ) || $user->user_level < 10 )
|
57 |
+
$user = $current_user;
|
58 |
+
|
59 |
+
global $wpdb;
|
60 |
+
|
61 |
+
$prefix = str_replace( '_', '\_', $wpdb->prefix );
|
62 |
+
$tables = $wpdb->get_col( "SHOW TABLES LIKE '{$prefix}%'" );
|
63 |
+
foreach ( $tables as $table ) {
|
64 |
+
$wpdb->query( "DROP TABLE $table" );
|
65 |
+
}
|
66 |
+
|
67 |
+
$result = wp_install( $blogname, $user->user_login, $user->user_email, $blog_public );
|
68 |
+
extract( $result, EXTR_SKIP );
|
69 |
+
|
70 |
+
$query = $wpdb->prepare( "UPDATE $wpdb->users SET user_pass = '".$user->user_pass."', user_activation_key = '' WHERE ID = '".$user_id."' ");
|
71 |
+
$wpdb->query( $query );
|
72 |
+
|
73 |
+
$get_user_meta = function_exists( 'get_user_meta' ) ? 'get_user_meta' : 'get_usermeta';
|
74 |
+
$update_user_meta = function_exists( 'update_user_meta' ) ? 'update_user_meta' : 'update_usermeta';
|
75 |
+
|
76 |
+
if ( $get_user_meta( $user_id, 'default_password_nag' ) )
|
77 |
+
$update_user_meta( $user_id, 'default_password_nag', false );
|
78 |
+
|
79 |
+
if ( $get_user_meta( $user_id, $wpdb->prefix . 'default_password_nag' ) )
|
80 |
+
$update_user_meta( $user_id, $wpdb->prefix . 'default_password_nag', false );
|
81 |
+
|
82 |
+
|
83 |
+
if ( defined( 'REACTIVATE_THE_RESET_WP' ) && REACTIVATE_THE_RESET_WP === true )
|
84 |
+
@activate_plugin( plugin_basename( __FILE__ ) );
|
85 |
+
|
86 |
+
|
87 |
+
wp_clear_auth_cookie();
|
88 |
+
|
89 |
+
wp_set_auth_cookie( $user_id );
|
90 |
+
|
91 |
+
wp_redirect( admin_url()."?reset-wp=reset-wp" );
|
92 |
+
exit();
|
93 |
+
}
|
94 |
+
|
95 |
+
if ( array_key_exists( 'reset-wp', $_GET ) && stristr( $_SERVER['HTTP_REFERER'], 'reset-wp' ) )
|
96 |
+
add_action( 'admin_notices', array( &$this, 'admin_notices_successfully_reset' ) );
|
97 |
+
}
|
98 |
+
|
99 |
+
// admin_menu action hook operations & Add the settings page
|
100 |
+
function add_page() {
|
101 |
+
if ( current_user_can( 'level_10' ) && function_exists( 'add_management_page' ) )
|
102 |
+
$hook = add_management_page( 'Reset WP', 'Reset WP', 'level_10', 'reset-wp', array( &$this, 'admin_page' ) );
|
103 |
+
add_action( "admin_print_scripts-{$hook}", array( &$this, 'admin_javascript' ) );
|
104 |
+
add_action( "admin_footer-{$hook}", array( &$this, 'footer_javascript' ) );
|
105 |
+
}
|
106 |
+
|
107 |
+
function add_favorite( $actions ) {
|
108 |
+
$reset['tools.php?page=reset-wp'] = array( 'Reset WP', 'level_10' );
|
109 |
+
return array_merge( $reset, $actions );
|
110 |
+
}
|
111 |
+
|
112 |
+
function admin_bar_link() {
|
113 |
+
global $wp_admin_bar;
|
114 |
+
$wp_admin_bar->add_menu(
|
115 |
+
array(
|
116 |
+
'parent' => 'site-name',
|
117 |
+
'id' => 'reset-wp',
|
118 |
+
'title' => 'Reset WP',
|
119 |
+
'href' => admin_url( 'tools.php?page=reset-wp' )
|
120 |
+
)
|
121 |
+
);
|
122 |
+
}
|
123 |
+
|
124 |
+
// Inform the user that WordPress has been successfully reset
|
125 |
+
function admin_notices_successfully_reset() {
|
126 |
+
$user = get_user_by( 'id', 1 );
|
127 |
+
echo '<div id="message" class="updated"><p><strong>WordPress has been reset successfully. The user "' . $user->user_login . '" is recreated with its current login password.</strong></p></div>';
|
128 |
+
do_action( 'reset_wp_post', $user );
|
129 |
+
}
|
130 |
+
|
131 |
+
function admin_javascript() {
|
132 |
+
wp_enqueue_script( 'jquery' );
|
133 |
+
}
|
134 |
+
|
135 |
+
function footer_javascript() {
|
136 |
+
?>
|
137 |
+
<script type="text/javascript">
|
138 |
+
jQuery('#reset_wp_submit').click(function(){
|
139 |
+
if ( jQuery('#reset_wp_confirm').val() == 'reset-wp' ) {
|
140 |
+
var message = 'This action can not be Undo.\n\nClicking "OK" will reset your database to the default installation.\n\nIt deletes all content and custom changes.\nIt will only reset the database.\nIt will not modify or delete any files.\n\n Click "Cancel" to stop this operation.'
|
141 |
+
var reset = confirm(message);
|
142 |
+
if ( reset ) {
|
143 |
+
jQuery('#reset_wp_form').submit();
|
144 |
+
} else {
|
145 |
+
jQuery('#reset_wp').val('false');
|
146 |
+
return false;
|
147 |
+
}
|
148 |
+
} else {
|
149 |
+
alert('Invalid confirmation. Please type \'reset-wp\' in the confirmation field.');
|
150 |
+
return false;
|
151 |
+
}
|
152 |
+
});
|
153 |
+
</script>
|
154 |
+
<?php
|
155 |
+
}
|
156 |
+
|
157 |
+
// add_option_page callback operations
|
158 |
+
function admin_page() {
|
159 |
+
global $current_user;
|
160 |
+
if ( isset( $_POST['reset_wp_confirm'] ) && $_POST['reset_wp_confirm'] != 'reset-wp' )
|
161 |
+
echo '<div class="error fade"><p><strong>Invalid confirmation. Please type \'reset-wp\' in the confirmation field.</strong></p></div>';
|
162 |
+
elseif ( isset( $_POST['_wpnonce'] ) )
|
163 |
+
echo '<div class="error fade"><p><strong>Invalid wpnonce. Please try again.</strong></p></div>';
|
164 |
+
|
165 |
+
?>
|
166 |
+
<div class="wrap">
|
167 |
+
<div id="icon-tools" class="icon32"><br /></div>
|
168 |
+
<h2>Reset WP</h2>
|
169 |
+
<p><strong>After completing this reset operation, you will be automatically redirected to the dashboard.</strong></p>
|
170 |
+
|
171 |
+
<?php $admin = get_user_by( 'login', 'admin' ); ?>
|
172 |
+
<?php if ( ! isset( $admin->user_login ) || $admin->user_level < 10 ) : $user = $current_user; ?>
|
173 |
+
<p>The 'admin' user does not exist. The user '<strong><?php echo esc_html( $user->user_login ); ?></strong>' will be recreated with its <strong>current password</strong> with user level 10.</p>
|
174 |
+
<?php else : ?>
|
175 |
+
|
176 |
+
<p>The '<strong>admin</strong>' user exists and will be recreated with its <strong>current password</strong>.</p>
|
177 |
+
<?php endif; ?>
|
178 |
+
<p>This plugin <strong>will be automatically reactivated</strong> after the reset operation.</p>
|
179 |
+
|
180 |
+
<hr/>
|
181 |
+
|
182 |
+
<p>To confirm the reset operation, type '<strong>reset-wp</strong>' in the confirmation field below and then click the Reset button</p>
|
183 |
+
<form id="reset_wp_form" action="" method="post" autocomplete="off">
|
184 |
+
<?php wp_nonce_field( 'reset_wp' ); ?>
|
185 |
+
<input id="reset_wp" type="hidden" name="reset_wp" value="true" />
|
186 |
+
<input id="reset_wp_confirm" type="text" name="reset_wp_confirm" value="" maxlength="8" />
|
187 |
+
<input id="reset_wp_submit" style="width: 80px;" type="submit" name="Submit" class="button-primary" value="Reset" />
|
188 |
+
|
189 |
+
</form>
|
190 |
+
</div>
|
191 |
+
<?php
|
192 |
+
}
|
193 |
+
}
|
194 |
+
|
195 |
+
$ResetWP = new ResetWP();
|
196 |
+
|
197 |
+
}
|
screenshot-1.png
ADDED
Binary file
|
screenshot-2.png
ADDED
Binary file
|
screenshot-3.png
ADDED
Binary file
|