WordPress Reset - Version 1.1

Version Description

(2009-10-01) = * WordPress 2.8 Updates, do not show auto generated password nag after reset

Download this release

Release Info

Developer sivel
Plugin Icon WordPress Reset
Version 1.1
Comparing to
See all releases

Code changes from version 1.0 to 1.1

Files changed (2) hide show
  1. readme.txt +6 -3
  2. wordpress-reset.php +30 -26
readme.txt CHANGED
@@ -1,10 +1,10 @@
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&currency_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
@@ -44,5 +44,8 @@ Open the wordpress-reset.php file in an editor and modify the line that reads `v
44
45
== Changelog ==
46
47
= 1.0 (2009-03-17): =
48
* Initial Public Release
1
=== WordPress Reset ===
2
Contributors: sivel, jdingman
3
+ Donate Link: http://sivel.net/donate
4
Tags: wordpress-reset, wordpress, reset, admin
5
Requires at least: 2.7
6
+ Tested up to: 2.9
7
+ Stable tag: 1.1
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
44
45
== Changelog ==
46
47
+ = 1.1 (2009-10-01) =
48
+ * WordPress 2.8 Updates, do not show auto generated password nag after reset
49
+
50
= 1.0 (2009-03-17): =
51
* Initial Public Release
wordpress-reset.php CHANGED
@@ -2,14 +2,14 @@
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
@@ -40,39 +40,43 @@ class WordPressReset {
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>\';'));
@@ -137,9 +141,9 @@ class WordPressReset {
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 : ?>
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
7
+ Version: 1.1
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
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 ( get_usermeta($user_id, 'default_password_nag') )
68
+ update_usermeta($user_id, 'default_password_nag', false);
69
70
if ( $this->auto_reactivate == true )
71
update_option('active_plugins', array(plugin_basename(__FILE__)));
72
73
+ wp_clear_auth_cookie();
74
+ wp_set_auth_cookie($user_id);
75
76
wp_redirect(admin_url() . '?reset');
77
exit();
78
}
79
+
80
if ( array_key_exists('reset', $_GET) && stristr($_SERVER['HTTP_REFERER'], 'wordpress-reset') ) {
81
$user = get_userdata(1);
82
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>\';'));
141
<ul>
142
<li><strong>After completing this reset you will taken to the dashboard.</strong></li>
143
<?php
144
+ $admin = get_userdatabylogin('admin');
145
+ if ( ! isset($admin->user_login) || $admin->user_level < 10 ) :
146
+ $user = $current_user;
147
?>
148
<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>
149
<?php else : ?>