WP Reset – Fastest WordPress Reset Plugin - Version 1.70

Version Description

Download this release

Release Info

Developer WebFactory
Plugin Icon 128x128 WP Reset – Fastest WordPress Reset Plugin
Version 1.70
Comparing to
See all releases

Code changes from version 1.65 to 1.70

css/wp-reset.css CHANGED
@@ -4,8 +4,61 @@
4
  * (c) WebFactory Ltd, 2017-2019
5
  */
6
 
7
- .tools_page_wp-reset #wp_reset_form input {
8
- vertical-align: middle;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
9
  }
10
 
11
  .tools_page_wp-reset h1 span {
@@ -65,19 +118,23 @@
65
  .tools_page_wp-reset .button {
66
  box-shadow: none;
67
  text-shadow: none;
68
- margin-top: 1em;
69
  }
70
 
71
  .tools_page_wp-reset .swal2-container {
72
  z-index: 99999;
73
  }
74
 
 
 
 
 
75
  .tools_page_wp-reset .swal2-container.swal2-shown {
76
  background-color: rgba(0, 0, 0, 0.6);
77
  }
78
 
79
  .tools_page_wp-reset .swal2-popup .swal2-title {
80
- line-height: 1;
 
81
  }
82
 
83
  .tools_page_wp-reset code {
@@ -89,8 +146,25 @@
89
  font-size: 14px;
90
  }
91
 
92
- .tools_page_wp-reset .button-delete:hover {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
93
  color: #cc2f2f;
 
94
  }
95
 
96
  .tools_page_wp-reset .rotating {
@@ -99,28 +173,54 @@
99
  animation: spin 1.5s linear infinite;
100
  }
101
 
102
- .tools_page_wp-reset .card.notice-wrapper {
103
- max-width: 600px;
104
- }
105
-
106
  .tools_page_wp-reset .notice-error {
107
  border-top-color: #dd3036;
 
108
  }
109
 
110
  .tools_page_wp-reset .notice-info {
111
  border-top-color: #0085ba;
 
 
 
 
 
 
 
 
 
 
112
  }
113
 
114
  .tools_page_wp-reset .toggle-card {
115
- position: absolute;
116
- right: 1em;
117
- top: 2.2em;
118
  text-decoration: none;
 
 
 
 
 
119
  }
120
 
121
  .tools_page_wp-reset .card {
122
- padding: 1em 1em 1em 1em;
123
- max-width: 560px;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
124
  }
125
 
126
  .tools_page_wp-reset .card.collapsed p,
@@ -129,23 +229,19 @@
129
  display: none;
130
  }
131
 
132
- .tools_page_wp-reset .swal2-popup {
133
- border-radius: 0;
134
  }
135
 
136
- .tools_page_wp-reset .create-new-snapshot-corner {
137
- position: absolute;
138
- top: 2em;
139
- right: 2em;
140
- margin: 0;
141
- box-shadow: none;
142
  }
143
 
144
  .tools_page_wp-reset table {
145
- width: calc(100% + 4em);
146
  border-spacing: 0;
147
  border-collapse: separate;
148
- margin: 0 0 0 -2em;
149
  }
150
 
151
  .tools_page_wp-reset table td {
@@ -158,7 +254,7 @@
158
  }
159
 
160
  .tools_page_wp-reset table .ss-actions {
161
- width: 55px;
162
  }
163
 
164
  .tools_page_wp-reset table th {
@@ -169,7 +265,7 @@
169
 
170
  .tools_page_wp-reset table .ss-action {
171
  text-decoration: none;
172
- margin: 0 7px 5px 0;
173
  display: inline-block;
174
  }
175
 
@@ -257,7 +353,7 @@
257
  }
258
 
259
  .wpr-table-container table.table_diff tr td {
260
- width: auto;
261
  border-left: none;
262
  word-break: break-all;
263
  font-size: 14px;
@@ -292,7 +388,7 @@
292
  position: relative;
293
  padding: 0px;
294
  zoom: 1;
295
- margin-top: 20px;
296
  }
297
 
298
  .tools_page_wp-reset .ui-tabs .ui-tabs-nav {
@@ -313,16 +409,10 @@
313
  text-decoration: none;
314
  }
315
 
316
- .tools_page_wp-reset .ui-tabs .ui-tabs-nav li.ui-tabs-selected {
317
- margin-bottom: 0;
318
- border-bottom: 1px solid #f1f1f1 !important;
319
- }
320
-
321
  .tools_page_wp-reset ul.ui-tabs-nav.wpr-main-tab li.ui-state-active {
322
- border-top: 3px solid #666666;
323
- background: #ffffff;
324
- transition: all 0.4s ease-out;
325
- border-bottom: 1px solid #fff;
326
  }
327
 
328
  .tools_page_wp-reset .ui-tabs .ui-tabs-nav li.ui-tabs-selected a,
@@ -337,13 +427,9 @@
337
  }
338
 
339
  .tools_page_wp-reset .ui-tabs .ui-tabs-panel {
340
- display: inline-block;
341
  border: none;
342
- padding: 20px;
343
- background: #ffffff;
344
  overflow: visible;
345
- min-width: 520px;
346
- border-top: 1px solid #e5e5e5;
347
  }
348
 
349
  .tools_page_wp-reset .ui-tabs .ui-tabs-hide {
@@ -354,8 +440,8 @@
354
  font-size: 14px;
355
  font-weight: 600;
356
  line-height: 32px;
357
- color: #aaaaaa;
358
- padding: 5px 10px;
359
  display: block;
360
  letter-spacing: 1px;
361
  }
@@ -380,21 +466,20 @@
380
  display: inline-block;
381
  font-size: 12px;
382
  line-height: 16px;
383
- margin: 0px 5px 0px 5px;
384
  text-decoration: none;
385
  text-shadow: none;
386
- background: rgba(255, 255, 255, 0.7);
387
  padding: 0;
388
  text-align: center;
389
- letter-spacing: 0.5px;
390
- min-width: 100px;
391
- border-top: 3px solid transparent;
392
- border-bottom: 1px solid #e5e5e5;
393
  }
394
 
395
- @media screen and (max-width: 782px) {
 
 
 
396
  .tools_page_wp-reset .ui-tabs ul.ui-tabs-nav li {
397
- min-width: inherit;
398
  }
399
  }
400
 
@@ -422,7 +507,7 @@
422
 
423
  .tools_page_wp-reset .ui-tabs ul.ui-tabs-nav li.ui-state-hover {
424
  background-color: #ffffff !important;
425
- border-bottom: 1px solid #fff;
426
  }
427
 
428
  .tools_page_wp-reset .ui-tabs-nav a:focus {
@@ -660,6 +745,10 @@
660
  color: #fefefe;
661
  }
662
 
 
 
 
 
663
  .webhooks-footer {
664
  text-align: center;
665
  }
4
  * (c) WebFactory Ltd, 2017-2019
5
  */
6
 
7
+ .tools_page_wp-reset #wpcontent,
8
+ .tools_page_wp-reset .auto-fold #wpcontent {
9
+ padding-left: 0;
10
+ }
11
+
12
+ .tools_page_wp-reset .wrap {
13
+ margin: 0;
14
+ background: #f9fbfd;
15
+ min-height: calc(100vh - 100px);
16
+ font-size: 14px;
17
+ padding: 0;
18
+ }
19
+
20
+ #wpbody-content {
21
+ background: #f9fbfd;
22
+ }
23
+
24
+ .wpr-container {
25
+ margin: 0 auto;
26
+ max-width: 100%;
27
+ width: 760px;
28
+ }
29
+
30
+ .tools_page_wp-reset header {
31
+ padding: 20px 10px;
32
+ background: #f9fbfd;
33
+ }
34
+
35
+ .tools_page_wp-reset nav {
36
+ background: #ffffff;
37
+ padding: 0;
38
+ margin: 0 0 35px 0;
39
+ border-top: 1px solid #e5e5e5;
40
+ border-bottom: 1px solid #e5e5e5;
41
+ }
42
+
43
+ #wpr-content {
44
+ padding: 0 0 35px 0;
45
+ }
46
+
47
+ #wpfooter {
48
+ padding: 20px;
49
+ border-top: 1px solid #e5e5e5;
50
+ }
51
+
52
+ #wpfooter a {
53
+ text-decoration: none;
54
+ }
55
+
56
+ #wpfooter span {
57
+ color: #ffb900;
58
+ }
59
+
60
+ .tools_page_wp-reset #wp_reset_confirm {
61
+ vertical-align: top;
62
  }
63
 
64
  .tools_page_wp-reset h1 span {
118
  .tools_page_wp-reset .button {
119
  box-shadow: none;
120
  text-shadow: none;
 
121
  }
122
 
123
  .tools_page_wp-reset .swal2-container {
124
  z-index: 99999;
125
  }
126
 
127
+ .tools_page_wp-reset .swal2-container .swal2-popup .swal2-actions {
128
+ margin: 2em auto 0;
129
+ }
130
+
131
  .tools_page_wp-reset .swal2-container.swal2-shown {
132
  background-color: rgba(0, 0, 0, 0.6);
133
  }
134
 
135
  .tools_page_wp-reset .swal2-popup .swal2-title {
136
+ line-height: 1.1;
137
+ font-weight: 700;
138
  }
139
 
140
  .tools_page_wp-reset code {
146
  font-size: 14px;
147
  }
148
 
149
+ .wp-core-ui .button.focus,
150
+ .wp-core-ui .button:focus,
151
+ .wp-core-ui .button-secondary:focus {
152
+ border-color: #999;
153
+ box-shadow: none;
154
+ }
155
+
156
+ .tools_page_wp-reset p > .button-delete {
157
+ margin-right: 10px;
158
+ }
159
+
160
+ .tools_page_wp-reset .button-delete {
161
+ color: #cc2f2f;
162
+ }
163
+
164
+ .tools_page_wp-reset .button-delete:hover,
165
+ .tools_page_wp-reset .button-delete:focus {
166
  color: #cc2f2f;
167
+ border-color: #cc2f2f;
168
  }
169
 
170
  .tools_page_wp-reset .rotating {
173
  animation: spin 1.5s linear infinite;
174
  }
175
 
 
 
 
 
176
  .tools_page_wp-reset .notice-error {
177
  border-top-color: #dd3036;
178
+ border-top-width: 3px;
179
  }
180
 
181
  .tools_page_wp-reset .notice-info {
182
  border-top-color: #0085ba;
183
+ border-top-width: 3px;
184
+ }
185
+
186
+ .tools_page_wp-reset .card-header-right {
187
+ height: 100%;
188
+ float: right;
189
+ }
190
+
191
+ .tools_page_wp-reset .card-header-right .button {
192
+ margin: -5px 0 0 0;
193
  }
194
 
195
  .tools_page_wp-reset .toggle-card {
 
 
 
196
  text-decoration: none;
197
+ color: #444;
198
+ }
199
+
200
+ .tools_page_wp-reset .toggle-card:hover {
201
+ color: #00a0d2;
202
  }
203
 
204
  .tools_page_wp-reset .card {
205
+ padding: 0 25px 15px 25px;
206
+ max-width: 100%;
207
+ width: 100%;
208
+ margin: 0 0 35px 0;
209
+ }
210
+
211
+ .tools_page_wp-reset .card.pro {
212
+ border-left: 1px solid #dd3036;
213
+ }
214
+
215
+ .card h4 {
216
+ border-bottom: 1px solid #e5e5e5;
217
+ margin: 0 -25px;
218
+ padding: 15px 25px;
219
+ background-color: #fcfcfc;
220
+ }
221
+
222
+ .tools_page_wp-reset .card.collapsed {
223
+ padding-bottom: 0;
224
  }
225
 
226
  .tools_page_wp-reset .card.collapsed p,
229
  display: none;
230
  }
231
 
232
+ .tools_page_wp-reset .card.collapsed h4 {
233
+ border: none;
234
  }
235
 
236
+ .tools_page_wp-reset .swal2-popup {
237
+ border-radius: 0;
 
 
 
 
238
  }
239
 
240
  .tools_page_wp-reset table {
241
+ width: 100%;
242
  border-spacing: 0;
243
  border-collapse: separate;
244
+ margin: 1em 0;
245
  }
246
 
247
  .tools_page_wp-reset table td {
254
  }
255
 
256
  .tools_page_wp-reset table .ss-actions {
257
+ width: 65px;
258
  }
259
 
260
  .tools_page_wp-reset table th {
265
 
266
  .tools_page_wp-reset table .ss-action {
267
  text-decoration: none;
268
+ margin: 5px 10px 5px 0;
269
  display: inline-block;
270
  }
271
 
353
  }
354
 
355
  .wpr-table-container table.table_diff tr td {
356
+ width: 45%;
357
  border-left: none;
358
  word-break: break-all;
359
  font-size: 14px;
388
  position: relative;
389
  padding: 0px;
390
  zoom: 1;
391
+ margin: 0;
392
  }
393
 
394
  .tools_page_wp-reset .ui-tabs .ui-tabs-nav {
409
  text-decoration: none;
410
  }
411
 
 
 
 
 
 
412
  .tools_page_wp-reset ul.ui-tabs-nav.wpr-main-tab li.ui-state-active {
413
+ border-bottom: 2px solid #dd3036;
414
+ background: transparent;
415
+ _transition: all 0.4s ease-out;
 
416
  }
417
 
418
  .tools_page_wp-reset .ui-tabs .ui-tabs-nav li.ui-tabs-selected a,
427
  }
428
 
429
  .tools_page_wp-reset .ui-tabs .ui-tabs-panel {
430
+ display: block;
431
  border: none;
 
 
432
  overflow: visible;
 
 
433
  }
434
 
435
  .tools_page_wp-reset .ui-tabs .ui-tabs-hide {
440
  font-size: 14px;
441
  font-weight: 600;
442
  line-height: 32px;
443
+ color: #616161;
444
+ padding: 5px 0;
445
  display: block;
446
  letter-spacing: 1px;
447
  }
466
  display: inline-block;
467
  font-size: 12px;
468
  line-height: 16px;
469
+ margin: 0px 20px 0px 5px;
470
  text-decoration: none;
471
  text-shadow: none;
 
472
  padding: 0;
473
  text-align: center;
474
+ border-bottom: 2px solid transparent;
 
 
 
475
  }
476
 
477
+ @media screen and (max-width: 880px) {
478
+ .tools_page_wp-reset .ui-tabs .ui-tabs-nav {
479
+ padding: 0 25px;
480
+ }
481
  .tools_page_wp-reset .ui-tabs ul.ui-tabs-nav li {
482
+ margin: 0px 10px 0px 5px;
483
  }
484
  }
485
 
507
 
508
  .tools_page_wp-reset .ui-tabs ul.ui-tabs-nav li.ui-state-hover {
509
  background-color: #ffffff !important;
510
+ border-bottom: 2px solid #dd3036;
511
  }
512
 
513
  .tools_page_wp-reset .ui-tabs-nav a:focus {
745
  color: #fefefe;
746
  }
747
 
748
+ .webhooks-dialog .ui-button.ui-dialog-titlebar-close {
749
+ color: #ffffff;
750
+ }
751
+
752
  .webhooks-footer {
753
  text-align: center;
754
  }
img/product-hunt.png DELETED
Binary file
js/{sweetalert2.min.js → wp-reset-libs.min.js} RENAMED
@@ -1,3 +1,12 @@
 
 
 
 
 
 
 
 
 
