Version Description
(2009-03-17): = * Initial Public Release
Download this release
Release Info
Developer | sivel |
Plugin | WordPress Reset |
Version | 1.0 |
Comparing to | |
See all releases |
Version 1.0
- readme.txt +48 -0
- wordpress-reset.php +161 -0
readme.txt
ADDED
@@ -0,0 +1,48 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
=== WordPress Reset ===
|
2 |
+
Contributors: sivel, jdingman
|
3 |
+
Donate Link: https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=C3UA7TDWM4NLQ&lc=US&item_name=Donations%20for%20Sivel%2enet%20WordPress%20Plugins&cn=Add%20special%20instructions%20to%20the%20seller&no_shipping=1&rm=1&return=http%3a%2f%2fsivel%2enet%2fthanks¤cy_code=USD&bn=PP%2dDonationsBF%3abtn_donateCC_LG%2egif%3aNonHosted
|
4 |
+
Tags: wordpress-reset, wordpress, reset, admin
|
5 |
+
Requires at least: 2.7
|
6 |
+
Tested up to: 2.7.1
|
7 |
+
Stable tag: 1.0
|
8 |
+
|
9 |
+
Resets the WordPress database back to it's defaults. Deletes all customizations and content. Does not modify files only resets the database.
|
10 |
+
|
11 |
+
== Description ==
|
12 |
+
|
13 |
+
Resets the WordPress database back to it's defaults. Deletes all customizations and content. Does not modify files only resets the database.
|
14 |
+
|
15 |
+
This plugin is very helpful for plugin and theme developers.
|
16 |
+
|
17 |
+
If the admin user exists and has level_10 permissions it will be recreated with its current password and email address. If the admin user does not exist or is a dummy account without admin permissions the username that is logged in will be recreated with its email address and current password. The blog name is also kept.
|
18 |
+
|
19 |
+
The plugin will add an entry to the favorites drop down and also reactivate itself after the reset. There is however a configuration option to keep it from reactivating after the reset.
|
20 |
+
|
21 |
+
Props to [Jonathan Dingman](http://www.ginside.com/) for the idea behind this plugin, testing and feedback.
|
22 |
+
|
23 |
+
== Installation ==
|
24 |
+
|
25 |
+
1. Upload the `wordpress-reset` folder to the `/wp-content/plugins/` directory or install directly through the plugin installer.
|
26 |
+
1. Activate the plugin through the 'Plugins' menu in WordPress or by using the link provided by the plugin installer
|
27 |
+
|
28 |
+
== Frequently Asked Questions ==
|
29 |
+
|
30 |
+
= How can I keep the plugin from automatically reactivating after the reset? =
|
31 |
+
|
32 |
+
Open the wordpress-reset.php file in an editor and modify the line that reads `var $auto_reactivate = true;` to be `var $auto_reactivate = false;`
|
33 |
+
|
34 |
+
== Upgrade ==
|
35 |
+
|
36 |
+
1. Use the plugin updater in WordPress or...
|
37 |
+
1. Delete the previous `wordpress-reset` folder from the `/wp-content/plugins/` directory
|
38 |
+
1. Upload the new `wordpress-reset` folder to the `/wp-content/plugins/` directory
|
39 |
+
|
40 |
+
== Usage ==
|
41 |
+
|
42 |
+
1. Visit the WordPress Reset Tools page by either clicking the link in the favorites dropdown menu or Tools>WordPress Reset
|
43 |
+
1. Type 'reset' in the text field and click reset.
|
44 |
+
|
45 |
+
== Changelog ==
|
46 |
+
|
47 |
+
= 1.0 (2009-03-17): =
|
48 |
+
* Initial Public Release
|
wordpress-reset.php
ADDED
@@ -0,0 +1,161 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/*
|
3 |
+
Plugin Name: WordPress Reset
|
4 |
+
Plugin URI: http://sivel.net/wordpress/wordpress-reset/
|
5 |
+
Description: Resets the WordPress database back to it's defaults. Deletes all customizations and content. Does not modify files only resets the database.
|
6 |
+
Author: Matt Martz</a> and <a href='http://www.ginside.com/'>Jonathan Dingman</a>
|
7 |
+
Version: 1.0
|
8 |
+
Author URI: http://sivel.net/
|
9 |
+
|
10 |
+
Copyright (c) 2009 Matt Martz (http://sivel.net)
|
11 |
+
WordPress Reset is released under the GNU General Public License (GPL)
|
12 |
+
http://www.gnu.org/licenses/gpl-2.0.txt
|
13 |
+
*/
|
14 |
+
|
15 |
+
// Only run the code if we are in the admin
|
16 |
+
if ( is_admin() ) :
|
17 |
+
|
18 |
+
class WordPressReset {
|
19 |
+
// Set to true by default, this allows the plugin to be automatically reactivated after the reset
|
20 |
+
var $auto_reactivate = true;
|
21 |
+
|
22 |
+
// Action/Filter Hooks
|
23 |
+
function WordPressReset() {
|
24 |
+
add_action('admin_menu', array(&$this, 'add_page'));
|
25 |
+
add_action('admin_footer', array(&$this, 'footer'));
|
26 |
+
add_action('admin_head', array(&$this, 'head'));
|
27 |
+
add_action('init', array(&$this, 'init'));
|
28 |
+
add_filter('favorite_actions', array(&$this, 'favorites'), 100);
|
29 |
+
}
|
30 |
+
|
31 |
+
// favorite_actions filter hook operations
|
32 |
+
// While this plugin is active put a link to the reset page in the favorites drop down.
|
33 |
+
function favorites($actions) {
|
34 |
+
$reset['tools.php?page=wordpress-reset'] = array('WordPress Reset', 'level_10');
|
35 |
+
return array_merge($reset, $actions);
|
36 |
+
}
|
37 |
+
|
38 |
+
// init action hook operations
|
39 |
+
// Checks for wordpress_reset post value and if there deletes all wp tables
|
40 |
+
// and performs an install, populating the users previous password also
|
41 |
+
function init() {
|
42 |
+
global $current_user;
|
43 |
+
if ( isset($_POST['wordpress_reset']) && $_POST['wordpress_reset'] == 'true' && isset($_POST['wordpress_reset_confirm']) && $_POST['wordpress_reset_confirm'] == 'reset' ) {
|
44 |
+
require_once(ABSPATH . '/wp-admin/includes/upgrade.php');
|
45 |
+
|
46 |
+
$blogname = get_option('blogname');
|
47 |
+
$admin_email = get_option('admin_email');
|
48 |
+
$blog_public = get_option('blog_public');
|
49 |
+
|
50 |
+
if ( $current_user->user_login != 'admin' )
|
51 |
+
$user = get_userdatabylogin('admin');
|
52 |
+
if ( ! isset($user) || $user->user_level < 10 )
|
53 |
+
$user = $current_user;
|
54 |
+
|
55 |
+
global $wpdb;
|
56 |
+
$tables = $wpdb->get_col("SHOW TABLES LIKE '{$wpdb->prefix}%'");
|
57 |
+
foreach ($tables as $table) {
|
58 |
+
$wpdb->query("DROP TABLE $table");
|
59 |
+
}
|
60 |
+
|
61 |
+
$result = wp_install($blogname, $user->user_login, $user->user_email, $blog_public);
|
62 |
+
extract($result, EXTR_SKIP);
|
63 |
+
|
64 |
+
$query = $wpdb->prepare("UPDATE $wpdb->users SET user_pass = %s, user_activation_key = '' WHERE ID = %d", $user->user_pass, $user_id);
|
65 |
+
$wpdb->query($query);
|
66 |
+
|
67 |
+
if ( $this->auto_reactivate == true )
|
68 |
+
update_option('active_plugins', array(plugin_basename(__FILE__)));
|
69 |
+
|
70 |
+
wp_clear_auth_cookie();
|
71 |
+
wp_set_auth_cookie($user_id);
|
72 |
+
|
73 |
+
wp_redirect(admin_url() . '?reset');
|
74 |
+
exit();
|
75 |
+
}
|
76 |
+
if ( array_key_exists('reset', $_GET) && stristr($_SERVER['HTTP_REFERER'], 'wordpress-reset') ) {
|
77 |
+
$user = get_userdata(1);
|
78 |
+
add_action('admin_notices',create_function('$a', 'echo \'<div id="message" class="updated fade"><p><strong>WordPress has been reset back to defaults. The user "' . $user->user_login . '" was recreated with its previous password.</strong></p></div>\';'));
|
79 |
+
do_action('wordpress_reset_post', $user);
|
80 |
+
}
|
81 |
+
}
|
82 |
+
|
83 |
+
// admin_head action hook operations
|
84 |
+
// Enqueue jQuery to the head
|
85 |
+
function head() {
|
86 |
+
wp_enqueue_script('jquery');
|
87 |
+
}
|
88 |
+
|
89 |
+
// admin_footer action hook operations
|
90 |
+
// Do some jQuery stuff to warn the user before submission
|
91 |
+
function footer() {
|
92 |
+
?>
|
93 |
+
<script type="text/javascript">
|
94 |
+
/* <![CDATA[ */
|
95 |
+
jQuery('#wordpress_reset_submit').click(function(){
|
96 |
+
if ( jQuery('#wordpress_reset_confirm').val() == 'reset' ) {
|
97 |
+
var message = 'This action is not reversable.\n\nClicking "OK" will reset your database back to it\'s defaults. Click "Cancel" to abort.'
|
98 |
+
var reset = confirm(message);
|
99 |
+
if ( reset ) {
|
100 |
+
jQuery('#wordpress_reset_form').submit();
|
101 |
+
} else {
|
102 |
+
jQuery('#wordpress_reset').val('false');
|
103 |
+
return false;
|
104 |
+
}
|
105 |
+
} else {
|
106 |
+
alert('Invalid confirmation word. Please type the word \'reset\' in the confirmation field.');
|
107 |
+
return false;
|
108 |
+
}
|
109 |
+
});
|
110 |
+
/* ]]> */
|
111 |
+
</script>
|
112 |
+
<?php
|
113 |
+
}
|
114 |
+
|
115 |
+
// admin_menu action hook operations
|
116 |
+
// Add the settings page
|
117 |
+
function add_page() {
|
118 |
+
if ( current_user_can('level_10') && function_exists('add_management_page') ) :
|
119 |
+
add_management_page('WordPress Reset', 'WordPress Reset', 'level_10', 'wordpress-reset', array(&$this, 'admin_page'));
|
120 |
+
endif;
|
121 |
+
}
|
122 |
+
|
123 |
+
// add_option_page callback operations
|
124 |
+
// The settings page
|
125 |
+
function admin_page() {
|
126 |
+
global $current_user;
|
127 |
+
if ( isset($_POST['wordpress_reset_confirm']) && $_POST['wordpress_reset_confirm'] != 'reset' )
|
128 |
+
echo '<div id="message" class="error fade"><p><strong>Invalid confirmation word. Please type the word \'reset\' in the confirmation field.</strong></p></div>';
|
129 |
+
?>
|
130 |
+
<div class="wrap">
|
131 |
+
<h2>WordPress Reset</h2>
|
132 |
+
<br />
|
133 |
+
<form id="wordpress_reset_form" action="" method="post">
|
134 |
+
<input id="wordpress_reset" type="hidden" name="wordpress_reset" value="true" />
|
135 |
+
Type 'reset' in the confirmation field to confirm the reset and then click the reset button:<br /><br />
|
136 |
+
<input id="wordpress_reset_confirm" type="text" name="wordpress_reset_confirm" value="" /> <input id="wordpress_reset_submit" type="submit" name="Submit" class="button-primary" value="Reset" /><br /><br />
|
137 |
+
<ul>
|
138 |
+
<li><strong>After completing this reset you will taken to the dashboard.</strong></li>
|
139 |
+
<?php
|
140 |
+
$admin = get_userdatabylogin('admin');
|
141 |
+
if ( ! isset($admin->user_login) || $admin->user_level < 10 ) :
|
142 |
+
$user = $current_user;
|
143 |
+
?>
|
144 |
+
<li>The 'admin' user does not exist. The user '<strong><?php echo $user->user_login; ?></strong>' will be recreated with its current password with user level 10.</li>
|
145 |
+
<?php else : ?>
|
146 |
+
<li>The '<strong>admin</strong>' user exists and will be recreated with its current password.</li>
|
147 |
+
<?php endif; ?>
|
148 |
+
<li>This plugin <strong>will<?php echo $this->auto_reactivate ? '</strong> ' : ' not</strong> ';?>be automatically reactivated after the reset.</li>
|
149 |
+
</ul>
|
150 |
+
</form>
|
151 |
+
</div>
|
152 |
+
<?php
|
153 |
+
}
|
154 |
+
}
|
155 |
+
|
156 |
+
// Instantiate the class
|
157 |
+
$WordPressReset = new WordPressReset();
|
158 |
+
|
159 |
+
// End if for is_admin
|
160 |
+
endif;
|
161 |
+
?>
|