Version Description
- Replaced 3.3 deprecated get_userdatabylogin() with get_user_by()
- Updated deprecated add_contextual_help() with add_help_tab()
- Small change in condition check for backup tables
- Removed custom rand_string() with core wpgenerate_password()
- Added Portuguese translation - thanks to Fernando Lopes
Download this release
Release Info
Developer | mousesports |
Plugin | WordPress Database Reset |
Version | 2.1 |
Comparing to | |
See all releases |
Code changes from version 2.0 to 2.1
- css/i/ajax-loader.gif +0 -0
- css/jquery.bsmselect.css +0 -0
- css/wp-reset.css +0 -0
- js/jquery.bsmselect.compatibility.js +0 -0
- js/jquery.bsmselect.js +0 -0
- js/jquery.bsmselect.sortable.js +0 -49
- languages/default.mo +0 -0
- languages/default.po +0 -0
- languages/wp-reset-fr_FR.mo +0 -0
- languages/wp-reset-fr_FR.po +0 -0
- languages/wp-reset-pt_BR.mo +0 -0
- languages/wp-reset-pt_BR.po +119 -0
- readme.txt +10 -3
- screenshot-1.jpg → screenshot-1.png +0 -0
- wp-reset.php +55 -54
css/i/ajax-loader.gif
CHANGED
File without changes
|
css/jquery.bsmselect.css
CHANGED
File without changes
|
css/wp-reset.css
CHANGED
File without changes
|
js/jquery.bsmselect.compatibility.js
CHANGED
File without changes
|
js/jquery.bsmselect.js
CHANGED
File without changes
|
js/jquery.bsmselect.sortable.js
DELETED
@@ -1,49 +0,0 @@
|
|
1 |
-
/*
|
2 |
-
* Better Select Multiple Sortable Plugin
|
3 |
-
*
|
4 |
-
* Copyright (c) 2010 by Victor Berchet - http://www.github.com/vicb
|
5 |
-
*
|
6 |
-
* Dual licensed under the MIT (MIT-LICENSE.txt) and GPL (GPL-LICENSE.txt) licenses.
|
7 |
-
*
|
8 |
-
* version: v1.1.1 - 2010-11-17
|
9 |
-
*/
|
10 |
-
(function($) {
|
11 |
-
$.bsmSelect.plugins.sortable = function(sortConfig, options)
|
12 |
-
{
|
13 |
-
if (!(this instanceof arguments.callee)) {
|
14 |
-
return new arguments.callee(sortConfig, options);
|
15 |
-
}
|
16 |
-
this.sortConfig = sortConfig;
|
17 |
-
this.options = $.extend({}, this.defaultOpt, options || {});
|
18 |
-
}
|
19 |
-
|
20 |
-
$.extend($.bsmSelect.plugins.sortable.prototype, {
|
21 |
-
defaultOpt: {
|
22 |
-
listSortableClass: 'bsmListSortable'
|
23 |
-
},
|
24 |
-
|
25 |
-
init: function(bsm) {
|
26 |
-
var o = $.extend({}, this.options, bsm.options),
|
27 |
-
config = $.extend({}, this.sortConfig, { items: '.' + o.listItemClass }),
|
28 |
-
self = this;
|
29 |
-
bsm.$list.addClass(o.listSortableClass).sortable(config);
|
30 |
-
bsm.$original.bind('change', function(e, info) { self.onChange.call(self, bsm, e, info); } );
|
31 |
-
bsm.$list.bind('sortupdate', function(e, ui) { self.onSort.call(self, bsm, e, ui); } );
|
32 |
-
},
|
33 |
-
|
34 |
-
onChange: function(bsm, e, info) {
|
35 |
-
if (info && info.type == 'add' && !bsm.buildingSelect) {
|
36 |
-
info.option.detach()[bsm.options.addItemTarget == 'top' ? 'prependTo' : 'appendTo'](bsm.$original);
|
37 |
-
bsm.$list.sortable('refresh');
|
38 |
-
}
|
39 |
-
},
|
40 |
-
|
41 |
-
onSort: function(bsm, e, ui) {
|
42 |
-
$('.' + bsm.options.listItemClass, bsm.$list).each(function() {
|
43 |
-
$(this).data('bsm-option').data('orig-option').detach().appendTo(bsm.$original);
|
44 |
-
});
|
45 |
-
bsm.triggerOriginalChange($(ui.item).data('bsm-option').data('orig-option'), 'sort');
|
46 |
-
}
|
47 |
-
});
|
48 |
-
})(jQuery);
|
49 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
languages/default.mo
CHANGED
File without changes
|
languages/default.po
CHANGED
File without changes
|
languages/wp-reset-fr_FR.mo
CHANGED
File without changes
|
languages/wp-reset-fr_FR.po
CHANGED
File without changes
|
languages/wp-reset-pt_BR.mo
ADDED
Binary file
|
languages/wp-reset-pt_BR.po
ADDED
@@ -0,0 +1,119 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
msgid ""
|
2 |
+
msgstr ""
|
3 |
+
"Project-Id-Version: WordPress Database Reset\n"
|
4 |
+
"Report-Msgid-Bugs-To: \n"
|
5 |
+
"POT-Creation-Date: 2011-11-08 02:00-0300\n"
|
6 |
+
"PO-Revision-Date: 2011-11-08 06:20-0300\n"
|
7 |
+
"Last-Translator: Fernando Lopes <contato@fernandolopes.com.br>\n"
|
8 |
+
"Language-Team: Fernando Lopes <contato@fernandolopes.com.br>\n"
|
9 |
+
"MIME-Version: 1.0\n"
|
10 |
+
"Content-Type: text/plain; charset=UTF-8\n"
|
11 |
+
"Content-Transfer-Encoding: 8bit\n"
|
12 |
+
"X-Poedit-KeywordsList: _;gettext;gettext_noop;__;_e\n"
|
13 |
+
"X-Poedit-Basepath: ../\n"
|
14 |
+
"X-Poedit-Language: Portuguese\n"
|
15 |
+
"X-Poedit-Country: BRAZIL\n"
|
16 |
+
"X-Poedit-SearchPath-0: .\n"
|
17 |
+
"X-Poedit-SearchPath-1: ..\n"
|
18 |
+
|
19 |
+
#: wp-reset.php:156
|
20 |
+
#: ../wordpress-database-reset/wp-reset.php:156
|
21 |
+
msgid "You entered the wrong value - please try again"
|
22 |
+
msgstr "Você digitou o valor errado - por favor tente novamente"
|
23 |
+
|
24 |
+
#: wp-reset.php:158
|
25 |
+
#: ../wordpress-database-reset/wp-reset.php:158
|
26 |
+
msgid "You did not select any database tables"
|
27 |
+
msgstr "Você não selecionou nenhuma tabela do banco de dados"
|
28 |
+
|
29 |
+
#: wp-reset.php:160
|
30 |
+
#: ../wordpress-database-reset/wp-reset.php:160
|
31 |
+
msgid "The WordPress database has been reset successfully"
|
32 |
+
msgstr "O banco de dados do WordPress foi reiniciado com sucesso"
|
33 |
+
|
34 |
+
#: wp-reset.php:165
|
35 |
+
#: ../wordpress-database-reset/wp-reset.php:165
|
36 |
+
msgid "Database Reset"
|
37 |
+
msgstr "Reiniciar Banco de Dados"
|
38 |
+
|
39 |
+
#: wp-reset.php:167
|
40 |
+
#: ../wordpress-database-reset/wp-reset.php:167
|
41 |
+
msgid "Please choose from the following database tables the ones you would like to reset"
|
42 |
+
msgstr "Por favor, escolha a partir das tabelas do banco de dados abaixo o que você gostaria de reiniciar"
|
43 |
+
|
44 |
+
#: wp-reset.php:169
|
45 |
+
#: ../wordpress-database-reset/wp-reset.php:169
|
46 |
+
msgid "Select All"
|
47 |
+
msgstr "Selecionar Tudas"
|
48 |
+
|
49 |
+
#: wp-reset.php:176
|
50 |
+
#: ../wordpress-database-reset/wp-reset.php:176
|
51 |
+
msgid "Type in (or copy/paste) the generated value into the text box"
|
52 |
+
msgstr "Digite (ou copie/cole) o valor gerado na caixa de texto"
|
53 |
+
|
54 |
+
#: wp-reset.php:180
|
55 |
+
#: ../wordpress-database-reset/wp-reset.php:180
|
56 |
+
msgid "Reset Database"
|
57 |
+
msgstr "Reiniciar Banco de Dados"
|
58 |
+
|
59 |
+
#: wp-reset.php:186
|
60 |
+
#: ../wordpress-database-reset/wp-reset.php:186
|
61 |
+
msgid "Reactivate current plugins after reset?"
|
62 |
+
msgstr "Reativar os plugins atuais depois de reiniciar?"
|
63 |
+
|
64 |
+
#: wp-reset.php:193
|
65 |
+
#: ../wordpress-database-reset/wp-reset.php:193
|
66 |
+
#, php-format
|
67 |
+
msgid "The default user <strong><u>admin</u></strong> was never created for this WordPress install. So <strong><u>%s</u></strong> will be recreated with its current password instead"
|
68 |
+
msgstr "O usuário padrão <strong><u>admin</u></strong>, nunca foi criado nesta instalação do WordPress. Então, o usuário <strong><u>%s</u></strong> será recriado com a sua senha atual"
|
69 |
+
|
70 |
+
#: wp-reset.php:195
|
71 |
+
#: ../wordpress-database-reset/wp-reset.php:195
|
72 |
+
msgid "The default user <strong><u>admin</u></strong> will be recreated with its current password upon resetting"
|
73 |
+
msgstr "O usuário padrão <strong><u>admin</u></strong> será recriado com sua senha atual mediante a reinicialização"
|
74 |
+
|
75 |
+
#: wp-reset.php:198
|
76 |
+
#: ../wordpress-database-reset/wp-reset.php:198
|
77 |
+
msgid "Note that once you reset the database, all users will be deleted except the initial admin user."
|
78 |
+
msgstr "Note que, uma vez que você reiniciar o banco de dados, todos os usuários serão apagados, exceto o usuário <strong><u>admin</u></strong> inicial."
|
79 |
+
|
80 |
+
#: wp-reset.php:216
|
81 |
+
#: ../wordpress-database-reset/wp-reset.php:216
|
82 |
+
msgid "Select Table"
|
83 |
+
msgstr "Selecionar Tabela"
|
84 |
+
|
85 |
+
#: wp-reset.php:226
|
86 |
+
#: ../wordpress-database-reset/wp-reset.php:226
|
87 |
+
msgid "Clicking OK will result in your database being reset to its initial settings. Continue?"
|
88 |
+
msgstr "Clicar em OK fará com que o banco de dados seja reiniciado para as configurações iniciais. Continuar?"
|
89 |
+
|
90 |
+
#: wp-reset.php:273
|
91 |
+
#: ../wordpress-database-reset/wp-reset.php:273
|
92 |
+
msgid "Have any cool ideas for this plugin? Contact me either by <a href=\"http://twitter.com/#!/chrisberthe\">Twitter</a> or by <a href=\"https://github.com/chrisberthe\">GitHub</a>."
|
93 |
+
msgstr "Tem alguma idéia legal para este plugin? Entre em contato comigo pelo <a href=\"http://twitter.com/#!/chrisberthe\">Twitter</a> ou pelo <a href=\"https://github.com/chrisberthe\">GitHub</a>."
|
94 |
+
|
95 |
+
#: wp-reset.php:274
|
96 |
+
#: ../wordpress-database-reset/wp-reset.php:274
|
97 |
+
msgid "If this plugin becomes non-functional in any way due to WordPress upgrades, rest assured I will update it."
|
98 |
+
msgstr "Se este plugin se tornar não-funcional de alguma forma devido a upgrades WordPress, eu vou atualizá-lo."
|
99 |
+
|
100 |
+
#: wp-reset.php:275
|
101 |
+
#: ../wordpress-database-reset/wp-reset.php:275
|
102 |
+
msgid "Goodbye for now."
|
103 |
+
msgstr "Adeus por agora."
|
104 |
+
|
105 |
+
#: wp-reset.php:345
|
106 |
+
#: ../wordpress-database-reset/wp-reset.php:345
|
107 |
+
msgid "WordPress Database Reset"
|
108 |
+
msgstr "WordPress Reiniciar Banco de Dados"
|
109 |
+
|
110 |
+
#: wp-reset.php:346
|
111 |
+
#: ../wordpress-database-reset/wp-reset.php:346
|
112 |
+
msgid "The tables you selected have been successfully reset to their default settings:"
|
113 |
+
msgstr "As tabelas selecionadas foram reiniciadas com sucesso para suas configurações padrão:"
|
114 |
+
|
115 |
+
#: wp-reset.php:347
|
116 |
+
#: ../wordpress-database-reset/wp-reset.php:347
|
117 |
+
msgid "Password: The password you chose during the install."
|
118 |
+
msgstr "Senha: A senha que você escolheu durante a instalação."
|
119 |
+
|
readme.txt
CHANGED
@@ -1,11 +1,11 @@
|
|
1 |
=== WordPress Database Reset ===
|
2 |
|
3 |
Contributors: mousesports
|
4 |
-
Tags: wordpress, database, database-reset, default-settings, default, wp-reset, security, secure
|
5 |
License: GPL2
|
6 |
Requires at least: 3.0
|
7 |
-
Tested up to: 3.
|
8 |
-
Stable tag: 2.
|
9 |
|
10 |
A secure and easy way to reinitialize the WordPress database to its default settings.
|
11 |
|
@@ -32,6 +32,13 @@ I wanted a simple and painless way to obtain a fresh clean database without actu
|
|
32 |
1. The plugin page - a more secure way of resetting your database.
|
33 |
|
34 |
== Changelog ==
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
35 |
= 2.0 =
|
36 |
* Added functionality to be able to select which tables you want to reset, rather than having to reset the entire database.
|
37 |
* Added bsmSelect for the multiple select.
|
1 |
=== WordPress Database Reset ===
|
2 |
|
3 |
Contributors: mousesports
|
4 |
+
Tags: wordpress, database, database-reset, development, default-settings, default, wp-reset, security, secure
|
5 |
License: GPL2
|
6 |
Requires at least: 3.0
|
7 |
+
Tested up to: 3.5
|
8 |
+
Stable tag: 2.1
|
9 |
|
10 |
A secure and easy way to reinitialize the WordPress database to its default settings.
|
11 |
|
32 |
1. The plugin page - a more secure way of resetting your database.
|
33 |
|
34 |
== Changelog ==
|
35 |
+
= 2.1 =
|
36 |
+
* Replaced 3.3 deprecated get_userdatabylogin() with get_user_by()
|
37 |
+
* Updated deprecated add_contextual_help() with add_help_tab()
|
38 |
+
* Small change in condition check for backup tables
|
39 |
+
* Removed custom _rand_string() with core wp_generate_password()
|
40 |
+
* Added Portuguese translation - thanks to Fernando Lopes
|
41 |
+
|
42 |
= 2.0 =
|
43 |
* Added functionality to be able to select which tables you want to reset, rather than having to reset the entire database.
|
44 |
* Added bsmSelect for the multiple select.
|
screenshot-1.jpg → screenshot-1.png
RENAMED
File without changes
|
wp-reset.php
CHANGED
@@ -3,8 +3,8 @@
|
|
3 |
Plugin Name: WordPress Database Reset
|
4 |
Plugin URI: https://github.com/chrisberthe/wordpress-database-reset
|
5 |
Description: A plugin that allows you to reset the database to WordPress's initial state.
|
6 |
-
Version: 2.
|
7 |
-
Author: Chris Berthe
|
8 |
Author URI: https://github.com/chrisberthe
|
9 |
License: GNU General Public License
|
10 |
*/
|
@@ -18,11 +18,6 @@ if ( ! class_exists('cb_wp_reset') && is_admin() ) :
|
|
18 |
*/
|
19 |
private $_nonce = 'wp-reset-nonce';
|
20 |
|
21 |
-
/**
|
22 |
-
* Plugins to reactivate
|
23 |
-
*/
|
24 |
-
private $_active_plugins;
|
25 |
-
|
26 |
/**
|
27 |
* Tables to preserve
|
28 |
*/
|
@@ -33,6 +28,11 @@ if ( ! class_exists('cb_wp_reset') && is_admin() ) :
|
|
33 |
*/
|
34 |
private $_wp_tables;
|
35 |
|
|
|
|
|
|
|
|
|
|
|
36 |
/**
|
37 |
* Loads default options
|
38 |
*
|
@@ -46,7 +46,6 @@ if ( ! class_exists('cb_wp_reset') && is_admin() ) :
|
|
46 |
add_action('admin_init', array($this, 'add_plugin_styles_and_scripts'));
|
47 |
add_action('admin_footer', array($this, 'add_admin_javascript'));
|
48 |
add_action('admin_menu', array($this, 'add_admin_menu'));
|
49 |
-
add_filter('contextual_help', array($this, 'add_contextual_help'), 10, 2);
|
50 |
add_filter('wp_mail', array($this, '_fix_mail'));
|
51 |
}
|
52 |
|
@@ -79,7 +78,7 @@ if ( ! class_exists('cb_wp_reset') && is_admin() ) :
|
|
79 |
$blog_title = get_option('blogname');
|
80 |
$public = get_option('blog_public');
|
81 |
|
82 |
-
$admin_user =
|
83 |
$user = ( ! $admin_user || ! user_can($admin_user->ID, 'update_core') ) ? $current_user : $admin_user;
|
84 |
|
85 |
// Get the selected tables
|
@@ -97,7 +96,7 @@ if ( ! class_exists('cb_wp_reset') && is_admin() ) :
|
|
97 |
// Grab the currently active plugins
|
98 |
if ( isset($_POST['wp-reset-check']) && $_POST['wp-reset-check'] == 'true' )
|
99 |
{
|
100 |
-
$
|
101 |
}
|
102 |
|
103 |
// Run through the database columns and drop all the tables
|
@@ -114,7 +113,7 @@ if ( ! class_exists('cb_wp_reset') && is_admin() ) :
|
|
114 |
}
|
115 |
|
116 |
// Delete and replace tables with the backed up table data
|
117 |
-
if (
|
118 |
{
|
119 |
foreach ($this->_tables as $table)
|
120 |
{
|
@@ -124,9 +123,9 @@ if ( ! class_exists('cb_wp_reset') && is_admin() ) :
|
|
124 |
$this->_backup_tables($backup_tables, 'reset');
|
125 |
}
|
126 |
|
127 |
-
if ( ! empty($
|
128 |
{
|
129 |
-
$wpdb->update($wpdb->options, array('option_value' => $
|
130 |
|
131 |
wp_redirect(admin_url($pagenow) . '?page=wp-reset&reset=success'); exit();
|
132 |
}
|
@@ -147,10 +146,10 @@ if ( ! class_exists('cb_wp_reset') && is_admin() ) :
|
|
147 |
global $current_user;
|
148 |
|
149 |
// Return to see if admin object exists
|
150 |
-
$admin_user =
|
151 |
|
152 |
// Generate a random value for the input box
|
153 |
-
$random_string =
|
154 |
?>
|
155 |
<?php if ( isset($_POST['wp-random-value'], $_POST['wp-reset-input']) && $_POST['wp-random-value'] != $_POST['wp-reset-input'] ) : ?>
|
156 |
<div class="error"><p><strong><?php _e('You entered the wrong value - please try again', 'wp-reset') ?>.</strong></p></div>
|
@@ -210,7 +209,8 @@ if ( ! class_exists('cb_wp_reset') && is_admin() ) :
|
|
210 |
?>
|
211 |
<script type="text/javascript">
|
212 |
/* <![CDATA[ */
|
213 |
-
|
|
|
214 |
$('#wp-tables').bsmSelect({
|
215 |
animate: true,
|
216 |
title: "<?php _e('Select Table', 'wp-reset') ?>",
|
@@ -238,7 +238,8 @@ if ( ! class_exists('cb_wp_reset') && is_admin() ) :
|
|
238 |
var op = $("#wp-tables option[value='options']:selected");
|
239 |
$('#reactivate').toggle(op.length > 0);
|
240 |
}
|
241 |
-
|
|
|
242 |
/* ]]> */
|
243 |
</script>
|
244 |
<?php
|
@@ -255,27 +256,49 @@ if ( ! class_exists('cb_wp_reset') && is_admin() ) :
|
|
255 |
if ( current_user_can('update_core') )
|
256 |
{
|
257 |
$this->_hook = add_submenu_page('tools.php', 'Database Reset', 'Database Reset', 'update_core', 'wp-reset', array($this, 'show_admin_page'));
|
|
|
|
|
258 |
}
|
259 |
}
|
260 |
|
261 |
/**
|
262 |
-
* Adds
|
263 |
*
|
264 |
-
* @access
|
265 |
-
* @
|
266 |
-
* @param $screen_id ID of the current admin screen
|
267 |
-
* @return $contextual_help String The help text
|
268 |
*/
|
269 |
-
function
|
270 |
-
{
|
271 |
-
|
272 |
-
{
|
273 |
-
$contextual_help = '<p>' . __('Have any cool ideas for this plugin? Contact me either by <a href="http://twitter.com/#!/chrisberthe">Twitter</a> or by <a href="https://github.com/chrisberthe">GitHub</a>.', 'wp-reset') . '</p>';
|
274 |
-
$contextual_help .= '<p>' . __('If this plugin becomes non-functional in any way due to WordPress upgrades, rest assured I will update it.', 'wp-reset') . '</p>';
|
275 |
-
$contextual_help .= '<p>' . __('Goodbye for now.', 'wp-reset') . '</p>';
|
276 |
-
}
|
277 |
|
278 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
279 |
}
|
280 |
|
281 |
/**
|
@@ -291,7 +314,6 @@ if ( ! class_exists('cb_wp_reset') && is_admin() ) :
|
|
291 |
|
292 |
wp_enqueue_script('bsmselect', plugins_url('js/jquery.bsmselect.js', __FILE__));
|
293 |
wp_enqueue_script('bsmselect-compatibility', plugins_url('js/jquery.bsmselect.compatibility.js', __FILE__));
|
294 |
-
wp_enqueue_script('bsmselect-sortable', plugins_url('js/jquery.bsmselect.sortable.js', __FILE__));
|
295 |
}
|
296 |
|
297 |
/**
|
@@ -440,28 +462,7 @@ if ( ! class_exists('cb_wp_reset') && is_admin() ) :
|
|
440 |
|
441 |
return FALSE;
|
442 |
}
|
443 |
-
|
444 |
-
/**
|
445 |
-
* Generates a random value for our input box
|
446 |
-
*
|
447 |
-
* @access private
|
448 |
-
* @param $length Length of the random string value
|
449 |
-
* @return $random_string
|
450 |
-
*/
|
451 |
-
function _rand_string($length = 5)
|
452 |
-
{
|
453 |
-
$random_string = '';
|
454 |
-
$chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
|
455 |
-
$size = strlen($chars);
|
456 |
-
|
457 |
-
for ($i = 0; $i < $length; $i++)
|
458 |
-
{
|
459 |
-
$random_string .= $chars[rand(0, $size-1)];
|
460 |
-
}
|
461 |
-
|
462 |
-
return $random_string;
|
463 |
-
}
|
464 |
-
|
465 |
}
|
466 |
|
467 |
$cb_wp_reset = new cb_wp_reset();
|
3 |
Plugin Name: WordPress Database Reset
|
4 |
Plugin URI: https://github.com/chrisberthe/wordpress-database-reset
|
5 |
Description: A plugin that allows you to reset the database to WordPress's initial state.
|
6 |
+
Version: 2.1
|
7 |
+
Author: Chris Berthe ☻
|
8 |
Author URI: https://github.com/chrisberthe
|
9 |
License: GNU General Public License
|
10 |
*/
|
18 |
*/
|
19 |
private $_nonce = 'wp-reset-nonce';
|
20 |
|
|
|
|
|
|
|
|
|
|
|
21 |
/**
|
22 |
* Tables to preserve
|
23 |
*/
|
28 |
*/
|
29 |
private $_wp_tables;
|
30 |
|
31 |
+
/**
|
32 |
+
* WordPress screen object
|
33 |
+
*/
|
34 |
+
private $_admin_screen;
|
35 |
+
|
36 |
/**
|
37 |
* Loads default options
|
38 |
*
|
46 |
add_action('admin_init', array($this, 'add_plugin_styles_and_scripts'));
|
47 |
add_action('admin_footer', array($this, 'add_admin_javascript'));
|
48 |
add_action('admin_menu', array($this, 'add_admin_menu'));
|
|
|
49 |
add_filter('wp_mail', array($this, '_fix_mail'));
|
50 |
}
|
51 |
|
78 |
$blog_title = get_option('blogname');
|
79 |
$public = get_option('blog_public');
|
80 |
|
81 |
+
$admin_user = get_user_by('login', 'admin');
|
82 |
$user = ( ! $admin_user || ! user_can($admin_user->ID, 'update_core') ) ? $current_user : $admin_user;
|
83 |
|
84 |
// Get the selected tables
|
96 |
// Grab the currently active plugins
|
97 |
if ( isset($_POST['wp-reset-check']) && $_POST['wp-reset-check'] == 'true' )
|
98 |
{
|
99 |
+
$active_plugins = $wpdb->get_var($wpdb->prepare("SELECT option_value FROM $wpdb->options WHERE option_name = %s", 'active_plugins'));
|
100 |
}
|
101 |
|
102 |
// Run through the database columns and drop all the tables
|
113 |
}
|
114 |
|
115 |
// Delete and replace tables with the backed up table data
|
116 |
+
if ( $backup_tables )
|
117 |
{
|
118 |
foreach ($this->_tables as $table)
|
119 |
{
|
123 |
$this->_backup_tables($backup_tables, 'reset');
|
124 |
}
|
125 |
|
126 |
+
if ( ! empty($active_plugins) )
|
127 |
{
|
128 |
+
$wpdb->update($wpdb->options, array('option_value' => $active_plugins), array('option_name' => 'active_plugins'));
|
129 |
|
130 |
wp_redirect(admin_url($pagenow) . '?page=wp-reset&reset=success'); exit();
|
131 |
}
|
146 |
global $current_user;
|
147 |
|
148 |
// Return to see if admin object exists
|
149 |
+
$admin_user = get_user_by('login', 'admin');
|
150 |
|
151 |
// Generate a random value for the input box
|
152 |
+
$random_string = wp_generate_password(5, false);
|
153 |
?>
|
154 |
<?php if ( isset($_POST['wp-random-value'], $_POST['wp-reset-input']) && $_POST['wp-random-value'] != $_POST['wp-reset-input'] ) : ?>
|
155 |
<div class="error"><p><strong><?php _e('You entered the wrong value - please try again', 'wp-reset') ?>.</strong></p></div>
|
209 |
?>
|
210 |
<script type="text/javascript">
|
211 |
/* <![CDATA[ */
|
212 |
+
(function($) {
|
213 |
+
|
214 |
$('#wp-tables').bsmSelect({
|
215 |
animate: true,
|
216 |
title: "<?php _e('Select Table', 'wp-reset') ?>",
|
238 |
var op = $("#wp-tables option[value='options']:selected");
|
239 |
$('#reactivate').toggle(op.length > 0);
|
240 |
}
|
241 |
+
|
242 |
+
})(jQuery);
|
243 |
/* ]]> */
|
244 |
</script>
|
245 |
<?php
|
256 |
if ( current_user_can('update_core') )
|
257 |
{
|
258 |
$this->_hook = add_submenu_page('tools.php', 'Database Reset', 'Database Reset', 'update_core', 'wp-reset', array($this, 'show_admin_page'));
|
259 |
+
|
260 |
+
add_action('load-' . $this->_hook, array($this, '_add_help_screen'));
|
261 |
}
|
262 |
}
|
263 |
|
264 |
/**
|
265 |
+
* Adds v3.3 style help menu for plugin page
|
266 |
*
|
267 |
+
* @access private
|
268 |
+
* @return void
|
|
|
|
|
269 |
*/
|
270 |
+
function _add_help_screen()
|
271 |
+
{
|
272 |
+
$this->_admin_screen = get_current_screen();
|
|
|
|
|
|
|
|
|
|
|
273 |
|
274 |
+
$help = '<p>' . __( 'Thank you for downloading the WordPress Database Reset plugin.' ) . '</p>';
|
275 |
+
$help .= '<p>' . __( 'This plugin allows you to securely and easily reinitialize the WordPress database back to its default settings without actually having to reinstall WordPress from scratch. This plugin will come in handy for both theme and plugin developers. Two possible use case scenarios would be to:') . '</p>';
|
276 |
+
$help .= '<p>' . __( '<strong>1.</strong> Erase excess junk in the <code>wp_options</code> table that accumulates over time.<br /><strong>2.</strong> Revert back to a fresh install of the WordPress database after experimenting with various back-end options.' ) . '</p>';
|
277 |
+
$help .= '<p>' . __( 'You can learn more on how to use this plugin by clicking the <code>Instructions</code> tab to the left.' ) . '</p>';
|
278 |
+
|
279 |
+
$this->_admin_screen->add_help_tab( array(
|
280 |
+
'id' => 'overview',
|
281 |
+
'title' => __( 'Overview' ),
|
282 |
+
'content' => $help,
|
283 |
+
) );
|
284 |
+
|
285 |
+
$help = '<p>' . __( 'Performing a database reset is quite straightforward.' ) . '</p>';
|
286 |
+
$help .= '<p>' . __( 'Select the different tables you would like to reinitialize from the drop down list. You can select any number of tables. If you know you would like to reset the entire database, simply click the <code>Select All</code> button.' ) . '</p>';
|
287 |
+
$help .= '<p>' . __( 'Next you will have to enter the <code>auto generated value</code> into the text box. Clicking on the <code>Reset Database</code> button will result in a pop-up.' ) . '</p>';
|
288 |
+
$help .= '<p>' . __( 'Once you are sure you would like to proceed, click <code>OK</code> to reset.' ) . '</p>';
|
289 |
+
|
290 |
+
$this->_admin_screen->add_help_tab( array(
|
291 |
+
'id' => 'instructions',
|
292 |
+
'title' => __( 'Instructions' ),
|
293 |
+
'content' => $help,
|
294 |
+
) );
|
295 |
+
|
296 |
+
unset($help);
|
297 |
+
|
298 |
+
$this->_admin_screen->set_help_sidebar(
|
299 |
+
'<p><strong>' . __( 'Contact information:' ) . '</strong></p>' .
|
300 |
+
'<p>' . __( 'Any ideas on features or ways to improve this plugin? Contact me at <a href="http://github.com/chrisberthe/" target="_blank">GitHub</a> or <a href="http://twitter.com/chrisberthe/" target="_blank">Twitter</a>.' ) . '</p>'
|
301 |
+
);
|
302 |
}
|
303 |
|
304 |
/**
|
314 |
|
315 |
wp_enqueue_script('bsmselect', plugins_url('js/jquery.bsmselect.js', __FILE__));
|
316 |
wp_enqueue_script('bsmselect-compatibility', plugins_url('js/jquery.bsmselect.compatibility.js', __FILE__));
|
|
|
317 |
}
|
318 |
|
319 |
/**
|
462 |
|
463 |
return FALSE;
|
464 |
}
|
465 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
466 |
}
|
467 |
|
468 |
$cb_wp_reset = new cb_wp_reset();
|