1
  /*
2
  SweetAlert2
3
  https://github.com/sweetalert2/sweetalert2
1
+ /**
2
+ * Copyright (c) 2007 Ariel Flesler - aflesler ○ gmail • com | https://github.com/flesler
3
+ * Licensed under MIT
4
+ * @author Ariel Flesler
5
+ * @version 2.1.2
6
+ */
7
+ ;(function(f){"use strict";"function"===typeof define&&define.amd?define(["jquery"],f):"undefined"!==typeof module&&module.exports?module.exports=f(require("jquery")):f(jQuery)})(function($){"use strict";function n(a){return!a.nodeName||-1!==$.inArray(a.nodeName.toLowerCase(),["iframe","#document","html","body"])}function h(a){return $.isFunction(a)||$.isPlainObject(a)?a:{top:a,left:a}}var p=$.scrollTo=function(a,d,b){return $(window).scrollTo(a,d,b)};p.defaults={axis:"xy",duration:0,limit:!0};$.fn.scrollTo=function(a,d,b){"object"=== typeof d&&(b=d,d=0);"function"===typeof b&&(b={onAfter:b});"max"===a&&(a=9E9);b=$.extend({},p.defaults,b);d=d||b.duration;var u=b.queue&&1<b.axis.length;u&&(d/=2);b.offset=h(b.offset);b.over=h(b.over);return this.each(function(){function k(a){var k=$.extend({},b,{queue:!0,duration:d,complete:a&&function(){a.call(q,e,b)}});r.animate(f,k)}if(null!==a){var l=n(this),q=l?this.contentWindow||window:this,r=$(q),e=a,f={},t;switch(typeof e){case "number":case "string":if(/^([+-]=?)?\d+(\.\d+)?(px|%)?$/.test(e)){e= h(e);break}e=l?$(e):$(e,q);case "object":if(e.length===0)return;if(e.is||e.style)t=(e=$(e)).offset()}var v=$.isFunction(b.offset)&&b.offset(q,e)||b.offset;$.each(b.axis.split(""),function(a,c){var d="x"===c?"Left":"Top",m=d.toLowerCase(),g="scroll"+d,h=r[g](),n=p.max(q,c);t?(f[g]=t[m]+(l?0:h-r.offset()[m]),b.margin&&(f[g]-=parseInt(e.css("margin"+d),10)||0,f[g]-=parseInt(e.css("border"+d+"Width"),10)||0),f[g]+=v[m]||0,b.over[m]&&(f[g]+=e["x"===c?"width":"height"]()*b.over[m])):(d=e[m],f[g]=d.slice&& "%"===d.slice(-1)?parseFloat(d)/100*n:d);b.limit&&/^\d+$/.test(f[g])&&(f[g]=0>=f[g]?0:Math.min(f[g],n));!a&&1<b.axis.length&&(h===f[g]?f={}:u&&(k(b.onAfterFirst),f={}))});k(b.onAfter)}})};p.max=function(a,d){var b="x"===d?"Width":"Height",h="scroll"+b;if(!n(a))return a[h]-$(a)[b.toLowerCase()]();var b="client"+b,k=a.ownerDocument||a.document,l=k.documentElement,k=k.body;return Math.max(l[h],k[h])-Math.min(l[b],k[b])};$.Tween.propHooks.scrollLeft=$.Tween.propHooks.scrollTop={get:function(a){return $(a.elem)[a.prop]()}, set:function(a){var d=this.get(a);if(a.options.interrupt&&a._last&&a._last!==d)return $(a.elem).stop();var b=Math.round(a.now);d!==b&&($(a.elem)[a.prop](b),a._last=this.get(a))}};return p});
8
+
9
+
10
  /*
11
  SweetAlert2
12
  https://github.com/sweetalert2/sweetalert2
js/wp-reset.js CHANGED
@@ -24,7 +24,7 @@ jQuery(document).ready(function($) {
24
  // get the link anchor and scroll to it
25
  target = this.href.split('#')[1];
26
  if (target) {
27
- $.scrollTo('#' + target, 500, {offset: {top:-50, left:0}});
28
  }
29
 
30
  return false;
@@ -102,6 +102,53 @@ jQuery(document).ready(function($) {
102
  return false;
103
  }); // delete htaccess file
104
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
105
  // compare snapshot
106
  $('#wpr-snapshots').on('click', '.compare-snapshot', 'click', function(e) {
107
  e.preventDefault();
@@ -197,7 +244,7 @@ jQuery(document).ready(function($) {
197
  });
198
 
199
  return false;
200
- }); // downlod snapshot
201
 
202
  // delete snapshot
203
  $('#wpr-snapshots').on('click', '.delete-snapshot', 'click', function(e) {
@@ -280,8 +327,10 @@ jQuery(document).ready(function($) {
280
 
281
  // standard way of running a tool, with confirmation, loading and success message
282
  function run_tool(button, tool_name, extra_data) {
 
 
283
  confirm_action(
284
- wp_reset.confirm_title,
285
  $(button).data('text-confirm'),
286
  $(button).data('btn-confirm'),
287
  wp_reset.cancel_button
@@ -364,6 +413,7 @@ jQuery(document).ready(function($) {
364
  html: question,
365
  showCancelButton: true,
366
  focusConfirm: false,
 
367
  confirmButtonText: btn_confirm,
368
  cancelButtonText: btn_cancel,
369
  confirmButtonColor: '#dd3036',
@@ -401,11 +451,12 @@ jQuery(document).ready(function($) {
401
 
402
  message = wp_reset.confirm1 + '<br>' + wp_reset.confirm2;
403
  swal({
404
- title: wp_reset.confirm_title,
405
  type: 'question',
406
  html: message,
407
  showCancelButton: true,
408
  focusConfirm: false,
 
409
  confirmButtonText: wp_reset.confirm_button,
410
  cancelButtonText: wp_reset.cancel_button,
411
  confirmButtonColor: '#dd3036',
@@ -629,13 +680,3 @@ function wpr_fix_dialog_close(event, ui) {
629
  jQuery('#' + event.target.id).dialog('close');
630
  });
631
  } // wpr_fix_dialog_close
632
-
633
-
634
- /**
635
- * Copyright (c) 2007 Ariel Flesler - aflesler ○ gmail • com | https://github.com/flesler
636
- * Licensed under MIT
637
- * @author Ariel Flesler
638
- * @version 2.1.2
639
- */
640
- ;(function(f){"use strict";"function"===typeof define&&define.amd?define(["jquery"],f):"undefined"!==typeof module&&module.exports?module.exports=f(require("jquery")):f(jQuery)})(function($){"use strict";function n(a){return!a.nodeName||-1!==$.inArray(a.nodeName.toLowerCase(),["iframe","#document","html","body"])}function h(a){return $.isFunction(a)||$.isPlainObject(a)?a:{top:a,left:a}}var p=$.scrollTo=function(a,d,b){return $(window).scrollTo(a,d,b)};p.defaults={axis:"xy",duration:0,limit:!0};$.fn.scrollTo=function(a,d,b){"object"=== typeof d&&(b=d,d=0);"function"===typeof b&&(b={onAfter:b});"max"===a&&(a=9E9);b=$.extend({},p.defaults,b);d=d||b.duration;var u=b.queue&&1<b.axis.length;u&&(d/=2);b.offset=h(b.offset);b.over=h(b.over);return this.each(function(){function k(a){var k=$.extend({},b,{queue:!0,duration:d,complete:a&&function(){a.call(q,e,b)}});r.animate(f,k)}if(null!==a){var l=n(this),q=l?this.contentWindow||window:this,r=$(q),e=a,f={},t;switch(typeof e){case "number":case "string":if(/^([+-]=?)?\d+(\.\d+)?(px|%)?$/.test(e)){e= h(e);break}e=l?$(e):$(e,q);case "object":if(e.length===0)return;if(e.is||e.style)t=(e=$(e)).offset()}var v=$.isFunction(b.offset)&&b.offset(q,e)||b.offset;$.each(b.axis.split(""),function(a,c){var d="x"===c?"Left":"Top",m=d.toLowerCase(),g="scroll"+d,h=r[g](),n=p.max(q,c);t?(f[g]=t[m]+(l?0:h-r.offset()[m]),b.margin&&(f[g]-=parseInt(e.css("margin"+d),10)||0,f[g]-=parseInt(e.css("border"+d+"Width"),10)||0),f[g]+=v[m]||0,b.over[m]&&(f[g]+=e["x"===c?"width":"height"]()*b.over[m])):(d=e[m],f[g]=d.slice&& "%"===d.slice(-1)?parseFloat(d)/100*n:d);b.limit&&/^\d+$/.test(f[g])&&(f[g]=0>=f[g]?0:Math.min(f[g],n));!a&&1<b.axis.length&&(h===f[g]?f={}:u&&(k(b.onAfterFirst),f={}))});k(b.onAfter)}})};p.max=function(a,d){var b="x"===d?"Width":"Height",h="scroll"+b;if(!n(a))return a[h]-$(a)[b.toLowerCase()]();var b="client"+b,k=a.ownerDocument||a.document,l=k.documentElement,k=k.body;return Math.max(l[h],k[h])-Math.min(l[b],k[b])};$.Tween.propHooks.scrollLeft=$.Tween.propHooks.scrollTop={get:function(a){return $(a.elem)[a.prop]()}, set:function(a){var d=this.get(a);if(a.options.interrupt&&a._last&&a._last!==d)return $(a.elem).stop();var b=Math.round(a.now);d!==b&&($(a.elem)[a.prop](b),a._last=this.get(a))}};return p});
641
-
24
  // get the link anchor and scroll to it
25
  target = this.href.split('#')[1];
26
  if (target) {
27
+ $.scrollTo('#' + target, 500, { offset: { top: -50, left: 0 } });
28
  }
29
 
30
  return false;
102
  return false;
103
  }); // delete htaccess file
104
 
105
+ // create&download backup
106
+ $('.tools_page_wp-reset').on('click', '.download-backup', 'click', function(e) {
107
+ e.preventDefault();
108
+ button = this;
109
+
110
+ block_ui(wp_reset.creating_backup);
111
+ $.get({
112
+ url: ajaxurl,
113
+ data: {
114
+ action: 'wp_reset_run_tool',
115
+ _ajax_nonce: wp_reset.nonce_run_tool,
116
+ tool: 'download_backup'
117
+ }
118
+ })
119
+ .always(function(data) {
120
+ swal.close();
121
+ })
122
+ .done(function(data) {
123
+ if (data.success) {
124
+ $.ajax({
125
+ type: 'HEAD',
126
+ url: data.data,
127
+ success: function() {
128
+ window.location = data.data;
129
+ },
130
+ error: function() {
131
+ swal({
132
+ type: 'error',
133
+ title: wp_reset.backup_not_accessible,
134
+ html: wp_reset.backup_not_accessible_details.replace('%url%', data.data)
135
+ });
136
+ }
137
+ });
138
+ } else {
139
+ swal({
140
+ type: 'error',
141
+ title: wp_reset.documented_error + ' ' + data.data
142
+ });
143
+ }
144
+ })
145
+ .fail(function(data) {
146
+ swal({ type: 'error', title: wp_reset.undocumented_error });
147
+ });
148
+
149
+ return false;
150
+ }); // create&download backup
151
+
152
  // compare snapshot
153
  $('#wpr-snapshots').on('click', '.compare-snapshot', 'click', function(e) {
154
  e.preventDefault();
244
  });
245
 
246
  return false;
247
+ }); // download snapshot
248
 
249
  // delete snapshot
