Version Description
- Fix plugin disabled after update, thanks to Ulrich Pogson
- Update the pot file
Download this release
Release Info
Developer | mousesports |
Plugin | WordPress Database Reset |
Version | 3.0.1 |
Comparing to | |
See all releases |
Code changes from version 3.0 to 3.0.1
- css/i/ajax-loader.gif +0 -0
- css/jquery.bsmselect.css +0 -76
- css/wp-reset.css +0 -16
- init.php +0 -36
- js/jquery.bsmselect.compatibility.js +0 -60
- js/jquery.bsmselect.js +0 -381
- languages/wordpress-database-reset.pot +73 -81
- readme.txt +6 -2
- wp-reset.php +36 -453
css/i/ajax-loader.gif
DELETED
Binary file
|
css/jquery.bsmselect.css
DELETED
@@ -1,76 +0,0 @@
|
|
1 |
-
.bsmContainer {
|
2 |
-
/* container that surrounds entire bsmSelect widget */
|
3 |
-
color: #555;
|
4 |
-
}
|
5 |
-
|
6 |
-
.bsmSelect {
|
7 |
-
/* the newly created regular 'select' */
|
8 |
-
display: inline;
|
9 |
-
}
|
10 |
-
|
11 |
-
.bsmOptionDisabled {
|
12 |
-
/* disabled options in new select */
|
13 |
-
color: #999;
|
14 |
-
}
|
15 |
-
|
16 |
-
.bsmHighlight {
|
17 |
-
/* the highlight span */
|
18 |
-
float: right;
|
19 |
-
padding: 0;
|
20 |
-
margin: 0 0 0 1em;
|
21 |
-
}
|
22 |
-
|
23 |
-
.bsmList {
|
24 |
-
/* html list that contains selected items */
|
25 |
-
border-color: #DFDFDF;
|
26 |
-
margin: 0.25em 0 1.5em 0;
|
27 |
-
position: relative;
|
28 |
-
display: block;
|
29 |
-
padding-left: 0;
|
30 |
-
list-style: none;
|
31 |
-
width: 287px;
|
32 |
-
}
|
33 |
-
|
34 |
-
.bsmListItem {
|
35 |
-
/* li item from the html list above */
|
36 |
-
position: relative;
|
37 |
-
margin-left: 0;
|
38 |
-
padding-left: 0;
|
39 |
-
list-style: none;
|
40 |
-
background: #FCFCFC;
|
41 |
-
border: 1px solid #DFDFDF;
|
42 |
-
width: 100%;
|
43 |
-
margin: 0 0 -1px 0;
|
44 |
-
line-height: 1em;
|
45 |
-
}
|
46 |
-
|
47 |
-
.bsmListItem:hover {
|
48 |
-
background-color: #F0F0F0;
|
49 |
-
}
|
50 |
-
|
51 |
-
.bsmListItemLabel {
|
52 |
-
/* this is a span that surrounds the text in the item, except for the remove link */
|
53 |
-
padding: 5px;
|
54 |
-
display: block;
|
55 |
-
}
|
56 |
-
|
57 |
-
.bsmListSortable .bsmListItemLabel {
|
58 |
-
cursor: move;
|
59 |
-
}
|
60 |
-
|
61 |
-
.bsmListItemRemove {
|
62 |
-
/* the remove link in each list item */
|
63 |
-
text-decoration: none;
|
64 |
-
position: absolute;
|
65 |
-
right: 0;
|
66 |
-
top: 0;
|
67 |
-
padding: 5px;
|
68 |
-
}
|
69 |
-
|
70 |
-
.bsmListItemRemove:hover {
|
71 |
-
text-decoration: underline;
|
72 |
-
}
|
73 |
-
|
74 |
-
#bsmListbsmContainer0 {
|
75 |
-
margin-top: 12px;
|
76 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
css/wp-reset.css
DELETED
@@ -1,16 +0,0 @@
|
|
1 |
-
#select-buttons {
|
2 |
-
width: 270px;
|
3 |
-
}
|
4 |
-
|
5 |
-
#select-all {
|
6 |
-
float: right;
|
7 |
-
margin-top: 4px;
|
8 |
-
}
|
9 |
-
|
10 |
-
#loader {
|
11 |
-
position: absolute;
|
12 |
-
margin-left: 10px;
|
13 |
-
margin-top: 1px;
|
14 |
-
}
|
15 |
-
|
16 |
-
#reactivate {color: #21759B}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
init.php
DELETED
@@ -1,36 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
/*
|
3 |
-
Plugin Name: WordPress Database Reset
|
4 |
-
Plugin URI: https://github.com/chrisberthe/wordpress-database-reset
|
5 |
-
Description: A plugin that allows you to skip the 5 minute installation and reset WordPress's database back to its original state.
|
6 |
-
Version: 3.0
|
7 |
-
Author: Chris Berthe
|
8 |
-
Author URI: https://github.com/chrisberthe
|
9 |
-
License: GNU General Public License
|
10 |
-
Text-domain: wp-reset
|
11 |
-
*/
|
12 |
-
|
13 |
-
define( 'DB_RESET_VERSION', '3.0' );
|
14 |
-
define( 'DB_RESET_PATH', dirname( __FILE__ ) );
|
15 |
-
define( 'DB_RESET_NAME', basename( DB_RESET_PATH ) );
|
16 |
-
define( 'AUTOLOADER', DB_RESET_PATH . '/lib/class-plugin-autoloader.php' );
|
17 |
-
|
18 |
-
require_once( DB_RESET_PATH . '/lib/helpers.php' );
|
19 |
-
|
20 |
-
register_activation_hook( __FILE__, 'db_reset_activate' );
|
21 |
-
|
22 |
-
load_plugin_textdomain( 'wordpress-database-reset', false, DB_RESET_NAME . '/languages/' );
|
23 |
-
|
24 |
-
if ( file_exists( AUTOLOADER ) ) {
|
25 |
-
require_once( AUTOLOADER );
|
26 |
-
new Plugin_Autoloader( DB_RESET_PATH );
|
27 |
-
|
28 |
-
add_action(
|
29 |
-
'wp_loaded',
|
30 |
-
array ( new DB_Reset_Manager( DB_RESET_VERSION ), 'run' )
|
31 |
-
);
|
32 |
-
}
|
33 |
-
|
34 |
-
if ( is_command_line() ) {
|
35 |
-
require_once( __DIR__ . '/class-db-reset-command.php' );
|
36 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
js/jquery.bsmselect.compatibility.js
DELETED
@@ -1,60 +0,0 @@
|
|
1 |
-
/*
|
2 |
-
* Better Select Multiple Compatibility Plugin - jQuery 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.0.0 - 2010-09-05
|
9 |
-
*/
|
10 |
-
(function($) {
|
11 |
-
$.bsmSelect.plugins.compatibility = function()
|
12 |
-
{
|
13 |
-
if (!(this instanceof arguments.callee)) {
|
14 |
-
return new arguments.callee();
|
15 |
-
}
|
16 |
-
}
|
17 |
-
|
18 |
-
$.extend($.bsmSelect.plugins.compatibility.prototype, {
|
19 |
-
init: function(bsm) {
|
20 |
-
|
21 |
-
var o = bsm.options;
|
22 |
-
|
23 |
-
if (typeof o.animate != 'undefined')
|
24 |
-
{
|
25 |
-
if (o.animate === true) {
|
26 |
-
o.showEffect = $.bsmSelect.effects.verticalListAdd;
|
27 |
-
o.hideEffect = $.bsmSelect.effects.verticalListRemove;
|
28 |
-
} else if ($.isFunction(o.animate.add)) {
|
29 |
-
o.showEffect = o.animate.add;
|
30 |
-
} else if (typeof(o.animate.add) == 'string' && $.isFunction($.bsmSelect.effects[o.animate.add])) {
|
31 |
-
o.showEffect = $.bsmSelect.effects[o.animate.add];
|
32 |
-
} else {
|
33 |
-
o.showEffect = $.bsmSelect.effects.show;
|
34 |
-
}
|
35 |
-
|
36 |
-
if ($.isFunction(o.animate.drop)) {
|
37 |
-
o.hideEffect = o.animate.drop;
|
38 |
-
} else if (typeof(o.animate.drop) == 'string' && $.isFunction($.bsmSelect.effects[o.animate.drop])) {
|
39 |
-
o.hideEffect = $.bsmSelect.effects[o.animate.drop];
|
40 |
-
} else {
|
41 |
-
o.hideEffect = $.bsmSelect.effects.remove;
|
42 |
-
}
|
43 |
-
}
|
44 |
-
|
45 |
-
if (typeof o.highlight != 'undefined')
|
46 |
-
{
|
47 |
-
if (o.highlight === true) {
|
48 |
-
o.highlightEffect = $.bsmSelect.effects.highlight;
|
49 |
-
} else if ($.isFunction(o.highlight)) {
|
50 |
-
o.highlightEffect = o.highlight;
|
51 |
-
} else if (typeof(o.highlight) == 'string' && $.isFunction($.bsmSelect.effects[o.highlight])) {
|
52 |
-
o.highlightEffect = $.bsmSelect.effects[o.highlight];
|
53 |
-
}
|
54 |
-
}
|
55 |
-
|
56 |
-
}
|
57 |
-
|
58 |
-
});
|
59 |
-
})(jQuery);
|
60 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
js/jquery.bsmselect.js
DELETED
@@ -1,381 +0,0 @@
|
|
1 |
-
/*
|
2 |
-
* Better Select Multiple - jQuery Plugin
|
3 |
-
*
|
4 |
-
* based on Alternate Select Multiple (asmSelect) 1.0.4a beta (http://www.ryancramer.com/projects/asmselect/)
|
5 |
-
*
|
6 |
-
* Copyright (c) 2009 by Ryan Cramer - http://www.ryancramer.com
|
7 |
-
* Copyright (c) 2010 by Victor Berchet - http://www.github.com/vicb
|
8 |
-
*
|
9 |
-
* Dual licensed under the MIT (MIT-LICENSE.txt) and GPL (GPL-LICENSE.txt) licenses.
|
10 |
-
*
|
11 |
-
* bsmSelect version: v1.4.3 - 2011-05-05
|
12 |
-
*/
|
13 |
-
|
14 |
-
(function($) {
|
15 |
-
|
16 |
-
function BsmSelect(target, options)
|
17 |
-
{
|
18 |
-
this.$original = $(target); // the original select multiple
|
19 |
-
this.buildingSelect = false; // is the new select being constructed right now?
|
20 |
-
this.ieClick = false; // in IE, has a click event occurred? ignore if not
|
21 |
-
this.ignoreOriginalChangeEvent = false; // originalChangeEvent bypassed when this is true
|
22 |
-
this.options = options;
|
23 |
-
this.buildDom();
|
24 |
-
}
|
25 |
-
|
26 |
-
BsmSelect.prototype = {
|
27 |
-
/**
|
28 |
-
* Generate an UID
|
29 |
-
*/
|
30 |
-
generateUid: function(index) {
|
31 |
-
return (this.uid = this.options.containerClass + index);
|
32 |
-
},
|
33 |
-
|
34 |
-
/**
|
35 |
-
* Build the DOM for bsmSelect
|
36 |
-
*/
|
37 |
-
buildDom: function() {
|
38 |
-
var self = this, o = this.options;
|
39 |
-
|
40 |
-
if (o.addItemTarget === 'original') {
|
41 |
-
$('option', this.$original).each(function(i, o) {
|
42 |
-
if ($(o).data('bsm-order') === null) { $(o).data('bsm-order', i); }
|
43 |
-
});
|
44 |
-
}
|
45 |
-
|
46 |
-
for (var index = 0; $('#' + this.generateUid(index)).size(); index++) {}
|
47 |
-
|
48 |
-
this.$select = $('<select>', {
|
49 |
-
'class': o.selectClass,
|
50 |
-
name: o.selectClass + this.uid,
|
51 |
-
id: o.selectClass + this.uid,
|
52 |
-
change: $.proxy(this.selectChangeEvent, this),
|
53 |
-
click: $.proxy(this.selectClickEvent, this)
|
54 |
-
});
|
55 |
-
|
56 |
-
this.$list = $.isFunction(o.listType)
|
57 |
-
? o.listType(this.$original)
|
58 |
-
: $('<' + o.listType + '>', { id: o.listClass + this.uid });
|
59 |
-
|
60 |
-
this.$list.addClass(o.listClass);
|
61 |
-
|
62 |
-
this.$container = $('<div>', { 'class': o.containerClass, id: this.uid });
|
63 |
-
|
64 |
-
this.buildSelect();
|
65 |
-
|
66 |
-
this.$original.change($.proxy(this.originalChangeEvent, this)).wrap(this.$container).before(this.$select);
|
67 |
-
|
68 |
-
// if the list isn't already in the document, add it (it might be inserted by a custom callback)
|
69 |
-
if (!this.$list.parent().length) { this.$original.before(this.$list); }
|
70 |
-
|
71 |
-
if (this.$original.attr('id')) {
|
72 |
-
$('label[for=' + this.$original.attr('id') + ']').attr('for', this.$select.attr('id'));
|
73 |
-
}
|
74 |
-
|
75 |
-
// set up remove event (may be a link, or the list item itself)
|
76 |
-
this.$list.delegate('.' + o.removeClass, 'click', function() {
|
77 |
-
self.dropListItem($(this).closest('li'));
|
78 |
-
return false;
|
79 |
-
});
|
80 |
-
|
81 |
-
$.each(o.plugins, function() { this.init(self); });
|
82 |
-
},
|
83 |
-
|
84 |
-
/**
|
85 |
-
* Triggered when an item has been selected
|
86 |
-
* Check to make sure it's not an IE screwup, and add it to the list
|
87 |
-
*/
|
88 |
-
selectChangeEvent: function() {
|
89 |
-
if ($.browser.msie && $.browser.version < 7 && !this.ieClick) { return; }
|
90 |
-
var bsmOpt = $('option:selected:eq(0)', this.$select);
|
91 |
-
if (bsmOpt.data('orig-option')) {
|
92 |
-
this.addListItem(bsmOpt);
|
93 |
-
this.triggerOriginalChange(bsmOpt.data('orig-option'), 'add');
|
94 |
-
}
|
95 |
-
this.ieClick = false;
|
96 |
-
},
|
97 |
-
|
98 |
-
/**
|
99 |
-
* IE6 lets you scroll around in a select without it being pulled down
|
100 |
-
* making sure a click preceded the change() event reduces the chance
|
101 |
-
* if unintended items being added. there may be a better solution?
|
102 |
-
*/
|
103 |
-
selectClickEvent: function() {
|
104 |
-
this.ieClick = true;
|
105 |
-
},
|
106 |
-
|
107 |
-
/**
|
108 |
-
* Rebuild bsmSelect when the 'change' event is triggered on the original select
|
109 |
-
*/
|
110 |
-
originalChangeEvent: function() {
|
111 |
-
if (this.ignoreOriginalChangeEvent) {
|
112 |
-
// We don't want to rebuild everything when an item is added / droped
|
113 |
-
this.ignoreOriginalChangeEvent = false;
|
114 |
-
} else {
|
115 |
-
this.buildSelect();
|
116 |
-
// opera has an issue where it needs a force redraw, otherwise
|
117 |
-
// the items won't appear until something else forces a redraw
|
118 |
-
if ($.browser.opera) { this.$list.hide().show(); }
|
119 |
-
}
|
120 |
-
},
|
121 |
-
|
122 |
-
/**
|
123 |
-
* Build the DOM for the new select
|
124 |
-
*/
|
125 |
-
buildSelect: function() {
|
126 |
-
var self = this;
|
127 |
-
|
128 |
-
this.buildingSelect = true;
|
129 |
-
|
130 |
-
// add a first option to be the home option / default selectLabel
|
131 |
-
this.$select.empty().prepend($('<option value=""></option>').text(this.$original.attr('title') || this.options.title));
|
132 |
-
this.$list.empty();
|
133 |
-
|
134 |
-
this.$original.children().each(function() {
|
135 |
-
if ($(this).is('option')) {
|
136 |
-
self.addSelectOption(self.$select, $(this));
|
137 |
-
} else if ($(this).is('optgroup')) {
|
138 |
-
self.addSelectOptionGroup(self.$select, $(this));
|
139 |
-
}
|
140 |
-
});
|
141 |
-
|
142 |
-
if (!this.options.debugMode) { this.$original.hide(); }
|
143 |
-
this.selectFirstItem();
|
144 |
-
this.buildingSelect = false;
|
145 |
-
},
|
146 |
-
|
147 |
-
/**
|
148 |
-
* Append an option to the new select
|
149 |
-
*
|
150 |
-
* @param {jQuery} $parent Where to append the option
|
151 |
-
* @param {jQuery} $origOpt Option from the original select
|
152 |
-
*/
|
153 |
-
addSelectOption: function ($parent, $origOpt) {
|
154 |
-
var $bsmOpt = $('<option>', {
|
155 |
-
text: $origOpt.text(),
|
156 |
-
val: $origOpt.val() }).appendTo($parent).data('orig-option', $origOpt),
|
157 |
-
isSelected = $origOpt.is(':selected'),
|
158 |
-
isDisabled = $origOpt.is(':disabled');
|
159 |
-
$origOpt.data('bsm-option', $bsmOpt);
|
160 |
-
if (isSelected && !isDisabled) {
|
161 |
-
this.addListItem($bsmOpt);
|
162 |
-
this.disableSelectOption($bsmOpt);
|
163 |
-
} else if (!isSelected && isDisabled) {
|
164 |
-
this.disableSelectOption($bsmOpt);
|
165 |
-
}
|
166 |
-
},
|
167 |
-
|
168 |
-
/**
|
169 |
-
* Append an option group to the new select
|
170 |
-
*
|
171 |
-
* @param {jQuery} $parent Where to append the group
|
172 |
-
* @param {jQuery} $group Model group from the original select
|
173 |
-
*/
|
174 |
-
addSelectOptionGroup: function($parent, $group)
|
175 |
-
{
|
176 |
-
var self = this,
|
177 |
-
$G = $('<optgroup>', { label: $group.attr('label')} ).appendTo($parent);
|
178 |
-
if ($group.is(':disabled')) { $G.attr('disabled', 'disabled'); }
|
179 |
-
$('option', $group).each(function() { self.addSelectOption($G, $(this)); });
|
180 |
-
},
|
181 |
-
|
182 |
-
/**
|
183 |
-
* Select the first item of the new select
|
184 |
-
*/
|
185 |
-
selectFirstItem: function() {
|
186 |
-
$('option:eq(0)', this.$select).attr('selected', 'selected');
|
187 |
-
},
|
188 |
-
|
189 |
-
/**
|
190 |
-
* Make an option disabled, indicating that it's already been selected
|
191 |
-
* because safari is the only browser that makes disabled items look 'disabled'
|
192 |
-
* we apply a class that reproduces the disabled look in other browsers
|
193 |
-
*
|
194 |
-
* @param {jQuery} $bsmOpt Option from the new select
|
195 |
-
*/
|
196 |
-
disableSelectOption: function($bsmOpt) {
|
197 |
-
$bsmOpt.addClass(this.options.optionDisabledClass)
|
198 |
-
.removeAttr('selected')
|
199 |
-
.attr('disabled', 'disabled')
|
200 |
-
.toggle(!this.options.hideWhenAdded);
|
201 |
-
if ($.browser.msie && $.browser.version < 8) { this.$select.hide().show(); } // this forces IE to update display
|
202 |
-
},
|
203 |
-
|
204 |
-
/**
|
205 |
-
* Enable a select option
|
206 |
-
*
|
207 |
-
* @param {jQuery} $bsmOpt Option from the new select
|
208 |
-
*/
|
209 |
-
enableSelectOption: function($bsmOpt) {
|
210 |
-
$bsmOpt.removeClass(this.options.optionDisabledClass)
|
211 |
-
.removeAttr('disabled')
|
212 |
-
.toggle(!this.options.hideWhenAdded);
|
213 |
-
if ($.browser.msie && $.browser.version < 8) { this.$select.hide().show(); } // this forces IE to update display
|
214 |
-
},
|
215 |
-
|
216 |
-
/**
|
217 |
-
* Append an item corresponding to the option to the list
|
218 |
-
*
|
219 |
-
* @param {jQuery} $bsmOpt Option from the new select
|
220 |
-
*/
|
221 |
-
addListItem: function($bsmOpt) {
|
222 |
-
var $item,
|
223 |
-
$origOpt = $bsmOpt.data('orig-option'),
|
224 |
-
o = this.options;
|
225 |
-
|
226 |
-
if (!$origOpt) { return; } // this is the first item, selectLabel
|
227 |
-
|
228 |
-
if (!this.buildingSelect) {
|
229 |
-
if ($origOpt.is(':selected')) { return; } // already have it
|
230 |
-
$origOpt.attr('selected', 'selected');
|
231 |
-
}
|
232 |
-
|
233 |
-
$item = $('<li>', { 'class': o.listItemClass })
|
234 |
-
.append($('<span>', { 'class': o.listItemLabelClass, html: o.extractLabel($bsmOpt, o)}))
|
235 |
-
.append($('<a>', { href: '#', 'class': o.removeClass, html: o.removeLabel }))
|
236 |
-
.data('bsm-option', $bsmOpt);
|
237 |
-
|
238 |
-
this.disableSelectOption($bsmOpt.data('item', $item));
|
239 |
-
|
240 |
-
switch (o.addItemTarget) {
|
241 |
-
case 'bottom':
|
242 |
-
this.$list.append($item.hide());
|
243 |
-
break;
|
244 |
-
case 'original':
|
245 |
-
var order = $origOpt.data('bsm-order'), inserted = false;
|
246 |
-
$('.' + o.listItemClass, this.$list).each(function() {
|
247 |
-
if (order < $(this).data('bsm-option').data('orig-option').data('bsm-order')) {
|
248 |
-
$item.hide().insertBefore(this);
|
249 |
-
inserted = true;
|
250 |
-
return false;
|
251 |
-
}
|
252 |
-
});
|
253 |
-
if (!inserted) { this.$list.append($item.hide()); }
|
254 |
-
break;
|
255 |
-
default:
|
256 |
-
this.$list.prepend($item.hide());
|
257 |
-
}
|
258 |
-
|
259 |
-
if (this.buildingSelect) {
|
260 |
-
$.bsmSelect.effects.show($item);
|
261 |
-
} else {
|
262 |
-
o.showEffect($item);
|
263 |
-
o.highlightEffect(this.$select, $item, o.highlightAddedLabel, this.options);
|
264 |
-
this.selectFirstItem();
|
265 |
-
}
|
266 |
-
},
|
267 |
-
|
268 |
-
/**
|
269 |
-
* Remove an item from the list of selection
|
270 |
-
*
|
271 |
-
* @param {jQuey} $item A list item
|
272 |
-
*/
|
273 |
-
dropListItem: function($item) {
|
274 |
-
var $bsmOpt = $item.data('bsm-option'), o = this.options;
|
275 |
-
$bsmOpt.removeData('item').data('orig-option').removeAttr('selected');
|
276 |
-
(this.buildingSelect ? $.bsmSelect.effects.remove : o.hideEffect)($item);
|
277 |
-
this.enableSelectOption($bsmOpt);
|
278 |
-
o.highlightEffect(this.$select, $item, o.highlightRemovedLabel, o);
|
279 |
-
this.triggerOriginalChange($bsmOpt.data('orig-option'), 'drop');
|
280 |
-
},
|
281 |
-
|
282 |
-
/**
|
283 |
-
* Trigger a change event on the original select multiple
|
284 |
-
* so that other scripts can pick them up
|
285 |
-
*
|
286 |
-
* @param {jQuery} $origOpt The option from the original select
|
287 |
-
* @param {String} type Event type
|
288 |
-
*/
|
289 |
-
triggerOriginalChange: function($origOpt, type) {
|
290 |
-
this.ignoreOriginalChangeEvent = true;
|
291 |
-
this.$original.trigger('change', [{
|
292 |
-
option: $origOpt,
|
293 |
-
value: $origOpt.val(),
|
294 |
-
item: $origOpt.data('bsm-option').data('item'),
|
295 |
-
type: type
|
296 |
-
}]);
|
297 |
-
}
|
298 |
-
};
|
299 |
-
|
300 |
-
$.fn.bsmSelect = function(customOptions) {
|
301 |
-
var options = $.extend({}, $.bsmSelect.conf, customOptions);
|
302 |
-
return this.each(function() {
|
303 |
-
var bsm = $(this).data("bsmSelect");
|
304 |
-
if (!bsm) {
|
305 |
-
bsm = new BsmSelect($(this), options);
|
306 |
-
$(this).data("bsmSelect", bsm);
|
307 |
-
}
|
308 |
-
});
|
309 |
-
};
|
310 |
-
|
311 |
-
$.bsmSelect = {};
|
312 |
-
$.extend($.bsmSelect, {
|
313 |
-
effects: {
|
314 |
-
show: function($el) { $el.show(); },
|
315 |
-
|
316 |
-
remove: function($el) { $el.remove(); },
|
317 |
-
|
318 |
-
highlight: function ($select, $item, label, conf) {
|
319 |
-
var $highlight,
|
320 |
-
id = $select.attr('id') + conf.highlightClass;
|
321 |
-
$('#' + id).remove();
|
322 |
-
$highlight = $('<span>', {
|
323 |
-
'class': conf.highlightClass,
|
324 |
-
id: id,
|
325 |
-
html: label + $item.children('.' + conf.listItemLabelClass).first().text()
|
326 |
-
}).hide();
|
327 |
-
$select.after($highlight.fadeIn('fast').delay(50).fadeOut('slow', function() { $(this).remove(); }));
|
328 |
-
},
|
329 |
-
|
330 |
-
verticalListAdd: function ($el) {
|
331 |
-
$el.animate({ opacity: 'show', height: 'show' }, 100, function() {
|
332 |
-
$(this).animate({ height: '+=2px' }, 100, function() {
|
333 |
-
$(this).animate({ height: '-=2px' }, 100);
|
334 |
-
});
|
335 |
-
});
|
336 |
-
},
|
337 |
-
|
338 |
-
verticalListRemove: function($el) {
|
339 |
-
$el.animate({ opacity: 'hide', height: 'hide' }, 100, function() {
|
340 |
-
$(this).prev('li').animate({ height: '-=2px' }, 100, function() {
|
341 |
-
$(this).animate({ height: '+=2px' }, 100);
|
342 |
-
});
|
343 |
-
$(this).remove();
|
344 |
-
});
|
345 |
-
}
|
346 |
-
},
|
347 |
-
plugins: {
|
348 |
-
}
|
349 |
-
});
|
350 |
-
|
351 |
-
// Default configuration
|
352 |
-
$.bsmSelect.conf = {
|
353 |
-
listType: 'ol', // Ordered list 'ol', or unordered list 'ul'
|
354 |
-
|
355 |
-
showEffect: $.bsmSelect.effects.show,
|
356 |
-
hideEffect: $.bsmSelect.effects.remove,
|
357 |
-
highlightEffect: $.noop,
|
358 |
-
|
359 |
-
addItemTarget: 'bottom', // Where to place new selected items in list: top or bottom
|
360 |
-
hideWhenAdded: false, // Hide the option when added to the list? works only in FF
|
361 |
-
debugMode: false, // Debug mode keeps original select visible
|
362 |
-
|
363 |
-
title: 'Select...', // Text used for the default select label
|
364 |
-
removeLabel: 'remove', // HTML used for the 'remove' link
|
365 |
-
highlightAddedLabel: 'Added: ', // Text that precedes highlight of added item
|
366 |
-
highlightRemovedLabel: 'Removed: ', // Text that precedes highlight of removed item
|
367 |
-
extractLabel: function($o) { return $o.html(); },
|
368 |
-
|
369 |
-
plugins: [], // An array of plugin objects to enable
|
370 |
-
|
371 |
-
containerClass: 'bsmContainer', // Class for container that wraps this widget
|
372 |
-
selectClass: 'bsmSelect', // Class for the newly created <select>
|
373 |
-
optionDisabledClass: 'bsmOptionDisabled', // Class for items that are already selected / disabled
|
374 |
-
listClass: 'bsmList', // Class for the list ($list)
|
375 |
-
listItemClass: 'bsmListItem', // Class for the <li> list items
|
376 |
-
listItemLabelClass: 'bsmListItemLabel', // Class for the label text that appears in list items
|
377 |
-
removeClass: 'bsmListItemRemove', // Class given to the 'remove' link
|
378 |
-
highlightClass: 'bsmHighlight' // Class given to the highlight <span>
|
379 |
-
};
|
380 |
-
|
381 |
-
})(jQuery);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
languages/wordpress-database-reset.pot
CHANGED
@@ -1,81 +1,73 @@
|
|
1 |
-
msgid ""
|
2 |
-
msgstr ""
|
3 |
-
"Project-Id-Version:
|
4 |
-
"
|
5 |
-
"
|
6 |
-
"
|
7 |
-
"
|
8 |
-
"Language
|
9 |
-
"MIME-Version: 1.0\n"
|
10 |
-
"Content-Type: text/plain; charset=UTF-8\n"
|
11 |
-
"Content-Transfer-Encoding: 8bit\n"
|
12 |
-
"X-
|
13 |
-
"X-Poedit-Basepath:
|
14 |
-
"
|
15 |
-
"X-Poedit-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
msgid "
|
44 |
-
msgstr ""
|
45 |
-
|
46 |
-
#:
|
47 |
-
msgid "The
|
48 |
-
msgstr ""
|
49 |
-
|
50 |
-
#:
|
51 |
-
msgid "
|
52 |
-
msgstr ""
|
53 |
-
|
54 |
-
#:
|
55 |
-
msgid "
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
#: wp-reset.php:251
|
75 |
-
msgid "The WordPress database has been successfully reset to its default settings:"
|
76 |
-
msgstr ""
|
77 |
-
|
78 |
-
#: wp-reset.php:252
|
79 |
-
msgid "Password: The password you chose during the install."
|
80 |
-
msgstr ""
|
81 |
-
|
1 |
+
msgid ""
|
2 |
+
msgstr ""
|
3 |
+
"Project-Id-Version: \n"
|
4 |
+
"POT-Creation-Date: 2015-09-26 08:45-0400\n"
|
5 |
+
"PO-Revision-Date: 2015-09-26 08:47-0400\n"
|
6 |
+
"Last-Translator: \n"
|
7 |
+
"Language-Team: \n"
|
8 |
+
"Language: en_CA\n"
|
9 |
+
"MIME-Version: 1.0\n"
|
10 |
+
"Content-Type: text/plain; charset=UTF-8\n"
|
11 |
+
"Content-Transfer-Encoding: 8bit\n"
|
12 |
+
"X-Generator: Poedit 1.8.4\n"
|
13 |
+
"X-Poedit-Basepath: ..\n"
|
14 |
+
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
|
15 |
+
"X-Poedit-KeywordsList: e_;__\n"
|
16 |
+
"X-Poedit-SearchPath-0: .\n"
|
17 |
+
|
18 |
+
#: class-db-reset-admin.php:85 class-db-reset-command.php:92
|
19 |
+
msgid "The selected tables were reset"
|
20 |
+
msgstr ""
|
21 |
+
|
22 |
+
#: class-db-reset-admin.php:104
|
23 |
+
msgid "You entered the wrong security code"
|
24 |
+
msgstr ""
|
25 |
+
|
26 |
+
#: class-db-reset-admin.php:113 class-db-reset-admin.php:114
|
27 |
+
msgid "Database Reset"
|
28 |
+
msgstr ""
|
29 |
+
|
30 |
+
#: class-db-reset-admin.php:182
|
31 |
+
msgid "Are you sure you want to continue?"
|
32 |
+
msgstr ""
|
33 |
+
|
34 |
+
#: class-db-reset-admin.php:183
|
35 |
+
msgid "Select Tables"
|
36 |
+
msgstr ""
|
37 |
+
|
38 |
+
#: class-db-reset-command.php:95
|
39 |
+
msgid "The current theme and plugins were reactivated"
|
40 |
+
msgstr ""
|
41 |
+
|
42 |
+
#: class-db-resetter.php:34
|
43 |
+
msgid "You did not select any database tables"
|
44 |
+
msgstr ""
|
45 |
+
|
46 |
+
#: lib/helpers.php:29
|
47 |
+
msgid "The WordPress Database Reset plugin requires at least PHP 5.3!"
|
48 |
+
msgstr ""
|
49 |
+
|
50 |
+
#: lib/helpers.php:33
|
51 |
+
msgid "The WordPress Database Reset plugin requires at least WordPress 3.0!"
|
52 |
+
msgstr ""
|
53 |
+
|
54 |
+
#: lib/helpers.php:111
|
55 |
+
msgid ""
|
56 |
+
"<strong><em>Note that password</em></strong> carefully! It is a <em>random</"
|
57 |
+
"em> password that was generated just for you."
|
58 |
+
msgstr ""
|
59 |
+
|
60 |
+
#: lib/helpers.php:117
|
61 |
+
msgid "Your chosen password."
|
62 |
+
msgstr ""
|
63 |
+
|
64 |
+
#: lib/helpers.php:120
|
65 |
+
msgid "User already exists. Password inherited."
|
66 |
+
msgstr ""
|
67 |
+
|
68 |
+
#: views/partials/disclaimer.php:2
|
69 |
+
#, php-format
|
70 |
+
msgid ""
|
71 |
+
"You selected the users table. Only the <strong><u>%s</u></strong> user will "
|
72 |
+
"be restored"
|
73 |
+
msgstr ""
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
readme.txt
CHANGED
@@ -4,8 +4,8 @@ Contributors: mousesports
|
|
4 |
Tags: wordpress, database, reset, restore, setup, developer, theme, default, secure
|
5 |
License: GPL2
|
6 |
Requires at least: 3.0
|
7 |
-
Tested up to: 4.
|
8 |
-
Stable tag: 3.0
|
9 |
|
10 |
A plugin that allows you to skip the 5 minute installation and reset WordPress's database back to its original state.
|
11 |
|
@@ -43,6 +43,10 @@ Create a new post in the [WordPress Database Reset support forum](https://wordpr
|
|
43 |
1. The WordPress Database Reset plugin page
|
44 |
|
45 |
== Changelog ==
|
|
|
|
|
|
|
|
|
46 |
= 3.0.0 =
|
47 |
* Completely re-written from scratch
|
48 |
* Add extended WP_CLI command class
|
4 |
Tags: wordpress, database, reset, restore, setup, developer, theme, default, secure
|
5 |
License: GPL2
|
6 |
Requires at least: 3.0
|
7 |
+
Tested up to: 4.3.1
|
8 |
+
Stable tag: 3.0.1
|
9 |
|
10 |
A plugin that allows you to skip the 5 minute installation and reset WordPress's database back to its original state.
|
11 |
|
43 |
1. The WordPress Database Reset plugin page
|
44 |
|
45 |
== Changelog ==
|
46 |
+
= 3.0.1 =
|
47 |
+
* Fix plugin disabled after update, thanks to Ulrich Pogson
|
48 |
+
* Update the pot file
|
49 |
+
|
50 |
= 3.0.0 =
|
51 |
* Completely re-written from scratch
|
52 |
* Add extended WP_CLI command class
|
wp-reset.php
CHANGED
@@ -1,453 +1,36 @@
|
|
1 |
-
<?php
|
2 |
-
/*
|
3 |
-
Plugin Name: WordPress Database Reset
|
4 |
-
Plugin URI: https://github.com/chrisberthe/wordpress-database-reset
|
5 |
-
Description: A plugin that allows you to
|
6 |
-
Version:
|
7 |
-
Author: Chris Berthe
|
8 |
-
Author URI: https://github.com/chrisberthe
|
9 |
-
License: GNU General Public License
|
10 |
-
Text
|
11 |
-
*/
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
function __construct() {
|
38 |
-
add_action( 'init', array( $this, 'init_language' ) );
|
39 |
-
add_action( 'admin_init', array( $this, 'wp_reset_init' ) );
|
40 |
-
add_action( 'admin_init', array( $this, '_redirect_user' ) );
|
41 |
-
add_action( 'admin_menu', array( $this, 'add_admin_menu' ) );
|
42 |
-
add_filter( 'wp_mail', array( $this, '_fix_mail' ) );
|
43 |
-
}
|
44 |
-
|
45 |
-
/**
|
46 |
-
* Handles the admin page functionality
|
47 |
-
*
|
48 |
-
* @access public
|
49 |
-
* @uses wp_install Located in includes/upgrade.php (line 22)
|
50 |
-
*/
|
51 |
-
function wp_reset_init() {
|
52 |
-
global $wpdb, $current_user, $pagenow;
|
53 |
-
|
54 |
-
// Grab the WordPress database tables
|
55 |
-
$this->_wp_tables = $wpdb->tables();
|
56 |
-
|
57 |
-
// Check for valid input - goes ahead and drops / resets tables
|
58 |
-
if ( isset( $_POST['wp-random-value'], $_POST['wp-reset-input'] ) && $_POST['wp-random-value'] == $_POST['wp-reset-input']
|
59 |
-
&& check_admin_referer( 'wp-nonce-submit', $this->_nonce ) ) {
|
60 |
-
|
61 |
-
require_once( ABSPATH . '/wp-admin/includes/upgrade.php' );
|
62 |
-
|
63 |
-
// No tables were selected
|
64 |
-
if ( empty( $_POST['tables'] ) ) {
|
65 |
-
wp_redirect( admin_url( $pagenow ) . '?page=wp-reset&reset=no-select' );
|
66 |
-
exit();
|
67 |
-
}
|
68 |
-
|
69 |
-
// Get current options
|
70 |
-
$blog_title = get_option( 'blogname' );
|
71 |
-
$public = get_option( 'blog_public' );
|
72 |
-
|
73 |
-
$admin_user = get_user_by( 'login', 'admin' );
|
74 |
-
$user = ( ! $admin_user || ! user_can( $admin_user->ID, 'update_core' ) ) ? $current_user : $admin_user;
|
75 |
-
|
76 |
-
// Get the selected tables
|
77 |
-
$tables = ( isset( $_POST['tables'] ) ) ? array_flip( $_POST['tables'] ) : array();
|
78 |
-
|
79 |
-
// Compare the selected tables against the ones in the database
|
80 |
-
$this->_tables = array_diff_key( $this->_wp_tables, $tables );
|
81 |
-
|
82 |
-
// Preserve the data from the tables that are unique
|
83 |
-
if ( 0 < count( $this->_tables ) ) {
|
84 |
-
$backup_tables = $this->_back_up_tables( $this->_tables );
|
85 |
-
}
|
86 |
-
|
87 |
-
// Grab the currently active plugins and theme
|
88 |
-
if ( ! empty($_POST['wp-reset-check']) ) {
|
89 |
-
$current_data = array(
|
90 |
-
'active-plugins' => get_option( 'active_plugins' ),
|
91 |
-
'current-theme' => get_option( 'current_theme' ),
|
92 |
-
'template' => get_option( 'template' ),
|
93 |
-
'stylesheet' => get_option( 'stylesheet' )
|
94 |
-
);
|
95 |
-
}
|
96 |
-
|
97 |
-
// Run through the database columns, drop all the tables and
|
98 |
-
// install wp with previous settings
|
99 |
-
if ( ! empty( $this->_wp_tables ) ) {
|
100 |
-
foreach ( $this->_wp_tables as $wp_table ) {
|
101 |
-
$wpdb->query( "DROP TABLE {$wp_table}" );
|
102 |
-
}
|
103 |
-
$keys = wp_install( $blog_title, $user->user_login, $user->user_email, $public );
|
104 |
-
$this->_wp_update_user( $user, $keys );
|
105 |
-
}
|
106 |
-
|
107 |
-
// Delete and replace tables with the backed up table data
|
108 |
-
if ( ! empty( $backup_tables ) ) {
|
109 |
-
foreach ( $this->_tables as $table ) {
|
110 |
-
$wpdb->query( "DELETE FROM " . $table );
|
111 |
-
}
|
112 |
-
$this->_restore_tables( $backup_tables );
|
113 |
-
}
|
114 |
-
|
115 |
-
if ( get_user_meta( $current_user->ID, 'session_tokens' ) ) {
|
116 |
-
delete_user_meta( $current_user->ID, 'session_tokens' );
|
117 |
-
}
|
118 |
-
|
119 |
-
wp_clear_auth_cookie();
|
120 |
-
wp_set_auth_cookie( $current_user->ID );
|
121 |
-
|
122 |
-
if ( ! empty( $current_data ) ) {
|
123 |
-
update_option( 'active_plugins', $current_data['active-plugins'] );
|
124 |
-
|
125 |
-
if ( ! empty( $current_data['current-theme'] ) ) {
|
126 |
-
update_option( 'current_theme', $current_data['current-theme'] );
|
127 |
-
}
|
128 |
-
|
129 |
-
update_option( 'template', $current_data['template'] );
|
130 |
-
update_option( 'stylesheet', $current_data['stylesheet'] );
|
131 |
-
|
132 |
-
wp_redirect( admin_url( $pagenow ) . '?page=wp-reset&reset=success' );
|
133 |
-
exit();
|
134 |
-
}
|
135 |
-
|
136 |
-
wp_redirect( admin_url() );
|
137 |
-
exit();
|
138 |
-
}
|
139 |
-
}
|
140 |
-
|
141 |
-
/**
|
142 |
-
* Displays the admin page
|
143 |
-
*
|
144 |
-
* @access public
|
145 |
-
* @return void
|
146 |
-
*/
|
147 |
-
function show_admin_page() {
|
148 |
-
global $current_user;
|
149 |
-
|
150 |
-
// Return to see if admin object exists
|
151 |
-
$admin_user = get_user_by( 'login', 'admin' );
|
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>
|
156 |
-
<?php elseif ( isset( $_GET['reset'] ) && 'no-select' == $_GET['reset'] ) : ?>
|
157 |
-
<div class="error"><p><strong><?php _e( 'You did not select any database tables', 'wp-reset' ) ?>.</strong></p></div>
|
158 |
-
<?php elseif ( isset( $_GET['reset'] ) && 'success' == $_GET['reset'] ) : ?>
|
159 |
-
<div class="updated"><p><strong><?php _e( 'The WordPress database has been reset successfully', 'wp-reset' ) ?>.</strong></p></div>
|
160 |
-
<?php endif ?>
|
161 |
-
|
162 |
-
<div class="wrap">
|
163 |
-
<?php screen_icon() ?>
|
164 |
-
<h2><?php _e( 'Database Reset', 'wp-reset' ) ?></h2>
|
165 |
-
<form action="" method="POST" id="wp-reset-form">
|
166 |
-
<p><?php _e( 'Please choose from the following database tables the ones you would like to reset', 'wp-reset' ) ?>:</p>
|
167 |
-
<div id="select-buttons">
|
168 |
-
<span><a href='#' id="select-all"><?php _e( 'Select All', 'wp-reset' ) ?></a></span>
|
169 |
-
<select id="wp-tables" multiple="multiple" name="tables[]">
|
170 |
-
<?php foreach ( $this->_wp_tables as $key => $value ) : ?>
|
171 |
-
<option value="<?php echo $key ?>"><?php echo $key ?></option>
|
172 |
-
<?php endforeach ?>
|
173 |
-
</select>
|
174 |
-
</div>
|
175 |
-
<p><?php _e( 'Type in (or copy/paste) the generated value into the text box', 'wp-reset' ) ?>: <strong><?php echo $random_string ?></strong></p>
|
176 |
-
<?php wp_nonce_field( 'wp-nonce-submit', $this->_nonce ) ?>
|
177 |
-
<input type="hidden" name="wp-random-value" value="<?php echo $random_string ?>" id="wp-random-value" />
|
178 |
-
<input type="text" name="wp-reset-input" value="" id="wp-reset-input" />
|
179 |
-
<input type="submit" name="wp-reset-submit" value="<?php _e( 'Reset Database', 'wp-reset' ) ?>" id="wp-reset-submit" class="button-primary" />
|
180 |
-
<img src="<?php echo plugins_url( 'css/i/ajax-loader.gif', __FILE__ ) ?>" alt="loader" id="loader" style="display: none" />
|
181 |
-
<div id="reactivate" style="display: none">
|
182 |
-
<p>
|
183 |
-
<label for="wp-reset-check">
|
184 |
-
<input type="checkbox" name="wp-reset-check" id="wp-reset-check" checked="checked" value="true" />
|
185 |
-
<?php _e( 'Reactivate current plugins and theme after reset?', 'wp-reset' ) ?>
|
186 |
-
</label>
|
187 |
-
</p>
|
188 |
-
</div>
|
189 |
-
</form>
|
190 |
-
|
191 |
-
<?php if ( ! $admin_user || ! user_can( $admin_user->ID, 'update_core' ) ) : ?>
|
192 |
-
<p style="margin-top: 25px"><?php printf( __( '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', 'wp-reset' ), $current_user->user_login ) ?>.</p>
|
193 |
-
<?php else : ?>
|
194 |
-
<p><?php _e( 'The default user <strong><u>admin</u></strong> will be recreated with its current password upon resetting', 'wp-reset' ) ?>.</p>
|
195 |
-
<?php endif ?>
|
196 |
-
|
197 |
-
<p><?php _e( 'Note that once you reset the database, all users will be deleted except the initial admin user.', 'wp-reset' ) ?></p>
|
198 |
-
</div>
|
199 |
-
<?php }
|
200 |
-
|
201 |
-
/**
|
202 |
-
* Add JavaScript to the bottom of the plugin page
|
203 |
-
*
|
204 |
-
* @access public
|
205 |
-
* @return bool TRUE on reset confirmation
|
206 |
-
*/
|
207 |
-
function add_admin_javascript() {
|
208 |
-
?>
|
209 |
-
<script type="text/javascript">
|
210 |
-
/* <![CDATA[ */
|
211 |
-
(function( $ ) {
|
212 |
-
|
213 |
-
$( '#wp-tables' ).bsmSelect({
|
214 |
-
animate: true,
|
215 |
-
title: "<?php _e( 'Select Table', 'wp-reset' ) ?>",
|
216 |
-
plugins: [$.bsmSelect.plugins.compatibility()]
|
217 |
-
});
|
218 |
-
|
219 |
-
$( '#select-all' ).click(function() {
|
220 |
-
$( '#wp-tables' ).children()
|
221 |
-
.attr( 'selected', 'selected' )
|
222 |
-
.end()
|
223 |
-
.change();
|
224 |
-
|
225 |
-
return false;
|
226 |
-
});
|
227 |
-
|
228 |
-
$( '#wp-reset-submit' ).click(function() {
|
229 |
-
var message = "<?php _e( 'Clicking OK will result in your database being reset to its initial settings. Continue?', 'wp-reset' ) ?>",
|
230 |
-
reset = confirm( message );
|
231 |
-
|
232 |
-
if (reset) {
|
233 |
-
$( '#wp-reset-form' ).submit();
|
234 |
-
$( '#loader' ).show();
|
235 |
-
} else {
|
236 |
-
return false;
|
237 |
-
}
|
238 |
-
});
|
239 |
-
|
240 |
-
$( '#wp-tables' ).change(function() {
|
241 |
-
$( '#reactivate' ).toggle( $( "option[value='options']:selected", this ).length > 0 );
|
242 |
-
});
|
243 |
-
|
244 |
-
})( jQuery );
|
245 |
-
/* ]]> */
|
246 |
-
</script>
|
247 |
-
<?php
|
248 |
-
}
|
249 |
-
|
250 |
-
/**
|
251 |
-
* Adds our submenu item to the Tools menu
|
252 |
-
*
|
253 |
-
* @access public
|
254 |
-
* @return void
|
255 |
-
*/
|
256 |
-
function add_admin_menu() {
|
257 |
-
if ( current_user_can( 'update_core' ) ) {
|
258 |
-
$this->_hook = add_submenu_page( 'tools.php', 'Database Reset', 'Database Reset', 'update_core', 'wp-reset', array( $this, 'show_admin_page' ) );
|
259 |
-
add_action( 'load-' . $this->_hook, array( $this, 'option_page_actions' ) );
|
260 |
-
}
|
261 |
-
}
|
262 |
-
|
263 |
-
/**
|
264 |
-
* Fires actions on option page load
|
265 |
-
*
|
266 |
-
* @access public
|
267 |
-
* @return void
|
268 |
-
*/
|
269 |
-
function option_page_actions() {
|
270 |
-
add_action( 'admin_enqueue_scripts', array( $this, 'add_plugin_styles_and_scripts' ) );
|
271 |
-
add_action( 'admin_footer', array( $this, 'add_admin_javascript' ) );
|
272 |
-
$this->_add_help_screen();
|
273 |
-
}
|
274 |
-
|
275 |
-
/**
|
276 |
-
* Adds v3.3 style help menu for plugin page
|
277 |
-
*
|
278 |
-
* @access private
|
279 |
-
* @return void
|
280 |
-
*/
|
281 |
-
function _add_help_screen() {
|
282 |
-
get_current_screen()->add_help_tab( array(
|
283 |
-
'id' => 'overview',
|
284 |
-
'title' => __( 'Overview' ),
|
285 |
-
'content' =>
|
286 |
-
'<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>' .
|
287 |
-
'<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>'
|
288 |
-
) );
|
289 |
-
get_current_screen()->add_help_tab( array(
|
290 |
-
'id' => 'instructions',
|
291 |
-
'title' => __( 'Instructions' ),
|
292 |
-
'content' =>
|
293 |
-
'<p>' . __( 'Performing a database reset is quite straightforward.' ) . '</p>' .
|
294 |
-
'<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>' .
|
295 |
-
'<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>' .
|
296 |
-
'<p>' . __( 'Once you are sure you would like to proceed, click <code>OK</code> to reset.' ) . '</p>'
|
297 |
-
) );
|
298 |
-
|
299 |
-
get_current_screen()->set_help_sidebar(
|
300 |
-
'<p><strong>' . __( 'Contact information:' ) . '</strong></p>' .
|
301 |
-
'<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>'
|
302 |
-
);
|
303 |
-
}
|
304 |
-
|
305 |
-
/**
|
306 |
-
* Adds any plugin styles to our page
|
307 |
-
*
|
308 |
-
* @access public
|
309 |
-
* @return void
|
310 |
-
*/
|
311 |
-
function add_plugin_styles_and_scripts() {
|
312 |
-
wp_enqueue_style( 'wordpress-reset-css', plugins_url( 'css/wp-reset.css', __FILE__ ) );
|
313 |
-
wp_enqueue_style( 'bsmselect-css', plugins_url( 'css/jquery.bsmselect.css', __FILE__ ) );
|
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 |
-
/**
|
320 |
-
* Load language path
|
321 |
-
*
|
322 |
-
* @access public
|
323 |
-
* @return void
|
324 |
-
*/
|
325 |
-
function init_language() {
|
326 |
-
$language_dir = basename( dirname( __FILE__ ) ) . '/languages';
|
327 |
-
load_plugin_textdomain( 'wp-reset', false, $language_dir );
|
328 |
-
}
|
329 |
-
|
330 |
-
/**
|
331 |
-
* For activation hook
|
332 |
-
*
|
333 |
-
* @access public
|
334 |
-
* @return void
|
335 |
-
*/
|
336 |
-
function plugin_activate() {
|
337 |
-
add_option( 'wp-reset-activated', true );
|
338 |
-
}
|
339 |
-
|
340 |
-
/**
|
341 |
-
* Redirects the user after the plugin is activated
|
342 |
-
*
|
343 |
-
* @access private
|
344 |
-
* @return void
|
345 |
-
*/
|
346 |
-
function _redirect_user() {
|
347 |
-
if ( get_option( 'wp-reset-activated', false ) ) {
|
348 |
-
delete_option( 'wp-reset-activated' );
|
349 |
-
wp_redirect( admin_url( 'tools.php' ) . '?page=wp-reset' );
|
350 |
-
}
|
351 |
-
}
|
352 |
-
|
353 |
-
/**
|
354 |
-
* Changes the password to a sentence rather than
|
355 |
-
* an auto-generated password that is sent by email
|
356 |
-
* right after the installation is complete
|
357 |
-
*
|
358 |
-
* @access private
|
359 |
-
* @return $mail Version with password changed
|
360 |
-
*/
|
361 |
-
function _fix_mail( $mail ) {
|
362 |
-
$subject = __( 'WordPress Database Reset', 'wp-reset' );
|
363 |
-
$message = __( 'The tables you selected have been successfully reset to their default settings:', 'wp-reset' );
|
364 |
-
$password = __( 'Password: The password you chose during the install.', 'wp-reset' );
|
365 |
-
|
366 |
-
if ( stristr( $mail['message'], 'Your new WordPress site has been successfully set up at:' ) ) {
|
367 |
-
$mail['subject'] = preg_replace( '/New WordPress Site/', $subject, $mail['subject'] );
|
368 |
-
$mail['message'] = preg_replace( '/Your new WordPress site has been successfully set up at:+/', $message, $mail['message'] );
|
369 |
-
$mail['message'] = preg_replace( '/Password:\s.+/', $password, $mail['message'] );
|
370 |
-
}
|
371 |
-
return $mail;
|
372 |
-
}
|
373 |
-
|
374 |
-
/**
|
375 |
-
* Preserves all the results from the tables the user
|
376 |
-
* did not select from the drop-down.
|
377 |
-
*
|
378 |
-
* @access private
|
379 |
-
* @return array Backed up data if type backup
|
380 |
-
*/
|
381 |
-
function _back_up_tables( $tables ) {
|
382 |
-
global $wpdb;
|
383 |
-
|
384 |
-
if ( is_array( $tables ) ) {
|
385 |
-
$backup_tables = array();
|
386 |
-
|
387 |
-
foreach ( $tables as $table ) {
|
388 |
-
$backup_tables[$table] = $wpdb->get_results( "SELECT * FROM " . $table );
|
389 |
-
}
|
390 |
-
|
391 |
-
return $backup_tables;
|
392 |
-
}
|
393 |
-
return;
|
394 |
-
}
|
395 |
-
|
396 |
-
/**
|
397 |
-
* Restores the data from the tables the user did not
|
398 |
-
* select during the backing up phase.
|
399 |
-
*
|
400 |
-
* @access private
|
401 |
-
* @return void
|
402 |
-
*/
|
403 |
-
function _restore_tables( $tables ) {
|
404 |
-
global $wpdb;
|
405 |
-
|
406 |
-
if ( is_array( $tables ) ) {
|
407 |
-
foreach ( $tables as $table_name => $table_data ) {
|
408 |
-
foreach ( $table_data as $row ) {
|
409 |
-
$columns = $values = array();
|
410 |
-
|
411 |
-
foreach ( $row as $column => $value ) {
|
412 |
-
$columns[] = $column;
|
413 |
-
$values[] = esc_sql( $value );
|
414 |
-
}
|
415 |
-
|
416 |
-
$wpdb->query( "INSERT INTO $table_name (" . implode( ', ', $columns ) . ") VALUES ('" . implode( "', '", $values ) . "')" );
|
417 |
-
}
|
418 |
-
}
|
419 |
-
}
|
420 |
-
return;
|
421 |
-
}
|
422 |
-
|
423 |
-
/**
|
424 |
-
* Updates the user password and clears / sets
|
425 |
-
* the authentication cookie for the user
|
426 |
-
*
|
427 |
-
* @access private
|
428 |
-
* @param $user Current or admin user
|
429 |
-
* @param $keys Array returned by wp_install()
|
430 |
-
* @return true on install success, false otherwise
|
431 |
-
*/
|
432 |
-
function _wp_update_user( $user, $keys ) {
|
433 |
-
global $wpdb;
|
434 |
-
extract( $keys, EXTR_SKIP );
|
435 |
-
|
436 |
-
$query = $wpdb->prepare( "UPDATE $wpdb->users SET user_pass = '%s', user_activation_key = '' WHERE ID = '%d'", $user->user_pass, $user_id );
|
437 |
-
|
438 |
-
if ( $wpdb->query( $query ) ) {
|
439 |
-
// Remove password reminder after installing
|
440 |
-
if ( get_user_meta( $user_id, 'default_password_nag' ) ) {
|
441 |
-
delete_user_meta( $user_id, 'default_password_nag' );
|
442 |
-
}
|
443 |
-
|
444 |
-
return true;
|
445 |
-
}
|
446 |
-
return false;
|
447 |
-
}
|
448 |
-
}
|
449 |
-
|
450 |
-
$cb_wp_reset = new CB_WP_Reset();
|
451 |
-
register_activation_hook( __FILE__, array( 'cb_wp_reset', 'plugin_activate' ) );
|
452 |
-
|
453 |
-
endif;
|
1 |
+
<?php
|
2 |
+
/*
|
3 |
+
Plugin Name: WordPress Database Reset
|
4 |
+
Plugin URI: https://github.com/chrisberthe/wordpress-database-reset
|
5 |
+
Description: A plugin that allows you to skip the 5 minute installation and reset WordPress's database back to its original state.
|
6 |
+
Version: 3.0.1
|
7 |
+
Author: Chris Berthe
|
8 |
+
Author URI: https://github.com/chrisberthe
|
9 |
+
License: GNU General Public License
|
10 |
+
Text-domain: wp-reset
|
11 |
+
*/
|
12 |
+
|
13 |
+
define( 'DB_RESET_VERSION', '3.0.1' );
|
14 |
+
define( 'DB_RESET_PATH', dirname( __FILE__ ) );
|
15 |
+
define( 'DB_RESET_NAME', basename( DB_RESET_PATH ) );
|
16 |
+
define( 'AUTOLOADER', DB_RESET_PATH . '/lib/class-plugin-autoloader.php' );
|
17 |
+
|
18 |
+
require_once( DB_RESET_PATH . '/lib/helpers.php' );
|
19 |
+
|
20 |
+
register_activation_hook( __FILE__, 'db_reset_activate' );
|
21 |
+
|
22 |
+
load_plugin_textdomain( 'wordpress-database-reset', false, DB_RESET_NAME . '/languages/' );
|
23 |
+
|
24 |
+
if ( file_exists( AUTOLOADER ) ) {
|
25 |
+
require_once( AUTOLOADER );
|
26 |
+
new Plugin_Autoloader( DB_RESET_PATH );
|
27 |
+
|
28 |
+
add_action(
|
29 |
+
'wp_loaded',
|
30 |
+
array ( new DB_Reset_Manager( DB_RESET_VERSION ), 'run' )
|
31 |
+
);
|
32 |
+
}
|
33 |
+
|
34 |
+
if ( is_command_line() ) {
|
35 |
+
require_once( __DIR__ . '/class-db-reset-command.php' );
|
36 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|