250
  $('#wpr-snapshots').on('click', '.delete-snapshot', 'click', function(e) {
327
 
328
  // standard way of running a tool, with confirmation, loading and success message
329
  function run_tool(button, tool_name, extra_data) {
330
+ var confirm_title = $(button).data('confirm-title') || wp_reset.confirm_title;
331
+
332
  confirm_action(
333
+ confirm_title,
334
  $(button).data('text-confirm'),
335
  $(button).data('btn-confirm'),
336
  wp_reset.cancel_button
413
  html: question,
414
  showCancelButton: true,
415
  focusConfirm: false,
416
+ focusCancel: true,
417
  confirmButtonText: btn_confirm,
418
  cancelButtonText: btn_cancel,
419
  confirmButtonColor: '#dd3036',
451
 
452
  message = wp_reset.confirm1 + '<br>' + wp_reset.confirm2;
453
  swal({
454
+ title: wp_reset.confirm_title_reset,
455
  type: 'question',
456
  html: message,
457
  showCancelButton: true,
458
  focusConfirm: false,
459
+ focusCancel: true,
460
  confirmButtonText: wp_reset.confirm_button,
461
  cancelButtonText: wp_reset.cancel_button,
462
  confirmButtonColor: '#dd3036',
680
  jQuery('#' + event.target.id).dialog('close');
681
  });
682
  } // wpr_fix_dialog_close
 
 
 
 
 
 
 
 
 
 
libs/dumper.php CHANGED
@@ -1,7 +1,7 @@
1
- <?php
2
  /**
3
  * Abstract dump file: provides common interface for writing
4
- * data to dump files.
5
  * (c) 2create Studio, Bulgaria
6
  * http://2create.bg/
7
  */
@@ -36,11 +36,11 @@ abstract class Shuttle_Dump_File {
36
 
37
  public static function is_gzip($filename) {
38
  return preg_match('~gz$~i', $filename);
39
- }
40
  }
41
 
42
  /**
43
- * Plain text implementation. Uses standard file functions in PHP.
44
  */
45
  class Shuttle_Dump_File_Plaintext extends Shuttle_Dump_File {
46
  function open() {
@@ -55,7 +55,7 @@ class Shuttle_Dump_File_Plaintext extends Shuttle_Dump_File {
55
  }
56
 
57
  /**
58
- * Gzip implementation. Uses gz* functions.
59
  */
60
  class Shuttle_Dump_File_Gzip extends Shuttle_Dump_File {
61
  function open() {
@@ -70,7 +70,7 @@ class Shuttle_Dump_File_Gzip extends Shuttle_Dump_File {
70
  }
71
 
72
  /**
73
- * MySQL insert statement builder.
74
  */
75
  class Shuttle_Insert_Statement {
76
  private $rows = array();
@@ -97,7 +97,7 @@ class Shuttle_Insert_Statement {
97
  return false;
98
  }
99
 
100
- return 'INSERT INTO `' . $this->table . '` VALUES ' .
101
  implode(",\n", $this->rows) . '; ';
102
  }
103
 
@@ -114,10 +114,10 @@ abstract class Shuttle_Dumper {
114
  * Maximum length of single insert statement
115
  */
116
  const INSERT_THRESHOLD = 838860;
117
-
118
  /**
119
  * @var Shuttle_DBConn
120
- */
121
  public $db;
122
 
123
  /**
@@ -141,14 +141,14 @@ abstract class Shuttle_Dumper {
141
  public $exclude_tables = array();
142
 
143
  /**
144
- * Factory method for dumper on current hosts's configuration.
145
  */
146
  static function create($db_options) {
147
  $db = Shuttle_DBConn::create($db_options);
148
 
149
  $db->connect();
150
 
151
- if (self::has_shell_access()
152
  && self::is_shell_command_available('mysqldump')
153
  && self::is_shell_command_available('gzip')
154
  ) {
@@ -183,7 +183,7 @@ abstract class Shuttle_Dumper {
183
  if (preg_match('~win~i', PHP_OS)) {
184
  /*
185
  On Windows, the `where` command checks for availabilty in PATH. According
186
- to the manual(`where /?`), there is quiet mode:
187
  ....
188
  /Q Returns only the exit code, without displaying the list
189
  of matched files. (Quiet mode)
@@ -202,7 +202,7 @@ abstract class Shuttle_Dumper {
202
  $last_line = exec('which ' . $command);
203
  $last_line = trim($last_line);
204
 
205
- // Whenever there is at least one line in the output,
206
  // it should be the path to the executable
207
  if (empty($last_line)) {
208
  return false;
@@ -210,7 +210,7 @@ abstract class Shuttle_Dumper {
210
  return true;
211
  }
212
  }
213
-
214
  }
215
 
216
  /**
@@ -226,7 +226,7 @@ abstract class Shuttle_Dumper {
226
  if (!empty($this->include_tables)) {
227
  return $this->include_tables;
228
  }
229
-
230
  // $tables will only include the tables and not views.
231
  // TODO - Handle views also, edits to be made in function 'get_create_table_sql' line 336
232
  $tables = $this->db->fetch_numeric('
@@ -247,8 +247,8 @@ abstract class Shuttle_Dumper {
247
  class Shuttle_Dumper_ShellCommand extends Shuttle_Dumper {
248
  function dump($export_file_location, $table_prefix='') {
249
  $command = 'mysqldump -h ' . escapeshellarg($this->db->host) .
250
- ' -u ' . escapeshellarg($this->db->username) .
251
- ' --password=' . escapeshellarg($this->db->password) .
252
  ' ' . escapeshellarg($this->db->name);
253
 
254
  $include_all_tables = empty($table_prefix) &&
@@ -284,6 +284,7 @@ class Shuttle_Dumper_ShellCommand extends Shuttle_Dumper {
284
 
285
  class Shuttle_Dumper_Native extends Shuttle_Dumper {
286
  public function dump($export_file_location, $table_prefix='') {
 
287
  $eol = $this->eol;
288
 
289
  $this->dump_file = Shuttle_Dump_File::create($export_file_location);
@@ -291,8 +292,10 @@ class Shuttle_Dumper_Native extends Shuttle_Dumper {
291
  $this->dump_file->write("-- Generation time: " . date('r') . $eol);
292
  $this->dump_file->write("-- Host: " . $this->db->host . $eol);
293
  $this->dump_file->write("-- DB name: " . $this->db->name . $eol);
 
 
294
  $this->dump_file->write("/*!40030 SET NAMES UTF8 */;$eol");
295
-
296
  $this->dump_file->write("/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;$eol");
297
  $this->dump_file->write("/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;$eol");
298
  $this->dump_file->write("/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;$eol");
@@ -308,7 +311,7 @@ class Shuttle_Dumper_Native extends Shuttle_Dumper {
308
  foreach ($tables as $table) {
309
  $this->dump_table($table);
310
  }
311
-
312
  $this->dump_file->write("$eol$eol");
313
  $this->dump_file->write("/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;$eol");
314
  $this->dump_file->write("/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;$eol");
@@ -354,7 +357,7 @@ class Shuttle_Dumper_Native extends Shuttle_Dumper {
354
  }
355
  $this->dump_file->write($eol . $eol);
356
  }
357
-
358
  public function get_create_table_sql($table) {
359
  $create_table_sql = $this->db->fetch('SHOW CREATE TABLE `' . $table . '`');
360
  return $create_table_sql[0]['Create Table'] . ';';
@@ -468,11 +471,11 @@ class Shuttle_DBConn_Mysqli extends Shuttle_DBConn {
468
  $this->connect();
469
  }
470
  $res = $this->connection->query($q);
471
-
472
  if (!$res) {
473
  throw new Shuttle_Exception("SQL error: " . $this->connection->error);
474
  }
475
-
476
  return $res;
477
  }
478
 
1
+ <?php
2
  /**
3
  * Abstract dump file: provides common interface for writing
4
+ * data to dump files.
5
  * (c) 2create Studio, Bulgaria
6
  * http://2create.bg/
7
  */
36
 
37
  public static function is_gzip($filename) {
38
  return preg_match('~gz$~i', $filename);
39
+ }
40
  }
41
 
42
  /**
43
+ * Plain text implementation. Uses standard file functions in PHP.
44
  */
45
  class Shuttle_Dump_File_Plaintext extends Shuttle_Dump_File {
46
  function open() {
55
  }
56
 
57
  /**
58
+ * Gzip implementation. Uses gz* functions.
59
  */
60
  class Shuttle_Dump_File_Gzip extends Shuttle_Dump_File {
61
  function open() {
70
  }
71
 
72
  /**
73
+ * MySQL insert statement builder.
74
  */
75
  class Shuttle_Insert_Statement {
76
  private $rows = array();
97
  return false;
98
  }
99
 
100
+ return 'INSERT INTO `' . $this->table . '` VALUES ' .
101
  implode(",\n", $this->rows) . '; ';
102
  }
103
 
114
  * Maximum length of single insert statement
115
  */
116
  const INSERT_THRESHOLD = 838860;
117
+
118
  /**
119
  * @var Shuttle_DBConn
120
+ */
121
  public $db;
122
 
123
  /**
141
  public $exclude_tables = array();
142
 
143
  /**
144
+ * Factory method for dumper on current hosts's configuration.
145
  */
146
  static function create($db_options) {
147
  $db = Shuttle_DBConn::create($db_options);
148
 
149
  $db->connect();
150
 
151
+ if (self::has_shell_access()
152
  && self::is_shell_command_available('mysqldump')
153
  && self::is_shell_command_available('gzip')
154
  ) {
183
  if (preg_match('~win~i', PHP_OS)) {
184
  /*
185
  On Windows, the `where` command checks for availabilty in PATH. According
186
+ to the manual(`where /?`), there is quiet mode:
187
  ....
188
  /Q Returns only the exit code, without displaying the list
189
  of matched files. (Quiet mode)
202
  $last_line = exec('which ' . $command);
203
  $last_line = trim($last_line);
204
 
205
+ // Whenever there is at least one line in the output,
206
  // it should be the path to the executable
207
  if (empty($last_line)) {
208
  return false;
210
  return true;
211
  }
212
  }
213
+
214
  }
215
 
216
  /**
226
  if (!empty($this->include_tables)) {
227
  return $this->include_tables;
228
  }
229
+
230
  // $tables will only include the tables and not views.
231
  // TODO - Handle views also, edits to be made in function 'get_create_table_sql' line 336
232
  $tables = $this->db->fetch_numeric('
247
  class Shuttle_Dumper_ShellCommand extends Shuttle_Dumper {
248
  function dump($export_file_location, $table_prefix='') {
249
  $command = 'mysqldump -h ' . escapeshellarg($this->db->host) .
250
+ ' -u ' . escapeshellarg($this->db->username) .
251
+ ' --password=' . escapeshellarg($this->db->password) .
252
  ' ' . escapeshellarg($this->db->name);
253
 
254
  $include_all_tables = empty($table_prefix) &&
284
 
285
  class Shuttle_Dumper_Native extends Shuttle_Dumper {
286
  public function dump($export_file_location, $table_prefix='') {
287
+ global $wp_reset;
288
  $eol = $this->eol;
289
 
290
  $this->dump_file = Shuttle_Dump_File::create($export_file_location);
292
  $this->dump_file->write("-- Generation time: " . date('r') . $eol);
293
  $this->dump_file->write("-- Host: " . $this->db->host . $eol);
294
  $this->dump_file->write("-- DB name: " . $this->db->name . $eol);
295
+ $this->dump_file->write("-- WP Reset ver: " . $wp_reset->get_plugin_version() . $eol);
296
+ $this->dump_file->write("-- Table Prefix: " . $table_prefix . $eol);
297
  $this->dump_file->write("/*!40030 SET NAMES UTF8 */;$eol");
298
+
299
  $this->dump_file->write("/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;$eol");
300
  $this->dump_file->write("/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;$eol");
301
  $this->dump_file->write("/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;$eol");
311
  foreach ($tables as $table) {
312
  $this->dump_table($table);
313
  }
314
+
315
  $this->dump_file->write("$eol$eol");
316
  $this->dump_file->write("/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;$eol");
317
  $this->dump_file->write("/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;$eol");
357
  }
358
  $this->dump_file->write($eol . $eol);
359
  }
360
+
361
  public function get_create_table_sql($table) {
362
  $create_table_sql = $this->db->fetch('SHOW CREATE TABLE `' . $table . '`');
363
  return $create_table_sql[0]['Create Table'] . ';';
471
  $this->connect();
472
  }
473
  $res = $this->connection->query($q);
474
+
475
  if (!$res) {
476
  throw new Shuttle_Exception("SQL error: " . $this->connection->error);
477
  }
478
+
479
  return $res;
480
  }
481
 
readme.txt CHANGED
@@ -1,29 +1,29 @@
1
  === WP Reset - Best WordPress Reset Plugin ===
2
- Tags: wordpress reset, reset database, reset wordpress database, reset, advanced wordpress reset, restart wordpress, clean wordpress, default wordpress, reset wp, wp reset, developer, wp-cli
3
  Contributors: WebFactory, wpreset, googlemapswidget, underconstructionpage
4
  Requires at least: 4.0
5
  Requires PHP: 5.2
6
  Tested up to: 5.2
7
- Stable tag: 1.65
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
11
- WordPress Reset resets any WordPress site to the default values without modifying any files. It deletes all customizations and content. Safe to use.
12
 
13
  == Description ==
14
 
15
- <a href="https://wpreset.com/?utm_source=wordpressorg&utm_medium=content&utm_campaign=wp-reset&utm_term=wp-reset-top">WP Reset</a> quickly resets the site's database to the default installation values without modifying any files. It deletes all customizations and content. WP Reset is fast and safe to use. It has multiple fail-safe mechanisms so you can never accidentally lose data. WP Reset is extremely helpful for plugin and theme developers. It **speeds up testing and debugging** by providing a quick way to reset settings and re-test code. It was developed by developers for developers.
16
 
17
  https://youtu.be/qMnkCW2PFoI?rel=0
18
 
19
- For support please use the <a href="https://wordpress.org/support/plugin/wp-reset">forums</a>, and if you need more information visit <a href="https://wpreset.com/?utm_source=wordpressorg&utm_medium=content&utm_campaign=wp-reset&utm_term=wpreset.com">wpreset.com</a> and be sure to check out the <a href="https://wpreset.com/roadmap/?utm_source=wordpressorg&utm_medium=content&utm_campaign=wp-reset&utm_term=roadmap">roadmap</a> for the list of upcoming features.
20
 
21
  Access WP Reset admin page via the "Tools" menu.
22
 
23
- WP Reset is fully integrated with <a href="https://wordpress.org/plugins/wp-webhooks/">WP Webhooks</a> plugin - a secure, universal system that connects WP to any 3rd party systems and enables you to initiate actions both from WPs end (for instance start a MailChimp campaign once a new user registers), and from any other application (create a new user in WP when a purchase is made on a 3rd party system). View more <a href="https://underconstructionpage.com/wp-webhooks-connect-integrate-wordpress/" target="_blank">practical use-cases</a> that save hours of repetitive work.
24
 
25
 
26
- **Please read carefully before proceeding to understand what WP Reset does**
27
 
28
  #### Resetting will delete:
29
 
@@ -40,12 +40,17 @@ WP Reset is fully integrated with <a href="https://wordpress.org/plugins/wp-webh
40
 
41
  #### What happens when I click the Reset button?
42
 
 
43
  * you will have to confirm the action one more time because there is NO UNDO
44
  * everything will be reset; see bullets above for details
45
  * site title, WordPress address, site address, site language, search engine visibility settings as well as the current user will be restored
46
  * you will be logged out, automatically logged in and taken to the admin dashboard
47
  * WP Reset plugin will be reactivated if that option is chosen in the post-reset options
48
 
 
 
 
 
49
  #### WP-CLI support
50
 
51
  WP Reset comes with full WP-CLI support. Help on our WP-CLI commands is available via _wp help reset_. By default the commands have to be confirmed but you can use the `--yes` option to skip confirmation. Instead of the active user, the first user with admin privileges found in the database will be restored after reset. Please be careful when using WP Reset with WP-CLI - as with using the GUI there is no undo.
@@ -97,12 +102,21 @@ Or if needed, upload manually;
97
 
98
  == Screenshots ==
99
 
100
- 1. WP Reset admin page
101
- 2. Reset action has to be double-confirmed
102
  3. Additional tools for resetting and deleting various WordPress objects
 
 
103
 
104
  == Changelog ==
105
 
 
 
 
 
 
 
 
106
  = v1.65 =
107
  * 2019/07/15
108
  * bug fixes
@@ -189,13 +203,17 @@ Or if needed, upload manually;
189
 
190
  == Frequently Asked Questions ==
191
 
 
 
 
 
192
  = How can I log in after resetting? =
193
 
194
  Use the same username and password you used while doing the reset. Only one user will be restored after resetting. The one you used at that time.
195
 
196
- = Will any files be deleted or modified? =
197
 
198
- No. All files are left untouched.
199
 
200
  = Will I have to reconfigure wp-config.php? =
201
 
1
  === WP Reset - Best WordPress Reset Plugin ===
2
+ Tags: wordpress reset, reset database, reset wordpress database, reset, advanced wordpress reset, restart wordpress, clean wordpress, default wp, default wordpress, reset wp, wp reset, developer, wp-cli, webhooks, backup, database backup
3
  Contributors: WebFactory, wpreset, googlemapswidget, underconstructionpage
4
  Requires at least: 4.0
5
  Requires PHP: 5.2
6
  Tested up to: 5.2
7
+ Stable tag: 1.70
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
11
+ WP Reset resets a WordPress site, or just the chosen parts, to the default values. It's safe to use with built-in 1-click backup.
12
 
13
  == Description ==
14
 
15
+ <a href="https://wpreset.com/?utm_source=wordpressorg&utm_medium=content&utm_campaign=wp-reset&utm_term=wp-reset-top">WP Reset</a> quickly resets the site's database to the default installation values without modifying any files. It deletes all customizations and content, or just chosen parts like theme settings. WP Reset is fast and safe to use thanks to the built-in 1-click backup function. It has multiple fail-safe mechanisms so you can never accidentally lose data. WP Reset is extremely helpful for plugin and theme developers. It **speeds up testing & debugging** by providing a quick way to reset settings and re-test code. It's the only WP development tool for non-developers.
16
 
17
  https://youtu.be/qMnkCW2PFoI?rel=0
18
 
19
+ For support please use the <a href="https://wordpress.org/support/plugin/wp-reset">official forum</a>, and if you need more information visit <a href="https://wpreset.com/?utm_source=wordpressorg&utm_medium=content&utm_campaign=wp-reset&utm_term=wpreset.com">wpreset.com</a> and be sure to check out the <a href="https://wpreset.com/roadmap/?utm_source=wordpressorg&utm_medium=content&utm_campaign=wp-reset&utm_term=roadmap">roadmap</a> for the list of upcoming features.
20
 
21
  Access WP Reset admin page via the "Tools" menu.
22
 
23
+ WP Reset is fully integrated with <a href="https://wordpress.org/plugins/wp-webhooks/">WP Webhooks</a> plugin - a secure, universal system that connects WP to any 3rd party systems and enables you to initiate actions both from WordPress (for instance start a MailChimp campaign once a new user registers), and from any other application (create a new user in WP when a purchase is made on a 3rd party system). View more <a href="https://underconstructionpage.com/wp-webhooks-connect-integrate-wordpress/" target="_blank">practical use-cases</a> that save hours of repetitive work.
24
 
25
 
26
+ **Please read carefully before proceeding to understand what WP Reset does, and remember to always create a backup**
27
 
28
  #### Resetting will delete:
29
 
40
 
41
  #### What happens when I click the Reset button?
42
 
43
+ * remember to always make a backup first
44
  * you will have to confirm the action one more time because there is NO UNDO
45
  * everything will be reset; see bullets above for details
46
  * site title, WordPress address, site address, site language, search engine visibility settings as well as the current user will be restored
47
  * you will be logged out, automatically logged in and taken to the admin dashboard
48
  * WP Reset plugin will be reactivated if that option is chosen in the post-reset options
49
 
50
+ #### 1-click Backup Tool
51
+
52
+ WP Reset comes with built-in backup functionality. Before deleting any data or running any reset tools make sure you download a fresh backup. Click any of the "download backup" links in the plugin, wait a few seconds till the backup is created and then save it to your computer. WP Reset does not backup any files! So the ZIP you download will only contain the full database; no files are included or saved anywhere.
53
+
54
  #### WP-CLI support
55
 
56
  WP Reset comes with full WP-CLI support. Help on our WP-CLI commands is available via _wp help reset_. By default the commands have to be confirmed but you can use the `--yes` option to skip confirmation. Instead of the active user, the first user with admin privileges found in the database will be restored after reset. Please be careful when using WP Reset with WP-CLI - as with using the GUI there is no undo.
102
 
103
  == Screenshots ==
104
 
105
+ 1. WP Reset - main reset page
106
+ 2. All reset actions have to be confirmed
107
  3. Additional tools for resetting and deleting various WordPress objects
108
+ 4. Database Snapshots enable 1-click restoring and testing
109
+ 5. Use our 1-click backup feature before running any reset tools
110
 
111
  == Changelog ==
112
 
113
+ = v1.70 =
114
+ * 2019/09/27
115
+ * bug fixes
116
+ * completely new GUI
117
+ * added .htaccess file to protect snapshots and backups folder
118
+ * added 1-click backup feature
119
+
120
  = v1.65 =
121
  * 2019/07/15
122
  * bug fixes
203
 
204
  == Frequently Asked Questions ==
205
 
206
+ = Does WP Reset make backups? =
207
+
208
+ Automatically no, it does not. But we have "download backup" links besides every tool in the plugin so make sure you download a backup before running them. Backups only contain the database, no files!
209
+
210
  = How can I log in after resetting? =
211
 
212
  Use the same username and password you used while doing the reset. Only one user will be restored after resetting. The one you used at that time.
213
 
214
+ = Will any files be deleted or modified when I reset the site? =
215
 
216
+ No. All files are left untouched if you do a full reset. However, there are tool like "delete themes" that do delete files.
217
 
218
  = Will I have to reconfigure wp-config.php? =
219
 
wp-reset-cli.php CHANGED
@@ -1,4 +1,5 @@
1
  <?php
 
2
  /**
3
  * WP Reset
4
  * https://wpreset.com/
@@ -19,32 +20,32 @@ class WP_Reset_CLI extends WP_CLI_Command
19
  {
20
 
21
  /**
22
- * Reset the site database to default values. No files are modified.
23
- *
24
- * ## OPTIONS
25
- *
26
- * [--reactivate-theme]
27
- * : Reactivate currently active theme after reset.
28
- *
29
- * [--reactivate-plugins]
30
- * : Reactivate all currently active plugins after reset.
31
- *
32
- * [--reactivate-webhooks]
33
- * : Reactivate WP Webhooks plugin after reset.
34
- *
35
- * [--deactivate-wp-reset]
36
- * : Deactivate WP Reset plugin after reset. By default it will stay active after reset.
37
- *
38
- * [--yes]
39
- * : Answer yes to the confirmation message.
40
- *
41
- * ## EXAMPLES
42
- *
43
- * $ wp reset reset --yes
44
- * Success: Database has been reset.
45
- *
46
- * @when after_wp_load
47
- */
48
  function reset($args, $assoc_args)
49
  {
50
  WP_CLI::confirm('Are you sure you want to reset the site? There is NO UNDO!', $assoc_args);
@@ -77,10 +78,10 @@ class WP_Reset_CLI extends WP_CLI_Command
77
 
78
 
79
  /**
80
- * Display WP Reset version.
81
- *
82
- * @when after_wp_load
83
- */
84
  function version($args, $assoc_args)
85
  {
86
  global $wp_reset;
@@ -90,32 +91,32 @@ class WP_Reset_CLI extends WP_CLI_Command
90
 
91
 
92
  /**
93
- * Delete selected WordPress objects.
94
- *
95
- * ## OPTIONS
96
- *
97
- * <plugins|themes|transients|uploads|custom-tables|htaccess|theme-options>
98
- * : WP objects to delete.
99
- *
100
- * [--yes]
101
- * : Answer yes to the confirmation message.
102
- *
103
- * [--empty]
104
- * : Empty (truncate) custom tables instead of deleting (dropping) them.
105
- *
106
- * ## EXAMPLES
107
- *
108
- * $ wp reset delete themes --yes
109
- * Success: 3 themes have been deleted.
110
- *
111
- * $ wp reset delete custom-tables --truncate --yes
112
- * Success: 3 custom tables have been emptied.
113
- *
114
- * $ wp reset delete htaccess --yes
115
- * Success: Htaccess file has been deleted.
116
- *
117
- * @when after_wp_load
118
- */
119
  function delete($args, $assoc_args)
120
  {
121
  global $wp_reset, $wpdb;
@@ -184,35 +185,35 @@ class WP_Reset_CLI extends WP_CLI_Command
184
 
185
 
186
  /**
187
- * List and manipulate DB snapshots.
188
- *
189
- * ## OPTIONS
190
- *
191
- * <list|create|restore|export|delete>
192
- * : Action to perform with snapshot.
193
- *
194
- * [--yes]
195
- * : Answer yes to the confirmation message.
196
- *
197
- * [--id=<snapshot-id>]
198
- * : Specify snapshot ID when doing restore, export and delete.
199
- *
200
- * [--name=<snapshot-name>]
201
- * : When creating a new snapshot specify an optional name.
202
- *
203
- * ## EXAMPLES
204
- *
205
- * wp reset snapshots create --yes
206
- * Success: New snapshot with ID 089bea has been created.
207
- *
208
- * $ wp reset snapshots delete --id=123456
209
- * Success: Snapshot has been deleted.
210
- *
211
- * $ wp reset snapshots export --id=123456
212
- * Success: Snapshot has been exported and saved to: https://test.site/wp-content/wp-reset-snapshots-export/wp-reset-snapshot-123456.sql.gz
213
- *
214
- * @when after_wp_load
215
- */
216
  function snapshots($args, $assoc_args)
217
  {
218
  global $wp_reset;
@@ -317,6 +318,78 @@ class WP_Reset_CLI extends WP_CLI_Command
317
  return;
318
  }
319
  } // snapshots
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
320
  } // WP_Reset_CLI
321
 
322
  WP_CLI::add_command('reset', 'WP_Reset_CLI');
1
  <?php
2
+
3
  /**
4
  * WP Reset
5
  * https://wpreset.com/
20
  {
21
 
22
  /**
23
+ * Reset the site database to default values. No files are modified.
24
+ *
25
+ * ## OPTIONS
26
+ *
27
+ * [--reactivate-theme]
28
+ * : Reactivate currently active theme after reset.
29
+ *
30
+ * [--reactivate-plugins]
31
+ * : Reactivate all currently active plugins after reset.
32
+ *
33
+ * [--reactivate-webhooks]
34
+ * : Reactivate WP Webhooks plugin after reset.
35
+ *
36
+ * [--deactivate-wp-reset]
37
+ * : Deactivate WP Reset plugin after reset. By default it will stay active after reset.
38
+ *
39
+ * [--yes]
40
+ * : Answer yes to the confirmation message.
41
+ *
42
+ * ## EXAMPLES
43
+ *
44
+ * $ wp reset reset --yes
45
+ * Success: Database has been reset.
46
+ *
47
+ * @when after_wp_load
48
+ */
49
  function reset($args, $assoc_args)
50
  {
51
  WP_CLI::confirm('Are you sure you want to reset the site? There is NO UNDO!', $assoc_args);
78
 
79
 
80
  /**
81
+ * Display WP Reset version.
82
+ *
83
+ * @when after_wp_load
84
+ */
85
  function version($args, $assoc_args)
86
  {
87
  global $wp_reset;
91
 
92
 
93
  /**
94
+ * Delete selected WordPress objects.
95
+ *
96
+ * ## OPTIONS
97
+ *
98
+ * <plugins|themes|transients|uploads|custom-tables|htaccess|theme-options>
99
+ * : WP objects to delete.
100
+ *
101
+ * [--yes]
102
+ * : Answer yes to the confirmation message.
103
+ *
104
+ * [--empty]
105
+ * : Empty (truncate) custom tables instead of deleting (dropping) them.
106
+ *
107
+ * ## EXAMPLES
108
+ *
109
+ * $ wp reset delete themes --yes
110
+ * Success: 3 themes have been deleted.
111
+ *
112
+ * $ wp reset delete custom-tables --truncate --yes
113
+ * Success: 3 custom tables have been emptied.
114
+ *
115
+ * $ wp reset delete htaccess --yes
116
+ * Success: Htaccess file has been deleted.
117
+ *
118
+ * @when after_wp_load
119
+ */
120
  function delete($args, $assoc_args)
121
  {
122
  global $wp_reset, $wpdb;
185
 
186
 
187
  /**
188
+ * List and manipulate DB snapshots.
189
+ *
190
+ * ## OPTIONS
191
+ *
192
+ * <list|create|restore|export|delete>
193
+ * : Action to perform with snapshot.
194
+ *
195
+ * [--yes]
196
+ * : Answer yes to the confirmation message.
197
+ *
198
+ * [--id=<snapshot-id>]
199
+ * : Specify snapshot ID when doing restore, export and delete.
200
+ *
201
+ * [--name=<snapshot-name>]
202
+ * : When creating a new snapshot specify an optional name.
203
+ *
204
+ * ## EXAMPLES
205
+ *
206
+ * wp reset snapshots create --yes
207
+ * Success: New snapshot with ID 089bea has been created.
208
+ *
209
+ * $ wp reset snapshots delete --id=123456
210
+ * Success: Snapshot has been deleted.
211
+ *
212
+ * $ wp reset snapshots export --id=123456
213
+ * Success: Snapshot has been exported and saved to: https://test.site/wp-content/wp-reset-snapshots-export/wp-reset-snapshot-123456.sql.gz
214
+ *
215
+ * @when after_wp_load
216
+ */
217
  function snapshots($args, $assoc_args)
218
  {
219
  global $wp_reset;
318
  return;
319
  }
320
  } // snapshots
321
+
322
+
323
+ /**
324
+ * Manipulate backups.
325
+ *
326
+ * ## OPTIONS
327
+ *
328
+ * <create|list>
329
+ * : Actions to take with backup(s).
330
+ *
331
+ * ## EXAMPLES
332
+ *
333
+ * $ wp reset backup create
334
+ * Success: New backup created; /wp-content/wp-reset-backups/wp-reset-backup-site-com-2019-09-25-16-44-37-654a.sql.gz
335
+ *
336
+ * $ wp reset backup list
337
+ * Success: 2 backups found.
338
+ * ---
339
+ * -
340
+ * file: /wp-content/wp-reset-backups/wp-reset-backup-site-com-2019-09-24-15-35-55-6514.sql.gz
341
+ * -
342
+ * file: /wp-content/wp-reset-backups/wp-reset-backup-site-com-2019-09-24-15-38-09-45ab.sql.gz
343
+ *
344
+ * @when after_wp_load
345
+ */
346
+ function backup($args, $assoc_args)
347
+ {
348
+ global $wp_reset;
349
+
350
+ if (empty($args[0])) {
351
+ WP_CLI::error('Please choose a subcommand: create or list.');
352
+ return;
353
+ } elseif (false == in_array($args[0], array('create', 'list'))) {
354
+ WP_CLI::error('Unknown subcommand. Please choose from: create or list.');
355
+ } else {
356
+ $subcommand = $args[0];
357
+ }
358
+
359
+ switch ($subcommand) {
360
+ case 'create':
361
+ $filename = $wp_reset->do_create_backup(true);
362
+ if (is_wp_error($filename)) {
363
+ WP_CLI::error('Unable to create new backup. ' . $filename->get_error_message());
364
+ } else {
365
+ WP_CLI::success('New backup created: /wp-content/' . $wp_reset->backups_folder . '/' . $filename);
366
+ }
367
+ break;
368
+ case 'list':
369
+ $out = array();
370
+ $files = @scandir(trailingslashit(WP_CONTENT_DIR) . $wp_reset->backups_folder . '/');
371
+ if (false === $files || !is_array($files)) {
372
+ WP_CLI::error('Unable to open backups folder.');
373
+ } else {
374
+ foreach ($files as $file) {
375
+ if (substr($file, -3) == '.gz') {
376
+ $out[] = array('file' => '/wp-content/' . $wp_reset->backups_folder . '/' . $file);
377
+ }
378
+ } // foreach
379
+ if ($out) {
380
+ WP_CLI::success(sizeof($out) . ' backup' . (sizeof($out) == 1 ? '' : 's') . ' found.');
381
+ WP_CLI\Utils\format_items('yaml', $out, array('file'));
382
+ } else {
383
+ WP_CLI::error('No backups found.');
384
+ }
385
+ }
386
+ break;
387
+ default:
388
+ // should never come to this but can't hurt
389
+ WP_CLI::error('Unknown subcommand. Please choose from: create or list.');
390
+ return;
391
+ }
392
+ } // backup
393
  } // WP_Reset_CLI
394
 
395
  WP_CLI::add_command('reset', 'WP_Reset_CLI');
wp-reset.php CHANGED
@@ -2,8 +2,8 @@
2
  /*
3
  Plugin Name: WP Reset
4
  Plugin URI: https://wpreset.com/
5
- Description: Reset the site to default installation values without modifying any files. Deletes all customizations and content.
6
- Version: 1.65
7
  Author: WebFactory Ltd
8
  Author URI: https://www.webfactoryltd.com/
9
  Text Domain: wp-reset
@@ -43,6 +43,7 @@ class WP_Reset
43
  public $plugin_url = '';
44
  public $plugin_dir = '';
45
  public $snapshots_folder = 'wp-reset-snapshots-export';
 
46
  protected $options = array();
47
  private $delete_count = 0;
48
  private $licensing_servers = array('https://license1.wpreset.com/', 'https://license2.wpreset.com/');
@@ -83,6 +84,7 @@ class WP_Reset
83
  add_action('wp_ajax_wp_reset_run_tool', array($this, 'ajax_run_tool'));
84
  add_action('wp_ajax_wp_reset_submit_survey', array($this, 'ajax_submit_survey'));
85
  add_action('admin_action_install_webhooks', array($this, 'install_webhooks'));
 
86
 
87
  add_filter('plugin_action_links_' . plugin_basename(__FILE__), array($this, 'plugin_action_links'));
88
  add_filter('plugin_row_meta', array($this, 'plugin_meta_links'), 10, 2);
@@ -132,6 +134,14 @@ class WP_Reset
132
  $options['last_run'] = array();
133
  $change = true;
134
  }
 
 
 
 
 
 
 
 
135
  if (!isset($options['options'])) {
136
  $options['options'] = array();
137
  $change = true;
@@ -331,11 +341,15 @@ class WP_Reset
331
  'cancel_button' => __('Cancel', 'wp-reset'),
332
  'open_survey' => $survey,
333
  'ok_button' => __('OK', 'wp-reset'),
 
334
  'confirm_button' => __('Reset WordPress', 'wp-reset'),
335
  'confirm_title' => __('Are you sure you want to proceed?', 'wp-reset'),
336
- 'confirm1' => __('Clicking "Reset WordPress" will reset your site to default values. All content will be lost. There is NO UNDO.', 'wp-reset'),
 
337
  'confirm2' => __('Click "Cancel" to abort.', 'wp-reset'),
338
  'doing_reset' => __('Resetting in progress. Please wait.', 'wp-reset'),
 
 
339
  'nonce_dismiss_notice' => wp_create_nonce('wp-reset_dismiss_notice'),
340
  'nonce_run_tool' => wp_create_nonce('wp-reset_run_tool'),
341
  'nonce_do_reset' => wp_create_nonce('wp-reset_do_reset'),
@@ -348,16 +362,20 @@ class WP_Reset
348
  $js_localize['webhooks_install_url'] = add_query_arg(array('action' => 'install_webhooks'), admin_url('admin.php'));
349
  }
350
 
 
351
  wp_enqueue_style('wp-jquery-ui-dialog');
352
  wp_enqueue_style('wp-reset', $this->plugin_url . 'css/wp-reset.css', array(), $this->version);
353
  wp_enqueue_style('wp-reset-sweetalert2', $this->plugin_url . 'css/sweetalert2.min.css', array(), $this->version);
354
 
 
355
  wp_enqueue_script('jquery-ui-dialog');
356
  wp_enqueue_script('jquery-ui-tabs');
357
- wp_enqueue_script('wp-reset-sweetalert2', $this->plugin_url . 'js/sweetalert2.min.js', array('jquery'), $this->version, true);
358
  wp_enqueue_script('wp-reset', $this->plugin_url . 'js/wp-reset.js', array('jquery'), $this->version, true);
359
  wp_localize_script('wp-reset', 'wp_reset', $js_localize);
360
 
 
 
361
  // fix for aggressive plugins that include their CSS on all pages
362
  wp_dequeue_style('uiStyleSheet');
363
  wp_dequeue_style('wpcufpnAdmin');
@@ -374,6 +392,22 @@ class WP_Reset
374
  } // admin_enqueue_scripts
375
 
376
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
377
  /**
378
  * Submit user selected survey answers to WPR servers
379
  *
@@ -455,7 +489,7 @@ class WP_Reset
455
  static function is_cli_running()
456
  {
457
  if (!is_null($value = apply_filters('wp-reset-override-is-cli-running', null))) {
458
- return (bool)$value;
459
  }
460
 
461
  if (defined('WP_CLI') && WP_CLI) {
@@ -668,13 +702,13 @@ class WP_Reset
668
  $this->delete_folder($folder . DIRECTORY_SEPARATOR . $file, $base_folder);
669
  } else {
670
  $tmp = @unlink($folder . DIRECTORY_SEPARATOR . $file);
671
- $this->delete_count = $this->delete_count + (int)$tmp;
672
  }
673
  } // foreach
674
 
675
  if ($folder != $base_folder) {
676
  $tmp = @rmdir($folder);
677
- $this->delete_count = $this->delete_count + (int)$tmp;
678
  return $tmp;
679
  } else {
680
  return true;
@@ -702,7 +736,7 @@ class WP_Reset
702
  $wp_reset_basename = plugin_basename(__FILE__);
703
 
704
  $all_plugins = get_plugins();
705
- $active_plugins = (array)get_option('active_plugins', array());
706
  if (true == $keep_wp_reset) {
707
  if (($key = array_search($wp_reset_basename, $active_plugins)) !== false) {
708
  unset($active_plugins[$key]);
@@ -926,6 +960,14 @@ class WP_Reset
926
  $url = content_url() . '/' . $this->snapshots_folder . '/' . $res;
927
  wp_send_json_success($url);
928
  }
 
 
 
 
 
 
 
 
929
  } elseif ($tool == 'restore_snapshot') {
930
  $res = $this->do_restore_snapshot($extra_data);
931
  if (is_wp_error($res)) {
@@ -1113,7 +1155,7 @@ class WP_Reset
1113
  'reactivate_wpreset' => '0',
1114
  'reactivate_webhooks' => '0'
1115
  );
1116
- $params = shortcode_atts($defaults, (array)@$_POST['wpr-post-reset']);
1117
 
1118
  $this->do_reinstall($params);
1119
  }
@@ -1193,7 +1235,7 @@ class WP_Reset
1193
  return $text;
1194
  }
1195
 
1196
- $text = '<i><a href="' . $this->generate_web_link('admin_footer') . '" title="' . __('Visit WP Reset page for more info', 'wp-reset') . '" target="_blank">WP Reset</a> v' . $this->version . ' by <a href="https://www.webfactoryltd.com/" title="' . __('Visit our site to get more great plugins', 'wp-reset') . '" target="_blank">WebFactory Ltd</a>. Please help us out by <a target="_blank" href="https://wordpress.org/support/plugin/wp-reset/reviews/#new-post" title="Rate the plugin">rating the plugin ★★★★★</a>.</i>';
1197
 
1198
  return $text;
1199
  } // admin_footer_text
@@ -1223,6 +1265,20 @@ class WP_Reset
1223
  } // notice_successful_reset
1224
 
1225
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1226
  /**
1227
  * Outputs complete plugin's admin page
1228
  *
@@ -1230,60 +1286,44 @@ class WP_Reset
1230
  */
1231
  function plugin_page()
1232
  {
1233
- $notice_shown = false;
1234
- $meta = $this->get_meta();
1235
- $snapshots = $this->get_snapshots();
1236
-
1237
  // double check for admin privileges
1238
  if (!current_user_can('administrator')) {
1239
  wp_die(__('Sorry, you are not allowed to access this page.', 'wp-reset'));
1240
  }
1241
 
1242
- settings_errors();
1243
  echo '<div class="wrap">';
1244
- echo '<h1><img id="logo-icon" src="' . $this->plugin_url . 'img/wp-reset-logo.png" title="' . __('WP Reset', 'wp-reset') . '" alt="' . __('WP Reset', 'wp-reset') . '"></h1>';
1245
  echo '<form id="wp_reset_form" action="' . admin_url('tools.php?page=wp-reset') . '" method="post" autocomplete="off">';
1246
 
1247
- if (false === $notice_shown && is_multisite()) {
1248
- echo '<div class="card notice-wrapper notice-error">';
1249
- echo '<h2>' . __('WP Reset is not compatible with multisite!', 'wp-reset') . '</h2>';
1250
- echo '<p>' . __('Please be careful when using WP Reset with multisite enabled. It\'s not recommended to reset the main site. Sub-sites should be OK. We\'re working on making it fully compatible with WP-MU. <b>Till then please be careful.</b> Thank you for understanding.', 'wp-reset') . '</p>';
1251
- echo '</div>';
1252
- $notice_shown = true;
1253
- }
1254
-
1255
- // ask for review
1256
- // disabled due to survey
1257
- if ((!empty($meta['reset_count']) || !empty($snapshots)) && false === $notice_shown && false == $this->get_dismissed_notices('rate')) {
1258
- echo '<div class="card notice-wrapper notice-info">';
1259
- echo '<h2>' . __('Please help us keep the plugin free &amp; up-to-date', 'wp-reset') . '</h2>';
1260
- echo '<p>' . __('If you use &amp; enjoy WP Reset, <b>please rate it on WordPress.org</b>. It only takes a second and helps us keep the plugin free and maintained. Thank you!', 'wp-reset') . '</p>';
1261
- echo '<p><a class="button-primary button" title="' . __('Rate WP Reset', 'wp-reset') . '" target="_blank" href="https://wordpress.org/support/plugin/wp-reset/reviews/#new-post">' . __('Help keep the plugin free - rate it!', 'wp-reset') . '</a> <a href="#" class="wpr-dismiss-notice dismiss-notice-rate" data-notice="rate">' . __('I\'ve already rated it', 'wp-reset') . '</a></p>';
1262
- echo '</div>';
1263
- $notice_shown = true;
1264
- }
1265
-
1266
- // Tidy Repo ad
1267
- // disabled for now
1268
- if (false && false === $notice_shown && $meta['reset_count'] >= 2 && false == $this->get_dismissed_notices('tidy')) {
1269
- echo '<div class="card notice-wrapper">';
1270
- echo '<h2>' . __('Are you a plugin author? Get your plugin reviewed on Tidy Repo', 'wp-reset') . '</h2>';
1271
- echo '<p>' . __('Since 2013 Tidy Repo has been reviewing the best and most reliable WordPress plugins. <b>Submitting a plugin is free</b>, so you have nothing to lose and a lot of exposure to gain when it gets reviewed.', 'wp-reset') . '</p>';
1272
- echo '<p><a class="button-primary button" title="' . __('Rate WP Reset', 'wp-reset') . '" target="_blank" href="https://tidyrepo.com/?utm_source=wp-reset-free&utm_medium=plugin&utm_content=notification&utm_campaign=wp-reset-free-v' . $this->version . '">' . __('Let Tidy Repo know you have a great plugin', 'wp-reset') . '</a> <a href="#" class="wpr-dismiss-notice dismiss-notice-rate" data-notice="tidy">' . __('Thanks, I\'m not interested', 'wp-reset') . '</a></p>';
1273
- echo '</div>';
1274
- $notice_shown = true;
1275
- }
1276
 
1277
- // tabs
1278
- echo '<div id="wp-reset-tabs" class' . __('="', 'wp-reset') . 'ui-tabs">';
1279
 
 
 
1280
  echo '<ul class="wpr-main-tab">';
1281
  echo '<li><a href="#tab-reset">' . __('Reset', 'wp-reset') . '</a></li>';
1282
  echo '<li><a href="#tab-tools">' . __('Tools', 'wp-reset') . '</a></li>';
1283
  echo '<li><a href="#tab-snapshots">' . __('DB Snapshots', 'wp-reset') . '</a></li>';
1284
- echo '<li><a href="#tab-collections">' . __('Collections', 'wp-reset') . '</a></li>';
1285
  echo '<li><a href="#tab-support">' . __('Support', 'wp-reset') . '</a></li>';
1286
  echo '</ul>';
 
 
 
 
 
 
 
 
 
 
 
 
1287
 
1288
  echo '<div style="display: none;" id="tab-reset">';
1289
  $this->tab_reset();
@@ -1305,7 +1345,9 @@ class WP_Reset
1305
  $this->tab_support();
1306
  echo '</div>';
1307
 
1308
- echo '</div>'; // tabs
 
 
1309
 
1310
  echo '</form>';
1311
  echo '</div>'; // wrap
@@ -1389,6 +1431,41 @@ class WP_Reset
1389
  } // plugin_page
1390
 
1391
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1392
  /**
1393
  * Echoes content for reset tab
1394
  *
@@ -1399,40 +1476,44 @@ class WP_Reset
1399
  global $current_user, $wpdb;
1400
 
1401
  echo '<div class="card" id="card-description">';
1402
- echo '<a class="toggle-card" href="#" title="' . __('Collapse / expand box', 'wp-reset') . '"><span class="dashicons dashicons-arrow-up-alt2"></span></a>';
1403
- echo '<h2>' . __('Please read carefully before proceeding. There is NO UNDO!', 'wp-reset') . '</h2>';
1404
- echo '<b class="red">' . __('Resetting will delete:', 'wp-reset') . '</b>';
 
 
1405
  echo '<ul class="plain-list">';
1406
  echo '<li>' . __('all posts, pages, custom post types, comments, media entries, users', 'wp-reset') . '</li>';
1407
  echo '<li>' . __('all default WP database tables', 'wp-reset') . '</li>';
1408
  echo '<li>' . sprintf(__('all custom database tables that have the same prefix "%s" as default tables in this installation', 'wp-reset'), $wpdb->prefix) . '</li>';
 
1409
  echo '</ul>';
1410
 
1411
- echo '<b class="green">' . __('Resetting will not delete:', 'wp-reset') . '</b>';
1412
  echo '<ul class="plain-list">';
1413
  echo '<li>' . __('media files - they\'ll remain in the <i>wp-uploads</i> folder but will no longer be listed under Media', 'wp-reset');
1414
- echo __('; use the <a href="#clean-uploads-folder" data-tab="1" class="change-tab">Clean Uploads Folder</a> tool to remove media files', 'wp-reset') . '</li>';
1415
  echo '<li>' . __('no files are touched; plugins, themes, uploads - everything stays', 'wp-reset');
1416
- echo __('; if needed use the <a href="#delete-themes" class="change-tab" data-tab="1">Delete Themes</a> &amp; <a href="#delete-plugins" class="change-tab" data-tab="1">Delete Plugins</a> tools', 'wp-reset') . '</li>';
1417
  echo '<li>' . __('site title, WordPress address, site address, site language and search engine visibility settings', 'wp-reset') . '</li>';
1418
  echo '<li>' . sprintf(__('logged in user "%s" will be restored with the current password', 'wp-reset'), $current_user->user_login) . '</li>';
1419
  echo '</ul>';
1420
 
1421
- echo '<b>' . __('What happens when I click the Reset button?', 'wp-reset') . '</b>';
1422
  echo '<ul class="plain-list">';
 
1423
  echo '<li>' . __('you will have to confirm the action one more time because there is NO UNDO', 'wp-reset') . '</li>';
1424
  echo '<li>' . __('everything will be reset; see bullets above for details', 'wp-reset') . '</li>';
1425
  echo '<li>' . __('site title, WordPress address, site address, site language, search engine visibility and current user will be restored', 'wp-reset') . '</li>';
1426
  echo '<li>' . __('you will be logged out, automatically logged in and taken to the admin dashboard', 'wp-reset') . '</li>';
1427
- echo '<li>' . __('WP Reset plugin will be reactivated if that option is chosen in the <a href="#card-post-reset">post-reset options</a>', 'wp-reset') . '</li>';
1428
  echo '</ul>';
1429
 
1430
- echo '<b>' . __('WP-CLI Support', 'wp-reset') . '</b>';
1431
- echo '<p>' . sprintf(__('All tools available via GUI are available in WP-CLI as well. To get the list of commands run %s. Instead of the active user, the first user with admin privileges found in the database will be restored. ', 'wp-reset'), '<code>wp help reset</code>');
1432
  echo sprintf(__('All actions have to be confirmed. If you want to skip confirmation use the standard %s option. Please be careful - there is NO UNDO.', 'wp-reset'), '<code>--yes</code>') . '</p>';
1433
 
1434
- echo '<b>' . __('WP Webhooks Support', 'wp-reset') . '</b>';
1435
- echo '<p>All WP Reset tools are integrated with <a href="https://wordpress.org/plugins/wp-webhooks/" target="_blank">WP Webhooks</a> and available as (receive data) actions. Webhooks are a standard, platform-independent way of connecting WordPress to any 3rd party system. This <a href="https://underconstructionpage.com/wp-webhooks-connect-integrate-wordpress/" target="_blank">article</a> has more info, videos and use-cases so you can see just how powerful and easy to use webhooks are.<br>';
1436
  if ($this->is_webhooks_active()) {
1437
  echo 'WP Webhooks are active. Make sure you enable WP Reset actions in <a href="' . admin_url('options-general.php?page=wp-webhooks-pro&wpwhvrs=settings') . '">settings</a>.';
1438
  } else {
@@ -1442,9 +1523,8 @@ class WP_Reset
1442
 
1443
  $theme = wp_get_theme();
1444
 
1445
- echo '<div class="card" id="card-post-reset">';
1446
- echo '<a class="toggle-card" href="#" title="' . __('Collapse / expand box', 'wp-reset') . '"><span class="dashicons dashicons-arrow-up-alt2"></span></a>';
1447
- echo '<h2>' . __('Post-reset actions', 'wp-reset') . '</h2>';
1448
  echo '<p><label for="reactivate-theme"><input name="wpr-post-reset[reactivate_theme]" type="checkbox" id="reactivate-theme" value="1"> ' . __('Reactivate current theme', 'wp-reset') . ' - ' . $theme->get('Name') . '</label></p>';
1449
  echo '<p><label for="reactivate-wpreset"><input name="wpr-post-reset[reactivate_wpreset]" type="checkbox" id="reactivate-wpreset" value="1" checked> ' . __('Reactivate WP Reset plugin', 'wp-reset') . '</label></p>';
1450
  if ($this->is_webhooks_active()) {
@@ -1454,17 +1534,13 @@ class WP_Reset
1454
  if ($this->is_webhooks_active()) {
1455
  echo '<p><a href="' . admin_url('options-general.php?page=wp-webhooks-pro&wpwhvrs=settings') . '">Configure WP Webhooks</a> to run additional actions after reset, or connect to any 3rd party system.</p>';
1456
  } else {
1457
- echo '<p>If you need to run additional actions after reset, or connect to any 3rd party system, <a href="#" class="open-webhooks-dialog">install WP Webhooks &amp; WPR addon</a>. It\'s a standard platform-independent way of connecting WordPress to any other web app. It automates complex workflows and saves time when developing. Have a look at this <a href="https://www.youtube.com/watch?v=m8XDFXCNP9g" target="_blank">short video</a> for a demonstration.</p>';
1458
  }
1459
- echo '</div>';
1460
-
1461
- echo '<div class="card">';
1462
- echo '<h2>' . __('Reset', 'wp-reset') . '</h2>';
1463
- echo '<p>' . __('Type <b>reset</b> in the confirmation field to confirm the reset and then click the "Reset WordPress" button. <b>There is NO UNDO. No backups are made by WP Reset.</b>', 'wp-reset') . '</p>';
1464
 
1465
  wp_nonce_field('wp-reset');
1466
  echo '<p><input id="wp_reset_confirm" type="text" name="wp_reset_confirm" placeholder="' . esc_attr__('Type in "reset"', 'wp-reset') . '" value="" autocomplete="off"> &nbsp;';
1467
- echo '<input id="wp_reset_submit" type="button" class="button-primary" value="' . __('Reset WordPress', 'wp-reset') . '"></p>';
1468
  echo '</div>';
1469
  } // tab_reset
1470
 
@@ -1477,50 +1553,50 @@ class WP_Reset
1477
  private function tab_tools()
1478
  {
1479
  echo '<div class="card">';
1480
- echo '<h2 id="delete-transients">' . __('Delete Transients', 'wp-reset') . '</h2>';
1481
- echo '<p>' . __('All transient related database entries will be deleted. Including expired and non-expired transients, and orphaned transient timeout entries.<br><b>There is NO UNDO. WP Reset does not make any backups.</b>', 'wp-reset') . '</p>';
1482
- echo '<p><a data-btn-confirm="Delete all transients" data-text-wait="Deleting transients. Please wait." data-text-confirm="All database entries related to transients will be deleted. There is NO UNDO. WP Reset will not make any backups." data-text-done="%n transient database entries have been deleted." data-text-done-singular="One transient database entry has been deleted." class="button button-delete" href="#" id="delete-transients">Delete all transients</a></p>';
1483
  echo '</div>';
1484
 
1485
  $upload_dir = wp_upload_dir(date('Y/m'), true);
1486
  $upload_dir['basedir'] = str_replace(array('/', '\\'), DIRECTORY_SEPARATOR, $upload_dir['basedir']);
1487
 
1488
  echo '<div class="card">';
1489
- echo '<h2 id="clean-uploads-folder">' . __('Clean Uploads Folder', 'wp-reset') . '</h2>';
1490
- echo '<p>' . __('All files in <code>' . $upload_dir['basedir'] . '</code> folder will be deleted. Including folders and subfolders, and files in subfolders. Files associated with <a href="' . admin_url('upload.php') . '">media</a> entries will be deleted too.<br><b>There is NO UNDO. WP Reset does not make any backups.</b>', 'wp-reset') . '</p>';
1491
  if (false != $upload_dir['error']) {
1492
  echo '<p><span style="color:#dd3036;"><b>Tool is not available.</b></span> Folder is not writeable by WordPress. Please check file and folder access rights.</p>';
1493
  } else {
1494
- echo '<p><a data-btn-confirm="Delete everything in uploads folder" data-text-wait="Deleting uploads. Please wait." data-text-confirm="All files and folders in uploads will be deleted. There is NO UNDO. WP Reset will not make any backups." data-text-done="%n files &amp; folders have been deleted." data-text-done-singular="One file or folder has been deleted." class="button button-delete" href="#" id="delete-uploads">Delete all files &amp; folders in uploads folder</a></p>';
1495
  }
1496
  echo '</div>';
1497
 
1498
  echo '<div class="card">';
1499
- echo '<h2 id="reset-theme-options">' . __('Reset Theme Options', 'wp-reset') . '</h2>';
1500
- echo '<p>' . __('All options (mods) for all themes will be reset; not just for the active theme. The tool works only for themes that use the <a href="https://codex.wordpress.org/Theme_Modification_API" target="_blank">WordPress theme modification API</a>. If options are saved in some other, custom way they won\'t be reset.<br><b>There is NO UNDO. WP Reset does not make any backups.</b>', 'wp-reset') . '</p>';
1501
- echo '<p><a data-btn-confirm="Reset theme options" data-text-wait="Resetting theme options. Please wait." data-text-confirm="All options (mods) for all themes will be reset. There is NO UNDO. WP Reset will not make any backups." data-text-done="Options for %n themes have been reset." data-text-done-singular="Options for one theme have been reset." class="button button-delete" href="#" id="reset-theme-options">Reset theme options</a></p>';
1502
  echo '</div>';
1503
 
1504
  $theme = wp_get_theme();
1505
 
1506
  echo '<div class="card">';
1507
- echo '<h2 id="delete-themes">' . __('Delete Themes', 'wp-reset') . '</h2>';
1508
- echo '<p>' . __('All themes will be deleted. Including the currently active theme - ' . $theme->get('Name') . '.<br><b>There is NO UNDO. WP Reset does not make any backups.</b>', 'wp-reset') . '</p>';
1509
- echo '<p><a data-btn-confirm="Delete all themes" data-text-wait="Deleting all themes. Please wait." data-text-confirm="All themes will be deleted. There is NO UNDO. WP Reset will not make any backups." data-text-done="%n themes have been deleted." data-text-done-singular="One theme has been deleted." class="button button-delete" href="#" id="delete-themes">Delete all themes</a></p>';
1510
  echo '</div>';
1511
 
1512
  echo '<div class="card">';
1513
- echo '<h2 id="delete-plugins">' . __('Delete Plugins', 'wp-reset') . '</h2>';
1514
- echo '<p>' . __('All plugins will be deleted except for WP Reset which will remain active.<br><b>There is NO UNDO. WP Reset does not make any backups.</b>', 'wp-reset') . '</p>';
1515
- echo '<p><a data-btn-confirm="Delete plugins" data-text-wait="Deleting plugins. Please wait." data-text-confirm="All plugins except WP Reset will be deleted. There is NO UNDO. WP Reset will not make any backups." data-text-done="%n plugins have been deleted." data-text-done-singular="One plugin has been deleted." class="button button-delete" href="#" id="delete-plugins">Delete plugins</a></p>';
1516
  echo '</div>';
1517
 
1518
  global $wpdb;
1519
  $custom_tables = $this->get_custom_tables();
1520
 
1521
  echo '<div class="card">';
1522
- echo '<h2 id="empty-delete-custom-tables">' . __('Empty or Delete Custom Tables', 'wp-reset') . '</h2>';
1523
- echo '<p>' . __('This action affects only custom tables with <code>' . $wpdb->prefix . '</code> prefix. Core WP tables and other tables in the database that do not have that prefix will not be deleted/emptied. Deleting (dropping) tables completely removes them from the database. Emptying (truncating) removes all content from them, but keeps the structure intact.<br><b>There is NO UNDO. WP Reset does not make any backups.</b></p>', 'wp-reset');
1524
  if ($custom_tables) {
1525
  echo '<p>' . __('The following ' . sizeof($custom_tables) . ' custom tables are affected by this tool: ');
1526
  foreach ($custom_tables as $tbl) {
@@ -1535,18 +1611,18 @@ class WP_Reset
1535
  echo '<p>' . __('There are no custom tables. There\'s nothing for this tool to empty or delete.', 'wp-reset') . '</p>';
1536
  $custom_tables_btns = ' disabled';
1537
  }
1538
- echo '<p><a data-btn-confirm="Empty custom tables" data-text-wait="Emptying custom tables. Please wait." data-text-confirm="All custom tables with prefix <code>' . $wpdb->prefix . '</code> will be emptied. There is NO UNDO. WP Reset will not make any backups." data-text-done="%n custom tables have been emptied." data-text-done-singular="One custom table has been emptied." class="button button-delete' . $custom_tables_btns . '" href="#" id="truncate-custom-tables">Empty (truncate) custom tables</a>&nbsp; &nbsp;';
1539
- echo '<a data-btn-confirm="Delete custom tables" data-text-wait="Deleting custom tables. Please wait." data-text-confirm="All custom tables with prefix <code>' . $wpdb->prefix . '</code> will be deleted. There is NO UNDO. WP Reset will not make any backups." data-text-done="%n custom tables have been deleted." data-text-done-singular="One custom table has been deleted." class="button button-delete' . $custom_tables_btns . '" href="#" id="drop-custom-tables">Delete (drop) custom tables</a></p>';
1540
 
1541
  echo '</div>';
1542
 
1543
  echo '<div class="card">';
1544
- echo '<h2 id="delete-htaccess-file">' . __('Delete .htaccess File', 'wp-reset') . '</h2>';
1545
- echo '<p>' . __('This action deletes the .htaccess file located in <code>' . $this->get_htaccess_path() . '</code><br><b>There is NO UNDO. WP Reset does not make any backups.</b></p>', 'wp-reset');
1546
 
1547
- echo '<p>If you need to edit .htaccess, install our free <a href="' . admin_url('plugin-install.php?s=htaccess+editor&tab=search&type=term') . '" target="_blank">WP Htaccess Editor</a> plugin. It automatically creates backups when you edit .htaccess. To create the default .htaccess file open <a href="' . admin_url('options-permalink.php') . '">Settings - Permalinks</a> and re-save settings. WordPress will recreate the file.</p>';
1548
 
1549
- echo '<a data-btn-confirm="Delete .htaccess file" data-text-wait="Deleting .htaccess file. Please wait." data-text-confirm="Htaccess file will be deleted. There is NO UNDO. WP Reset will not make any backups." data-text-done="Htaccess file has been deleted." class="button button-delete" href="#" id="delete-htaccess">Delete .htaccess file</a></p>';
1550
 
1551
  echo '</div>';
1552
  } // tab_tools
@@ -1560,13 +1636,9 @@ class WP_Reset
1560
  private function tab_collections()
1561
  {
1562
  echo '<div class="card">';
1563
- echo '<h2>' . __('What are Plugin &amp; Theme Collections', 'wp-reset') . '</h2>';
1564
- echo '<p>' . __('Another tools that will save your precious time! Have a set of plugins and themes that you install and activate after every reset? Or on every fresh WP installation? Well, no more clicking install/active for five minutes! Build the collection once and install it with one click the next time you need it. Collections are stored in the cloud so they\'re accessible on every site.', 'wp-reset') . '</p>';
1565
- echo '</div>';
1566
-
1567
- echo '<div class="card">';
1568
- echo '<h2>' . __('So where do I click?!', 'wp-reset') . '</h2>';
1569
- echo '<p>' . __('We are working hard on building collections as we speak and plan to have a beta version done by late May. Want to be the first to try the beta? Or tell us to code faster? :) Give us a shout <a href="https://twitter.com/webfactoryltd" target="_blank">@webfactoryltd</a>.', 'wp-reset') . '</p>';
1570
  echo '</div>';
1571
  } // tab_collections
1572
 
@@ -1579,22 +1651,22 @@ class WP_Reset
1579
  private function tab_support()
1580
  {
1581
  echo '<div class="card">';
1582
- echo '<h2>' . __('Documentation', 'wp-reset') . '</h2>';
1583
- echo '<p>' . __('All tools and functions are explained in detail in <a href="' . $this->generate_web_link('support-tab', '/documentation/') . '" target="_blank">the documentation</a>. We did our best to describe how things work on both the code level and a "average user" level.', 'wp-reset') . '</p>';
1584
  echo '</div>';
1585
 
1586
  echo '<div class="card">';
1587
- echo '<h2>' . __('Public support forum', 'wp-reset') . '</h2>';
1588
  echo '<p>' . __('We are very active on the <a href="https://wordpress.org/support/plugin/wp-reset" target="_blank">official WP Reset support forum</a>. If you found a bug, have a feature idea or just want to say hi - please drop by. We love to hear back from our users.', 'wp-reset') . '</p>';
1589
  echo '</div>';
1590
 
1591
  echo '<div class="card">';
1592
- echo '<h2>' . __('Private contact', 'wp-reset') . '</h2>';
1593
  echo '<p>' . __('If there\'s a need to contact us privately send emails to <a href="mailto:wpreset@webfactoryltd.com">wpreset@webfactoryltd.com</a>. Please know that although we\'ll gladly have a look at issues you are having with any site, we can\'t promise we\'ll fix them. Thank you for understanding.', 'wp-reset') . '</p>';
1594
  echo '</div>';
1595
 
1596
  echo '<div class="card">';
1597
- echo '<h2>' . __('Care to help out?', 'wp-reset') . '</h2>';
1598
  echo '<p>' . __('No need for donations or anything like that :) If you can give us a <a href="https://wordpress.org/support/plugin/wp-reset/reviews/#new-post" target="_blank">five star rating</a> you\'ll help out more than you can imagine. A public mention <a href="https://twitter.com/webfactoryltd" target="_blank">@webfactoryltd</a> also does wonders. Thank you!', 'wp-reset') . '</p>';
1599
  echo '</div>';
1600
  } // tab_support
@@ -1611,10 +1683,13 @@ class WP_Reset
1611
  $tbl_core = $tbl_custom = $tbl_size = $tbl_rows = 0;
1612
 
1613
  echo '<div class="card" id="card-snapshots">';
1614
- echo '<a class="toggle-card" href="#" title="' . __('Collapse / expand box', 'wp-reset') . '"><span class="dashicons dashicons-arrow-up-alt2"></span></a>';
1615
- echo '<h2>' . __('Database Snapshots', 'wp-reset') . '</h2>';
1616
- echo '<p>A snapshot is a copy of all WP database tables, standard and custom ones, saved in your database. Files are not saved or included in snapshots in any way. <a href="https://www.youtube.com/watch?v=xBfMmS12vMY" target="_blank">Watch a short video</a> overview and tutorial about Snapshots.<br>
1617
- Snapshots are primarily a development tool. Although they can be used for backups (and downloaded), we suggest finding a more suitable tool for live sites, such as <a href="https://wordpress.org/plugins/updraftplus/" target="_blank">UpdraftPlus</a>. Use snapshots to find out what changes a plugin made to your database or to quickly restore the dev environment after testing database related changes.<br>Restoring a snapshot does not affect other snapshots, or WP Reset settings.</p>';
 
 
 
1618
 
1619
  $table_status = $wpdb->get_results('SHOW TABLE STATUS');
1620
  if (is_array($table_status)) {
@@ -1648,8 +1723,10 @@ class WP_Reset
1648
  echo '</div>';
1649
 
1650
  echo '<div class="card no-padding-bottom">';
1651
- echo '<a id="create-new-snapshot-primary" data-msg-success="Snapshot created!" data-msg-wait="Creating snapshot. Please wait." data-btn-confirm="Create snapshot" data-placeholder="Snapshot name or brief description, ie: before plugin install" data-text="Enter snapshot name or brief description, up to 64 characters." data-title="Create a new snapshot" title="Create a new database snapshot" href="#" class="button button-primary create-new-snapshot create-new-snapshot-corner">' . __('Create new', 'wp-reset') . '</a>';
1652
- echo '<h2>' . __('Saved Snapshots', 'wp-reset') . '</h2>';
 
 
1653
 
1654
  if ($snapshots = $this->get_snapshots()) {
1655
  echo '<table id="wpr-snapshots">';
@@ -1921,9 +1998,17 @@ class WP_Reset
1921
  return new WP_Error(1, 'Unable to create wp-content/' . $this->snapshots_folder . '/ folder.');
1922
  }
1923
 
 
 
 
 
 
 
 
 
1924
  $world_dumper->dump(trailingslashit(WP_CONTENT_DIR) . $this->snapshots_folder . '/wp-reset-snapshot-' . $uid . '.sql.gz', $uid . '_');
1925
  } catch (Shuttle_Exception $e) {
1926
- return new WP_Error(1, "Couldn't dump snapshot: " . $e->getMessage());
1927
  }
1928
 
1929
  do_action('wp_reset_export_snapshot', 'wp-reset-snapshot-' . $uid . '.sql.gz');
@@ -1932,6 +2017,68 @@ class WP_Reset
1932
  } // export_snapshot
1933
 
1934
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1935
  /**
1936
  * Replace current tables with ones in snapshot.
1937
  *
@@ -2309,9 +2456,9 @@ class WP_Reset
2309
  } // foreach
2310
  }
2311
 
2312
- if ($plugin_info = get_transient('wf-plugin-info-' . $plugin_slug)) {
2313
- array_unshift($res->plugins, $plugin_info);
2314
- } else {
2315
  $plugin_info = plugins_api('plugin_information', array(
2316
  'slug' => $plugin_slug,
2317
  'is_ssl' => is_ssl(),
@@ -2325,11 +2472,14 @@ class WP_Reset
2325
  )
2326
  ));
2327
  if (!is_wp_error($plugin_info)) {
2328
- $res->plugins = array_merge(array($plugin_info), $res->plugins);
2329
  set_transient('wf-plugin-info-' . $plugin_slug, $plugin_info, DAY_IN_SECONDS * 7);
2330
  }
2331
  }
2332
 
 
 
 
 
2333
  return $res;
2334
  } // add_plugin_featured
2335
 
@@ -2343,8 +2493,10 @@ class WP_Reset
2343
  {
2344
  remove_filter('plugins_api_result', array($this, 'plugins_api_result'), 10, 3);
2345
 
2346
- $res = $this->add_plugin_featured('security-ninja', $res);
2347
  $res = $this->add_plugin_featured('under-construction-page', $res);
 
 
 
2348
 
2349
  return $res;
2350
  } // plugins_api_result
2
  /*
3
  Plugin Name: WP Reset
4
  Plugin URI: https://wpreset.com/
5
+ Description: Reset the entire site or selected parts to default installation values without having to edit any files.
6
+ Version: 1.70
7
  Author: WebFactory Ltd
8
  Author URI: https://www.webfactoryltd.com/
9
  Text Domain: wp-reset
43
  public $plugin_url = '';
44
  public $plugin_dir = '';
45
  public $snapshots_folder = 'wp-reset-snapshots-export';
46
+ public $backups_folder = 'wp-reset-backups';
47
  protected $options = array();
48
  private $delete_count = 0;
49
  private $licensing_servers = array('https://license1.wpreset.com/', 'https://license2.wpreset.com/');
84
  add_action('wp_ajax_wp_reset_run_tool', array($this, 'ajax_run_tool'));
85
  add_action('wp_ajax_wp_reset_submit_survey', array($this, 'ajax_submit_survey'));
86
  add_action('admin_action_install_webhooks', array($this, 'install_webhooks'));
87
+ add_action('admin_print_scripts', array($this, 'remove_admin_notices'));
88
 
89
  add_filter('plugin_action_links_' . plugin_basename(__FILE__), array($this, 'plugin_action_links'));
90
  add_filter('plugin_row_meta', array($this, 'plugin_meta_links'), 10, 2);
134
  $options['last_run'] = array();
135
  $change = true;
136
  }
137
+ if (!isset($options['last_backup_filename'])) {
138
+ $options['last_backup_filename'] = '';
139
+ $change = true;
140
+ }
141
+ if (!isset($options['last_backup_timestamp'])) {
142
+ $options['last_backup_timestamp'] = 0;
143
+ $change = true;
144
+ }
145
  if (!isset($options['options'])) {
146
  $options['options'] = array();
147
  $change = true;
341
  'cancel_button' => __('Cancel', 'wp-reset'),
342
  'open_survey' => $survey,
343
  'ok_button' => __('OK', 'wp-reset'),
344
+ 'creating_backup' => __('Creating backup. Please wait.', 'wp-reset'),
345
  'confirm_button' => __('Reset WordPress', 'wp-reset'),
346
  'confirm_title' => __('Are you sure you want to proceed?', 'wp-reset'),
347
+ 'confirm_title_reset' => __('Are you sure you want to reset the site?', 'wp-reset'),
348
+ 'confirm1' => __('Clicking "Reset WordPress" will reset your site to default values. All content will be lost. There is NO UNDO. Always <a href="#" class="download-backup">create a backup</a>.</b>', 'wp-reset'),
349
  'confirm2' => __('Click "Cancel" to abort.', 'wp-reset'),
350
  'doing_reset' => __('Resetting in progress. Please wait.', 'wp-reset'),
351
+ 'backup_not_accessible' => __('Backup was created but it\'s not accessible.', 'wp-reset'),
352
+ 'backup_not_accessible_details' => __('Please check your folder access rights. File should be accessible on <a href="%url%" target="_blank">this URL</a>.', 'wp-reset'),
353
  'nonce_dismiss_notice' => wp_create_nonce('wp-reset_dismiss_notice'),
354
  'nonce_run_tool' => wp_create_nonce('wp-reset_run_tool'),
355
  'nonce_do_reset' => wp_create_nonce('wp-reset_do_reset'),
362
  $js_localize['webhooks_install_url'] = add_query_arg(array('action' => 'install_webhooks'), admin_url('admin.php'));
363
  }
364
 
365
+ wp_enqueue_style('plugin-install');
366
  wp_enqueue_style('wp-jquery-ui-dialog');
367
  wp_enqueue_style('wp-reset', $this->plugin_url . 'css/wp-reset.css', array(), $this->version);
368
  wp_enqueue_style('wp-reset-sweetalert2', $this->plugin_url . 'css/sweetalert2.min.css', array(), $this->version);
369
 
370
+ wp_enqueue_script('plugin-install');
371
  wp_enqueue_script('jquery-ui-dialog');
372
  wp_enqueue_script('jquery-ui-tabs');
373
+ wp_enqueue_script('wp-reset-sweetalert2', $this->plugin_url . 'js/wp-reset-libs.min.js', array('jquery'), $this->version, true);
374
  wp_enqueue_script('wp-reset', $this->plugin_url . 'js/wp-reset.js', array('jquery'), $this->version, true);
375
  wp_localize_script('wp-reset', 'wp_reset', $js_localize);
376
 
377
+ add_thickbox();
378
+
379
  // fix for aggressive plugins that include their CSS on all pages
380
  wp_dequeue_style('uiStyleSheet');
381
  wp_dequeue_style('wpcufpnAdmin');
392
  } // admin_enqueue_scripts
393
 
394
 
395
+ /**
396
+ * Remove all WP notices on WPR page
397
+ *
398
+ * @return null
399
+ */
400
+ function remove_admin_notices()
401
+ {
402
+ if (!$this->is_plugin_page()) {
403
+ return false;
404
+ }
405
+
406
+ global $wp_filter;
407
+ unset($wp_filter['user_admin_notices'], $wp_filter['admin_notices']);
408
+ } // remove_admin_notices
409
+
410
+
411
  /**
412
  * Submit user selected survey answers to WPR servers
413
  *
489
  static function is_cli_running()
490
  {
491
  if (!is_null($value = apply_filters('wp-reset-override-is-cli-running', null))) {
492
+ return (bool) $value;
493
  }
494
 
495
  if (defined('WP_CLI') && WP_CLI) {
702
  $this->delete_folder($folder . DIRECTORY_SEPARATOR . $file, $base_folder);
703
  } else {
704
  $tmp = @unlink($folder . DIRECTORY_SEPARATOR . $file);
705
+ $this->delete_count = $this->delete_count + (int) $tmp;
706
  }
707
  } // foreach
708
 
709
  if ($folder != $base_folder) {
710
  $tmp = @rmdir($folder);
711
+ $this->delete_count = $this->delete_count + (int) $tmp;
712
  return $tmp;
713
  } else {
714
  return true;
736
  $wp_reset_basename = plugin_basename(__FILE__);
737
 
738
  $all_plugins = get_plugins();
739
+ $active_plugins = (array) get_option('active_plugins', array());
740
  if (true == $keep_wp_reset) {
741
  if (($key = array_search($wp_reset_basename, $active_plugins)) !== false) {
742
  unset($active_plugins[$key]);
960
  $url = content_url() . '/' . $this->snapshots_folder . '/' . $res;
961
  wp_send_json_success($url);
962
  }
963
+ } elseif ($tool == 'download_backup') {
964
+ $res = $this->do_create_backup();
965
+ if (is_wp_error($res)) {
966
+ wp_send_json_error($res->get_error_message());
967
+ } else {
968
+ $url = content_url() . '/' . $this->backups_folder . '/' . $res;
969
+ wp_send_json_success($url);
970
+ }
971
  } elseif ($tool == 'restore_snapshot') {
972
  $res = $this->do_restore_snapshot($extra_data);
973
  if (is_wp_error($res)) {
1155
  'reactivate_wpreset' => '0',
1156
  'reactivate_webhooks' => '0'
1157
  );
1158
+ $params = shortcode_atts($defaults, (array) @$_POST['wpr-post-reset']);
1159
 
1160
  $this->do_reinstall($params);
1161
  }
1235
  return $text;
1236
  }
1237
 
1238
+ $text = '<i><a href="' . $this->generate_web_link('admin_footer') . '" title="' . __('Visit WP Reset page for more info', 'wp-reset') . '" target="_blank">WP Reset</a> v' . $this->version . '. Please <a target="_blank" href="https://wordpress.org/support/plugin/wp-reset/reviews/#new-post" title="Rate the plugin">rate the plugin <span>★★★★★</span></a> to help us spread the word. Thank you from the WP Reset team!</i>';
1239
 
1240
  return $text;
1241
  } // admin_footer_text
1265
  } // notice_successful_reset
1266
 
1267
 
1268
+ /**
1269
+ * Generates a button that initiates backup creation and download
1270
+ *
1271
+ * @return string
1272
+ */
1273
+ function get_backup_button($tool_id = '')
1274
+ {
1275
+ $out = '';
1276
+ $out .= '<a data-tool-id="' . $tool_id . '" class="button download-backup" href="#">Create &amp; download backup</a>';
1277
+
1278
+ return $out;
1279
+ } // get_backup_button
1280
+
1281
+
1282
  /**
1283
  * Outputs complete plugin's admin page
1284
  *
1286
  */
1287
  function plugin_page()
1288
  {
 
 
 
 
1289
  // double check for admin privileges
1290
  if (!current_user_can('administrator')) {
1291
  wp_die(__('Sorry, you are not allowed to access this page.', 'wp-reset'));
1292
  }
1293
 
 
1294
  echo '<div class="wrap">';
 
1295
  echo '<form id="wp_reset_form" action="' . admin_url('tools.php?page=wp-reset') . '" method="post" autocomplete="off">';
1296
 
1297
+ echo '<header>';
1298
+ echo '<div class="wpr-container">';
1299
+ echo '<img id="logo-icon" src="' . $this->plugin_url . 'img/wp-reset-logo.png" title="' . __('WP Reset', 'wp-reset') . '" alt="' . __('WP Reset', 'wp-reset') . '">';
1300
+ echo '<a href="' . $this->generate_web_link('header', '/pro-version-launch/') . '" target="_blank" class="button button-primary alignright">Grab the limited LTD offer!</a>';
1301
+ echo '</div>';
1302
+ echo '</header>';
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1303
 
1304
+ echo '<div id="wp-reset-tabs" class="ui-tabs">';
 
1305
 
1306
+ echo '<nav>';
1307
+ echo '<div class="wpr-container">';
1308
  echo '<ul class="wpr-main-tab">';
1309
  echo '<li><a href="#tab-reset">' . __('Reset', 'wp-reset') . '</a></li>';
1310
  echo '<li><a href="#tab-tools">' . __('Tools', 'wp-reset') . '</a></li>';
1311
  echo '<li><a href="#tab-snapshots">' . __('DB Snapshots', 'wp-reset') . '</a></li>';
1312
+ echo '<li><a href="#tab-collections">' . __('Plugins &amp; Themes Collections', 'wp-reset') . '</a></li>';
1313
  echo '<li><a href="#tab-support">' . __('Support', 'wp-reset') . '</a></li>';
1314
  echo '</ul>';
1315
+ echo '</div>'; // container
1316
+ echo '</nav>';
1317
+
1318
+ echo '<div id="wpr-notifications">';
1319
+ echo '<div class="wpr-container">';
1320
+ $this->custom_notifications();
1321
+ echo '</div>';
1322
+ echo '</div>'; // wpr-notifications
1323
+
1324
+ // tabs
1325
+ echo '<div class="wpr-container">';
1326
+ echo '<div id="wpr-content">';
1327
 
1328
  echo '<div style="display: none;" id="tab-reset">';
1329
  $this->tab_reset();
1345
  $this->tab_support();
1346
  echo '</div>';
1347
 
1348
+ echo '</div>'; // content
1349
+ echo '</div>'; // container
1350
+ echo '</div>'; // wp-reset-tabs
1351
 
1352
  echo '</form>';
1353
  echo '</div>'; // wrap
1431
  } // plugin_page
1432
 
1433
 
1434
+ /**
1435
+ * Echoes all custom plugin notitications
1436
+ *
1437
+ * @return null
1438
+ */
1439
+ private function custom_notifications()
1440
+ {
1441
+ $notice_shown = false;
1442
+ $meta = $this->get_meta();
1443
+ $snapshots = $this->get_snapshots();
1444
+
1445
+ // warn that WPR is not WPMU compatible
1446
+ if (false === $notice_shown && is_multisite()) {
1447
+ echo '<div class="card notice-wrapper notice-error">';
1448
+ echo '<h2>' . __('WP Reset is not compatible with multisite!', 'wp-reset') . '</h2>';
1449
+ echo '<p>' . __('Please be careful when using WP Reset with multisite enabled. It\'s not recommended to reset the main site. Sub-sites should be OK. We\'re working on making it fully compatible with WP-MU. <b>Till then please be careful.</b> Thank you for understanding.', 'wp-reset') . '</p>';
1450
+ echo '</div>';
1451
+ $notice_shown = true;
1452
+ }
1453
+
1454
+ // ask for review
1455
+ if ((!empty($meta['reset_count']) || !empty($snapshots) || current_time('timestamp', true) - $meta['first_install'] > WEEK_IN_SECONDS)
1456
+ && false === $notice_shown
1457
+ && false == $this->get_dismissed_notices('rate')
1458
+ ) {
1459
+ echo '<div class="card notice-wrapper notice-info">';
1460
+ echo '<h2>' . __('Please help us spread the word &amp; keep the plugin up-to-date', 'wp-reset') . '</h2>';
1461
+ echo '<p>' . __('If you use &amp; enjoy WP Reset, <b>please rate it on WordPress.org</b>. It only takes a second and helps us keep the plugin maintained. Thank you!', 'wp-reset') . '</p>';
1462
+ echo '<p><a class="button-primary button" title="' . __('Rate WP Reset', 'wp-reset') . '" target="_blank" href="https://wordpress.org/support/plugin/wp-reset/reviews/#new-post">' . __('Rate the plugin ★★★★★', 'wp-reset') . '</a> <a href="#" class="wpr-dismiss-notice dismiss-notice-rate" data-notice="rate">' . __('I\'ve already rated it', 'wp-reset') . '</a></p>';
1463
+ echo '</div>';
1464
+ $notice_shown = true;
1465
+ }
1466
+ } // custom_notifications
1467
+
1468
+
1469
  /**
1470
  * Echoes content for reset tab
1471
  *
1476
  global $current_user, $wpdb;
1477
 
1478
  echo '<div class="card" id="card-description">';
1479
+ echo '<h4>';
1480
+ echo __('Please read carefully before proceeding. There is NO UNDO!', 'wp-reset');
1481
+ echo '<div class="card-header-right"><a class="toggle-card" href="#" title="' . __('Collapse / expand box', 'wp-reset') . '"><span class="dashicons dashicons-arrow-up-alt2"></span></a></div>';
1482
+ echo '</h4>';
1483
+ echo '<p><b class="red">' . __('Resetting will delete:', 'wp-reset') . '</b></p>';
1484
  echo '<ul class="plain-list">';
1485
  echo '<li>' . __('all posts, pages, custom post types, comments, media entries, users', 'wp-reset') . '</li>';
1486
  echo '<li>' . __('all default WP database tables', 'wp-reset') . '</li>';
1487
  echo '<li>' . sprintf(__('all custom database tables that have the same prefix "%s" as default tables in this installation', 'wp-reset'), $wpdb->prefix) . '</li>';
1488
+ echo '<li>' . __('always <a href="#" class="download-backup">make a backup</a> first', 'wp-reset') . '</li>';
1489
  echo '</ul>';
1490
 
1491
+ echo '<p><b class="green">' . __('Resetting will not delete:', 'wp-reset') . '</b></p>';
1492
  echo '<ul class="plain-list">';
1493
  echo '<li>' . __('media files - they\'ll remain in the <i>wp-uploads</i> folder but will no longer be listed under Media', 'wp-reset');
1494
+ echo __('; use the <a href="#tool-delete-uploads" data-tab="1" class="change-tab">Clean Uploads Folder</a> tool to remove media files', 'wp-reset') . '</li>';
1495
  echo '<li>' . __('no files are touched; plugins, themes, uploads - everything stays', 'wp-reset');
1496
+ echo __('; if needed use the <a href="#tool-delete-themes" class="change-tab" data-tab="1">Delete Themes</a> &amp; <a href="#tool-delete-plugins" class="change-tab" data-tab="1">Delete Plugins</a> tools', 'wp-reset') . '</li>';
1497
  echo '<li>' . __('site title, WordPress address, site address, site language and search engine visibility settings', 'wp-reset') . '</li>';
1498
  echo '<li>' . sprintf(__('logged in user "%s" will be restored with the current password', 'wp-reset'), $current_user->user_login) . '</li>';
1499
  echo '</ul>';
1500
 
1501
+ echo '<p><b>' . __('What happens when I click the Reset button?', 'wp-reset') . '</b></p>';
1502
  echo '<ul class="plain-list">';
1503
+ echo '<li>' . __('remember, always <a href="#" class="download-backup">make a backup</a> first', 'wp-reset') . '</li>';
1504
  echo '<li>' . __('you will have to confirm the action one more time because there is NO UNDO', 'wp-reset') . '</li>';
1505
  echo '<li>' . __('everything will be reset; see bullets above for details', 'wp-reset') . '</li>';
1506
  echo '<li>' . __('site title, WordPress address, site address, site language, search engine visibility and current user will be restored', 'wp-reset') . '</li>';
1507
  echo '<li>' . __('you will be logged out, automatically logged in and taken to the admin dashboard', 'wp-reset') . '</li>';
1508
+ echo '<li>' . __('WP Reset plugin will be reactivated if that option is chosen in the <a href="#card-reset">post-reset options</a>', 'wp-reset') . '</li>';
1509
  echo '</ul>';
1510
 
1511
+ echo '<p><b>' . __('WP-CLI Support', 'wp-reset') . '</b><br>';
1512
+ echo '' . sprintf(__('All tools available via GUI are available in WP-CLI as well. To get the list of commands run %s. Instead of the active user, the first user with admin privileges found in the database will be restored. ', 'wp-reset'), '<code>wp help reset</code>');
1513
  echo sprintf(__('All actions have to be confirmed. If you want to skip confirmation use the standard %s option. Please be careful - there is NO UNDO.', 'wp-reset'), '<code>--yes</code>') . '</p>';
1514
 
1515
+ echo '<p><b>' . __('WP Webhooks Support', 'wp-reset') . '</b><br>';
1516
+ echo 'All WP Reset tools are integrated with <a href="https://wordpress.org/plugins/wp-webhooks/" target="_blank">WP Webhooks</a> and available as (receive data) actions. Webhooks are a standard, platform-independent way of connecting WordPress to any 3rd party system. This <a href="https://underconstructionpage.com/wp-webhooks-connect-integrate-wordpress/" target="_blank">article</a> has more info, videos and use-cases so you can see just how powerful and easy to use webhooks are.<br>';
1517
  if ($this->is_webhooks_active()) {
1518
  echo 'WP Webhooks are active. Make sure you enable WP Reset actions in <a href="' . admin_url('options-general.php?page=wp-webhooks-pro&wpwhvrs=settings') . '">settings</a>.';
1519
  } else {
1523
 
1524
  $theme = wp_get_theme();
1525
 
1526
+ echo '<div class="card" id="card-reset">';
1527
+ echo '<h4>' . __('Reset', 'wp-reset') . '</h4>';
 
1528
  echo '<p><label for="reactivate-theme"><input name="wpr-post-reset[reactivate_theme]" type="checkbox" id="reactivate-theme" value="1"> ' . __('Reactivate current theme', 'wp-reset') . ' - ' . $theme->get('Name') . '</label></p>';
1529
  echo '<p><label for="reactivate-wpreset"><input name="wpr-post-reset[reactivate_wpreset]" type="checkbox" id="reactivate-wpreset" value="1" checked> ' . __('Reactivate WP Reset plugin', 'wp-reset') . '</label></p>';
1530
  if ($this->is_webhooks_active()) {
1534
  if ($this->is_webhooks_active()) {
1535
  echo '<p><a href="' . admin_url('options-general.php?page=wp-webhooks-pro&wpwhvrs=settings') . '">Configure WP Webhooks</a> to run additional actions after reset, or connect to any 3rd party system.</p>';
1536
  } else {
1537
+ echo '<p>To run additional actions after reset or automate a complex workflow <a href="#" class="open-webhooks-dialog">install WP Webhooks &amp; WPR addon</a>. It\'s a standard, platform-independent way of connecting WordPress to any web app. This <a href="https://www.youtube.com/watch?v=m8XDFXCNP9g" target="_blank">short video</a> explains it well.</p>';
1538
  }
1539
+ echo '<p><br>' . __('Type <b>reset</b> in the confirmation field to confirm the reset and then click the "Reset WordPress" button.<br><b>There is NO UNDO.</b> Always <a href="#" class="download-backup">create a backup</a> before deleting anything.', 'wp-reset') . '</p>';
 
 
 
 
1540
 
1541
  wp_nonce_field('wp-reset');
1542
  echo '<p><input id="wp_reset_confirm" type="text" name="wp_reset_confirm" placeholder="' . esc_attr__('Type in "reset"', 'wp-reset') . '" value="" autocomplete="off"> &nbsp;';
1543
+ echo '<a id="wp_reset_submit" class="button button-delete">' . __('Reset WordPress', 'wp-reset') . '</a>' . $this->get_backup_button('reset-wordpress') . '</p>';
1544
  echo '</div>';
1545
  } // tab_reset
1546
 
1553
  private function tab_tools()
1554
  {
1555
  echo '<div class="card">';
1556
+ echo '<h4 id="tool-delete-transients">' . __('Delete Transients', 'wp-reset') . '</h4>';
1557
+ echo '<p>All transient related database entries will be deleted. Including expired and non-expired transients, and orphaned transient timeout entries.<br><b>There is NO UNDO.</b> Always <a href="#" class="download-backup">create a backup</a> before deleting anything.</p>';
1558
+ echo '<p><a data-confirm-title="Are you sure you want to delete all transients?" data-btn-confirm="Delete all transients" data-text-wait="Deleting transients. Please wait." data-text-confirm="All database entries related to transients will be deleted. There is NO UNDO. Always ' . esc_attr('<a href="#" class="download-backup">create a backup</a>') . '." data-text-done="%n transient database entries have been deleted." data-text-done-singular="One transient database entry has been deleted." class="button button-delete" href="#" id="delete-transients">Delete all transients</a>' . $this->get_backup_button('delete-transients') . '</p>';
1559
  echo '</div>';
1560
 
1561
  $upload_dir = wp_upload_dir(date('Y/m'), true);
1562
  $upload_dir['basedir'] = str_replace(array('/', '\\'), DIRECTORY_SEPARATOR, $upload_dir['basedir']);
1563
 
1564
  echo '<div class="card">';
1565
+ echo '<h4 id="tool-delete-uploads">' . __('Clean Uploads Folder', 'wp-reset') . '</h4>';
1566
+ echo '<p>' . __('All files in <code>' . $upload_dir['basedir'] . '</code> folder will be deleted. Including folders and subfolders, and files in subfolders. Files associated with <a href="' . admin_url('upload.php') . '">media</a> entries will be deleted too.<br><b>There is NO UNDO. WP Reset does not make any file backups.</b>', 'wp-reset') . '</p>';
1567
  if (false != $upload_dir['error']) {
1568
  echo '<p><span style="color:#dd3036;"><b>Tool is not available.</b></span> Folder is not writeable by WordPress. Please check file and folder access rights.</p>';
1569
  } else {
1570
+ echo '<p><a data-confirm-title="Are you sure you want to delete all files &amp; folders in uploads folder?" data-btn-confirm="Delete everything in uploads folder" data-text-wait="Deleting uploads. Please wait." data-text-confirm="All files and folders in uploads will be deleted. There is NO UNDO. WP Reset does not make any file backups." data-text-done="%n files &amp; folders have been deleted." data-text-done-singular="One file or folder has been deleted." class="button button-delete" href="#" id="delete-uploads">Delete all files &amp; folders in uploads folder</a></p>';
1571
  }
1572
  echo '</div>';
1573
 
1574
  echo '<div class="card">';
1575
+ echo '<h4 id="tool-reset-theme-options">' . __('Reset Theme Options', 'wp-reset') . '</h4>';
1576
+ echo '<p>' . __('All options (mods) for all themes will be reset; not just for the active theme. The tool works only for themes that use the <a href="https://codex.wordpress.org/Theme_Modification_API" target="_blank">WordPress theme modification API</a>. If options are saved in some other, custom way they won\'t be reset.<br><b>There is NO UNDO.</b> Always <a href="#" class="download-backup">create a backup</a> before deleting anything.', 'wp-reset') . '</p>';
1577
+ echo '<p><a data-confirm-title="Are you sure you want to reset all theme options?" data-btn-confirm="Reset theme options" data-text-wait="Resetting theme options. Please wait." data-text-confirm="All options (mods) for all themes will be reset. There is NO UNDO. Always ' . esc_attr('<a href="#" class="download-backup">create a backup</a>') . '." data-text-done="Options for %n themes have been reset." data-text-done-singular="Options for one theme have been reset." class="button button-delete" href="#" id="reset-theme-options">Reset theme options</a>' . $this->get_backup_button('reset-theme-options') . '</p>';
1578
  echo '</div>';
1579
 
1580
  $theme = wp_get_theme();
1581
 
1582
  echo '<div class="card">';
1583
+ echo '<h4 id="tool-delete-themes">' . __('Delete Themes', 'wp-reset') . '</h4>';
1584
+ echo '<p>' . __('All themes will be deleted. Including the currently active theme - ' . $theme->get('Name') . '.<br><b>There is NO UNDO. WP Reset does not make any file backups.</b>', 'wp-reset') . '</p>';
1585
+ echo '<p><a data-confirm-title="Are you sure you want to delete all themes?" data-btn-confirm="Delete all themes" data-text-wait="Deleting all themes. Please wait." data-text-confirm="All themes will be deleted. There is NO UNDO. WP Reset does not make any file backups." data-text-done="%n themes have been deleted." data-text-done-singular="One theme has been deleted." class="button button-delete" href="#" id="delete-themes">Delete all themes</a></p>';
1586
  echo '</div>';
1587
 
1588
  echo '<div class="card">';
1589
+ echo '<h4 id="tool-delete-plugins">' . __('Delete Plugins', 'wp-reset') . '</h4>';
1590
+ echo '<p>' . __('All plugins will be deleted except for WP Reset which will remain active.<br><b>There is NO UNDO. WP Reset does not make any file backups.</b>', 'wp-reset') . '</p>';
1591
+ echo '<p><a data-confirm-title="Are you sure you want to delete all plugins?" data-btn-confirm="Delete plugins" data-text-wait="Deleting plugins. Please wait." data-text-confirm="All plugins except WP Reset will be deleted. There is NO UNDO. WP Reset does not make any file backups." data-text-done="%n plugins have been deleted." data-text-done-singular="One plugin has been deleted." class="button button-delete" href="#" id="delete-plugins">Delete plugins</a></p>';
1592
  echo '</div>';
1593
 
1594
  global $wpdb;
1595
  $custom_tables = $this->get_custom_tables();
1596
 
1597
  echo '<div class="card">';
1598
+ echo '<h4 id="tool-empty-delete-custom-tables">' . __('Empty or Delete Custom Tables', 'wp-reset') . '</h4>';
1599
+ echo '<p>' . __('This action affects only custom tables with <code>' . $wpdb->prefix . '</code> prefix. Core WP tables and other tables in the database that do not have that prefix will not be deleted/emptied. Deleting (dropping) tables completely removes them from the database. Emptying (truncating) removes all content from them, but keeps the structure intact.<br><b>There is NO UNDO.</b> Always <a href="#" class="download-backup">create a backup</a> before deleting anything.</p>', 'wp-reset');
1600
  if ($custom_tables) {
1601
  echo '<p>' . __('The following ' . sizeof($custom_tables) . ' custom tables are affected by this tool: ');
1602
  foreach ($custom_tables as $tbl) {
1611
  echo '<p>' . __('There are no custom tables. There\'s nothing for this tool to empty or delete.', 'wp-reset') . '</p>';
1612
  $custom_tables_btns = ' disabled';
1613
  }
1614
+ echo '<p><a data-confirm-title="Are you sure you want to empty all custom tables?" data-btn-confirm="Empty custom tables" data-text-wait="Emptying custom tables. Please wait." data-text-confirm="All custom tables with prefix <code>' . $wpdb->prefix . '</code> will be emptied. There is NO UNDO. Always ' . esc_attr('<a href="#" class="download-backup">create a backup</a>') . '." data-text-done="%n custom tables have been emptied." data-text-done-singular="One custom table has been emptied." class="button button-delete' . $custom_tables_btns . '" href="#" id="truncate-custom-tables">Empty (truncate) custom tables</a>';
1615
+ echo '<a data-confirm-title="Are you sure you want to delete all custom tables?" data-btn-confirm="Delete custom tables" data-text-wait="Deleting custom tables. Please wait." data-text-confirm="All custom tables with prefix <code>' . $wpdb->prefix . '</code> will be deleted. There is NO UNDO. Always ' . esc_attr('<a href="#" class="download-backup">create a backup</a>') . '." data-text-done="%n custom tables have been deleted." data-text-done-singular="One custom table has been deleted." class="button button-delete' . $custom_tables_btns . '" href="#" id="drop-custom-tables">Delete (drop) custom tables</a>' . $this->get_backup_button('drop-custom-tables') . '</p>';
1616
 
1617
  echo '</div>';
1618
 
1619
  echo '<div class="card">';
1620
+ echo '<h4 id="tool-delete-htaccess">' . __('Delete .htaccess File', 'wp-reset') . '</h4>';
1621
+ echo '<p>' . __('This action deletes the .htaccess file located in <code>' . $this->get_htaccess_path() . '</code><br><b>There is NO UNDO. WP Reset does not make any file backups.</b></p>', 'wp-reset');
1622
 
1623
+ echo '<p>If you need to edit .htaccess, install our free <a href="' . admin_url('plugin-install.php?tab=plugin-information&plugin=wp-htaccess-editor&TB_iframe=true&width=600&height=550') . '" class="thickbox open-plugin-details-modal">WP Htaccess Editor</a> plugin. It automatically creates backups when you edit .htaccess as well as checks for syntax errors. To create the default .htaccess file open <a href="' . admin_url('options-permalink.php') . '">Settings - Permalinks</a> and re-save settings. WordPress will recreate the file.</p>';
1624
 
1625
+ echo '<a data-confirm-title="Are you sure you want to delete the .htaccess file?" data-btn-confirm="Delete .htaccess file" data-text-wait="Deleting .htaccess file. Please wait." data-text-confirm="Htaccess file will be deleted. There is NO UNDO. WP Reset does not make any file backups." data-text-done="Htaccess file has been deleted." data-text-done-singular="Htaccess file has been deleted." class="button button-delete" href="#" id="delete-htaccess">Delete .htaccess file</a></p>';
1626
 
1627
  echo '</div>';
1628
  } // tab_tools
1636
  private function tab_collections()
1637
  {
1638
  echo '<div class="card">';
1639
+ echo '<h4>' . __('What are Plugin &amp; Theme Collections?', 'wp-reset') . '</h4>';
1640
+ echo '<p>' . __('A tool that\'s coming with WP Reset PRO that will <b>save hours &amp; hours of your precious time</b>! Have a set of plugins (and themes) that you install and activate after every reset? Or on every fresh WP installation? Well, no more clicking install &amp; active for ten minutes! Build the collection once and install it with one click as many times as needed.<br>WP Reset stores collections in the cloud so they\'re accessible on every site you build. You can use free plugins and themes from the official repo, and PRO ones by uploading a ZIP file. We\'ll safely store your license keys too, so you have everything in one place.', 'wp-reset') . '</p>';
1641
+ echo '<p class="textcenter"><br><a href="' . $this->generate_web_link('collections-tab', '/pro-version-launch/') . '" target="_blank" class="button button-primary">Sign up for the private LTD launch of WP Reset PRO in early November</a></p>';
 
 
 
 
1642
  echo '</div>';
1643
  } // tab_collections
1644
 
1651
  private function tab_support()
1652
  {
1653
  echo '<div class="card">';
1654
+ echo '<h4>' . __('Documentation', 'wp-reset') . '</h4>';
1655
+ echo '<p>' . __('All tools and functions are explained in detail in <a href="' . $this->generate_web_link('support-tab', '/documentation/') . '" target="_blank">the documentation</a>. We did our best to describe how things work on both the code level and an "average user" level.', 'wp-reset') . '</p>';
1656
  echo '</div>';
1657
 
1658
  echo '<div class="card">';
1659
+ echo '<h4>' . __('Public support forum', 'wp-reset') . '</h4>';
1660
  echo '<p>' . __('We are very active on the <a href="https://wordpress.org/support/plugin/wp-reset" target="_blank">official WP Reset support forum</a>. If you found a bug, have a feature idea or just want to say hi - please drop by. We love to hear back from our users.', 'wp-reset') . '</p>';
1661
  echo '</div>';
1662
 
1663
  echo '<div class="card">';
1664
+ echo '<h4>' . __('Private contact', 'wp-reset') . '</h4>';
1665
  echo '<p>' . __('If there\'s a need to contact us privately send emails to <a href="mailto:wpreset@webfactoryltd.com">wpreset@webfactoryltd.com</a>. Please know that although we\'ll gladly have a look at issues you are having with any site, we can\'t promise we\'ll fix them. Thank you for understanding.', 'wp-reset') . '</p>';
1666
  echo '</div>';
1667
 
1668
  echo '<div class="card">';
1669
+ echo '<h4>' . __('Care to help out?', 'wp-reset') . '</h4>';
1670
  echo '<p>' . __('No need for donations or anything like that :) If you can give us a <a href="https://wordpress.org/support/plugin/wp-reset/reviews/#new-post" target="_blank">five star rating</a> you\'ll help out more than you can imagine. A public mention <a href="https://twitter.com/webfactoryltd" target="_blank">@webfactoryltd</a> also does wonders. Thank you!', 'wp-reset') . '</p>';
1671
  echo '</div>';
1672
  } // tab_support
1683
  $tbl_core = $tbl_custom = $tbl_size = $tbl_rows = 0;
1684
 
1685
  echo '<div class="card" id="card-snapshots">';
1686
+ echo '<h4>';
1687
+ echo __('Database Snapshots', 'wp-reset');
1688
+ echo '<div class="card-header-right"><a class="toggle-card" href="#" title="' . __('Collapse / expand box', 'wp-reset') . '"><span class="dashicons dashicons-arrow-up-alt2"></span></a></div>';
1689
+ echo '</h4>';
1690
+ echo '<p>A snapshot is a copy of all WP database tables, standard and custom ones, saved in your database. Files are not saved or included in snapshots in any way. <a href="https://www.youtube.com/watch?v=xBfMmS12vMY" target="_blank">Watch a short video</a> overview and tutorial about Snapshots.</p>';
1691
+ echo '<p>Snapshots are primarily a development tool. Although they can be used for backups (and downloaded), when using various reset tools we advise using our 1-click backup tool available in every tool\'s confirmation dialog. If you need a full backup that includes files, use something like <a href="' . admin_url('plugin-install.php?tab=plugin-information&plugin=updraftplus&TB_iframe=true&width=600&height=550') . '" class="thickbox open-plugin-details-modal">UpdraftPlus</a>.</p>';
1692
+ echo '<p>Use snapshots to find out what changes a plugin made to your database or to quickly restore the dev environment after testing database related changes. Restoring a snapshot does not affect other snapshots, or WP Reset settings.</p>';
1693
 
1694
  $table_status = $wpdb->get_results('SHOW TABLE STATUS');
1695
  if (is_array($table_status)) {
1723
  echo '</div>';
1724
 
1725
  echo '<div class="card no-padding-bottom">';
1726
+ echo '<h4>';
1727
+ echo __('Saved Snapshots', 'wp-reset');
1728
+ echo '<div class="card-header-right"><a id="create-new-snapshot-primary" data-msg-success="Snapshot created!" data-msg-wait="Creating snapshot. Please wait." data-btn-confirm="Create snapshot" data-placeholder="Snapshot name or brief description, ie: before plugin install" data-text="Enter snapshot name or brief description, up to 64 characters." data-title="Create a new snapshot" title="Create a new database snapshot" href="#" class="button button-primary create-new-snapshot">' . __('Create new Snapshot', 'wp-reset') . '</a></div>';
1729
+ echo '</h4>';
1730
 
1731
  if ($snapshots = $this->get_snapshots()) {
1732
  echo '<table id="wpr-snapshots">';
1998
  return new WP_Error(1, 'Unable to create wp-content/' . $this->snapshots_folder . '/ folder.');
1999
  }
2000
 
2001
+ $htaccess_content = 'AddType application/octet-stream .gz' . PHP_EOL;
2002
+ $htaccess_content .= 'Options -Indexes' . PHP_EOL;
2003
+ $htaccess_file = @fopen(trailingslashit(WP_CONTENT_DIR) . $this->snapshots_folder . '/.htaccess', 'w');
2004
+ if ($htaccess_file) {
2005
+ fputs($htaccess_file, $htaccess_content);
2006
+ fclose($htaccess_file);
2007
+ }
2008
+
2009
  $world_dumper->dump(trailingslashit(WP_CONTENT_DIR) . $this->snapshots_folder . '/wp-reset-snapshot-' . $uid . '.sql.gz', $uid . '_');
2010
  } catch (Shuttle_Exception $e) {
2011
+ return new WP_Error(1, 'Couldn\'t create snapshot: ' . $e->getMessage());
2012
  }
2013
 
2014
  do_action('wp_reset_export_snapshot', 'wp-reset-snapshot-' . $uid . '.sql.gz');
2017
  } // export_snapshot
2018
 
2019
 
2020
+
2021
+ /**
2022
+ * Exports DB tables as SQL dump; saved in gzipped file in WP_CONTENT folder.
2023
+ *
2024
+ * @return string|WP_Error Export base filename, or error object on fail.
2025
+ */
2026
+ function do_create_backup($skip_timestamp_check = false)
2027
+ {
2028
+ require_once $this->plugin_dir . 'libs/dumper.php';
2029
+ global $wpdb;
2030
+
2031
+ if (
2032
+ false == $skip_timestamp_check
2033
+ && !empty($this->options['last_backup_timestamp'])
2034
+ && !empty($this->options['last_backup_filename'])
2035
+ && time() - $this->options['last_backup_timestamp'] < 30
2036
+ ) {
2037
+ return $this->options['last_backup_filename'];
2038
+ }
2039
+
2040
+ try {
2041
+ $world_dumper = Shuttle_Dumper::create(array(
2042
+ 'host' => DB_HOST,
2043
+ 'username' => DB_USER,
2044
+ 'password' => DB_PASSWORD,
2045
+ 'db_name' => DB_NAME,
2046
+ ));
2047
+
2048
+ $folder = wp_mkdir_p(trailingslashit(WP_CONTENT_DIR) . $this->backups_folder);
2049
+ if (!$folder) {
2050
+ return new WP_Error(1, 'Unable to create wp-content/' . $this->backups_folder . '/ folder.');
2051
+ }
2052
+
2053
+ $htaccess_content = 'AddType application/octet-stream .gz' . PHP_EOL;
2054
+ $htaccess_content .= 'Options -Indexes' . PHP_EOL;
2055
+ $htaccess_file = @fopen(trailingslashit(WP_CONTENT_DIR) . $this->backups_folder . '/.htaccess', 'w');
2056
+ if ($htaccess_file) {
2057
+ fputs($htaccess_file, $htaccess_content);
2058
+ fclose($htaccess_file);
2059
+ }
2060
+
2061
+ $rand_id = sprintf('%04x', mt_rand(0, 0xFFFF));
2062
+ $filename = '';
2063
+ $filename .= 'wp-reset-backup-' . str_replace(array('http://', 'https://', '.'), array('', '', '-'), home_url());
2064
+ $filename .= '-' . date('Y-m-d-H-i-s', current_time('timestamp')) . '-' . $rand_id;
2065
+ $filename = sanitize_file_name($filename) . '.sql.gz';
2066
+ $filename = apply_filters('wp_reset_backup_filename', $filename);
2067
+
2068
+ $world_dumper->dump(trailingslashit(WP_CONTENT_DIR) . $this->backups_folder . '/' . $filename, $wpdb->prefix);
2069
+ } catch (Shuttle_Exception $e) {
2070
+ return new WP_Error(1, 'Couldn\'t create backup: ' . $e->getMessage());
2071
+ }
2072
+
2073
+ do_action('wp_reset_create_backup', $filename);
2074
+
2075
+ $this->update_options('last_backup_timestamp', time());
2076
+ $this->update_options('last_backup_filename', $filename);
2077
+
2078
+ return $filename;
2079
+ } // create_backup
2080
+
2081
+
2082
  /**
2083
  * Replace current tables with ones in snapshot.
2084
  *
2456
  } // foreach
2457
  }
2458
 
2459
+ $plugin_info = get_transient('wf-plugin-info-' . $plugin_slug);
2460
+
2461
+ if (!$plugin_info) {
2462
  $plugin_info = plugins_api('plugin_information', array(
2463
  'slug' => $plugin_slug,
2464
  'is_ssl' => is_ssl(),
2472
  )
2473
  ));
2474
  if (!is_wp_error($plugin_info)) {
 
2475
  set_transient('wf-plugin-info-' . $plugin_slug, $plugin_info, DAY_IN_SECONDS * 7);
2476
  }
2477
  }
2478
 
2479
+ if ($plugin_info) {
2480
+ array_unshift($res->plugins, $plugin_info);
2481
+ }
2482
+
2483
  return $res;
2484
  } // add_plugin_featured
2485
 
2493
  {
2494
  remove_filter('plugins_api_result', array($this, 'plugins_api_result'), 10, 3);
2495
 
 
2496
  $res = $this->add_plugin_featured('under-construction-page', $res);
2497
+ $res = $this->add_plugin_featured('wp-force-ssl', $res);
2498
+ $res = $this->add_plugin_featured('eps-301-redirects', $res);
2499
+
2500
 
2501
  return $res;
2502
  } // plugins_api_result