Migration, Backup, Staging – WPvivid - Version 0.9.78

Version Description

  • Added an option to create quick database snapshots.
  • Added a check for siteurl and home in a restore process.
  • Fixed: Some used images were falsely scanned as unused.
  • Fixed some bugs in the plugin code and optimized the plugin code.
Download this release

Release Info

Developer wpvivid
Plugin Icon 128x128 Migration, Backup, Staging – WPvivid
Version 0.9.78
Comparing to
See all releases

Code changes from version 0.9.77 to 0.9.78

admin/class-wpvivid-admin.php CHANGED
@@ -1548,7 +1548,7 @@ class WPvivid_Admin {
1548
  <tfoot>
1549
  <tr>
1550
  <th><?php _e('*No credit card needed. Trial starts with the Free Trial plan with 2 sites. You can choose a plan at the end of the trial.', 'wpvivid-backuprestore'); ?></th>
1551
- <th colspan="4" style="text-align:center;"><p style="margin-top: 6px;"><a href="https://wpvivid.com/pricing" class="page-title-action"><?php _e('START 14-DAY FREE TRIAL', 'wpvivid-backuprestore'); ?></a></p></th>
1552
  </tr>
1553
  </tfoot>
1554
  </table>
1548
  <tfoot>
1549
  <tr>
1550
  <th><?php _e('*No credit card needed. Trial starts with the Free Trial plan with 2 sites. You can choose a plan at the end of the trial.', 'wpvivid-backuprestore'); ?></th>
1551
+ <th colspan="4" style="text-align:center;"><p style="margin-top: 6px;"><a href="https://wpvivid.com/pricing" class="page-title-action"><?php _e('See Plans', 'wpvivid-backuprestore'); ?></a></p></th>
1552
  </tr>
1553
  </tfoot>
1554
  </table>
admin/css/wpvivid-quick-snapshot-style.css ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+
3
+
4
+
5
+ .wpvivid-span-progress {
6
+ display:block;
7
+ width:100%;
8
+ height:1.5em;
9
+ background-color:#9d9fa5;
10
+ border-radius:0;
11
+ color: #fff;
12
+
13
+ }
14
+
15
+ .wpvivid-span-processed-progress {
16
+ display:block;
17
+ height:1.5em;
18
+ background-color:#8bc34a;
19
+ border-radius:0;
20
+ color: #fff;
21
+ padding-left:0.5em;
22
+ }
23
+
24
+ .wpvivid-dashicons-green {
25
+ color:#8bc34a;
26
+ }
admin/css/wpvivid-snapshot-style.css ADDED
@@ -0,0 +1,1058 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * All of the CSS for WPvivid Plugins Dashboard should be
3
+ * included in this file.
4
+ */
5
+ .wpvivid-canvas {
6
+ max-width:1600px;
7
+ box-sizing: border-box;
8
+ }
9
+ .wpvivid-dashboard, .wpvivid-backup{
10
+ position: relative;
11
+
12
+ border: 1px solid #ccd0d4;
13
+ box-shadow: 0 1px 1px rgba(0,0,0,.04);
14
+ background: #fff;
15
+ }
16
+ .wpvivid-welcome-panel {
17
+ width:100%;
18
+ padding: 0px 10px 0;
19
+ border: 1px solid #ccd0d4;
20
+ box-shadow: 0 1px 1px rgba(0,0,0,.04);
21
+ background: #fff;
22
+ box-sizing: border-box;
23
+ }
24
+ .wpvivid-red {
25
+ background:red;
26
+ color:#fff;
27
+ }
28
+ .wpvivid-green {
29
+ background:#8bc34a;
30
+ color:#fff;
31
+ }
32
+ .wpvivid-blue {
33
+ background:#007cba;
34
+ color:#fff;
35
+ }
36
+ .wpvivid-orange {
37
+ background:orange;
38
+ color:#fff;
39
+ }
40
+ .wpvivid-grey {
41
+ background-color:grey;
42
+ color: #fff;
43
+ }
44
+ span.dashicons{
45
+ margin-right:2px;
46
+ }
47
+ .wpvivid-welcome-panel .about-description{
48
+ font-size: 16px;
49
+ margin: 0;
50
+ }
51
+ .wpvivid-page-title {
52
+ font-weight: 700;
53
+ font-size:1.2em;
54
+ }
55
+ .wpvivid-dashicons-large {
56
+ font-size:5em;
57
+ width:1.2em;
58
+ height:1.2em;
59
+ float:left;
60
+ }
61
+ .wpvivid-dashicons-large:hover{
62
+ text-shadow: 0px 0px 2px rgba(0,0,0,0.4);
63
+ }
64
+ .wpvivid-dashicons-middle {
65
+ font-size:3em;
66
+ width:1.2em;
67
+ height:1.2em;
68
+ float:left;
69
+
70
+ }
71
+
72
+ .wpvivid-welcome-bar{
73
+ width:100%;
74
+ box-sizing: border-box;
75
+
76
+ }
77
+ .wpvivid-welcome-bar-left, .wpvivid-block-left {
78
+ width:50%;
79
+ float:left;
80
+ padding:1em;
81
+ box-sizing: border-box;
82
+ }
83
+ .wpvivid-welcome-bar-right, .wpvivid-block-right {
84
+ width:50%;
85
+ float:left;
86
+ padding:1em;
87
+ box-sizing: border-box;
88
+ }
89
+ .wpvivid-features-box, .wpvivid-two-cols{
90
+ width:50%;
91
+ float:left;
92
+ font-size:14px;
93
+ padding:1em 1em 1em 1em;
94
+ box-sizing: border-box;
95
+ }
96
+ .wpvivid-four-cols{
97
+ width:25%;
98
+ float:left;
99
+ font-size:14px;
100
+
101
+ box-sizing: border-box;
102
+ border:1px solid #f1f1f1;
103
+ }
104
+ .wpvivid-one-coloum {
105
+ width:100%;
106
+ float:left;
107
+ padding:1em 1em 1em 1em;
108
+ box-sizing: border-box;
109
+ }
110
+
111
+ .wpvivid-dashboard-list {
112
+ padding:1em;
113
+ border:1px solid #eee;
114
+ box-sizing: border-box;
115
+ }
116
+
117
+ .wpvivid-dashboard li {
118
+ border: 1px solid #eee;
119
+ margin: 0px;
120
+ padding: 10px;
121
+ box-sizing: border-box;
122
+
123
+ }
124
+
125
+ .wpvivid-dashboard li::after {
126
+ content: "";
127
+ clear: both;
128
+ display: table;
129
+ }
130
+
131
+ .wpvivid-dashboard .wpvivid-two-col li {
132
+ border: 1px solid #eee;
133
+ margin: 0px;
134
+ padding: 10px;
135
+ box-sizing: border-box;
136
+
137
+ }
138
+
139
+ .wpvivid-dashboard .wpvivid-two-col li::after {
140
+ content: "";
141
+ clear: both;
142
+ display: table;
143
+ }
144
+
145
+ .wpvivid-dashboard .wpvivid-three-cols li img {
146
+ padding:1em;
147
+ width: 5em;
148
+ height: 5em;
149
+ float: left;
150
+ margin: 0.5em;
151
+ }
152
+
153
+ .wpvivid-dashboard .wpvivid-two-col .wpvivid-three-cols li img {
154
+ padding:1em;
155
+ width: 5em;
156
+ height: 5em;
157
+ float: left;
158
+ margin: 0.5em;
159
+ }
160
+ .wpvivid-dashboard .wpvivid-three-cols li
161
+ {
162
+ width:33%;
163
+ float:left;
164
+ box-sizing: border-box;
165
+ }
166
+ .wpvivid-dashboard .wpvivid-three-cols-update{
167
+ position:absolute;
168
+ display:block;
169
+ width:1.5em;
170
+ height:1.5em;
171
+ border:1px solid orange;
172
+ border-radius:50%;
173
+ text-align:center;
174
+ vertical-align:middle;
175
+ background:orange;
176
+ color:#fff;
177
+ }
178
+ .wpvivid-dashboard .wpvivid-three-cols li {
179
+ border: 1px solid #eee;
180
+ padding:0.2em 0.2em 0 0.2em;
181
+ box-sizing: border-box;
182
+
183
+ }
184
+
185
+ .wpvivid-dashboard .wpvivid-three-cols li::after {
186
+ content: "";
187
+ clear: both;
188
+ display: table;
189
+ }
190
+ .wpvivid-dashboard .wpvivid-three-cols-li {
191
+ padding:0.5em 0;
192
+ }
193
+ .wpvivid-dashboard .wpvivid-three-cols-active {
194
+ background:#eaf1fe;
195
+ }
196
+ .wpvivid-sidebar-main{
197
+ width:100%;
198
+ float:left;
199
+ font-size:13px;
200
+ box-sizing: border-box;
201
+
202
+ }
203
+ .wpvivid-sidebar-main li::after {
204
+ content: "";
205
+ clear: both;
206
+ display: table;
207
+ }
208
+ .wpvivid-sidebar-main li {
209
+ margin: 0px;
210
+ padding: 10px;
211
+ box-sizing: border-box;
212
+
213
+ }
214
+ .wpvivid-sidebar-main li img {
215
+ padding:1em;
216
+ width: 5em;
217
+ height: 5em;
218
+ float: left;
219
+ margin: 0.5em;
220
+ }
221
+ .wpvivid-sidebar{
222
+ width:100%;
223
+ float:left;
224
+ font-size:13px;
225
+ box-sizing: border-box;
226
+
227
+ }
228
+ .wpvivid-sidebar li::after {
229
+ content: "";
230
+ clear: both;
231
+ display: table;
232
+ }
233
+ .wpvivid-sidebar li {
234
+ border-bottom: 1px solid #eee;
235
+ margin: 0px;
236
+ padding: 10px;
237
+ box-sizing: border-box;
238
+
239
+ }
240
+ .wpvivid-sidebar li img {
241
+ padding:1em;
242
+ width: 5em;
243
+ height: 5em;
244
+ float: left;
245
+ margin: 0.5em;
246
+ }
247
+ .wpvivid-features-box-image-progress {
248
+ width:100%;
249
+ }
250
+ .wpvivid-features-box-image-optimiztion-details {
251
+ width:50%;
252
+ }
253
+ .wpvivid-features-box-image-optimiztion-plate {
254
+ width:50%;
255
+ }
256
+ .wpvivid-features-box-image-optimiztion-percentage{
257
+ margin-top:2.5em;
258
+ }
259
+ .wpvivid-features-box-image-optimiztion-number {
260
+ font-size: 5em;
261
+ font-family:Sans-serif;
262
+ font-weight:600;
263
+ color:orange;
264
+ float:left;
265
+ text-shadow:0 0.05em 0.05em rgba(0,0,0,0.4);
266
+ }
267
+ .wpvivid-features-box-image-optimiztion-percentage-unit {
268
+ font-size:1em;
269
+ color:grey;
270
+ float:left;
271
+ font-size:1.2em;
272
+ padding-bottom:1em;
273
+ }
274
+ .wpvivid-rectangle {
275
+ border-radius:0.4em;
276
+ padding:0.5em;
277
+ margin-left: 0.5em;
278
+ margin-right:0.5em;
279
+ font-size:0.8em;
280
+ }
281
+ .wpvivid-rectangle-small {
282
+ border-radius:0.4em;
283
+ padding:0.2em;
284
+ margin-left: 0.5em;
285
+ margin-right:0.5em;
286
+ font-size:0.6em;
287
+ }
288
+ .wpvivid-span-progress {
289
+ display:block;
290
+ width:100%;
291
+ height:1.5em;
292
+ background-color:#9d9fa5;
293
+ border-radius:0;
294
+ color: #fff;
295
+
296
+ }
297
+ .wpvivid-span-processed-progress {
298
+ display:block;
299
+ height:1.5em;
300
+ background-color:#8bc34a;
301
+ border-radius:0;
302
+ color: #fff;
303
+ padding-left:0.5em;
304
+ }
305
+ .wpvivid-span-processed-percent-progress{
306
+ width:53%;
307
+ }
308
+ .wpvivid-clear-float {
309
+ content: "";
310
+ clear: both;
311
+ display: table;
312
+ width:100%;
313
+ }
314
+ .wpvivid-title {
315
+ font-size:1.2em;
316
+ color:#000;
317
+ }
318
+ .wpvivid-nav-bar{
319
+ width: 100%;
320
+ float: left;
321
+ padding: 1em;
322
+ background-color: #fff;
323
+ margin-bottom: 1em;
324
+ border-top:1px solid #ddd;
325
+ border-bottom:1px solid #ddd;
326
+ box-sizing: border-box;
327
+
328
+ }
329
+
330
+ .wpvivid-two-col{
331
+ width:50%;
332
+ float:left;
333
+ box-sizing: border-box;
334
+ }
335
+ .wpvivid-float-right{
336
+ float:right;
337
+ }
338
+ .wpvivid-float-left{
339
+ float:left;
340
+ }
341
+ .wpvivid-dashicons-green {
342
+ color:#8bc34a;
343
+ }
344
+ .wpvivid-dashicons-red {
345
+ color:red;
346
+ }
347
+ .wpvivid-dashicons-orange {
348
+ color:orange;
349
+ }
350
+ .wpvivid-dashicons-blue {
351
+ color:#007cba;
352
+ }
353
+ .wpvivid-dashicons-grey, .wpvivid-dashicons-editor-help{
354
+ color:#999;
355
+ }
356
+ .wpvivid-nav-tab-wrapper {
357
+ padding-bottom:0!important;
358
+
359
+ }
360
+ .wpvivid-nav-tab {
361
+ background:#ffffff;
362
+ }
363
+ .wpvivid-nav-tab-active,.wpvivid-nav-tab-active, .wpvivid-nav-tab-active:focus:active, .wpvivid-nav-tab-active:hover {
364
+ border-bottom:1px solid #ffffff;
365
+ background:#ffffff;
366
+ }
367
+ .wpvivid-tabcontent {
368
+ display: none;
369
+ }
370
+
371
+
372
+ .wpvivid-workflow {
373
+ padding:1em;
374
+ border:1px solid #eee;
375
+ border-radius:8px;
376
+ }
377
+
378
+
379
+ /* tooltip */
380
+ .wpvivid-tooltip {
381
+ display:inline-block;
382
+ position:relative;
383
+ text-align:left;
384
+ }
385
+ /* tooltip - top */
386
+ .wpvivid-top {
387
+ min-width:300px;
388
+ top:-20px;
389
+ left:50%;
390
+ transform:translate(-50%, -100%);
391
+ padding:10px 20px;
392
+ color:#444444;
393
+ background-color:#FFFFFF;
394
+ font-weight:normal;
395
+ font-size:13px;
396
+ border-radius:8px;
397
+ position:absolute;
398
+ z-index:99999999;
399
+ box-sizing:border-box;
400
+ box-shadow:0 1px 8px rgba(0,0,0,0.5);
401
+ visibility:hidden; opacity:0; transition:opacity 0.8s;
402
+ }
403
+
404
+ .wpvivid-tooltip:hover .wpvivid-top {
405
+ visibility:visible; opacity:1;
406
+ }
407
+
408
+ .wpvivid-tooltip .wpvivid-top i {
409
+ position:absolute;
410
+ top:100%;
411
+ left:50%;
412
+ margin-left:-12px;
413
+ width:24px;
414
+ height:12px;
415
+ overflow:hidden;
416
+ }
417
+
418
+ .wpvivid-tooltip .wpvivid-top i::after {
419
+ content:'';
420
+ position:absolute;
421
+ width:12px;
422
+ height:12px;
423
+ left:50%;
424
+ transform:translate(-50%,-50%) rotate(45deg);
425
+ background-color:#FFFFFF;
426
+ box-shadow:0 1px 8px rgba(0,0,0,0.5);
427
+ }
428
+
429
+ /* tooltip - bottom */
430
+ .wpvivid-bottom {
431
+ min-width:300px;
432
+ top:40px;
433
+ left:50%;
434
+ transform:translate(-50%, 0);
435
+ padding:10px 20px;
436
+ color:#444444;
437
+ background-color:#FFFFFF;
438
+ font-weight:normal;
439
+ font-size:13px;
440
+ border-radius:8px;
441
+ position:absolute;
442
+ z-index:99999999;
443
+ box-sizing:border-box;
444
+ box-shadow:0 1px 8px rgba(0,0,0,0.5);
445
+ visibility:hidden; opacity:0; transition:opacity 0.4s;
446
+ }
447
+
448
+ .wpvivid-dashicons-editor-help:hover .wpvivid-bottom {
449
+ visibility:visible; opacity:1;
450
+ }
451
+
452
+ .wpvivid-dashicons-white-editor-help:hover .wpvivid-bottom {
453
+ visibility:visible; opacity:1;
454
+ }
455
+
456
+ .wpvivid-dashicons-white:hover .wpvivid-bottom {
457
+ visibility:visible; opacity:1;
458
+ }
459
+
460
+ .wpvivid-tooltip .wpvivid-bottom i {
461
+ position:absolute;
462
+ bottom:100%;
463
+ left:50%;
464
+ margin-left:-12px;
465
+ width:24px;
466
+ height:12px;
467
+ overflow:hidden;
468
+ }
469
+
470
+ .wpvivid-tooltip .wpvivid-bottom i::after {
471
+ content:'';
472
+ position:absolute;
473
+ width:12px;
474
+ height:12px;
475
+ left:50%;
476
+ transform:translate(-50%,50%) rotate(45deg);
477
+ background-color:#FFFFFF;
478
+ box-shadow:0 1px 8px rgba(0,0,0,0.5);
479
+ }
480
+ /* tooltip - left */
481
+ .wpvivid-left {
482
+ min-width:300px;
483
+ top:50%;
484
+ right:100%;
485
+ margin-right:20px;
486
+ transform:translate(0, -50%);
487
+ padding:10px 20px;
488
+ color:#444444;
489
+ background-color:#FFFFFF;
490
+ font-weight:normal;
491
+ font-size:13px;
492
+ border-radius:8px;
493
+ position:absolute;
494
+ z-index:99999999;
495
+ box-sizing:border-box;
496
+ box-shadow:0 1px 8px rgba(0,0,0,0.5);
497
+ visibility:hidden; opacity:0; transition:opacity 0.8s;
498
+ }
499
+
500
+ .wpvivid-tooltip:hover .wpvivid-left {
501
+ visibility:visible; opacity:1;
502
+ }
503
+
504
+ .wpvivid-tooltip .wpvivid-left i {
505
+ position:absolute;
506
+ top:50%;
507
+ left:100%;
508
+ margin-top:-12px;
509
+ width:12px;
510
+ height:24px;
511
+ overflow:hidden;
512
+ }
513
+
514
+ .wpvivid-tooltip .wpvivid-left i::after {
515
+ content:'';
516
+ position:absolute;
517
+ width:12px;
518
+ height:12px;
519
+ left:0;
520
+ top:50%;
521
+ transform:translate(-50%,-50%) rotate(-45deg);
522
+ background-color:#FFFFFF;
523
+ box-shadow:0 1px 8px rgba(0,0,0,0.5);
524
+ }
525
+ /* tooltip - right */
526
+ .wpvivid-right {
527
+ min-width:300px;
528
+ top:50%;
529
+ left:100%;
530
+ margin-left:20px;
531
+ transform:translate(0, -50%);
532
+ padding:10px 20px;
533
+ color:#444444;
534
+ background-color:#FFFFFF;
535
+ font-weight:normal;
536
+ font-size:13px;
537
+ border-radius:8px;
538
+ position:absolute;
539
+ z-index:99999999;
540
+ box-sizing:border-box;
541
+ box-shadow:0 1px 8px rgba(0,0,0,0.5);
542
+ visibility:hidden;
543
+ opacity:0;
544
+ transition:opacity 0.8s;
545
+ }
546
+
547
+ .wpvivid-tooltip:hover .wpvivid-right {
548
+ visibility:visible; opacity:1;
549
+ }
550
+ .wpvivid-installer-list li{
551
+ padding:0.2em 0;
552
+ }
553
+ .wpvivid-tooltip .wpvivid-right i {
554
+ position:absolute;
555
+ top:50%;
556
+ right:100%;
557
+ margin-top:-12px;
558
+ width:12px;
559
+ height:24px;
560
+ overflow:hidden;
561
+ }
562
+
563
+ .wpvivid-tooltip .wpvivid-right i::after {
564
+ content:'';
565
+ position:absolute;
566
+ width:12px;
567
+ height:12px;
568
+ left:0;
569
+ top:50%;
570
+ transform:translate(50%,-50%) rotate(-45deg);
571
+ background-color:#FFFFFF;
572
+ box-shadow:0 1px 8px rgba(0,0,0,0.5);
573
+ }
574
+
575
+ /* radio box style */
576
+
577
+ .wpvivid-radio {
578
+ display: block;
579
+ position: relative;
580
+ padding-left: 2em;
581
+ margin-bottom: 1em;
582
+ cursor: pointer;
583
+ font-size: 1em;
584
+ -webkit-user-select: none;
585
+ -moz-user-select: none;
586
+ -ms-user-select: none;
587
+ user-select: none;
588
+ }
589
+ /* Hide the browser's default radio button */
590
+ .wpvivid-radio input {
591
+ position: absolute;
592
+ opacity: 0;
593
+ cursor: pointer;
594
+ }
595
+ /* Create a custom radio button */
596
+ .wpvivid-radio-checkmark {
597
+ position: absolute;
598
+ top: 2px;
599
+ left: 0;
600
+ height: 16px;
601
+ width: 16px;
602
+ background-color: #eee;
603
+ border-radius: 50%;
604
+ }
605
+ /* On mouse-over, add a grey background color */
606
+ .wpvivid-radio:hover input ~ .wpvivid-radio-checkmark {
607
+ background-color: #ccc;
608
+ }
609
+ /* When the radio button is checked, add a blue background */
610
+ .wpvivid-radio input:checked ~ .wpvivid-radio-checkmark {
611
+ background-color: #8bc34a;
612
+ }
613
+ /* Create the indicator (the dot/circle - hidden when not checked) */
614
+ .wpvivid-radio-checkmark:after {
615
+ content: "✔";
616
+ position: absolute;
617
+ font-size:12px;
618
+ top:-1px;
619
+ left:3px;
620
+ display: none;
621
+ color:white;
622
+ }
623
+ /* Show the indicator (dot/circle) when checked */
624
+ .wpvivid-radio input:checked ~ .wpvivid-radio-checkmark:after {
625
+ display: block;
626
+ }
627
+
628
+ /* custom checkbox */
629
+
630
+ /* Customize the label (the container) */
631
+ .wpvivid-checkbox {
632
+ display: block;
633
+ position: relative;
634
+
635
+ padding-left: 2em;
636
+ cursor: pointer;
637
+ font-size: 1em;
638
+
639
+ -webkit-user-select: none;
640
+ -moz-user-select: none;
641
+ -ms-user-select: none;
642
+ user-select: none;
643
+ }
644
+ /* Hide the browser's default checkbox */
645
+ .wpvivid-checkbox input {
646
+ position: absolute;
647
+ opacity: 0;
648
+ cursor: pointer;
649
+ height: 0;
650
+ width: 0;
651
+ }
652
+ /* Create a custom checkbox */
653
+ .wpvivid-checkbox-checkmark {
654
+ position: absolute;
655
+ top: 3px;
656
+ left: 0;
657
+ height: 16px;
658
+ width: 16px;
659
+ background-color: #eee;
660
+ border-radius: 4px;
661
+ }
662
+ /* On mouse-over, add a grey background color */
663
+ .wpvivid-checkbox:hover input ~ .wpvivid-checkbox-checkmark {
664
+ background-color: #ccc;
665
+ border-radius: 4px;
666
+ }
667
+ /* When the checkbox is checked, add a blue background */
668
+ .wpvivid-checkbox input:checked ~ .wpvivid-checkbox-checkmark {
669
+ background-color: #8bc34a;
670
+ border-radius: 4px;
671
+ }
672
+ /* Create the checkmark/indicator (hidden when not checked) */
673
+ .wpvivid-checkbox-checkmark:after {
674
+ content: "";
675
+ position: absolute;
676
+ display: none;
677
+ }
678
+ /* Show the checkmark when checked */
679
+ .wpvivid-checkbox input:checked ~ .wpvivid-checkbox-checkmark:after {
680
+ display: block;
681
+ }
682
+ /* Style the checkmark/indicator */
683
+ .wpvivid-checkbox .wpvivid-checkbox-checkmark:after {
684
+ left: 4px;
685
+ top: 0px;
686
+ width: 5px;
687
+ height: 10px;
688
+ border: solid white;
689
+ border-width: 0px 3px 3px 0;
690
+ -webkit-transform: rotate(45deg);
691
+ -ms-transform: rotate(45deg);
692
+ transform: rotate(45deg);
693
+ }
694
+ /* toggle switch */
695
+
696
+ /* The switch - the box around the slider */
697
+ .wpvivid-switch {
698
+ position: relative;
699
+ display: inline-block;
700
+ width: 32px;
701
+ height: 16px;
702
+ }
703
+
704
+ /* Hide default HTML checkbox */
705
+ .wpvivid-switch input {
706
+ opacity: 0;
707
+ width: 0;
708
+ height: 0;
709
+ }
710
+
711
+ /* The slider */
712
+ .wpvivid-slider {
713
+ position: absolute;
714
+ cursor: pointer;
715
+ top: 0;
716
+ left: 0;
717
+ right: 0;
718
+ bottom: 0px;
719
+ background-color: #ccc;
720
+ -webkit-transition: .4s;
721
+ transition: .4s;
722
+ }
723
+
724
+ .wpvivid-slider:before {
725
+ position: absolute;
726
+ content: "";
727
+ height: 12px;
728
+ width: 12px;
729
+ left: 2px;
730
+ bottom: 2px;
731
+ background-color: white;
732
+ -webkit-transition: .4s;
733
+ transition: .4s;
734
+ }
735
+
736
+ input:checked + .wpvivid-slider {
737
+ background-color: #8bc34a;
738
+ }
739
+
740
+ input:focus + .wpvivid-slider {
741
+ box-shadow: 0 0 1px #8bc34a;
742
+ }
743
+
744
+
745
+ input:checked + .wpvivid-slider:before {
746
+ -webkit-transform: translateX(16px);
747
+ -ms-transform: translateX(16px);
748
+ transform: translateX(16px);
749
+ }
750
+
751
+ /* Rounded sliders */
752
+ .wpvivid-slider.wpvivid-round {
753
+ border-radius: 16px;
754
+ }
755
+
756
+ .wpvivid-slider.wpvivid-round:before {
757
+ border-radius: 50%;
758
+ }
759
+
760
+
761
+ /*general postion*/
762
+ .wpvivid-tooltip-padding-top {
763
+ padding-top:0.2em;
764
+ }
765
+ .wpvivid-tooltip-padding-top-small {
766
+ padding-top:0.1em;
767
+ }
768
+
769
+ /* HD computer monitor */
770
+
771
+ @media only screen and (min-width: 1366px) {
772
+
773
+ .wpvivid-four-cols{
774
+ width:100%;
775
+ margin-bottom:1em;
776
+ }
777
+ }
778
+
779
+ /* Tablets in landscape mode, older desktop monitors */
780
+
781
+ @media only screen and (min-width: 1024px) and (max-width: 1365px) {
782
+
783
+
784
+ #poststuff #post-body.columns-2 {
785
+ margin-right: 0px;
786
+ }
787
+ #wpbody-content #post-body.columns-2 #postbox-container-1 {
788
+ margin-right: 0;
789
+ width: 100%;
790
+ }
791
+ .wpvivid-four-cols{
792
+ width:100%;
793
+ margin-bottom:1em;
794
+ }
795
+ }
796
+
797
+
798
+
799
+ /* Tablets in portrait mode, large display smartphones landscape mode */
800
+
801
+ @media only screen and (min-width: 768px) and (max-width: 1023px) {
802
+ .wpvivid-two-col {
803
+ width:100%;
804
+ }
805
+ .wpvivid-float-right{
806
+ float:left;
807
+ }
808
+ .wpvivid-dashboard .wpvivid-three-cols li{
809
+ width:100%;
810
+ box-sizing: border-box;
811
+ }
812
+ .wpvivid-four-cols{
813
+ width:100%;
814
+ margin-bottom:1em;
815
+ }
816
+ .wpvivid-welcome-bar-left{
817
+ width:100%;
818
+
819
+ }
820
+ .wpvivid-welcome-bar-right{
821
+ display:none;
822
+ }
823
+ .wpvivid-ignore{
824
+ display:none;
825
+ }
826
+
827
+ }
828
+
829
+ /* Smartphones in landscape mode */
830
+
831
+ @media only screen and (min-width: 421px) and (max-width: 767px) {
832
+ .wpvivid-features-box,.wpvivid-two-col {
833
+ width:100%;
834
+ }
835
+ .wpvivid-float-right{
836
+ float:left;
837
+ }
838
+ .wpvivid-welcome-bar-left{
839
+ width:100%;
840
+ }
841
+ .wpvivid-welcome-bar-right{
842
+ display:none;
843
+ }
844
+ .wpvivid-four-cols{
845
+ width:100%;
846
+ margin-bottom:1em;
847
+ }
848
+ .wpvivid-ignore{
849
+ display:none;
850
+ }
851
+ .wpvivid-dashboard .wpvivid-three-cols li{
852
+ width:100%;
853
+ box-sizing: border-box;
854
+ }
855
+ }
856
+
857
+ /* Smartphones in portrait mode */
858
+
859
+ @media only screen and (max-width: 420px) {
860
+ .wpvivid-features-box,.wpvivid-two-col {
861
+ width:100%;
862
+ }
863
+ .wpvivid-float-right{
864
+ float:left;
865
+ }
866
+ .wpvivid-welcome-bar-left{
867
+ width:100%;
868
+
869
+ }
870
+ .wpvivid-welcome-bar-right{
871
+ display:none;
872
+ }
873
+
874
+ .wpvivid-four-cols{
875
+ width:100%;
876
+ margin-bottom:1em;
877
+ }
878
+ .wpvivid-ignore{
879
+ display:none;
880
+ }
881
+ .wpvivid-img-opt-responsive{
882
+ margin-top:1em;
883
+ padding-top:1em;
884
+ border-top:1px solid #f1f1f1;
885
+ }
886
+ .wpvivid-dashboard .wpvivid-three-cols li{
887
+ width:100%;
888
+ box-sizing: border-box;
889
+ }
890
+ }
891
+
892
+ .wpvivid-rectangle {
893
+ border-radius:0.4em;
894
+ padding:0.5em;
895
+ margin-left: 0.5em;
896
+ margin-right:0.5em;
897
+ font-size:0.8em;
898
+ }
899
+ .wpvivid-rectangle-small {
900
+ border-radius:0.4em;
901
+ padding:0.2em;
902
+ margin-left: 0.5em;
903
+ margin-right:0.5em;
904
+ font-size:0.6em;
905
+ }
906
+ .wpvivid-icon-16px{
907
+ font-size:16px;
908
+ margin-top:2px;
909
+ color:#aaa;
910
+ cursor:pointer;
911
+ }
912
+ .wpvivid-icon-16px-nopointer{
913
+ font-size:16px;
914
+ margin-top:2px;
915
+ }
916
+ .wpvivid-text-line{
917
+ padding:1px;
918
+ white-space:nowrap;
919
+ }
920
+ .wpvivid-text-selected{
921
+ background:#eee;
922
+ }
923
+ .wpvivid-text-line:hover{
924
+ background:#eee;
925
+ }
926
+ .wpvivid-grey {
927
+ background-color:grey;
928
+ color: #fff;
929
+ }
930
+ .wpvivid-grey-light {
931
+ background-color:#eee;
932
+ color: grey;
933
+ }
934
+ .wpvivid-hover-blue:hover{
935
+ background:#007cba;
936
+ color:#fff;
937
+ cursor:pointer;
938
+ }
939
+ .wpvivid-font-hover-blue:hover{
940
+ color:#007cba;
941
+ cursor:pointer;
942
+ }
943
+ .wpvivid-hover-green:hover{
944
+ background:#8bc34a;
945
+ color:#fff;
946
+ cursor:pointer;
947
+ }
948
+ .nav-tab-delete-img-addon{position: absolute;top: 2px;right: 3px;}
949
+
950
+ /* WPvivid Restore Progress Bar */
951
+ .wpvivid-stepper-wrapper
952
+ {
953
+ margin-top: auto;
954
+ display: flex;
955
+ justify-content: space-between;
956
+ margin-bottom: 20px;
957
+ }
958
+ .wpvivid-stepper-item
959
+ {
960
+ position: relative;
961
+ display: flex;
962
+ flex-direction: column;
963
+ align-items: center;
964
+ flex: 1;
965
+ }
966
+
967
+ @media (max-width: 768px)
968
+ {
969
+ .wpvivid-stepper-item
970
+ {
971
+ font-size: 12px;
972
+ }
973
+ }
974
+
975
+
976
+ .wpvivid-stepper-item::before
977
+ {
978
+ position: absolute;
979
+ content: "";
980
+ border-bottom: 2px solid #ccc;
981
+ width: 100%;
982
+ top: 20px;
983
+ left: -50%;
984
+ z-index: 2;
985
+ }
986
+
987
+ .wpvivid-stepper-item::after {
988
+ position: absolute;
989
+ content: "";
990
+ border-bottom: 2px solid #ccc;
991
+ width: 100%;
992
+ top: 20px;
993
+ left: 50%;
994
+ z-index: 2;
995
+ }
996
+
997
+ .wpvivid-stepper-item .wpvivid-step-counter {
998
+ position: relative;
999
+ z-index: 5;
1000
+ display: flex;
1001
+ justify-content: center;
1002
+ align-items: center;
1003
+ width: 40px;
1004
+ height: 40px;
1005
+ border-radius: 50%;
1006
+ background: #ccc;
1007
+ margin-bottom: 6px;
1008
+ }
1009
+
1010
+ .wpvivid-stepper-item.active {
1011
+ font-weight: bold;
1012
+ }
1013
+
1014
+ .wpvivid-stepper-item.completed .wpvivid-step-counter {
1015
+ background-color: #8bc34a;
1016
+ color:#fff;
1017
+ }
1018
+
1019
+ .wpvivid-stepper-item.completed::after {
1020
+ position: absolute;
1021
+ content: "";
1022
+ border-bottom: 2px solid #4bb543;
1023
+ width: 100%;
1024
+ top: 20px;
1025
+ left: 50%;
1026
+ z-index: 3;
1027
+ }
1028
+
1029
+ .wpvivid-stepper-item:first-child::before {
1030
+ content: none;
1031
+ }
1032
+ .wpvivid-stepper-item:last-child::after {
1033
+ content: none;
1034
+ }
1035
+
1036
+ .wpvivid-custom-exclude-tree-info .jstree-open>.jstree-ocl {
1037
+ background-position: -165px -75px !important;
1038
+ }
1039
+
1040
+ .wpvivid-custom-exclude-tree-info .jstree-closed>.jstree-ocl {
1041
+ background-position: -133px -75px !important;
1042
+ }
1043
+
1044
+ .wpvivid-addon-info-text {
1045
+ overflow: hidden;
1046
+ text-overflow: ellipsis;
1047
+ display: -webkit-box;
1048
+ -webkit-line-clamp: 2;
1049
+ -webkit-box-orient: vertical;
1050
+ }
1051
+
1052
+ .wpvivid-addons {
1053
+ cursor:pointer;
1054
+ }
1055
+
1056
+ .wpvivid-remote-storage-tab h2.nav-tab-wrapper :nth-child(n+3):nth-child(-n+11) {
1057
+ display:block;
1058
+ }
admin/js/wpvivid-quick-snapshot.js ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ function wpvivid_post_request_quick(ajax_data, callback, error_callback, time_out){
2
+ if(typeof time_out === 'undefined') time_out = 30000;
3
+ ajax_data.nonce=wpvivid_quick_snapshot_ajax_object.ajax_nonce;
4
+ jQuery.ajax({
5
+ type: "post",
6
+ url: wpvivid_quick_snapshot_ajax_object.ajax_url,
7
+ data: ajax_data,
8
+ cache:false,
9
+ success: function (data) {
10
+ callback(data);
11
+ },
12
+ error: function (XMLHttpRequest, textStatus, errorThrown) {
13
+ error_callback(XMLHttpRequest, textStatus, errorThrown);
14
+ },
15
+ timeout: time_out
16
+ });
17
+ }
18
+
admin/partials/wpvivid-settings-page-display.php CHANGED
@@ -299,16 +299,6 @@ function wpvivid_clean_junk()
299
  {
300
  global $wpvivid_plugin;
301
  $junk_file=$wpvivid_plugin->_junk_files_info_ex();
302
- //echo json_encode($junk_file);
303
- //$junk_file=$wpvivid_plugin->_junk_files_info();
304
- /*$junk_file['sum_size']=0;
305
- $junk_file['log_dir_size']=0;
306
- $junk_file['backup_dir_size'] =0;
307
- $junk_file['log_path'] = $log_dir = $wpvivid_plugin->wpvivid_log->GetSaveLogFolder();
308
- $dir = WPvivid_Setting::get_backupdir();
309
- $junk_file['old_files_path'] = WP_CONTENT_DIR . DIRECTORY_SEPARATOR . $dir . DIRECTORY_SEPARATOR . WPVIVID_DEFAULT_ROLLBACK_DIR;
310
- $dir = WP_CONTENT_DIR . DIRECTORY_SEPARATOR . $dir;
311
- $junk_file['junk_path'] = $dir;*/
312
  ?>
313
  <div class="postbox schedule-tab-block" id="wpvivid_clean_junk">
314
  <div>
@@ -342,12 +332,6 @@ function wpvivid_clean_junk()
342
  <span class="wpvivid-element-space-right"><?php _e( 'Junk Size:', 'wpvivid-backuprestore' ); ?></span>
343
  <span class="wpvivid-size-calc" id="wpvivid_junk_size"><?php _e($junk_file['junk_size'], 'wpvivid-backuprestore'); ?></span>
344
  </label>
345
- <!--<label for="wpvivid_junk_temporary_file">
346
- <input type="checkbox" id="wpvivid_junk_temporary_file" option="junk-files" name="old_files" value="junk-temporary-files" />
347
- <span class="wpvivid-element-space-right"><?php _e( 'Temporary Files', 'wpvivid-backuprestore' ); ?></span>
348
- <span style="margin-right: 2px;"><?php _e('Path:', 'wpvivid-backuprestore'); ?></span><span id="wpvivid_restore_temp_file_path"><?php _e($junk_file['old_files_path'], 'wpvivid-backuprestore'); ?></span>
349
- <p><?php echo __('Temporary Files are created by WPvivid when restoring a website.', 'wpvivid-backuprestore'); ?></p>
350
- </label>-->
351
  </fieldset>
352
  </div>
353
  <div><input class="button-primary" id="wpvivid_clean_junk_file" type="submit" name="Empty-all-files" value="<?php esc_attr_e( 'Empty', 'wpvivid-backuprestore' ); ?>" /></div>
299
  {
300
  global $wpvivid_plugin;
301
  $junk_file=$wpvivid_plugin->_junk_files_info_ex();
 
 
 
 
 
 
 
 
 
 
302
  ?>
303
  <div class="postbox schedule-tab-block" id="wpvivid_clean_junk">
304
  <div>
332
  <span class="wpvivid-element-space-right"><?php _e( 'Junk Size:', 'wpvivid-backuprestore' ); ?></span>
333
  <span class="wpvivid-size-calc" id="wpvivid_junk_size"><?php _e($junk_file['junk_size'], 'wpvivid-backuprestore'); ?></span>
334
  </label>
 
 
 
 
 
 
335
  </fieldset>
336
  </div>
337
  <div><input class="button-primary" id="wpvivid_clean_junk_file" type="submit" name="Empty-all-files" value="<?php esc_attr_e( 'Empty', 'wpvivid-backuprestore' ); ?>" /></div>
includes/class-wpvivid-export-import.php CHANGED
@@ -66,7 +66,7 @@ class WPvivid_Export_Import
66
  $menu['tab']= 'admin.php?page=wpvivid-export-import';
67
  $menu['href']=$admin_url . 'admin.php?page=wpvivid-export-import';
68
  $menu['capability']='administrator';
69
- $menu['index']=3;
70
  $toolbar_menus[$menu['parent']]['child'][$menu['id']]=$menu;
71
  return $toolbar_menus;
72
  }
@@ -78,7 +78,7 @@ class WPvivid_Export_Import
78
  $submenu['menu_title']=__('Export & Import', 'wpvivid-backuprestore');
79
  $submenu['capability']='administrator';
80
  $submenu['menu_slug']='wpvivid-export-import';
81
- $submenu['index']=3;
82
  $submenu['function']=array($this, 'init_page');
83
  $submenus[$submenu['menu_slug']]=$submenu;
84
  return $submenus;
66
  $menu['tab']= 'admin.php?page=wpvivid-export-import';
67
  $menu['href']=$admin_url . 'admin.php?page=wpvivid-export-import';
68
  $menu['capability']='administrator';
69
+ $menu['index']=4;
70
  $toolbar_menus[$menu['parent']]['child'][$menu['id']]=$menu;
71
  return $toolbar_menus;
72
  }
78
  $submenu['menu_title']=__('Export & Import', 'wpvivid-backuprestore');
79
  $submenu['capability']='administrator';
80
  $submenu['menu_slug']='wpvivid-export-import';
81
+ $submenu['index']=4;
82
  $submenu['function']=array($this, 'init_page');
83
  $submenus[$submenu['menu_slug']]=$submenu;
84
  return $submenus;
includes/class-wpvivid-restore-database.php CHANGED
@@ -101,23 +101,71 @@ class WPvivid_RestoreDB
101
 
102
  private function wpvivid_fix_siteurl_home(){
103
  global $wpvivid_plugin;
 
104
  $option_table = $this->new_prefix.'options';
105
  if($this->old_site_url!=$this->new_site_url)
106
  {
107
  //siteurl
108
- $update_query ='UPDATE '.$option_table.' SET option_value="'.$this->new_site_url.'" WHERE option_name="siteurl";';
109
- $wpvivid_plugin->restore_data->write_log($update_query, 'notice');
110
- $wpvivid_plugin->restore_data->write_log('update query len:'.strlen($update_query), 'notice');
111
- $this->execute_sql($update_query);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
112
  }
113
 
114
  if($this->old_home_url!=$this->new_home_url)
115
  {
116
  //home
117
- $update_query ='UPDATE '.$option_table.' SET option_value="'.$this->new_home_url.'" WHERE option_name="home";';
118
- $wpvivid_plugin->restore_data->write_log($update_query, 'notice');
119
- $wpvivid_plugin->restore_data->write_log('update query len:'.strlen($update_query), 'notice');
120
- $this->execute_sql($update_query);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
121
  }
122
  }
123
 
@@ -292,6 +340,8 @@ class WPvivid_RestoreDB
292
 
293
  $current_table='';
294
  $current_old_table='';
 
 
295
  while(!feof($sql_handle))
296
  {
297
  $line = fgets($sql_handle);
@@ -357,6 +407,59 @@ class WPvivid_RestoreDB
357
  if (preg_match('#^\\s*CREATE TABLE#', $query))
358
  {
359
  $current_table=$this->create_table($query,$current_old_table);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
360
  }else if(preg_match('#^\\s*LOCK TABLES#',$query))
361
  {
362
  $this->lock_table($query);
101
 
102
  private function wpvivid_fix_siteurl_home(){
103
  global $wpvivid_plugin;
104
+ global $wpdb;
105
  $option_table = $this->new_prefix.'options';
106
  if($this->old_site_url!=$this->new_site_url)
107
  {
108
  //siteurl
109
+ $db_siteurl = false;
110
+ $siteurl_sql = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM $option_table WHERE option_name = %s", 'siteurl' ) );
111
+ foreach ( $siteurl_sql as $siteurl )
112
+ {
113
+ $db_siteurl = untrailingslashit($siteurl->option_value);
114
+ }
115
+ if($db_siteurl !== false)
116
+ {
117
+ $update_query ='UPDATE '.$option_table.' SET option_value="'.$this->new_site_url.'" WHERE option_name="siteurl";';
118
+ $wpvivid_plugin->restore_data->write_log($update_query, 'notice');
119
+ $wpvivid_plugin->restore_data->write_log('update query len:'.strlen($update_query), 'notice');
120
+ $this->execute_sql($update_query);
121
+ }
122
+ else
123
+ {
124
+ $insert_query = $wpdb->prepare("INSERT INTO {$option_table} (option_name,option_value) VALUES ('siteurl',%s)", $this->new_site_url);
125
+ $wpvivid_plugin->restore_data->write_log('siteurl not found, insert: '.$insert_query, 'notice');
126
+ if ($wpdb->get_results($insert_query) === false) {
127
+ $error = $wpdb->last_error;
128
+ $wpvivid_plugin->restore_data->write_log('insert siteurl failed: '.$error, 'notice');
129
+ }
130
+ else
131
+ {
132
+ $wpvivid_plugin->restore_data->write_log('insert siteurl success', 'notice');
133
+ }
134
+ }
135
+
136
+
137
  }
138
 
139
  if($this->old_home_url!=$this->new_home_url)
140
  {
141
  //home
142
+ $db_home = false;
143
+ $home_sql = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM $option_table WHERE option_name = %s", 'home' ) );
144
+ foreach ( $home_sql as $home )
145
+ {
146
+ $db_home = untrailingslashit($home->option_value);
147
+ }
148
+ if($db_home !== false)
149
+ {
150
+ $update_query ='UPDATE '.$option_table.' SET option_value="'.$this->new_home_url.'" WHERE option_name="home";';
151
+ $wpvivid_plugin->restore_data->write_log($update_query, 'notice');
152
+ $wpvivid_plugin->restore_data->write_log('update query len:'.strlen($update_query), 'notice');
153
+ $this->execute_sql($update_query);
154
+ }
155
+ else
156
+ {
157
+ $insert_query = $wpdb->prepare("INSERT INTO {$option_table} (option_name,option_value) VALUES ('home',%s)", $this->new_home_url);
158
+ $wpvivid_plugin->restore_data->write_log('home not found, insert: '.$insert_query, 'notice');
159
+ if ($wpdb->get_results($insert_query) === false) {
160
+ $error = $wpdb->last_error;
161
+ $wpvivid_plugin->restore_data->write_log('insert home failed: '.$error, 'notice');
162
+ }
163
+ else
164
+ {
165
+ $wpvivid_plugin->restore_data->write_log('insert home success', 'notice');
166
+ }
167
+ }
168
+
169
  }
170
  }
171
 
340
 
341
  $current_table='';
342
  $current_old_table='';
343
+ $is_restore_option_table = false;
344
+ $reset_option_table = false;
345
  while(!feof($sql_handle))
346
  {
347
  $line = fgets($sql_handle);
407
  if (preg_match('#^\\s*CREATE TABLE#', $query))
408
  {
409
  $current_table=$this->create_table($query,$current_old_table);
410
+ if($current_table === $wpdb->prefix.'options')
411
+ {
412
+ $is_restore_option_table = true;
413
+ }
414
+
415
+ if($is_restore_option_table === true && $current_table !== $wpdb->prefix.'options' && $reset_option_table === false)
416
+ {
417
+ $option_table = $wpdb->prefix.'options';
418
+
419
+ $db_siteurl = false;
420
+ $siteurl_sql = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM $option_table WHERE option_name = %s", 'siteurl' ) );
421
+ foreach ( $siteurl_sql as $siteurl )
422
+ {
423
+ $db_siteurl = untrailingslashit($siteurl->option_value);
424
+ }
425
+ if($db_siteurl === false)
426
+ {
427
+ $insert_query = $wpdb->prepare("INSERT INTO {$option_table} (option_name,option_value) VALUES ('siteurl',%s)", untrailingslashit(site_url()));
428
+ $wpvivid_plugin->restore_data->write_log('siteurl not found, insert: '.$insert_query, 'notice');
429
+ if ($wpdb->get_results($insert_query) === false) {
430
+ $error = $wpdb->last_error;
431
+ $wpvivid_plugin->restore_data->write_log('insert siteurl failed: '.$error, 'notice');
432
+ }
433
+ else
434
+ {
435
+ $wpvivid_plugin->restore_data->write_log('insert siteurl success', 'notice');
436
+ }
437
+ }
438
+
439
+
440
+ $db_home = false;
441
+ $home_sql = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM $option_table WHERE option_name = %s", 'home' ) );
442
+ foreach ( $home_sql as $home )
443
+ {
444
+ $db_home = untrailingslashit($home->option_value);
445
+ }
446
+ if($db_home === false)
447
+ {
448
+ $insert_query = $wpdb->prepare("INSERT INTO {$option_table} (option_name,option_value) VALUES ('home',%s)", untrailingslashit(home_url()));
449
+ $wpvivid_plugin->restore_data->write_log('home not found, insert: '.$insert_query, 'notice');
450
+ if ($wpdb->get_results($insert_query) === false) {
451
+ $error = $wpdb->last_error;
452
+ $wpvivid_plugin->restore_data->write_log('insert home failed: '.$error, 'notice');
453
+ }
454
+ else
455
+ {
456
+ $wpvivid_plugin->restore_data->write_log('insert home success', 'notice');
457
+ }
458
+ }
459
+
460
+ $reset_option_table = true;
461
+ }
462
+
463
  }else if(preg_match('#^\\s*LOCK TABLES#',$query))
464
  {
465
  $this->lock_table($query);
includes/class-wpvivid.php CHANGED
@@ -203,6 +203,8 @@ class WPvivid {
203
  include_once WPVIVID_PLUGIN_DIR . '/includes/upload-cleaner/class-wpvivid-uploads-cleaner.php';
204
  include_once WPVIVID_PLUGIN_DIR . '/includes/staging/class-wpvivid-staging.php';
205
 
 
 
206
  $this->function_realize=new WPvivid_Function_Realize();
207
  $this->migrate=new WPvivid_Migrate();
208
  $this->backup_uploader=new Wpvivid_BackupUploader();
@@ -211,6 +213,8 @@ class WPvivid {
211
  $export_import = new WPvivid_Export_Import();
212
  $cleaner=new WPvivid_Uploads_Cleaner();
213
  $this->staging=new WPvivid_Staging_Free();
 
 
214
  }
215
 
216
  public function init_pclzip_tmp_folder()
203
  include_once WPVIVID_PLUGIN_DIR . '/includes/upload-cleaner/class-wpvivid-uploads-cleaner.php';
204
  include_once WPVIVID_PLUGIN_DIR . '/includes/staging/class-wpvivid-staging.php';
205
 
206
+ include_once WPVIVID_PLUGIN_DIR . '/includes/snapshot/class-wpvivid-snapshot.php';
207
+
208
  $this->function_realize=new WPvivid_Function_Realize();
209
  $this->migrate=new WPvivid_Migrate();
210
  $this->backup_uploader=new Wpvivid_BackupUploader();
213
  $export_import = new WPvivid_Export_Import();
214
  $cleaner=new WPvivid_Uploads_Cleaner();
215
  $this->staging=new WPvivid_Staging_Free();
216
+
217
+ new WPvivid_Snapshot_Ex();
218
  }
219
 
220
  public function init_pclzip_tmp_folder()
includes/customclass/class-wpvivid-sftpclass.php CHANGED
@@ -409,7 +409,7 @@ class WPvivid_SFTPClass extends WPvivid_Remote{
409
  $ret = $conn->login($username,$password);
410
  if(!$ret)
411
  {
412
- return array('result'=>WPVIVID_FAILED,'error'=>'Login failed. You have entered the incorrect credential(s). Please try again.');
413
  }
414
 
415
  return $conn;
409
  $ret = $conn->login($username,$password);
410
  if(!$ret)
411
  {
412
+ return array('result'=>WPVIVID_FAILED,'error'=>'The connection failed because of incorrect credentials or server connection timeout. Please try again.');
413
  }
414
 
415
  return $conn;
includes/snapshot/class-wpvivid-snapshot-function.php ADDED
@@ -0,0 +1,752 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if (!defined('WPVIVID_PLUGIN_DIR'))
4
+ {
5
+ die;
6
+ }
7
+
8
+ class WPvivid_Snapshot_Function_Ex
9
+ {
10
+ public $options;
11
+
12
+ public function __construct()
13
+ {
14
+ $this->options=new WPvivid_Snapshot_Option_Ex();
15
+ }
16
+
17
+ public function check_manual_snapshot()
18
+ {
19
+ $snapshots=$this->options->get_option('wpvivid_snapshot');
20
+ $manual_snapshots=array();
21
+ foreach ($snapshots as $snapshot)
22
+ {
23
+ if($snapshot['type']=='manual')
24
+ {
25
+ $manual_snapshots[]=$snapshot;
26
+ }
27
+ }
28
+ $setting=$this->options->get_option('wpvivid_snapshot_setting');
29
+ $count=isset($setting['snapshot_retention'])?$setting['snapshot_retention']:6;
30
+ if(empty($count))
31
+ {
32
+ $count=6;
33
+ }
34
+
35
+ usort($manual_snapshots, function ($a, $b)
36
+ {
37
+ if ($a['time'] == $b['time'])
38
+ return 0;
39
+
40
+ if ($a['time'] > $b['time'])
41
+ return 1;
42
+ else
43
+ return -1;
44
+ });
45
+
46
+ while(count($manual_snapshots)>=$count)
47
+ {
48
+ $manual_snapshot=array_shift($manual_snapshots);
49
+ $this->remove_snapshot($manual_snapshot['id']);
50
+ }
51
+ }
52
+
53
+ public function create_merge_snapshot($comment='')
54
+ {
55
+ global $wpdb;
56
+
57
+ $snapshot_id = 'wp'.$this->create_snapshot_uid();
58
+ $tables = $wpdb->get_results('SHOW TABLE STATUS');
59
+ $exclude_tables[]=$wpdb->prefix.'wpvivid_log';
60
+ $exclude_tables[]=$wpdb->base_prefix."wpvivid_increment_big_ids";
61
+ $exclude_tables[]=$wpdb->prefix.'wpvivid_merge_db';
62
+ $exclude_tables[]=$wpdb->prefix.'wpvivid_options';
63
+ $exclude_tables[]=$wpdb->base_prefix."wpvivid_record_task";
64
+ $exclude_tables=apply_filters('wpvivid_create_snapshot_exclude_tables',$exclude_tables);
65
+
66
+ $snapshot_tables=array();
67
+
68
+ foreach ($tables as $table)
69
+ {
70
+ if (0 !== stripos($table->Name, $wpdb->prefix))
71
+ {
72
+ continue;
73
+ }
74
+ if (empty($table->Engine))
75
+ {
76
+ continue;
77
+ }
78
+
79
+ if(in_array($table->Name,$exclude_tables))
80
+ {
81
+ continue;
82
+ }
83
+
84
+ $snapshot_table['Name']=$table->Name;
85
+ $snapshot_table['finished']=0;
86
+ $snapshot_tables[$table->Name]=$snapshot_table;
87
+ }
88
+
89
+ if (!empty($snapshot_tables))
90
+ {
91
+ foreach ($snapshot_tables as $table_name=>$snapshot_table)
92
+ {
93
+ $new_table=$this->str_replace_first($wpdb->prefix,$snapshot_id,$table_name);
94
+
95
+ $wpdb->query("OPTIMIZE TABLE {$table_name}");
96
+ $wpdb->query("CREATE TABLE `{$new_table}` LIKE `{$table_name}`");
97
+ $wpdb->query("INSERT `{$new_table}` SELECT * FROM `{$table_name}`");
98
+ }
99
+ }
100
+ else
101
+ {
102
+ $ret['result']='failed';
103
+ $ret['error']='create snapshot failed';
104
+ return $ret;
105
+ }
106
+
107
+ $this->update_snapshot($snapshot_id,'merge',$comment);
108
+ $ret['result']='success';
109
+ $ret['finished']=1;
110
+ $ret['snapshot_id']=$snapshot_id;
111
+
112
+ return $ret;
113
+ }
114
+
115
+ public function check_dev_snapshot()
116
+ {
117
+ $snapshots=$this->options->get_option('wpvivid_snapshot');
118
+ $dev_snapshots=array();
119
+ foreach ($snapshots as $snapshot)
120
+ {
121
+ if($snapshot['type']=='dev')
122
+ {
123
+ $dev_snapshots[]=$snapshot;
124
+ }
125
+ }
126
+
127
+ $setting=$this->options->get_option('wpvivid_merge_setting');
128
+ $count=isset($setting['snapshot_retention'])?$setting['snapshot_retention']:6;
129
+ if(empty($count))
130
+ {
131
+ $count=6;
132
+ }
133
+
134
+ while(count($dev_snapshots)>=$count)
135
+ {
136
+ usort($dev_snapshots, function ($a, $b)
137
+ {
138
+ if ($a['time'] == $b['time'])
139
+ return 0;
140
+
141
+ if ($a['time'] > $b['time'])
142
+ return 1;
143
+ else
144
+ return -1;
145
+ });
146
+
147
+ $dev_snapshot=array_shift($dev_snapshots);
148
+ $this->remove_snapshot($dev_snapshot['id']);
149
+ }
150
+ }
151
+
152
+ public function create_dev_snapshot($task_data)
153
+ {
154
+ global $wpdb;
155
+
156
+ $snapshot_id = 'wp'.$this->create_snapshot_uid();
157
+ $tables = $wpdb->get_results('SHOW TABLE STATUS');
158
+ //$exclude_tables[]=$wpdb->prefix.'wpvivid_log';
159
+ //$exclude_tables[]=$wpdb->prefix.'wpvivid_merge_db';
160
+ $exclude_tables[]=$wpdb->prefix.'wpvivid_options';
161
+ $exclude_tables[]=$wpdb->base_prefix."wpvivid_record_task";
162
+ $exclude_tables=apply_filters('wpvivid_create_snapshot_exclude_tables',$exclude_tables);
163
+
164
+ $start_time=time();
165
+ $snapshot_tables=array();
166
+
167
+ foreach ($tables as $table)
168
+ {
169
+ if (0 !== stripos($table->Name, $wpdb->prefix))
170
+ {
171
+ continue;
172
+ }
173
+ if (empty($table->Engine))
174
+ {
175
+ continue;
176
+ }
177
+
178
+ if(in_array($table->Name,$exclude_tables))
179
+ {
180
+ continue;
181
+ }
182
+
183
+ $snapshot_table['Name']=$table->Name;
184
+ $snapshot_table['finished']=0;
185
+ $snapshot_tables[$table->Name]=$snapshot_table;
186
+ }
187
+
188
+ $this->init_task($snapshot_id,$snapshot_tables,'dev',$task_data['comment']);
189
+
190
+ if (!empty($snapshot_tables))
191
+ {
192
+ foreach ($snapshot_tables as $table_name=>$snapshot_table)
193
+ {
194
+ if($snapshot_table['finished']==1)
195
+ continue;
196
+
197
+ $new_table=$this->str_replace_first($wpdb->prefix,$snapshot_id,$table_name);
198
+
199
+ $wpdb->query("OPTIMIZE TABLE {$table_name}");
200
+ $wpdb->query("CREATE TABLE `{$new_table}` LIKE `{$table_name}`");
201
+ $wpdb->query("INSERT `{$new_table}` SELECT * FROM `{$table_name}`");
202
+
203
+ $snapshot_tables[$table_name]['finished']=1;
204
+ $this->update_task($snapshot_id,$snapshot_tables);
205
+
206
+ if($this->is_time_limit_exceeded($start_time))
207
+ {
208
+ $ret['result']='success';
209
+ $ret['finished']=0;
210
+ $ret['snapshot_id']=$snapshot_id;
211
+ $ret['snapshot_tables']=$snapshot_tables;
212
+ return $ret;
213
+ }
214
+ }
215
+ }
216
+ else
217
+ {
218
+ $ret['result']='failed';
219
+ $ret['error']='create snapshot failed';
220
+ return $ret;
221
+ }
222
+
223
+ $this->update_snapshot($snapshot_id,'dev',$task_data['comment']);
224
+ $ret['result']='success';
225
+ $ret['finished']=1;
226
+ $ret['snapshot_id']=$snapshot_id;
227
+
228
+ return $ret;
229
+ }
230
+
231
+ public function create_snapshot($type='',$comment='')
232
+ {
233
+ global $wpdb;
234
+
235
+ $snapshot_id=$this->create_snapshot_uid();
236
+ $snapshot_id = 'wp'.$snapshot_id;
237
+
238
+ $tables = $wpdb->get_results('SHOW TABLE STATUS');
239
+
240
+ $exclude_tables[]=$wpdb->prefix.'wpvivid_log';
241
+ $exclude_tables[]=$wpdb->base_prefix."wpvivid_increment_big_ids";
242
+ $exclude_tables[]=$wpdb->prefix.'wpvivid_merge_db';
243
+ $exclude_tables[]=$wpdb->prefix.'wpvivid_options';
244
+ $exclude_tables[]=$wpdb->base_prefix."wpvivid_record_task";
245
+ $exclude_tables=apply_filters('wpvivid_create_snapshot_exclude_tables',$exclude_tables);
246
+
247
+ $start_time=time();
248
+ $snapshot_tables=array();
249
+
250
+ foreach ($tables as $table)
251
+ {
252
+ if (0 !== stripos($table->Name, $wpdb->prefix))
253
+ {
254
+ continue;
255
+ }
256
+ if (empty($table->Engine))
257
+ {
258
+ continue;
259
+ }
260
+
261
+ if(in_array($table->Name,$exclude_tables))
262
+ {
263
+ continue;
264
+ }
265
+
266
+ $snapshot_table['Name']=$table->Name;
267
+ $snapshot_table['finished']=0;
268
+ $snapshot_tables[$table->Name]=$snapshot_table;
269
+ }
270
+
271
+ if(empty($type))
272
+ {
273
+ $type='manual';
274
+ }
275
+
276
+ $this->init_task($snapshot_id,$snapshot_tables,$type,$comment);
277
+
278
+ if (!empty($snapshot_tables))
279
+ {
280
+ foreach ($snapshot_tables as $table_name=>$snapshot_table)
281
+ {
282
+ if($snapshot_table['finished']==1)
283
+ continue;
284
+
285
+ $new_table=$this->str_replace_first($wpdb->prefix,$snapshot_id,$table_name);
286
+
287
+ $wpdb->query("OPTIMIZE TABLE {$table_name}");
288
+ $wpdb->query("DROP TABLE IF EXISTS `{$new_table}`");
289
+ $wpdb->query("CREATE TABLE `{$new_table}` LIKE `{$table_name}`");
290
+ $wpdb->query("INSERT `{$new_table}` SELECT * FROM `{$table_name}`");
291
+
292
+ $snapshot_tables[$table_name]['finished']=1;
293
+ $this->update_task($snapshot_id,$snapshot_tables);
294
+
295
+ if($this->is_time_limit_exceeded($start_time))
296
+ {
297
+ $ret['result']='success';
298
+ $ret['finished']=0;
299
+ $ret['snapshot_id']=$snapshot_id;
300
+ $ret['snapshot_tables']=$snapshot_tables;
301
+ return $ret;
302
+ }
303
+ }
304
+ }
305
+ else
306
+ {
307
+ $ret['result']='failed';
308
+ $ret['error']='Creating the snapshot failed.';
309
+ return $ret;
310
+ }
311
+
312
+ $this->update_task($snapshot_id,$snapshot_tables);
313
+ $this->update_snapshot($snapshot_id,$type,$comment);
314
+ $ret['result']='success';
315
+ $ret['finished']=1;
316
+ $ret['snapshot_id']=$snapshot_id;
317
+ return $ret;
318
+ }
319
+
320
+ public function resume_create_snapshot()
321
+ {
322
+ global $wpdb;
323
+
324
+ $start_time=time();
325
+
326
+ $ret=$this->get_task_data();
327
+ if($ret['result']=='failed')
328
+ {
329
+ return $ret;
330
+ }
331
+
332
+ $snapshot_id=$ret['snapshot_id'];
333
+ $snapshot_tables=$ret['snapshot_tables'];
334
+ $type=$ret['type'];
335
+ $comment=$ret['comment'];
336
+
337
+ if (!empty($snapshot_tables))
338
+ {
339
+ foreach ($snapshot_tables as $table_name=>$snapshot_table)
340
+ {
341
+ if($snapshot_table['finished']==1)
342
+ continue;
343
+
344
+ $new_table=$this->str_replace_first($wpdb->prefix,$snapshot_id,$table_name);
345
+
346
+ $wpdb->query("OPTIMIZE TABLE {$table_name}");
347
+ $wpdb->query("DROP TABLE IF EXISTS `{$new_table}`");
348
+ $wpdb->query("CREATE TABLE `{$new_table}` LIKE `{$table_name}`");
349
+ $wpdb->query("INSERT `{$new_table}` SELECT * FROM `{$table_name}`");
350
+
351
+ $snapshot_tables[$table_name]['finished']=1;
352
+ $this->update_task($snapshot_id,$snapshot_tables);
353
+ if($this->is_time_limit_exceeded($start_time))
354
+ {
355
+ $ret['result']='success';
356
+ $ret['finished']=0;
357
+ $ret['snapshot_id']=$snapshot_id;
358
+ $ret['snapshot_tables']=$snapshot_tables;
359
+ $this->update_task($snapshot_id,$snapshot_tables);
360
+ return $ret;
361
+ }
362
+ }
363
+ }
364
+ else
365
+ {
366
+ $ret['result']='failed';
367
+ $ret['error']='Creating the snapshot failed.';
368
+ return $ret;
369
+ }
370
+
371
+ $this->update_task($snapshot_id,$snapshot_tables);
372
+ $this->update_snapshot($snapshot_id,$type,$comment);
373
+ $ret['result']='success';
374
+ $ret['finished']=1;
375
+ $ret['snapshot_id']=$snapshot_id;
376
+
377
+ return $ret;
378
+ }
379
+
380
+ public function init_task($snapshot_id,$snapshot_tables,$type,$comment)
381
+ {
382
+ $snapshot_task=$this->options->get_option('wpvivid_snapshot_task');
383
+ if(empty($snapshot_task))
384
+ {
385
+ $snapshot_task=array();
386
+ }
387
+
388
+ $snapshot_task['snapshot_id']=$snapshot_id;
389
+ $snapshot_task['snapshot_tables']=$snapshot_tables;
390
+ $snapshot_task['type']=$type;
391
+ $snapshot_task['comment']=$comment;
392
+
393
+ $this->options->update_option('wpvivid_snapshot_task',$snapshot_task);
394
+ }
395
+
396
+ public function get_progress()
397
+ {
398
+ $snapshot_task=$this->options->get_option('wpvivid_snapshot_task');
399
+ if(empty($snapshot_task))
400
+ {
401
+ $progress['main_percent']='0%';
402
+ $progress['doing']="Creating a snapshot.";
403
+ }
404
+
405
+ $snapshot_tables=$snapshot_task['snapshot_tables'];
406
+ $i_sum=count($snapshot_tables);
407
+ $i_finished=0;
408
+ $b_finished=true;
409
+ foreach ($snapshot_tables as $table_name=>$snapshot_table)
410
+ {
411
+ if($snapshot_table['finished']==1)
412
+ {
413
+ $i_finished++;
414
+ }
415
+ else
416
+ {
417
+ $b_finished=false;
418
+ }
419
+ }
420
+
421
+ $i_progress=intval(($i_finished/$i_sum)*100);
422
+ $progress['main_percent']=$i_progress.'%';
423
+ if($b_finished)
424
+ {
425
+ $progress['doing']="Create snapshot completed.";
426
+ }
427
+ else
428
+ {
429
+ $progress['doing']="Creating a snapshot.";
430
+ }
431
+
432
+ return $progress;
433
+ }
434
+
435
+ public function update_task($snapshot_id,$snapshot_tables)
436
+ {
437
+ $snapshot_task=$this->options->get_option('wpvivid_snapshot_task');
438
+ if(empty($snapshot_task))
439
+ {
440
+ $snapshot_task=array();
441
+ }
442
+
443
+ $snapshot_task['snapshot_id']=$snapshot_id;
444
+ $snapshot_task['snapshot_tables']=$snapshot_tables;
445
+
446
+ $this->options->update_option('wpvivid_snapshot_task',$snapshot_task);
447
+ }
448
+
449
+ public function get_task_data()
450
+ {
451
+ $snapshot_task=$this->options->get_option('wpvivid_snapshot_task');
452
+ if(empty($snapshot_task))
453
+ {
454
+ $ret['result']='failed';
455
+ $ret['error']='Creating snapshot task not found.';
456
+ return $ret;
457
+ }
458
+
459
+ if(empty($snapshot_task['snapshot_id'])||empty($snapshot_task['snapshot_tables']))
460
+ {
461
+ $ret['result']='failed';
462
+ $ret['error']='Creating snapshot task not found.';
463
+ return $ret;
464
+ }
465
+
466
+ $ret['result']='success';
467
+ $ret['snapshot_id']=$snapshot_task['snapshot_id'];
468
+ $ret['snapshot_tables']=$snapshot_task['snapshot_tables'];
469
+ $ret['type']=$snapshot_task['type'];
470
+ $ret['comment']=$snapshot_task['comment'];
471
+ return $ret;
472
+ }
473
+
474
+ public function get_snapshots($type='')
475
+ {
476
+ $snapshot_data=$this->options->get_option('wpvivid_snapshot');
477
+ if(empty($snapshot_data))
478
+ {
479
+ $snapshot_data=array();
480
+ }
481
+
482
+ if(empty($type))
483
+ {
484
+ return $snapshot_data;
485
+ }
486
+ else
487
+ {
488
+ $get_snapshot_data=array();
489
+ foreach ($snapshot_data as $data)
490
+ {
491
+ if($data['type']==$type)
492
+ {
493
+ $get_snapshot_data[]=$data;
494
+ }
495
+ }
496
+ return $snapshot_data;
497
+ }
498
+ }
499
+
500
+ public function restore_snapshot($snapshot_id)
501
+ {
502
+ global $wpdb;
503
+
504
+ $tables = $wpdb->get_results('SHOW TABLE STATUS');
505
+
506
+ //$exclude_tables[]=$wpdb->prefix.'wpvivid_log';
507
+ //$exclude_tables[]=$wpdb->base_prefix."wpvivid_increment_big_ids";
508
+ //$exclude_tables[]=$wpdb->prefix.'wpvivid_merge_db';
509
+ $exclude_tables[]=$wpdb->prefix.'wpvivid_options';
510
+ $exclude_tables=apply_filters('wpvivid_create_snapshot_exclude_tables',$exclude_tables);
511
+
512
+ add_filter('wpvivid_merge_query_lock', array($this,'query_lock'), 9999);
513
+
514
+ $new_tables = array();
515
+ if (is_array($tables))
516
+ {
517
+ foreach ($tables as $table)
518
+ {
519
+ if (0 !== stripos($table->Name, $snapshot_id))
520
+ {
521
+ continue;
522
+ }
523
+
524
+ if (empty($table->Engine))
525
+ {
526
+ continue;
527
+ }
528
+
529
+ if(in_array($table->Name,$exclude_tables))
530
+ {
531
+ continue;
532
+ }
533
+
534
+ $new_table['Name']=$table->Name;
535
+ $new_table['finished']=0;
536
+ $new_tables[$table->Name] =$new_table;
537
+ }
538
+ }
539
+ else
540
+ {
541
+ $ret['result']='failed';
542
+ $ret['error']='Failed to retrieve list of database tables.';
543
+ return $ret;
544
+ }
545
+
546
+ $this->init_restore_task($snapshot_id,$new_tables);
547
+
548
+ /*
549
+ foreach ($tables as $table)
550
+ {
551
+ if (0 !== stripos($table->Name, $wpdb->prefix))
552
+ {
553
+ continue;
554
+ }
555
+ if (empty($table->Engine))
556
+ {
557
+ continue;
558
+ }
559
+
560
+ if(in_array($table->Name,$exclude_tables))
561
+ {
562
+ continue;
563
+ }
564
+
565
+ $wpdb->query('DROP TABLE ' . $table->Name);
566
+ }*/
567
+
568
+ foreach ($new_tables as $table_name=>$table)
569
+ {
570
+ $new_table=$this->str_replace_first($snapshot_id,$wpdb->prefix,$table_name);
571
+
572
+ $wpdb->query('DROP TABLE ' . $new_table);
573
+ $wpdb->query("CREATE TABLE `{$new_table}` LIKE `{$table_name}`");
574
+ $wpdb->query("INSERT `{$new_table}` SELECT * FROM `{$table_name}`");
575
+ $new_tables[$table_name]['finished']=1;
576
+ $this->update_restore_task($snapshot_id,$new_tables);
577
+ }
578
+
579
+ $ret['result']='success';
580
+ return $ret;
581
+ }
582
+
583
+ public function init_restore_task($snapshot_id,$snapshot_tables)
584
+ {
585
+ $snapshot_task=$this->options->get_option('wpvivid_restore_snapshot_task');
586
+ if(empty($snapshot_task))
587
+ {
588
+ $snapshot_task=array();
589
+ }
590
+
591
+ $snapshot_task['snapshot_id']=$snapshot_id;
592
+ $snapshot_task['snapshot_tables']=$snapshot_tables;
593
+
594
+ $this->options->update_option('wpvivid_restore_snapshot_task',$snapshot_task);
595
+ }
596
+
597
+ public function update_restore_task($snapshot_id,$snapshot_tables)
598
+ {
599
+ $snapshot_task=$this->options->get_option('wpvivid_restore_snapshot_task');
600
+ if(empty($snapshot_task))
601
+ {
602
+ $snapshot_task=array();
603
+ }
604
+
605
+ $snapshot_task['snapshot_id']=$snapshot_id;
606
+ $snapshot_task['snapshot_tables']=$snapshot_tables;
607
+
608
+ $this->options->update_option('wpvivid_restore_snapshot_task',$snapshot_task);
609
+ }
610
+
611
+ public function get_restore_task_data()
612
+ {
613
+ $snapshot_task=$this->options->get_option('wpvivid_restore_snapshot_task');
614
+ if(empty($snapshot_task))
615
+ {
616
+ $ret['result']='failed';
617
+ $ret['error']='Restoring snapshot task not found.';
618
+ return $ret;
619
+ }
620
+
621
+ if(empty($snapshot_task['snapshot_id'])||empty($snapshot_task['snapshot_tables']))
622
+ {
623
+ $ret['result']='failed';
624
+ $ret['error']='Restoring snapshot task not found.';
625
+ return $ret;
626
+ }
627
+
628
+ $ret['result']='success';
629
+ $ret['snapshot_id']=$snapshot_task['snapshot_id'];
630
+ $ret['snapshot_tables']=$snapshot_task['snapshot_tables'];
631
+ return $ret;
632
+ }
633
+
634
+ public function remove_snapshot($snapshot_id)
635
+ {
636
+ global $wpdb;
637
+
638
+ $tables = $wpdb->get_col($wpdb->prepare('SHOW TABLES LIKE %s', array($snapshot_id . '%')));
639
+ foreach ($tables as $table)
640
+ {
641
+ $wpdb->query('DROP TABLE IF EXISTS `' . $table.'`');
642
+ }
643
+
644
+ $snapshot_data=$this->options->get_option('wpvivid_snapshot');
645
+ unset($snapshot_data[$snapshot_id]);
646
+ $this->options->update_option('wpvivid_snapshot',$snapshot_data);
647
+
648
+ $ret['result']='success';
649
+ return $ret;
650
+ }
651
+
652
+ public function str_replace_first($from, $to, $content)
653
+ {
654
+ $from = '/'.preg_quote($from, '/').'/';
655
+
656
+ return preg_replace($from, $to, $content, 1);
657
+ }
658
+
659
+ public function create_snapshot_uid()
660
+ {
661
+ global $wpdb;
662
+ $count = 0;
663
+
664
+ do
665
+ {
666
+ $count++;
667
+ $uid = sprintf('%06x', mt_rand(0, 0xFFFFFF));
668
+
669
+ $verify_db = $wpdb->get_col($wpdb->prepare('SHOW TABLES LIKE %s', array('%' . $uid . '%')));
670
+
671
+ } while (!empty($verify_db) && $count < 10);
672
+
673
+ if ($count == 10)
674
+ {
675
+ $uid = false;
676
+ }
677
+
678
+ return $uid;
679
+ }
680
+
681
+ public function update_snapshot($snapshot_id,$type,$comment)
682
+ {
683
+ $snapshot_data=$this->options->get_option('wpvivid_snapshot');
684
+ if(empty($snapshot_data))
685
+ {
686
+ $snapshot_data=array();
687
+ }
688
+
689
+ $snapshot_data[$snapshot_id]['id']=$snapshot_id;
690
+ $snapshot_data[$snapshot_id]['type']=$type;
691
+ $snapshot_data[$snapshot_id]['time']=time();
692
+ $snapshot_data[$snapshot_id]['comment']=$comment;
693
+
694
+ $this->options->update_option('wpvivid_snapshot',$snapshot_data);
695
+ }
696
+
697
+ public function is_time_limit_exceeded($start_time)
698
+ {
699
+ $time_limit =20;
700
+ $time_taken = microtime(true) -$start_time;
701
+ if($time_taken >= $time_limit)
702
+ {
703
+ return true;
704
+ }
705
+
706
+ return false;
707
+ }
708
+
709
+ public function get_dev_progress()
710
+ {
711
+ $snapshot_task=$this->options->get_option('wpvivid_snapshot_task');
712
+ if(empty($snapshot_task))
713
+ {
714
+ $progress['main_percent']='0%';
715
+ $progress['text']="creating snapshot for dev site.";
716
+ }
717
+
718
+ $snapshot_tables=$snapshot_task['snapshot_tables'];
719
+ $i_sum=count($snapshot_tables);
720
+ $i_finished=0;
721
+ $b_finished=true;
722
+ foreach ($snapshot_tables as $table_name=>$snapshot_table)
723
+ {
724
+ if($snapshot_table['finished']==1)
725
+ {
726
+ $i_finished++;
727
+ }
728
+ else
729
+ {
730
+ $b_finished=false;
731
+ }
732
+ }
733
+
734
+ $i_progress=intval(($i_finished/$i_sum)*100);
735
+ $progress['main_percent']=$i_progress.'%';
736
+ if($b_finished)
737
+ {
738
+ $progress['text']="creating snapshot for dev site completed.";
739
+ }
740
+ else
741
+ {
742
+ $progress['text']="creating snapshot for dev site - $i_finished/$i_sum tables";
743
+ }
744
+
745
+ return $progress;
746
+ }
747
+
748
+ public function query_lock($lock)
749
+ {
750
+ return true;
751
+ }
752
+ }
includes/snapshot/class-wpvivid-snapshot-options.php ADDED
@@ -0,0 +1,77 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ if (!defined('WPVIVID_PLUGIN_DIR'))
3
+ {
4
+ die;
5
+ }
6
+
7
+ class WPvivid_Snapshot_Option_Ex
8
+ {
9
+ public $options_table;
10
+
11
+ public function __construct()
12
+ {
13
+ global $wpdb;
14
+ $this->options_table = $wpdb->base_prefix."wpvivid_options";
15
+ $this->check_tables();
16
+ }
17
+
18
+ public function check_tables()
19
+ {
20
+ global $wpdb;
21
+
22
+ if($wpdb->get_var("SHOW TABLES LIKE '$this->options_table'") != $this->options_table)
23
+ {
24
+ $sql = "CREATE TABLE IF NOT EXISTS $this->options_table (
25
+ `option_id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
26
+ `option_name` varchar(191) NOT NULL DEFAULT '',
27
+ `option_value` longtext NOT NULL,
28
+ PRIMARY KEY (`option_id`),
29
+ UNIQUE KEY `option_name` (`option_name`)
30
+ );";
31
+
32
+ $wpdb->query($sql);
33
+ }
34
+ }
35
+
36
+ public function get_option($option_name)
37
+ {
38
+ global $wpdb;
39
+
40
+ $query =$wpdb->prepare('select option_value from '.$this->options_table .' where option_name = %s', $option_name);
41
+
42
+ $result =$wpdb->get_var($query);
43
+ if(empty($result))
44
+ {
45
+ return false;
46
+ }
47
+ else
48
+ {
49
+ return maybe_unserialize($result);
50
+ }
51
+ }
52
+
53
+ public function update_option($option_name,$value)
54
+ {
55
+ global $wpdb;
56
+
57
+ if($this->is_exists_option($option_name))
58
+ {
59
+ $option_value = maybe_serialize($value);
60
+ return $wpdb->update($this->options_table, compact('option_name', 'option_value'), compact('option_name'));
61
+ }
62
+ else
63
+ {
64
+ $option_value = maybe_serialize($value);
65
+ return $wpdb->insert($this->options_table, compact('option_name', 'option_value'));
66
+ }
67
+ }
68
+
69
+ public function is_exists_option($option_name)
70
+ {
71
+ global $wpdb;
72
+
73
+ $query = $wpdb->prepare('select option_value from '.$this->options_table.' where option_name = %s', $option_name);
74
+ $result =$wpdb->get_row($query);
75
+ return !empty($result);
76
+ }
77
+ }
includes/snapshot/class-wpvivid-snapshot.php ADDED
@@ -0,0 +1,1502 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if (!defined('WPVIVID_PLUGIN_DIR'))
4
+ {
5
+ die;
6
+ }
7
+
8
+ class WPvivid_Snapshot_Ex
9
+ {
10
+ public $options;
11
+ public $main_tab;
12
+
13
+ public function __construct()
14
+ {
15
+ include_once WPVIVID_PLUGIN_DIR . '/includes/snapshot/class-wpvivid-snapshot-function.php';
16
+ include_once WPVIVID_PLUGIN_DIR . '/includes/snapshot/class-wpvivid-snapshot-options.php';
17
+ if(is_admin())
18
+ {
19
+ include_once WPVIVID_PLUGIN_DIR . '/includes/snapshot/class-wpvivid-snapshots-list.php';
20
+
21
+ //add_filter('wpvivid_get_dashboard_menu', array($this, 'get_dashboard_menu'), 10, 2);
22
+ //add_filter('wpvivid_get_dashboard_screens', array($this, 'get_dashboard_screens'), 10);
23
+
24
+ $this->options=new WPvivid_Snapshot_Option_Ex();
25
+
26
+ /*
27
+ if (is_multisite())
28
+ {
29
+ add_action('network_admin_menu',array( $this,'add_admin_menu'));
30
+ }
31
+ else
32
+ {
33
+ add_action('admin_menu',array( $this,'add_admin_menu'));
34
+ }
35
+ add_filter('wpvivid_snapshot_get_screen_ids', array($this,'get_screen_ids'), 9999);
36
+ */
37
+
38
+ add_filter('wpvivid_get_admin_menus',array($this,'get_admin_menus'),22);
39
+ add_filter('wpvivid_get_screen_ids',array($this,'get_screen_ids'),12);
40
+
41
+ add_action('admin_enqueue_scripts', array($this, 'enqueue_styles'), 11);
42
+ add_action('admin_enqueue_scripts', array($this, 'enqueue_scripts'), 11);
43
+
44
+
45
+ add_action('wp_ajax_wpvivid_create_snapshot',array( $this,'create_snapshot'));
46
+ add_action('wp_ajax_wpvivid_get_snapshot_progress',array( $this,'get_snapshot_progress'));
47
+ //
48
+ add_action('wp_ajax_wpvivid_resume_create_snapshot',array( $this,'resume_create_snapshot'));
49
+ add_action('wp_ajax_wpvivid_restore_snapshot',array( $this,'restore_snapshot'));
50
+ add_action('wp_ajax_wpvivid_get_restore_snapshot_status',array( $this,'get_restore_snapshot_status'));
51
+ add_action('wp_ajax_wpvivid_delete_snapshot',array( $this,'delete_snapshot'));
52
+
53
+ add_filter('wpvivid_check_create_snapshot',array($this,'check_create_snapshot'));
54
+ add_action('wpvivid_create_snapshot',array($this,'create_snapshot_ex'),10,1);
55
+
56
+ add_action('wp_ajax_wpvivid_set_snapshot_setting',array( $this,'set_setting'));
57
+ //
58
+ add_action('wpvivid_snapshot_add_sidebar',array( $this,'add_sidebar'));
59
+
60
+ $snapshot_setting=$this->options->get_option('wpvivid_snapshot_setting');
61
+
62
+ $quick_snapshot=isset($snapshot_setting['quick_snapshot'])?$snapshot_setting['quick_snapshot']:false;
63
+
64
+ if($quick_snapshot)
65
+ {
66
+ add_action('admin_bar_menu',array( $this,'add_toolbar_items'),100);
67
+ add_action('admin_footer',array( $this,'quick_snapshot'));
68
+ }
69
+ }
70
+
71
+ }
72
+
73
+ public function get_admin_menus($submenus)
74
+ {
75
+ $submenu['parent_slug']=apply_filters('wpvivid_white_label_slug', WPVIVID_PLUGIN_SLUG);
76
+ $submenu['page_title']= apply_filters('wpvivid_white_label_display', 'WPvivid Backup');
77
+ $submenu['menu_title']=__('Database Snapshots', 'wpvivid-backuprestore');
78
+ $submenu['capability']='administrator';
79
+ $submenu['menu_slug']=strtolower(sprintf('%s-snapshot-ex', apply_filters('wpvivid_white_label_slug', 'wpvivid')));
80
+ $submenu['index']=2;
81
+ $submenu['function']=array($this, 'init_page');
82
+ $submenus[$submenu['menu_slug']]=$submenu;
83
+ return $submenus;
84
+ }
85
+
86
+ public function get_screen_ids($screen_ids)
87
+ {
88
+ $screen_ids[]=apply_filters('wpvivid_white_label_screen_id', 'wpvivid-backup_page_wpvivid-snapshot-ex');
89
+ return $screen_ids;
90
+ }
91
+
92
+ public function add_toolbar_items($wp_admin_bar)
93
+ {
94
+ $wp_admin_bar->add_menu(array(
95
+ 'id' => 'wpvivid_snapshot_admin_menu',
96
+ 'title' => 'Quick Snapshot',
97
+ 'meta' =>array(
98
+ 'class' => 'wpvivid-quick-create-snapshot',
99
+ )
100
+ ));
101
+ }
102
+
103
+ public function add_admin_menu()
104
+ {
105
+ $page_title=apply_filters('wpvivid_white_label_display', 'WPvivid Snapshot');
106
+ $menu_title=apply_filters('wpvivid_white_label_display', 'WPvivid Snapshot');
107
+
108
+ $capability = 'administrator';
109
+
110
+ $menu_slug ='wpvivid-snapshot';
111
+
112
+ $function=array($this, 'init_page');
113
+ $icon_url='dashicons-camera-alt';
114
+ $position=100;
115
+
116
+ $menu['page_title']= $page_title;
117
+ $menu['menu_title']= $menu_title;
118
+ $menu['capability']='administrator';
119
+ $menu['menu_slug']=$menu_slug;
120
+ $menu['function']=array($this, 'init_page');
121
+ $menu['icon_url']=$icon_url;
122
+ $menu['position']=100;
123
+
124
+ $menu=apply_filters('wpvivid_snapshot_get_main_admin_menus', $menu);
125
+
126
+ if($menu!=false)
127
+ add_menu_page( $page_title, $menu_title, $capability, $menu_slug, $function, $icon_url, $position);
128
+ }
129
+
130
+ public function get_dashboard_menu($submenus,$parent_slug)
131
+ {
132
+ $display = apply_filters('wpvivid_get_menu_capability_addon', 'menu_backup');
133
+ if($display)
134
+ {
135
+ $submenu['parent_slug'] = $parent_slug;
136
+ $submenu['page_title'] = apply_filters('wpvivid_white_label_display', 'Database Snapshots');
137
+ $submenu['menu_title'] = 'Database Snapshots';
138
+ $submenu['capability'] = 'administrator';
139
+ $submenu['menu_slug'] = strtolower(sprintf('%s-snapshot', apply_filters('wpvivid_white_label_slug', 'wpvivid')));
140
+ $submenu['index'] = 11;//10;
141
+ $submenu['function'] = array($this, 'init_page');
142
+ $submenus[$submenu['menu_slug']] = $submenu;
143
+ }
144
+
145
+ add_filter('wpvivid_snapshot_get_main_admin_menus',array($this,'get_main_admin_menus'),9999);
146
+ return $submenus;
147
+ }
148
+
149
+ public function get_dashboard_screens($screens)
150
+ {
151
+ $screen['menu_slug']='wpvivid-snapshot';
152
+ $screen['screen_id']='wpvivid-plugin_page_wpvivid-snapshot';
153
+ $screen['is_top']=false;
154
+ $screens[]=$screen;
155
+ return $screens;
156
+ }
157
+
158
+ public function get_main_admin_menus($menu)
159
+ {
160
+ return false;
161
+ }
162
+
163
+ /*
164
+ public function get_screen_ids($screen_ids)
165
+ {
166
+ $screen_ids=array();
167
+ $screen['menu_slug']='wpvivid-snapshot';
168
+ $screen['screen_id']='toplevel_page_wpvivid-snapshot';
169
+ $screen['is_top']=true;
170
+ $screens[]=$screen;
171
+
172
+ foreach ($screens as $screen)
173
+ {
174
+ $screen_ids[]=$screen['screen_id'];
175
+ if(is_multisite())
176
+ {
177
+ if(substr($screen['screen_id'],-8)=='-network')
178
+ continue;
179
+ $screen_ids[]=$screen['screen_id'].'-network';
180
+ }
181
+ else
182
+ {
183
+ $screen_ids[]=$screen['screen_id'];
184
+ }
185
+ }
186
+ return $screen_ids;
187
+ }
188
+ */
189
+
190
+ public function enqueue_styles()
191
+ {
192
+ $screen_ids=array();
193
+ $screen_ids=apply_filters('wpvivid_get_screen_ids',$screen_ids);
194
+ if(in_array(get_current_screen()->id,$screen_ids))
195
+ {
196
+ wp_enqueue_style('wpvivid_snapshot_ex', WPVIVID_PLUGIN_DIR_URL . 'css/wpvivid-snapshot-style.css', array(), WPVIVID_PLUGIN_VERSION, 'all');
197
+ }
198
+ }
199
+
200
+ public function enqueue_scripts()
201
+ {
202
+
203
+ $snapshot_setting=$this->options->get_option('wpvivid_snapshot_setting');
204
+
205
+ $quick_snapshot=isset($snapshot_setting['quick_snapshot'])?$snapshot_setting['quick_snapshot']:false;
206
+
207
+ if($quick_snapshot)
208
+ {
209
+ wp_enqueue_style('wpvivid_quick_snapshot_ex', WPVIVID_PLUGIN_DIR_URL . 'css/wpvivid-quick-snapshot-style.css', array(), WPVIVID_PLUGIN_VERSION, 'all');
210
+ wp_enqueue_style ( 'wp-jquery-ui-dialog');
211
+ wp_enqueue_script( 'jquery-ui-dialog' );
212
+ wp_enqueue_script ( 'wpvivid_qucick_snapshot_ex_js' , // handle
213
+ WPVIVID_PLUGIN_DIR_URL . 'js/wpvivid-quick-snapshot.js' , // source
214
+ array('jquery-ui-dialog'),
215
+ WPVIVID_PLUGIN_VERSION, false
216
+ );
217
+ wp_localize_script('wpvivid_qucick_snapshot_ex_js', 'wpvivid_quick_snapshot_ajax_object', array('ajax_url' => admin_url('admin-ajax.php'),'ajax_nonce'=>wp_create_nonce('wpvivid_ajax')));
218
+ }
219
+ }
220
+
221
+ public function added_quick_snapshot($added)
222
+ {
223
+ return true;
224
+ }
225
+
226
+ public function quick_snapshot()
227
+ {
228
+ if(apply_filters('wpvivid_added_quick_snapshot',false))
229
+ {
230
+ return;
231
+ }
232
+ add_filter('wpvivid_added_quick_snapshot',array( $this,'added_quick_snapshot'));
233
+ ?>
234
+ <div id="wpvivid_quick_snapshot_dialog">
235
+ <span id="wpvivid_quick_snapshot_close" class="dashicons dashicons-no" style="float:right;cursor: pointer"></span>
236
+ <div id="wpvivid_quick_snapshot_message_box" style="padding:20px 0;">
237
+ <p style="text-align:center;font-size:24px;">
238
+ <span id="wpvivid_quick_snapshot_message">Are you sure you want to create a snapshot now?</span>
239
+ <span id="wpvivid_quick_snapshot_loading"><img src="<?php echo admin_url().'/images/loading.gif'; ?>"></span>
240
+ </p>
241
+ <p style="text-align:center;" id="wpvivid_quick_create_snapshot_comment_box">
242
+ <span class="dashicons dashicons-welcome-write-blog wpvivid-dashicons-green" style="margin-top:0.2em;"></span>
243
+ <span><strong>Comment the snapshot</strong>(optional): </span>
244
+ <input id="wpvivid_quick_create_snapshot_comment" type="text" placeholder="e.g. mysnapshot">
245
+ </p>
246
+ </div>
247
+ <div id="wpvivid_quick_snapshot_progress" style="display: none">
248
+ <p>
249
+ <span class="wpvivid-span-progress">
250
+ <span class="wpvivid-span-processed-progress">0% completed</span>
251
+ </span>
252
+ </p>
253
+ <p><span>Action: </span><span></span><span></span></p>
254
+ </div>
255
+ <div style="padding:0 0 10px 0">
256
+ <p style="text-align:center;">
257
+ <input class="button-primary" style="width: 150px; height: 40px; font-size: 16px; margin-bottom: 10px; pointer-events: auto; opacity: 1;" id="wpvivid_quick_create_snapshot" type="submit" value="Create Now">
258
+ </p>
259
+ </div>
260
+ </div>
261
+ <script>
262
+ var b_quick_end_create_progress=false;
263
+ var b_quick_need_update=false;
264
+ jQuery('.wpvivid-quick-create-snapshot').click(function()
265
+ {
266
+ jQuery("#wpvivid_quick_snapshot_message_box").show();
267
+ //
268
+ jQuery("#wpvivid_quick_snapshot_loading").hide();
269
+ jQuery("#wpvivid_quick_create_snapshot_comment_box").show();
270
+ jQuery("#wpvivid_quick_snapshot_progress").hide();
271
+ //
272
+ jQuery("#wpvivid_quick_snapshot_message").html("Are you sure you want to create a snapshot now?");
273
+ jQuery("#wpvivid_quick_snapshot_dialog").dialog("widget").find(".ui-dialog-titlebar").hide();
274
+ jQuery("#wpvivid_quick_snapshot_dialog").dialog("open");
275
+
276
+ return false;
277
+ });
278
+
279
+ //wpvivid_quick_snapshot_close
280
+ jQuery('#wpvivid_quick_snapshot_close').click(function()
281
+ {
282
+ jQuery("#wpvivid_quick_snapshot_dialog").dialog('close');
283
+ });
284
+
285
+ jQuery('#wpvivid_quick_create_snapshot').click(function()
286
+ {
287
+ wpvivid_quick_create_snapshot();
288
+ });
289
+
290
+ function wpvivid_quick_simulate_create_progress()
291
+ {
292
+ var MaxProgess = 30,
293
+ currentProgess = 0,
294
+ steps = 1,
295
+ time_steps=1000;
296
+
297
+ var timer = setInterval(function ()
298
+ {
299
+ if(currentProgess>100)
300
+ {
301
+ currentProgess=100;
302
+ }
303
+ else
304
+ {
305
+ currentProgess += steps;
306
+ }
307
+
308
+ if(b_quick_end_create_progress)
309
+ {
310
+ clearInterval(timer);
311
+ return;
312
+ }
313
+ var progress_html='<p><span class="wpvivid-span-progress">' +
314
+ '<span class="wpvivid-span-processed-progress wpvivid-span-processed-percent-progress" style="width: '+currentProgess+'%">' +
315
+ currentProgess+'% completed</span></span></p><p>' +
316
+ '<span class="dashicons dashicons-welcome-write-blog wpvivid-dashicons-grey"></span><span>Action:</span>' +
317
+ '<span>Creating the snapshot.</span></p>';
318
+
319
+ jQuery("#wpvivid_quick_snapshot_progress").html(progress_html);
320
+ if (currentProgess >= MaxProgess)
321
+ {
322
+ clearInterval(timer);
323
+ }
324
+ }, time_steps);
325
+ }
326
+
327
+ function wpvivid_quick_create_snapshot()
328
+ {
329
+ var comment=jQuery('#wpvivid_quick_create_snapshot_comment').val();
330
+ var ajax_data= {
331
+ 'action': 'wpvivid_create_snapshot',
332
+ 'comment':comment,
333
+ };
334
+ var default_progress='<p><span class="wpvivid-span-progress"><span class="wpvivid-span-processed-progress wpvivid-span-processed-percent-progress" style="width: 0%">0% completed</span></span></p><p><span class="dashicons dashicons-welcome-write-blog wpvivid-dashicons-grey"></span><span>Action:</span><span>Creating a snapshot.</span></p>';
335
+ jQuery('#wpvivid_quick_snapshot_progress').show();
336
+ jQuery('#wpvivid_quick_snapshot_progress').html(default_progress);
337
+ jQuery("#wpvivid_quick_snapshot_loading").show();
338
+ jQuery("#wpvivid_quick_create_snapshot_comment_box").hide();
339
+ jQuery("#wpvivid_quick_snapshot_message").html("Creating the snapshot...");
340
+ b_quick_need_update=true;
341
+ b_quick_end_create_progress=false;
342
+ wpvivid_quick_simulate_create_progress();
343
+
344
+ setTimeout(function(){
345
+ wpvivid_quick_get_snapshot_progress();
346
+ }, 3000);
347
+
348
+ jQuery('#wpvivid_quick_create_snapshot').css({'pointer-events': 'none', 'opacity': '0.4'});
349
+ wpvivid_post_request(ajax_data, function(data)
350
+ {
351
+ b_quick_end_create_progress=true;
352
+ var jsonarray = jQuery.parseJSON(data);
353
+ if (jsonarray.result === 'success')
354
+ {
355
+ jQuery('#wpvivid_quick_snapshot_progress').html(jsonarray.progress);
356
+ if(jsonarray.finished==1)
357
+ {
358
+ jQuery("#wpvivid_quick_snapshot_dialog").dialog('close');
359
+ b_quick_need_update=false;
360
+ jQuery('#wpvivid_quick_snapshot_progress').hide();
361
+ jQuery('#wpvivid_quick_create_snapshot').css({'pointer-events': 'auto', 'opacity': '1'});
362
+
363
+ jQuery("#wpvivid_quick_snapshot_loading").hide();
364
+ jQuery("#wpvivid_quick_create_snapshot_comment_box").show();
365
+ jQuery("#wpvivid_quick_snapshot_message").html("Are you sure you want to create a snapshot now?");
366
+
367
+ alert("Creating a snapshot completed successfully.");
368
+ }
369
+ else
370
+ {
371
+ wpvivid_quick_resume_create_snapshot();
372
+ }
373
+ }
374
+ else
375
+ {
376
+ alert(jsonarray.error);
377
+ b_quick_need_update=false;
378
+ jQuery('#wpvivid_quick_snapshot_progress').hide();
379
+ jQuery('#wpvivid_quick_create_snapshot').css({'pointer-events': 'auto', 'opacity': '1'});
380
+
381
+ jQuery("#wpvivid_quick_snapshot_loading").hide();
382
+ jQuery("#wpvivid_quick_create_snapshot_comment_box").show();
383
+ jQuery("#wpvivid_quick_snapshot_message").html("Are you sure you want to create a snapshot now?");
384
+ }
385
+ }, function(XMLHttpRequest, textStatus, errorThrown)
386
+ {
387
+ setTimeout(function(){
388
+ wpvivid_quick_resume_create_snapshot(0);
389
+ }, 15000);
390
+ });
391
+ }
392
+
393
+ function wpvivid_quick_get_snapshot_progress()
394
+ {
395
+ var ajax_data= {
396
+ 'action': 'wpvivid_get_snapshot_progress',
397
+ };
398
+
399
+ wpvivid_post_request(ajax_data, function(data)
400
+ {
401
+ var jsonarray = jQuery.parseJSON(data);
402
+ b_quick_end_create_progress=true;
403
+ jQuery('#wpvivid_quick_snapshot_progress').html(jsonarray.progress);
404
+
405
+ if(b_quick_need_update)
406
+ {
407
+ setTimeout(function(){
408
+ wpvivid_quick_get_snapshot_progress();
409
+ }, 1000);
410
+ }
411
+ }, function(XMLHttpRequest, textStatus, errorThrown)
412
+ {
413
+ if(b_quick_need_update)
414
+ {
415
+ setTimeout(function(){
416
+ wpvivid_quick_get_snapshot_progress();
417
+ }, 1000);
418
+ }
419
+ });
420
+ }
421
+
422
+ function wpvivid_quick_resume_create_snapshot(resume)
423
+ {
424
+ if(resume>6)
425
+ {
426
+ alert('Creating the snapshot timed out.');
427
+ b_quick_need_update=false;
428
+ jQuery("#wpvivid_quick_snapshot_message_box").show();
429
+ jQuery('#wpvivid_quick_snapshot_progress').hide();
430
+ jQuery('#wpvivid_quick_create_snapshot').css({'pointer-events': 'auto', 'opacity': '1'});
431
+
432
+ jQuery("#wpvivid_quick_snapshot_loading").hide();
433
+ jQuery("#wpvivid_quick_create_snapshot_comment_box").show();
434
+ jQuery("#wpvivid_quick_snapshot_message").html("Are you sure you want to create a snapshot now?");
435
+ return;
436
+ }
437
+ var ajax_data= {
438
+ 'action': 'wpvivid_resume_create_snapshot'
439
+ };
440
+
441
+ wpvivid_post_request(ajax_data, function(data)
442
+ {
443
+ try {
444
+ var jsonarray = jQuery.parseJSON(data);
445
+ if (jsonarray.result === 'success')
446
+ {
447
+ jQuery('#wpvivid_quick_snapshot_progress').html(jsonarray.progress);
448
+
449
+ if(jsonarray.finished==1)
450
+ {
451
+ b_quick_need_update=false;
452
+ jQuery("#wpvivid_quick_snapshot_dialog").dialog('close');
453
+
454
+ jQuery("#wpvivid_quick_snapshot_message_box").show();
455
+ jQuery('#wpvivid_quick_snapshot_progress').hide();
456
+ jQuery('#wpvivid_quick_create_snapshot').css({'pointer-events': 'auto', 'opacity': '1'});
457
+
458
+ jQuery("#wpvivid_quick_snapshot_loading").hide();
459
+ jQuery("#wpvivid_quick_create_snapshot_comment_box").show();
460
+ jQuery("#wpvivid_quick_snapshot_message").html("Are you sure you want to create a snapshot now?");
461
+ alert("Creating a snapshot completed successfully.");
462
+ }
463
+ else
464
+ {
465
+ wpvivid_quick_resume_create_snapshot();
466
+ }
467
+ }
468
+ else
469
+ {
470
+ b_quick_need_update=false;
471
+ jQuery("#wpvivid_quick_snapshot_message_box").show();
472
+ alert(jsonarray.error);
473
+ jQuery('#wpvivid_quick_snapshot_progress').hide();
474
+ jQuery('#wpvivid_quick_create_snapshot').css({'pointer-events': 'auto', 'opacity': '1'});
475
+
476
+ jQuery("#wpvivid_quick_snapshot_loading").hide();
477
+ jQuery("#wpvivid_quick_create_snapshot_comment_box").show();
478
+ jQuery("#wpvivid_quick_snapshot_message").html("Are you sure you want to create a snapshot now?");
479
+ }
480
+ }
481
+ catch (e)
482
+ {
483
+ resume+=1;
484
+ setTimeout(function(){
485
+ wpvivid_quick_resume_create_snapshot(resume);
486
+ }, 15000);
487
+ }
488
+
489
+ }, function(XMLHttpRequest, textStatus, errorThrown)
490
+ {
491
+ resume+=1;
492
+ setTimeout(function(){
493
+ wpvivid_quick_resume_create_snapshot(resume);
494
+ }, 15000);
495
+ });
496
+ }
497
+
498
+ jQuery(document).ready(function ()
499
+ {
500
+ jQuery(function($)
501
+ {
502
+ jQuery("#wpvivid_quick_snapshot_dialog").dialog({
503
+ 'dialogClass' : 'noTitleStuff',
504
+ 'modal' : true,
505
+ 'autoOpen' : false,
506
+ 'closeOnEscape' : true,
507
+ 'width': '600px',
508
+ 'minWidth' : "260px"
509
+ });
510
+ });
511
+ });
512
+ </script>
513
+ <?php
514
+ }
515
+
516
+ public function init_page()
517
+ {
518
+ ?>
519
+ <div class="wrap wpvivid-canvas">
520
+ <div class="icon32"></div>
521
+ <h1><?php esc_attr_e( apply_filters('wpvivid_white_label_display', 'WPvivid').' Plugins - Snapshots', 'wpvivid' ); ?></h1>
522
+ <div id="wpvivid_backup_notice"></div>
523
+ <div id="poststuff">
524
+ <div id="post-body" class="metabox-holder columns-2">
525
+ <div id="post-body-content">
526
+ <div class="meta-box-sortables ui-sortable">
527
+ <div class="wpvivid-backup">
528
+ <?php $this->welcome_bar();?>
529
+ <div class="wpvivid-canvas wpvivid-clear-float">
530
+ <!--- backup progress --->
531
+ <?php
532
+
533
+ if(!class_exists('WPvivid_Tab_Page_Container_Ex'))
534
+ include_once WPVIVID_PLUGIN_DIR . '/includes/snapshot/class-wpvivid-tab-page-container-ex.php';
535
+ $this->main_tab=new WPvivid_Tab_Page_Container_Ex();
536
+
537
+ $args['is_parent_tab']=0;
538
+ $args['div_style']='padding-top:0;display:block;';
539
+ $args['span_class']='dashicons dashicons-camera';
540
+ $args['span_style']='color:#007cba; padding-right:0.5em;margin-top:0.2em;';
541
+ //
542
+ $tabs['merge']['title']='Snapshots';
543
+ $tabs['merge']['slug']='snapshots';
544
+ $tabs['merge']['callback']=array($this, 'output_snapshots');
545
+ $tabs['merge']['args']=$args;
546
+
547
+ $args['div_style']='padding-top:0;';
548
+ $args['span_class']='dashicons dashicons-admin-generic';
549
+ $args['span_style']='color:grey;padding-right:0.5em;margin-top:0.1em;';
550
+ $tabs['snapshot']['title']='Setting';
551
+ $tabs['snapshot']['slug']='snapshots_setting';
552
+ $tabs['snapshot']['callback']=array($this, 'output_snapshots_setting');
553
+ $tabs['snapshot']['args']=$args;
554
+
555
+ foreach ($tabs as $key=>$tab)
556
+ {
557
+ $this->main_tab->add_tab($tab['title'],$tab['slug'],$tab['callback'], $tab['args']);
558
+ }
559
+
560
+ $this->main_tab->display();
561
+ ?>
562
+ </div>
563
+ </div>
564
+ </div>
565
+ </div>
566
+ <?php
567
+ do_action( 'wpvivid_snapshot_add_sidebar');
568
+ ?>
569
+ </div>
570
+ </div>
571
+ </div>
572
+ <?php
573
+ }
574
+
575
+ public function welcome_bar()
576
+ {
577
+ ?>
578
+ <div class="wpvivid-welcome-bar wpvivid-clear-float">
579
+ <div class="wpvivid-welcome-bar-left">
580
+ <p><span class="dashicons dashicons-camera-alt wpvivid-dashicons-large wpvivid-dashicons-green"></span><span class="wpvivid-page-title">Database Snapshots</span></p>
581
+ <p><span class="about-description">Create snapshots of the website database and restore the database from a snapshot.</span></p>
582
+ </div>
583
+ <div class="wpvivid-welcome-bar-right">
584
+ <p></p>
585
+ <div style="float:right;">
586
+ <span>Local Time:</span>
587
+ <span>
588
+ <a href="<?php esc_attr_e(apply_filters('wpvivid_get_admin_url', '').'options-general.php'); ?>">
589
+ <?php
590
+ $offset=get_option('gmt_offset');
591
+ echo esc_html(date("l, F-d-Y H:i",time()+$offset*60*60));
592
+ ?>
593
+ </a>
594
+ </span>
595
+ <span class="dashicons dashicons-editor-help wpvivid-dashicons-editor-help wpvivid-tooltip">
596
+ <div class="wpvivid-left">
597
+ <p>Clicking the date and time will redirect you to the WordPress General Settings page where you can change your timezone settings.</p>
598
+ <i></i> <!-- do not delete this line -->
599
+ </div>
600
+ </span>
601
+ </div>
602
+ </div>
603
+ </div>
604
+ <?php
605
+ }
606
+
607
+ public function output_snapshots()
608
+ {
609
+ $snapshot=new WPvivid_Snapshot_Function_Ex();
610
+ $snapshot_data=$snapshot->get_snapshots();
611
+
612
+ ?>
613
+ <div class="wpvivid-one-coloum wpvivid-workflow wpvivid-clear-float" style="margin-bottom:1rem;">
614
+ <div id="wpvivid_snapshot_progress" style="display: none">
615
+ <p>
616
+ <span class="wpvivid-span-progress">
617
+ <span class="wpvivid-span-processed-progress wpvivid-span-processed-percent-progress">0% completed</span>
618
+ </span>
619
+ </p>
620
+ <p><span>Action: </span><span></span><span class="wpvivid-animate-flicker"></span></p>
621
+ </div>
622
+ <div>
623
+ <input class="button-primary" style="width: 200px; height: 50px; font-size: 20px; margin-bottom: 10px; pointer-events: auto; opacity: 1;" id="wpvivid_create_snapshot" type="submit" value="Create a snapshot">
624
+ </div>
625
+ <div>
626
+ <p>
627
+ <span class="dashicons dashicons-welcome-write-blog wpvivid-dashicons-green" style="margin-top:0.2em;"></span>
628
+ <span><strong>Comment the snapshot</strong>(optional): </span>
629
+ <input id="wpvivid_create_snapshot_comment" type="text" placeholder="e.g. mysnapshot">
630
+ </p>
631
+ </div>
632
+
633
+ <div id="wpvivid_snapshots_list">
634
+ <?php
635
+ $Snapshots_list = new WPvivid_Snapshots_List_Ex();
636
+ $Snapshots_list->set_list($snapshot_data);
637
+ $Snapshots_list->prepare_items();
638
+ $Snapshots_list->display();
639
+ ?>
640
+ </div>
641
+ </div>
642
+ <script>
643
+ var b_need_update=false;
644
+ var b_restore_finished=false;
645
+ var b_end_create_progress=false;
646
+ jQuery('#wpvivid_create_snapshot').click(function()
647
+ {
648
+ wpvivid_create_snapshot();
649
+ });
650
+
651
+ function wpvivid_simulate_restore_progress()
652
+ {
653
+ var MaxProgess = 95,
654
+ currentProgess = 0,
655
+ steps = 1,
656
+ time_steps=1000;
657
+
658
+ var timer = setInterval(function ()
659
+ {
660
+ if(b_restore_finished)
661
+ {
662
+ currentProgess=100;
663
+ }
664
+ else
665
+ {
666
+ currentProgess += steps;
667
+ }
668
+
669
+
670
+ var progress_html='<p><span class="wpvivid-span-progress">' +
671
+ '<span class="wpvivid-span-processed-progress wpvivid-span-processed-percent-progress" style="width: '+currentProgess+'%">' +
672
+ currentProgess+'% completed</span></span></p><p>' +
673
+ '<span class="dashicons dashicons-welcome-write-blog wpvivid-dashicons-grey"></span><span>Action:</span>' +
674
+ '<span>Restoring the snapshot.</span></p>';
675
+
676
+ jQuery("#wpvivid_snapshot_progress").html(progress_html);
677
+ if (currentProgess >= MaxProgess)
678
+ {
679
+ clearInterval(timer);
680
+ }
681
+ }, time_steps);
682
+ }
683
+
684
+ function wpvivid_simulate_create_progress()
685
+ {
686
+ var MaxProgess = 30,
687
+ currentProgess = 0,
688
+ steps = 1,
689
+ time_steps=1000;
690
+
691
+ var timer = setInterval(function ()
692
+ {
693
+ if(currentProgess>100)
694
+ {
695
+ currentProgess=100;
696
+ }
697
+ else
698
+ {
699
+ currentProgess += steps;
700
+ }
701
+
702
+ if(b_end_create_progress)
703
+ {
704
+ clearInterval(timer);
705
+ return;
706
+ }
707
+ var progress_html='<p><span class="wpvivid-span-progress">' +
708
+ '<span class="wpvivid-span-processed-progress wpvivid-span-processed-percent-progress" style="width: '+currentProgess+'%">' +
709
+ currentProgess+'% completed</span></span></p><p>' +
710
+ '<span class="dashicons dashicons-welcome-write-blog wpvivid-dashicons-grey"></span><span>Action:</span>' +
711
+ '<span>Creating the snapshot.</span></p>';
712
+
713
+ jQuery("#wpvivid_snapshot_progress").html(progress_html);
714
+ if (currentProgess >= MaxProgess)
715
+ {
716
+ clearInterval(timer);
717
+ }
718
+ }, time_steps);
719
+ }
720
+
721
+ function wpvivid_create_snapshot()
722
+ {
723
+ var comment=jQuery('#wpvivid_create_snapshot_comment').val();
724
+ var ajax_data= {
725
+ 'action': 'wpvivid_create_snapshot',
726
+ 'comment':comment,
727
+ };
728
+ var default_progress='<p><span class="wpvivid-span-progress"><span class="wpvivid-span-processed-progress wpvivid-span-processed-percent-progress" style="width: 0%">0% completed</span></span></p><p><span class="dashicons dashicons-welcome-write-blog wpvivid-dashicons-grey"></span><span>Action:</span><span>Creating a snapshot.</span></p>';
729
+ jQuery('#wpvivid_snapshot_progress').show();
730
+ jQuery('#wpvivid_snapshot_progress').html(default_progress);
731
+
732
+ b_need_update=true;
733
+ b_end_create_progress=false;
734
+ wpvivid_simulate_create_progress();
735
+
736
+ setTimeout(function(){
737
+ wpvivid_get_snapshot_progress();
738
+ }, 3000);
739
+
740
+ jQuery('#wpvivid_create_snapshot').css({'pointer-events': 'none', 'opacity': '0.4'});
741
+ wpvivid_post_request(ajax_data, function(data)
742
+ {
743
+ b_end_create_progress=true;
744
+ var jsonarray = jQuery.parseJSON(data);
745
+ if (jsonarray.result === 'success')
746
+ {
747
+ jQuery('#wpvivid_snapshot_progress').html(jsonarray.progress);
748
+ if(jsonarray.finished==1)
749
+ {
750
+ b_need_update=false;
751
+ alert('Creating a snapshot completed successfully.');
752
+ location.reload();
753
+ }
754
+ else
755
+ {
756
+ wpvivid_resume_create_snapshot();
757
+ }
758
+ }
759
+ else
760
+ {
761
+ b_need_update=false;
762
+ alert(jsonarray.error);
763
+ jQuery('#wpvivid_snapshot_progress').hide();
764
+ jQuery('#wpvivid_create_snapshot').css({'pointer-events': 'auto', 'opacity': '1'});
765
+ }
766
+ }, function(XMLHttpRequest, textStatus, errorThrown)
767
+ {
768
+ setTimeout(function(){
769
+ wpvivid_resume_create_snapshot(0);
770
+ }, 15000);
771
+ });
772
+ }
773
+
774
+ function wpvivid_get_snapshot_progress()
775
+ {
776
+ var ajax_data= {
777
+ 'action': 'wpvivid_get_snapshot_progress',
778
+ };
779
+
780
+ wpvivid_post_request(ajax_data, function(data)
781
+ {
782
+ var jsonarray = jQuery.parseJSON(data);
783
+ b_end_create_progress=true;
784
+ jQuery('#wpvivid_snapshot_progress').html(jsonarray.progress);
785
+
786
+ if(b_need_update)
787
+ {
788
+ setTimeout(function(){
789
+ wpvivid_get_snapshot_progress();
790
+ }, 1000);
791
+ }
792
+ }, function(XMLHttpRequest, textStatus, errorThrown)
793
+ {
794
+ if(b_need_update)
795
+ {
796
+ setTimeout(function(){
797
+ wpvivid_get_snapshot_progress();
798
+ }, 1000);
799
+ }
800
+ });
801
+ }
802
+
803
+ function wpvivid_resume_create_snapshot(resume)
804
+ {
805
+ if(resume>6)
806
+ {
807
+ b_need_update=false;
808
+ alert('Creating the snapshot timed out.');
809
+ jQuery('#wpvivid_snapshot_progress').hide();
810
+ jQuery('#wpvivid_create_snapshot').css({'pointer-events': 'auto', 'opacity': '1'});
811
+ return;
812
+ }
813
+ var ajax_data= {
814
+ 'action': 'wpvivid_resume_create_snapshot'
815
+ };
816
+
817
+ wpvivid_post_request(ajax_data, function(data)
818
+ {
819
+ try {
820
+ var jsonarray = jQuery.parseJSON(data);
821
+ if (jsonarray.result === 'success')
822
+ {
823
+ jQuery('#wpvivid_snapshot_progress').html(jsonarray.progress);
824
+
825
+ if(jsonarray.finished==1)
826
+ {
827
+ b_need_update=false;
828
+
829
+ alert('Creating a snapshot completed successfully.');
830
+ location.reload();
831
+ }
832
+ else
833
+ {
834
+ wpvivid_resume_create_snapshot();
835
+ }
836
+ }
837
+ else
838
+ {
839
+ b_need_update=false;
840
+ alert(jsonarray.error);
841
+ jQuery('#wpvivid_snapshot_progress').hide();
842
+ jQuery('#wpvivid_create_snapshot').css({'pointer-events': 'auto', 'opacity': '1'});
843
+ }
844
+ }
845
+ catch (e)
846
+ {
847
+ resume+=1;
848
+ setTimeout(function(){
849
+ wpvivid_resume_create_snapshot(resume);
850
+ }, 15000);
851
+ }
852
+
853
+ }, function(XMLHttpRequest, textStatus, errorThrown)
854
+ {
855
+ resume+=1;
856
+ setTimeout(function(){
857
+ wpvivid_resume_create_snapshot(resume);
858
+ }, 15000);
859
+ });
860
+ }
861
+
862
+ jQuery('#wpvivid_snapshots_list').on("click",'.wpvivid-snapshot-restore',function()
863
+ {
864
+ var Obj=jQuery(this);
865
+ var snapshot_id=Obj.closest('tr').attr('slug');
866
+
867
+ var descript = '<?php _e('Are you sure you want to restore this snapshot?', 'wpvivid'); ?>';
868
+ var ret = confirm(descript);
869
+ if (ret === true)
870
+ {
871
+ var ajax_data= {
872
+ 'action': 'wpvivid_restore_snapshot',
873
+ 'id':snapshot_id
874
+ };
875
+ jQuery('#wpvivid_create_snapshot').css({'pointer-events': 'none', 'opacity': '0.4'});
876
+ var default_progress='<p><span class="wpvivid-span-progress"><span class="wpvivid-span-processed-progress wpvivid-span-processed-percent-progress" style="width: 0%">0% completed</span></span></p><p><span class="dashicons dashicons-welcome-write-blog wpvivid-dashicons-grey"></span><span>Action:</span><span>Restoring the snapshot.</span></p>';
877
+ jQuery('#wpvivid_snapshot_progress').show();
878
+ jQuery('#wpvivid_snapshot_progress').html(default_progress);
879
+ b_restore_finished=false;
880
+ wpvivid_simulate_restore_progress();
881
+
882
+ wpvivid_post_request(ajax_data, function(data)
883
+ {
884
+ var jsonarray = jQuery.parseJSON(data);
885
+ if (jsonarray.result === 'success')
886
+ {
887
+ b_restore_finished=true;
888
+ jQuery('#wpvivid_snapshot_progress').html(jsonarray.progress);
889
+ alert('Restoring the snapshot completed successfully.');
890
+ location.reload(); }
891
+ else
892
+ {
893
+ b_restore_finished=true;
894
+ jQuery('#wpvivid_snapshot_progress').hide();
895
+ alert(jsonarray.error);
896
+ jQuery('#wpvivid_create_snapshot').css({'pointer-events': 'auto', 'opacity': '1'});
897
+ }
898
+ }, function(XMLHttpRequest, textStatus, errorThrown)
899
+ {
900
+ setTimeout(function(){
901
+ wpvivid_get_restore_snapshot_status();
902
+ }, 1000);
903
+ });
904
+ }
905
+ });
906
+
907
+ function wpvivid_get_restore_snapshot_status()
908
+ {
909
+ var ajax_data= {
910
+ 'action': 'wpvivid_get_restore_snapshot_status',
911
+ };
912
+
913
+ wpvivid_post_request(ajax_data, function(data)
914
+ {
915
+ try
916
+ {
917
+ var jsonarray = jQuery.parseJSON(data);
918
+ if (jsonarray.result === 'success')
919
+ {
920
+ if(jsonarray.finished==1)
921
+ {
922
+ jQuery('#wpvivid_snapshot_progress').html(jsonarray.progress);
923
+ b_restore_finished=true;
924
+ alert('Restoring the snapshot completed successfully.');
925
+ location.reload();
926
+ }
927
+ else
928
+ {
929
+ setTimeout(function(){
930
+ wpvivid_get_restore_snapshot_status();
931
+ }, 1000);
932
+ }
933
+ }
934
+ else
935
+ {
936
+ b_restore_finished=true;
937
+ jQuery('#wpvivid_snapshot_progress').hide();
938
+ alert(jsonarray.error);
939
+ jQuery('#wpvivid_create_snapshot').css({'pointer-events': 'auto', 'opacity': '1'});
940
+ }
941
+ }
942
+ catch (err)
943
+ {
944
+ setTimeout(function(){
945
+ wpvivid_get_restore_snapshot_status();
946
+ }, 1000);
947
+ }
948
+
949
+ }, function(XMLHttpRequest, textStatus, errorThrown)
950
+ {
951
+ setTimeout(function(){
952
+ wpvivid_get_restore_snapshot_status();
953
+ }, 1000);
954
+ });
955
+ }
956
+
957
+ jQuery('#wpvivid_snapshots_list').on("click",'.wpvivid-snapshot-delete',function()
958
+ {
959
+ var Obj=jQuery(this);
960
+ var snapshot_id=Obj.closest('tr').attr('slug');
961
+
962
+ var descript = '<?php _e('Are you sure you want to delete this snapshot?', 'wpvivid'); ?>';
963
+ var ret = confirm(descript);
964
+ if (ret === true)
965
+ {
966
+ var ajax_data= {
967
+ 'action': 'wpvivid_delete_snapshot',
968
+ 'id':snapshot_id
969
+ };
970
+ jQuery('#wpvivid_create_snapshot').css({'pointer-events': 'none', 'opacity': '0.4'});
971
+ wpvivid_post_request(ajax_data, function(data)
972
+ {
973
+ var jsonarray = jQuery.parseJSON(data);
974
+ if (jsonarray.result === 'success')
975
+ {
976
+ alert('The snapshot has been deleted successfully.');
977
+ jQuery('#wpvivid_snapshots_list').html(jsonarray.html);
978
+ jQuery('#wpvivid_create_snapshot').css({'pointer-events': 'auto', 'opacity': '1'});
979
+ }
980
+ else
981
+ {
982
+ alert(jsonarray.error);
983
+ jQuery('#wpvivid_create_snapshot').css({'pointer-events': 'auto', 'opacity': '1'});
984
+ }
985
+ }, function(XMLHttpRequest, textStatus, errorThrown)
986
+ {
987
+ jQuery('#wpvivid_create_snapshot').css({'pointer-events': 'auto', 'opacity': '1'});
988
+ alert("Deleting the snapshot(s) failed.");
989
+ });
990
+ }
991
+ });
992
+
993
+ jQuery('#wpvivid_snapshots_list').on("click",'#wpvivid_delete_snapshots_action',function()
994
+ {
995
+ var delete_snapshots_array = new Array();
996
+ var count = 0;
997
+
998
+ jQuery('#wpvivid_snapshots_list .wpvivid-snapshot-row input').each(function (i)
999
+ {
1000
+ if(jQuery(this).prop('checked'))
1001
+ {
1002
+ delete_snapshots_array[count] =jQuery(this).closest('tr').attr('slug');
1003
+ count++;
1004
+ }
1005
+ });
1006
+ if( count === 0 )
1007
+ {
1008
+ alert('<?php _e('Please select at least one item.','wpvivid'); ?>');
1009
+ }
1010
+ else
1011
+ {
1012
+ var descript = '<?php _e('Are you sure to delete the selected snapshots? These snapshots will be deleted permanently.', 'wpvivid'); ?>';
1013
+
1014
+ var ret = confirm(descript);
1015
+ if (ret === true)
1016
+ {
1017
+ jQuery('#wpvivid_delete_snapshots_action').css({'pointer-events': 'none', 'opacity': '0.4'});
1018
+ wpvivid_delete_snapshot_array(delete_snapshots_array,0);
1019
+ }
1020
+ }
1021
+ });
1022
+
1023
+ function wpvivid_delete_snapshot_array(delete_snapshots_array,index)
1024
+ {
1025
+ if(index >= delete_snapshots_array.length)
1026
+ {
1027
+ alert('The snapshot has been deleted successfully.');
1028
+ jQuery('#wpvivid_delete_snapshots_action').css({'pointer-events': 'auto', 'opacity': '1'});
1029
+ return;
1030
+ }
1031
+ const snapshot_id = delete_snapshots_array[index];
1032
+ var ajax_data= {
1033
+ 'action': 'wpvivid_delete_snapshot',
1034
+ 'id':snapshot_id
1035
+ };
1036
+ wpvivid_post_request(ajax_data, function(data)
1037
+ {
1038
+ var jsonarray = jQuery.parseJSON(data);
1039
+ if (jsonarray.result === 'success')
1040
+ {
1041
+ jQuery('#wpvivid_snapshots_list').html(jsonarray.html);
1042
+ index++;
1043
+ wpvivid_delete_snapshot_array(delete_snapshots_array,index);
1044
+ }
1045
+ else
1046
+ {
1047
+ alert(jsonarray.error);
1048
+ jQuery('#wpvivid_delete_snapshots_action').css({'pointer-events': 'auto', 'opacity': '1'});
1049
+ }
1050
+ }, function(XMLHttpRequest, textStatus, errorThrown)
1051
+ {
1052
+ alert('Deleting the snapshot(s) failed.');
1053
+ jQuery('#wpvivid_delete_snapshots_action').css({'pointer-events': 'auto', 'opacity': '1'});
1054
+ });
1055
+ }
1056
+ </script>
1057
+ <?php
1058
+ }
1059
+
1060
+ public function output_snapshots_setting()
1061
+ {
1062
+
1063
+ $setting=$this->options->get_option('wpvivid_snapshot_setting');
1064
+ if(empty($setting))
1065
+ {
1066
+ $setting=array();
1067
+ }
1068
+
1069
+ $snapshot_retention=isset($setting['snapshot_retention'])?$setting['snapshot_retention']:6;
1070
+ $quick_snapshot=isset($setting['quick_snapshot'])?$setting['quick_snapshot']:false;
1071
+ if($quick_snapshot)
1072
+ {
1073
+ $quick_snapshot='checked';
1074
+ }
1075
+ else
1076
+ {
1077
+ $quick_snapshot='';
1078
+ }
1079
+ ?>
1080
+ <div class="wpvivid-canvas wpvivid-clear-float">
1081
+ <table class="widefat" style="border-left:none;border-top:none;border-right:none;">
1082
+ <tr>
1083
+ <td class="row-title" style="min-width:200px;">
1084
+ <label for="tablecell">Snapshot Retention</label>
1085
+ </td>
1086
+ <td>
1087
+ <p>
1088
+ <span>Up to </span>
1089
+ <span>
1090
+ <select id="wpvivid_snapshot_retention" option="setting" name="snapshot_retention">
1091
+ <option value="3">3</option>
1092
+ <option value="4">4</option>
1093
+ <option value="5">5</option>
1094
+ <option value="6" selected>6</option>
1095
+ <option value="7">7</option>
1096
+ <option value="8">8</option>
1097
+ <option value="9">9</option>
1098
+ <option value="10">10</option>
1099
+ <option value="11">11</option>
1100
+ <option value="12">12</option>
1101
+ </select>
1102
+ </span>
1103
+ <span>snapshots retained</span></p>
1104
+ <p>It is not recommended to create too many snapshots.</p>
1105
+ </td>
1106
+ </tr>
1107
+ <tr>
1108
+ <td class="row-title" style="min-width:200px;">
1109
+ <label for="tablecell">Quick Snapshot</label>
1110
+ </td>
1111
+ <td>
1112
+ <p>
1113
+ <label class="wpvivid-checkbox">
1114
+ <span>Enable Quick Snapshot</span>
1115
+ <input type="checkbox" option="setting" name="quick_snapshot" <?php esc_attr_e($quick_snapshot); ?> />
1116
+ <span class="wpvivid-checkbox-checkmark"></span>
1117
+ </label>
1118
+ </p>
1119
+ <p><code>Show a menu in top admin bar for quickly creating a snapshot.</code></p>
1120
+ </td>
1121
+ </tr>
1122
+ </table>
1123
+ <div style="padding:1em 1em 0 0;"><input class="button-primary wpvivid-snapshot-setting-save" type="submit" value="Save Changes"></div>
1124
+ </div>
1125
+ <script>
1126
+ jQuery('.wpvivid-snapshot-setting-save').click(function()
1127
+ {
1128
+ wpvivid_snapshot_setting_save();
1129
+ });
1130
+
1131
+ function wpvivid_ajax_snapshot_data_transfer(data_type){
1132
+ var json = {};
1133
+ jQuery('input:checkbox[option='+data_type+']').each(function() {
1134
+ var value = '0';
1135
+ var key = jQuery(this).prop('name');
1136
+ if(jQuery(this).prop('checked')) {
1137
+ value = '1';
1138
+ }
1139
+ else {
1140
+ value = '0';
1141
+ }
1142
+ json[key]=value;
1143
+ });
1144
+ jQuery('input:radio[option='+data_type+']').each(function() {
1145
+ if(jQuery(this).prop('checked'))
1146
+ {
1147
+ var key = jQuery(this).prop('name');
1148
+ var value = jQuery(this).prop('value');
1149
+ json[key]=value;
1150
+ }
1151
+ });
1152
+ jQuery('input:text[option='+data_type+']').each(function(){
1153
+ var obj = {};
1154
+ var key = jQuery(this).prop('name');
1155
+ var value = jQuery(this).val();
1156
+ json[key]=value;
1157
+ });
1158
+ jQuery('input:password[option='+data_type+']').each(function(){
1159
+ var obj = {};
1160
+ var key = jQuery(this).prop('name');
1161
+ var value = jQuery(this).val();
1162
+ json[key]=value;
1163
+ });
1164
+ jQuery('select[option='+data_type+']').each(function(){
1165
+ var obj = {};
1166
+ var key = jQuery(this).prop('name');
1167
+ var value = jQuery(this).val();
1168
+ json[key]=value;
1169
+ });
1170
+ return JSON.stringify(json);
1171
+ }
1172
+
1173
+ function wpvivid_snapshot_setting_save()
1174
+ {
1175
+ var setting_data = wpvivid_ajax_snapshot_data_transfer('setting');
1176
+ var json = JSON.parse(setting_data);
1177
+ setting_data=JSON.stringify(json);
1178
+
1179
+ var ajax_data = {
1180
+ 'action': 'wpvivid_set_snapshot_setting',
1181
+ 'setting': setting_data,
1182
+ };
1183
+ jQuery('.wpvivid-snapshot-setting-save').css({'pointer-events': 'none', 'opacity': '0.4'});
1184
+ wpvivid_post_request(ajax_data, function (data)
1185
+ {
1186
+ try
1187
+ {
1188
+ var jsonarray = jQuery.parseJSON(data);
1189
+
1190
+ jQuery('.wpvivid-snapshot-setting-save').css({'pointer-events': 'auto', 'opacity': '1'});
1191
+ if (jsonarray.result === 'success')
1192
+ {
1193
+ location.reload();
1194
+ }
1195
+ else
1196
+ {
1197
+ alert(jsonarray.error);
1198
+ }
1199
+ }
1200
+ catch (err)
1201
+ {
1202
+ alert(err);
1203
+ jQuery('.wpvivid-snapshot-setting-save').css({'pointer-events': 'auto', 'opacity': '1'});
1204
+ }
1205
+ },function (XMLHttpRequest, textStatus, errorThrown)
1206
+ {
1207
+ var error_msg = "request: "+ textStatus + "(" + errorThrown + "): an error occurred when changing snapshot settings. " +
1208
+ "This error may be request not reaching or server not responding. Please try again later.";
1209
+ alert(error_msg);
1210
+ });
1211
+ }
1212
+
1213
+ jQuery(document).ready(function ()
1214
+ {
1215
+ jQuery('#wpvivid_snapshot_retention').val("<?php echo esc_attr($snapshot_retention)?>").change();
1216
+ });
1217
+ </script>
1218
+ <?php
1219
+ }
1220
+
1221
+ public function create_snapshot()
1222
+ {
1223
+ $this->ajax_check_security();
1224
+
1225
+ if(isset($_POST['comment'])&&!empty($_POST['comment']))
1226
+ {
1227
+ $comment=sanitize_text_field($_POST['comment']);
1228
+ }
1229
+ else
1230
+ {
1231
+ $comment='';
1232
+ }
1233
+
1234
+ set_time_limit(300);
1235
+ $snapshot=new WPvivid_Snapshot_Function_Ex();
1236
+ $snapshot->check_manual_snapshot();
1237
+ $ret=$snapshot->create_snapshot('manual',$comment);
1238
+ if($ret['result']=='success')
1239
+ {
1240
+ if($ret['finished']==1)
1241
+ {
1242
+ $ret['progress'] = '<p><span class="wpvivid-span-progress"><span class="wpvivid-span-processed-progress wpvivid-span-processed-percent-progress" style="width:100%">100% completed</span></span></p>
1243
+ <p><span class="dashicons dashicons-welcome-write-blog wpvivid-dashicons-grey"></span><span>Action:</span><span>Create snapshot completed.</span></p>';
1244
+ }
1245
+ else
1246
+ {
1247
+ $progress=$snapshot->get_progress();
1248
+ $ret['progress'] = '<p><span class="wpvivid-span-progress"><span class="wpvivid-span-processed-progress wpvivid-span-processed-percent-progress" style="width:'.$progress['main_percent'].'">'.$progress['main_percent'].' completed</span></span></p>
1249
+ <p><span class="dashicons dashicons-welcome-write-blog wpvivid-dashicons-grey"></span><span>Action:</span><span>'.$progress['doing'].'</span></p>';
1250
+ }
1251
+ }
1252
+
1253
+ echo json_encode($ret);
1254
+ die();
1255
+ }
1256
+
1257
+ public function get_snapshot_progress()
1258
+ {
1259
+ $this->ajax_check_security();
1260
+
1261
+ set_time_limit(300);
1262
+ $snapshot=new WPvivid_Snapshot_Function_Ex();
1263
+
1264
+ $progress=$snapshot->get_progress();
1265
+ $ret['progress'] = '<p><span class="wpvivid-span-progress"><span class="wpvivid-span-processed-progress wpvivid-span-processed-percent-progress" style="width:'.$progress['main_percent'].'">'.$progress['main_percent'].' completed</span></span></p>
1266
+ <p><span class="dashicons dashicons-welcome-write-blog wpvivid-dashicons-grey"></span><span>Action:</span><span>'.$progress['doing'].'</span></p>';
1267
+
1268
+ echo json_encode($ret);
1269
+ die();
1270
+ }
1271
+
1272
+ public function resume_create_snapshot()
1273
+ {
1274
+ $this->ajax_check_security();
1275
+
1276
+ set_time_limit(300);
1277
+ $snapshot=new WPvivid_Snapshot_Function_Ex();
1278
+ $ret=$snapshot->resume_create_snapshot();
1279
+
1280
+ if($ret['result']=='success')
1281
+ {
1282
+ if($ret['finished']==1)
1283
+ {
1284
+ $ret['progress'] = '<p><span class="wpvivid-span-progress"><span class="wpvivid-span-processed-progress wpvivid-span-processed-percent-progress" style="width:100%">100% completed</span></span></p>
1285
+ <p><span class="dashicons dashicons-welcome-write-blog wpvivid-dashicons-grey"></span><span>Action:</span><span>Create snapshot completed.</span></p>';
1286
+ }
1287
+ else
1288
+ {
1289
+ $progress=$snapshot->get_progress();
1290
+ $ret['progress'] = '<p><span class="wpvivid-span-progress"><span class="wpvivid-span-processed-progress wpvivid-span-processed-percent-progress" style="width:'.$progress['main_percent'].'">'.$progress['main_percent'].' completed</span></span></p>
1291
+ <p><span class="dashicons dashicons-welcome-write-blog wpvivid-dashicons-grey"></span><span>Action:</span><span>'.$progress['doing'].'</span></p>';
1292
+ }
1293
+ }
1294
+
1295
+ echo json_encode($ret);
1296
+ die();
1297
+ }
1298
+
1299
+ public function restore_snapshot()
1300
+ {
1301
+ $this->ajax_check_security();
1302
+
1303
+ if(isset($_POST['id']))
1304
+ {
1305
+ $snapshot_id=sanitize_text_field($_POST['id']);
1306
+
1307
+ set_time_limit(300);
1308
+ $snapshot=new WPvivid_Snapshot_Function_Ex();
1309
+ $ret=$snapshot->restore_snapshot($snapshot_id);
1310
+ if($ret['result']=='success')
1311
+ {
1312
+ $ret['progress'] = '<p><span class="wpvivid-span-progress"><span class="wpvivid-span-processed-progress wpvivid-span-processed-percent-progress" style="width:100%">100% completed</span></span></p>
1313
+ <p><span class="dashicons dashicons-welcome-write-blog wpvivid-dashicons-grey"></span><span>Action:</span><span>Restoring the snapshot completed.</span></p>';
1314
+ }
1315
+ echo json_encode($ret);
1316
+ }
1317
+
1318
+ die();
1319
+ }
1320
+
1321
+ public function get_restore_snapshot_status()
1322
+ {
1323
+ $this->ajax_check_security();
1324
+
1325
+ set_time_limit(300);
1326
+ $snapshot=new WPvivid_Snapshot_Function_Ex();
1327
+ $ret=$snapshot->get_restore_task_data();
1328
+
1329
+ if($ret['result']!='failed')
1330
+ {
1331
+ $finished=true;
1332
+ $i_sum=count($ret['snapshot_tables']);
1333
+ $i_finished=0;
1334
+ foreach ($ret['snapshot_tables'] as $table)
1335
+ {
1336
+ if($table['finished']==0)
1337
+ {
1338
+ $finished=false;
1339
+ }
1340
+ else
1341
+ {
1342
+ $i_finished++;
1343
+ }
1344
+ }
1345
+
1346
+ $i_progress=intval(($i_finished/$i_sum)*100);
1347
+ $progress['main_percent']=$i_progress.'%';
1348
+ $progress['doing']="Restoring the snapshot.";
1349
+ $ret['progress'] = '<p><span class="wpvivid-span-progress"><span class="wpvivid-span-processed-progress wpvivid-span-processed-percent-progress" style="width:'.$progress['main_percent'].'">'.$progress['main_percent'].' completed</span></span></p>
1350
+ <p><span class="dashicons dashicons-welcome-write-blog wpvivid-dashicons-grey"></span><span>Action:</span><span>'.$progress['doing'].'</span></p>';
1351
+
1352
+ $ret['finished']=$finished;
1353
+ }
1354
+
1355
+ echo json_encode($ret);
1356
+ die();
1357
+ }
1358
+
1359
+ public function delete_snapshot()
1360
+ {
1361
+ $this->ajax_check_security();
1362
+
1363
+ if(isset($_POST['id']))
1364
+ {
1365
+ $snapshot_id=sanitize_text_field($_POST['id']);
1366
+
1367
+ set_time_limit(300);
1368
+ $snapshot=new WPvivid_Snapshot_Function_Ex();
1369
+ $ret=$snapshot->remove_snapshot($snapshot_id);
1370
+ if($ret['result']=='success')
1371
+ {
1372
+ $snapshot_data=$snapshot->get_snapshots();
1373
+ $Snapshots_list = new WPvivid_Snapshots_List_Ex();
1374
+ $Snapshots_list->set_list($snapshot_data);
1375
+ $Snapshots_list->prepare_items();
1376
+ ob_start();
1377
+ $Snapshots_list->display();
1378
+ $html = ob_get_clean();
1379
+ $ret['html']=$html;
1380
+ }
1381
+
1382
+ echo json_encode($ret);
1383
+ }
1384
+ die();
1385
+ }
1386
+
1387
+ public function ajax_check_security($role='administrator')
1388
+ {
1389
+ check_ajax_referer( 'wpvivid_ajax', 'nonce' );
1390
+
1391
+ if(is_admin()&&current_user_can('administrator'))
1392
+ {
1393
+ return;
1394
+ }
1395
+ else
1396
+ {
1397
+ $check=is_admin()&&current_user_can($role);
1398
+ $check=apply_filters('wpvivid_ajax_check_security',$check);
1399
+ if(!$check)
1400
+ {
1401
+ die();
1402
+ }
1403
+ }
1404
+ }
1405
+
1406
+ public function check_create_snapshot($check)
1407
+ {
1408
+ return true;
1409
+ }
1410
+
1411
+ public function create_snapshot_ex($comment)
1412
+ {
1413
+ set_time_limit(300);
1414
+ $snapshot=new WPvivid_Snapshot_Function_Ex();
1415
+ $snapshot->create_snapshot('manual',$comment);
1416
+ }
1417
+
1418
+ public function set_setting()
1419
+ {
1420
+ $this->ajax_check_security('manage_options');
1421
+
1422
+ if(isset($_POST['setting'])&&!empty($_POST['setting']))
1423
+ {
1424
+ $json_setting = sanitize_text_field($_POST['setting']);
1425
+ $json_setting = stripslashes($json_setting);
1426
+ $setting = json_decode($json_setting, true);
1427
+ if (is_null($setting))
1428
+ {
1429
+ $ret['result']='failed';
1430
+ $ret['error']='json decode failed';
1431
+ echo json_encode($ret);
1432
+ die();
1433
+ }
1434
+
1435
+ $old_setting=$this->options->get_option('wpvivid_snapshot_setting');
1436
+ if(empty($setting))
1437
+ {
1438
+ $setting=array();
1439
+ }
1440
+
1441
+ if(isset($setting['snapshot_retention']))
1442
+ {
1443
+ $old_setting['snapshot_retention']=intval($setting['snapshot_retention']);
1444
+ }
1445
+
1446
+ if(isset($setting['quick_snapshot']))
1447
+ {
1448
+ $old_setting['quick_snapshot']=intval($setting['quick_snapshot']);
1449
+ }
1450
+
1451
+ $this->options->update_option('wpvivid_snapshot_setting',$old_setting);
1452
+ }
1453
+ $ret['result']='success';
1454
+ echo json_encode($ret);
1455
+ die();
1456
+ }
1457
+
1458
+ public function add_sidebar()
1459
+ {
1460
+ ?>
1461
+ <div id="postbox-container-1" class="postbox-container">
1462
+ <div class="meta-box-sortables ui-sortable">
1463
+ <div class="postbox wpvivid-sidebar">
1464
+ <h2 style="margin-top:0.5em;">
1465
+ <span class="dashicons dashicons-book-alt wpvivid-dashicons-orange" ></span>
1466
+ <span><?php esc_attr_e(
1467
+ 'Documentation', 'WpAdminStyle'
1468
+ ); ?></span></h2>
1469
+ <div class="inside" style="padding-top:0;">
1470
+ <ul class="" >
1471
+ <li>
1472
+ <span class="dashicons dashicons-camera-alt wpvivid-dashicons-grey"></span>
1473
+ <a href="https://docs.wpvivid.com/wpvivid-database-snapshots-create-database-snapshots-wordpress.html"><b><?php _e('Create Database Snapshots', 'wpvivid'); ?></b></a>
1474
+ <small><span style="float: right;"><a href="#" style="text-decoration: none;"><span class="dashicons dashicons-migrate wpvivid-dashicons-grey"></span></a></span></small><br>
1475
+ </li>
1476
+ <li>
1477
+ <span class="dashicons dashicons-camera-alt wpvivid-dashicons-grey"></span>
1478
+ <a href="https://docs.wpvivid.com/wpvivid-database-snapshots-restore-database-snapshots-wordpress.html"><b><?php _e('Restore Database Snapshots', 'wpvivid'); ?></b></a>
1479
+ <small><span style="float: right;"><a href="#" style="text-decoration: none;"><span class="dashicons dashicons-migrate wpvivid-dashicons-grey"></span></a></span></small><br>
1480
+ </li>
1481
+ </ul>
1482
+ </div>
1483
+ <h2><span class="dashicons dashicons-businesswoman wpvivid-dashicons-green"></span>
1484
+ <span><?php esc_attr_e(
1485
+ 'Support', 'WpAdminStyle'
1486
+ ); ?></span></h2>
1487
+ <div class="inside">
1488
+ <ul class="">
1489
+ <li><span class="dashicons dashicons-admin-comments wpvivid-dashicons-green"></span>
1490
+ <a href="https://wordpress.org/support/plugin/snapshot-database/"><b><?php _e('Get Support on Forum', 'wpvivid'); ?></b></a>
1491
+ <br>
1492
+ <?php _e('If you need any help with our plugin, start a thread on the plugin support forum and we will respond shortly.', 'wpvivid'); ?>
1493
+ </li>
1494
+ </ul>
1495
+
1496
+ </div>
1497
+ </div>
1498
+ </div>
1499
+ </div>
1500
+ <?php
1501
+ }
1502
+ }
includes/snapshot/class-wpvivid-snapshots-list.php ADDED
@@ -0,0 +1,360 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ if (!defined('WPVIVID_PLUGIN_DIR'))
3
+ {
4
+ die;
5
+ }
6
+
7
+ if ( ! class_exists( 'WP_List_Table' ) )
8
+ {
9
+ require_once( ABSPATH . 'wp-admin/includes/class-wp-list-table.php' );
10
+ }
11
+
12
+ if ( ! class_exists( 'WPvivid_Snapshots_List_Ex' ) )
13
+ {
14
+ class WPvivid_Snapshots_List_Ex extends WP_List_Table
15
+ {
16
+ public $page_num;
17
+ public $Snapshots_list;
18
+
19
+ public function __construct( $args = array() )
20
+ {
21
+ parent::__construct(
22
+ array(
23
+ 'plural' => 'snapshots',
24
+ 'screen' => 'snapshots'
25
+ )
26
+ );
27
+ }
28
+
29
+ protected function get_table_classes()
30
+ {
31
+ return array( 'widefat striped' );
32
+ }
33
+
34
+ public function get_columns()
35
+ {
36
+ $columns = array();
37
+ $columns['cb'] = __( 'cb', 'wpvivid-snapshot-database' );
38
+ $columns['wpvivid_time'] = __( 'Time', 'wpvivid-snapshot-database' );
39
+ $columns['wpvivid_type'] = __( 'Type', 'wpvivid-snapshot-database' );
40
+ $columns['wpvivid_prefix'] = __( 'Prefix', 'wpvivid-snapshot-database' );
41
+ $columns['wpvivid_comment'] = __( 'Comment', 'wpvivid-snapshot-database' );
42
+ $columns['wpvivid_actions'] = __( 'Actions', 'wpvivid-snapshot-database' );
43
+ return $columns;
44
+ }
45
+
46
+ public function column_cb( $data )
47
+ {
48
+ echo '<input type="checkbox"/>';
49
+ }
50
+
51
+ public function _column_wpvivid_time( $data )
52
+ {
53
+ $time = date('M-d-Y H:i', $data['time']);
54
+ echo '<td>' . esc_html( $time ) . '</td>';
55
+ }
56
+
57
+ public function _column_wpvivid_type( $data )
58
+ {
59
+ echo '<td>' . esc_html( $data['type'] ) . '</td>';
60
+ }
61
+
62
+ public function _column_wpvivid_prefix( $data )
63
+ {
64
+ echo '<td>' . esc_html( $data['id'] ) . '</td>';
65
+ }
66
+
67
+ public function _column_wpvivid_comment( $data )
68
+ {
69
+ echo '<td>' . esc_html($data['comment'] ) . '</td>';
70
+ }
71
+
72
+ public function _column_wpvivid_actions( $data )
73
+ {
74
+ echo '<td>
75
+ <div style="cursor:pointer;float:left;">
76
+ <span class="dashicons dashicons-update wpvivid-dashicons-green wpvivid-snapshot-restore"></span>
77
+ <span class="wpvivid-snapshot-restore">Restore</span>
78
+ <span style="width:1rem;">|</span>
79
+ <span class="dashicons dashicons-trash wpvivid-dashicons-grey wpvivid-snapshot-delete"></span>
80
+ <span class="wpvivid-snapshot-delete">Delete</span>
81
+ </div>
82
+ </td>';
83
+ }
84
+
85
+ public function set_list($Snapshots_list,$page_num=1)
86
+ {
87
+ $this->Snapshots_list=$Snapshots_list;
88
+ $this->page_num=$page_num;
89
+ }
90
+
91
+ public function get_pagenum()
92
+ {
93
+ if($this->page_num=='first')
94
+ {
95
+ $this->page_num=1;
96
+ }
97
+ else if($this->page_num=='last')
98
+ {
99
+ $this->page_num=$this->_pagination_args['total_pages'];
100
+ }
101
+ $pagenum = $this->page_num ? $this->page_num : 0;
102
+
103
+ if ( isset( $this->_pagination_args['total_pages'] ) && $pagenum > $this->_pagination_args['total_pages'] )
104
+ {
105
+ $pagenum = $this->_pagination_args['total_pages'];
106
+ }
107
+
108
+ return max( 1, $pagenum );
109
+ }
110
+
111
+ public function prepare_items()
112
+ {
113
+ $columns = $this->get_columns();
114
+ $hidden = array();
115
+ $sortable = array();
116
+ $this->_column_headers = array($columns, $hidden, $sortable);
117
+
118
+ $total_items =sizeof($this->Snapshots_list);
119
+
120
+ $this->set_pagination_args(
121
+ array(
122
+ 'total_items' => $total_items,
123
+ 'per_page' => 10,
124
+ )
125
+ );
126
+ }
127
+
128
+ public function has_items()
129
+ {
130
+ return !empty($this->Snapshots_list);
131
+ }
132
+
133
+ public function display_rows()
134
+ {
135
+ $this->_display_rows($this->Snapshots_list);
136
+ }
137
+
138
+ private function _display_rows($Snapshots_list)
139
+ {
140
+ $page=$this->get_pagenum();
141
+
142
+ $page_file_list=array();
143
+ $count=0;
144
+ while ( $count<$page )
145
+ {
146
+ $page_file_list = array_splice( $Snapshots_list, 0, 10);
147
+ $count++;
148
+ }
149
+ foreach ( $page_file_list as $data)
150
+ {
151
+ $this->single_row($data);
152
+ }
153
+ }
154
+
155
+ public function single_row($data)
156
+ {
157
+ ?>
158
+ <tr class='wpvivid-snapshot-row' slug="<?php echo esc_attr($data['id']);?>">
159
+ <?php $this->single_row_columns( $data ); ?>
160
+ </tr>
161
+ <?php
162
+ }
163
+
164
+ protected function pagination( $which )
165
+ {
166
+ if ( empty( $this->_pagination_args ) )
167
+ {
168
+ return;
169
+ }
170
+
171
+ $total_items = $this->_pagination_args['total_items'];
172
+ $total_pages = $this->_pagination_args['total_pages'];
173
+ $infinite_scroll = false;
174
+ if ( isset( $this->_pagination_args['infinite_scroll'] ) )
175
+ {
176
+ $infinite_scroll = $this->_pagination_args['infinite_scroll'];
177
+ }
178
+
179
+ if ( 'top' === $which && $total_pages > 1 )
180
+ {
181
+ $this->screen->render_screen_reader_content( 'heading_pagination' );
182
+ }
183
+
184
+ $output = '<span class="displaying-num">' . sprintf( _n( '%s item', '%s items', $total_items ), number_format_i18n( $total_items ) ) . '</span>';
185
+
186
+ $current = $this->get_pagenum();
187
+
188
+ $page_links = array();
189
+
190
+ $total_pages_before = '<span class="paging-input">';
191
+ $total_pages_after = '</span></span>';
192
+
193
+ $disable_first = $disable_last = $disable_prev = $disable_next = false;
194
+
195
+ if ( $current == 1 ) {
196
+ $disable_first = true;
197
+ $disable_prev = true;
198
+ }
199
+ if ( $current == 2 ) {
200
+ $disable_first = true;
201
+ }
202
+ if ( $current == $total_pages ) {
203
+ $disable_last = true;
204
+ $disable_next = true;
205
+ }
206
+ if ( $current == $total_pages - 1 ) {
207
+ $disable_last = true;
208
+ }
209
+
210
+ if ( $disable_first ) {
211
+ $page_links[] = '<span class="tablenav-pages-navspan button disabled" aria-hidden="true">&laquo;</span>';
212
+ } else {
213
+ $page_links[] = sprintf(
214
+ "<div class='first-page button'><span class='screen-reader-text'>%s</span><span aria-hidden='true'>%s</span></div>",
215
+ __( 'First page' ),
216
+ '&laquo;'
217
+ );
218
+ }
219
+
220
+ if ( $disable_prev ) {
221
+ $page_links[] = '<span class="tablenav-pages-navspan button disabled" aria-hidden="true">&lsaquo;</span>';
222
+ } else {
223
+ $page_links[] = sprintf(
224
+ "<div class='prev-page button' value='%s'><span class='screen-reader-text'>%s</span><span aria-hidden='true'>%s</span></div>",
225
+ $current,
226
+ __( 'Previous page' ),
227
+ '&lsaquo;'
228
+ );
229
+ }
230
+
231
+ if ( 'bottom' === $which ) {
232
+ $html_current_page = $current;
233
+ $total_pages_before = '<span class="screen-reader-text">' . __( 'Current Page' ) . '</span><span id="table-paging" class="paging-input"><span class="tablenav-paging-text">';
234
+ } else {
235
+ $html_current_page = sprintf(
236
+ "%s<input class='current-page' id='current-page-selector-filelist' type='text' name='paged' value='%s' size='%d' aria-describedby='table-paging' /><span class='tablenav-paging-text'>",
237
+ '<label for="current-page-selector-filelist" class="screen-reader-text">' . __( 'Current Page' ) . '</label>',
238
+ $current,
239
+ strlen( $total_pages )
240
+ );
241
+ }
242
+ $html_total_pages = sprintf( "<span class='total-pages'>%s</span>", number_format_i18n( $total_pages ) );
243
+ $page_links[] = $total_pages_before . sprintf( _x( '%1$s of %2$s', 'paging' ), $html_current_page, $html_total_pages ) . $total_pages_after;
244
+
245
+ if ( $disable_next ) {
246
+ $page_links[] = '<span class="tablenav-pages-navspan button disabled" aria-hidden="true">&rsaquo;</span>';
247
+ } else {
248
+ $page_links[] = sprintf(
249
+ "<div class='next-page button' value='%s'><span class='screen-reader-text'>%s</span><span aria-hidden='true'>%s</span></div>",
250
+ $current,
251
+ __( 'Next page' ),
252
+ '&rsaquo;'
253
+ );
254
+ }
255
+
256
+ if ( $disable_last ) {
257
+ $page_links[] = '<span class="tablenav-pages-navspan button disabled" aria-hidden="true">&raquo;</span>';
258
+ } else {
259
+ $page_links[] = sprintf(
260
+ "<div class='last-page button'><span class='screen-reader-text'>%s</span><span aria-hidden='true'>%s</span></div>",
261
+ __( 'Last page' ),
262
+ '&raquo;'
263
+ );
264
+ }
265
+
266
+ $pagination_links_class = 'pagination-links';
267
+ if ( ! empty( $infinite_scroll ) ) {
268
+ $pagination_links_class .= ' hide-if-js';
269
+ }
270
+ $output .= "\n<span class='$pagination_links_class'>" . join( "\n", $page_links ) . '</span>';
271
+
272
+ if ( $total_pages ) {
273
+ $page_class = $total_pages < 2 ? ' one-page' : '';
274
+ } else {
275
+ $page_class = ' no-pages';
276
+ }
277
+ $this->_pagination = "<div class='tablenav-pages{$page_class}'>$output</div>";
278
+
279
+ echo $this->_pagination;
280
+ }
281
+
282
+ protected function display_tablenav( $which ) {
283
+ $css_type = '';
284
+ if ( 'top' === $which ) {
285
+ wp_nonce_field( 'bulk-' . $this->_args['plural'] );
286
+ $css_type = 'margin: 0 0 10px 0';
287
+ }
288
+ else if( 'bottom' === $which ) {
289
+ $css_type = 'margin: 10px 0 0 0';
290
+ }
291
+
292
+ $total_pages = $this->_pagination_args['total_pages'];
293
+ if ( $total_pages >1 && 'top' === $which)
294
+ {
295
+ ?>
296
+ <div class="tablenav <?php echo esc_attr( $which ); ?>" style="<?php esc_attr_e($css_type); ?>">
297
+ <input type="submit" id="wpvivid_delete_snapshots_action" class="button action" value="Delete the selected snapshots">
298
+ <?php
299
+ $this->extra_tablenav( $which );
300
+ $this->pagination( $which );
301
+ ?>
302
+
303
+ <br class="clear" />
304
+ </div>
305
+ <?php
306
+ }
307
+ else if($total_pages >1)
308
+ {
309
+ ?>
310
+ <div class="tablenav <?php echo esc_attr( $which ); ?>" style="<?php esc_attr_e($css_type); ?>">
311
+ <?php
312
+ $this->extra_tablenav( $which );
313
+ $this->pagination( $which );
314
+ ?>
315
+
316
+ <br class="clear" />
317
+ </div>
318
+ <?php
319
+ }
320
+ else if($total_pages <=1 && 'top' === $which)
321
+ {
322
+ ?>
323
+ <input type="submit" id="wpvivid_delete_snapshots_action" class="button action" value="Delete the selected snapshots">
324
+ <p></p>
325
+ <?php
326
+ }
327
+ }
328
+
329
+ public function display()
330
+ {
331
+ $singular = $this->_args['singular'];
332
+
333
+ $this->display_tablenav( 'top' );
334
+
335
+ $this->screen->render_screen_reader_content( 'heading_list' );
336
+ ?>
337
+ <table class="wp-list-table <?php echo implode( ' ', $this->get_table_classes() ); ?>">
338
+ <thead>
339
+ <tr>
340
+ <?php $this->print_column_headers(); ?>
341
+ </tr>
342
+ </thead>
343
+
344
+ <tbody id="the-list"
345
+ <?php
346
+ if ( $singular ) {
347
+ echo esc_attr(" data-wp-lists='list:$singular'");
348
+ }
349
+ ?>
350
+ >
351
+ <?php $this->display_rows_or_placeholder(); ?>
352
+ </tbody>
353
+
354
+ </table>
355
+ <?php
356
+ $this->display_tablenav( 'bottom' );
357
+ }
358
+ }
359
+ }
360
+
includes/snapshot/class-wpvivid-tab-page-container-ex.php ADDED
@@ -0,0 +1,273 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if (!defined('WPVIVID_PLUGIN_DIR'))
4
+ {
5
+ die;
6
+ }
7
+
8
+ if(!class_exists('WPvivid_Tab_Page_Container'))
9
+ {
10
+ include_once WPVIVID_PLUGIN_DIR . '/includes/class-wpvivid-tab-page-container.php';
11
+ }
12
+
13
+ class WPvivid_Tab_Page_Container_Ex extends WPvivid_Tab_Page_Container
14
+ {
15
+ public $is_transparency=0;
16
+
17
+ public function add_tab($title,$slug,$callback,$args=array())
18
+ {
19
+ $new_tab['title']=$title;
20
+ $new_tab['slug']=$slug;
21
+ $new_tab['page']=$callback;
22
+ foreach ($args as $key=>$arg)
23
+ {
24
+ $new_tab[$key]=$arg;
25
+ if($key === 'is_parent_tab') {
26
+ $this->is_parent_tab = $arg;
27
+ }
28
+ if($key === 'transparency'){
29
+ $this->is_transparency = $arg;
30
+ }
31
+ }
32
+
33
+ $this->tabs[]=$new_tab;
34
+ }
35
+
36
+ public function display()
37
+ {
38
+ $class = '';
39
+ if($this->is_transparency){
40
+ $class .= ' wpvivid-intab-addon';
41
+ }
42
+ ?>
43
+ <div class="wpvivid-one-coloum" id="<?php echo esc_attr($this->container_id); ?>">
44
+ <h2 class="nav-tab-wrapper wpvivid-nav-tab-wrapper">
45
+ <?php
46
+ $this->display_tabs();
47
+ ?>
48
+ </h2>
49
+ </div>
50
+ <?php
51
+ if($this->is_parent_tab){
52
+ ?>
53
+ <div style="margin: 10px 0 0 2px;">
54
+ <div id="poststuff" style="padding-top: 0;">
55
+ <div id="post-body" class="metabox-holder columns-2">
56
+ <div id="post-body-content">
57
+ <div class="inside" style="margin-top:0;">
58
+ <div>
59
+ <?php
60
+ $this->display_page();
61
+ ?>
62
+ </div>
63
+ </div>
64
+ </div>
65
+ <div id="postbox-container-1" class="postbox-container">
66
+ <div class="meta-box-sortables">
67
+ </div>
68
+ </div>
69
+ </div>
70
+ <br class="clear">
71
+ </div>
72
+ </div>
73
+ <?php
74
+ }
75
+ else{
76
+ ?>
77
+ <?php
78
+ $this->display_page();
79
+ ?>
80
+ <?php
81
+ }
82
+ ?>
83
+
84
+ <script>
85
+ jQuery('#<?php echo esc_js($this->container_id)?>').on("click",".<?php echo esc_js($this->container_id)?>-tab",function()
86
+ {
87
+ jQuery('#<?php echo esc_js($this->container_id)?>').find( '.<?php echo esc_js($this->container_id)?>-tab' ).each(function()
88
+ {
89
+ jQuery(this).removeClass( "nav-tab-active wpvivid-nav-tab-active" );
90
+ });
91
+
92
+ jQuery('.<?php echo esc_js($this->container_id)?>-content').each(function()
93
+ {
94
+ jQuery(this).hide();
95
+ });
96
+
97
+ var id=jQuery(this).attr('id');
98
+ id= id.substr(12);
99
+
100
+ jQuery("#wpvivid_page_"+id).show();
101
+ jQuery(this).addClass( "nav-tab-active wpvivid-nav-tab-active" );
102
+ var top = jQuery(this).offset().top-jQuery(this).height();
103
+ jQuery('html, body').animate({scrollTop:top}, 'slow');
104
+ });
105
+
106
+ jQuery('#<?php echo esc_js($this->container_id)?>').on("click",".nav-tab-delete-img-addon",function(event)
107
+ {
108
+ event.stopPropagation();
109
+ var redirect=jQuery(this).attr('redirect');
110
+ jQuery(this).parent().hide();
111
+
112
+ jQuery('#<?php echo esc_js($this->container_id)?>').find( '.<?php echo esc_js($this->container_id)?>-tab' ).each(function()
113
+ {
114
+ jQuery(this).removeClass( "nav-tab-active wpvivid-nav-tab-active" );
115
+ });
116
+
117
+ jQuery('.<?php echo esc_js($this->container_id)?>-content').each(function()
118
+ {
119
+ jQuery(this).hide();
120
+ });
121
+
122
+ jQuery("#wpvivid_page_"+redirect).show();
123
+ jQuery("#wpvivid_tab_"+redirect).addClass( "nav-tab-active wpvivid-nav-tab-active" );
124
+ //jQuery(this).addClass( "nav-tab-active wpvivid-nav-tab-active" );
125
+ });
126
+
127
+ jQuery(document).ready(function($)
128
+ {
129
+ jQuery(document).on('<?php echo esc_js($this->container_id)?>-show', function(event,id,redirect)
130
+ {
131
+ jQuery('#<?php echo esc_js($this->container_id)?>').find( '.<?php echo esc_js($this->container_id)?>-tab' ).each(function()
132
+ {
133
+ jQuery(this).removeClass( "nav-tab-active wpvivid-nav-tab-active" );
134
+ });
135
+
136
+ jQuery('.<?php echo esc_js($this->container_id); ?>-content').each(function()
137
+ {
138
+ jQuery(this).hide();
139
+ });
140
+
141
+ jQuery("#wpvivid_page_"+id).show();
142
+ jQuery("#wpvivid_tab_"+id).show();
143
+ jQuery("#wpvivid_tab_"+id).find( '.nav-tab-delete-img-addon' ).each(function()
144
+ {
145
+ jQuery(this).attr('redirect',redirect);
146
+ });
147
+ jQuery("#wpvivid_tab_"+id).addClass( "nav-tab-active wpvivid-nav-tab-active" );
148
+ var top = jQuery("#wpvivid_tab_"+id).offset().top-jQuery("#wpvivid_tab_"+id).height();
149
+ jQuery('html, body').animate({scrollTop:top}, 'slow');
150
+ });
151
+
152
+ jQuery(document).on('<?php echo esc_js($this->container_id)?>-delete', function(event,id,redirect)
153
+ {
154
+ jQuery('#<?php echo esc_js($this->container_id)?>').find( '.<?php echo esc_js($this->container_id)?>-tab' ).each(function()
155
+ {
156
+ jQuery(this).removeClass( "nav-tab-active wpvivid-nav-tab-active" );
157
+ });
158
+
159
+ jQuery('#<?php echo esc_js($this->container_id)?>').find( '.<?php echo esc_js($this->container_id)?>-content' ).each(function()
160
+ {
161
+ jQuery(this).hide();
162
+ });
163
+
164
+ jQuery("#wpvivid_page_"+id).hide();
165
+ jQuery("#wpvivid_tab_"+id).hide();
166
+ jQuery("#wpvivid_page_"+redirect).show();
167
+ jQuery("#wpvivid_tab_"+redirect).addClass( "nav-tab-active wpvivid-nav-tab-active" );
168
+ });
169
+ });
170
+ </script>
171
+ <?php
172
+ }
173
+
174
+ public function display_tabs()
175
+ {
176
+ $first=true;
177
+
178
+ foreach ($this->tabs as $tab)
179
+ {
180
+ $class='nav-tab wpvivid-nav-tab '.$this->container_id.'-tab';
181
+ $span_class='';
182
+ $span_style='';
183
+ if($first)
184
+ {
185
+ $class.=' nav-tab-active wpvivid-nav-tab-active';
186
+ $first=false;
187
+ }
188
+
189
+ $style='cursor:pointer;';
190
+
191
+ if(isset($tab['hide']))
192
+ {
193
+ $style.=' display: none';
194
+ }
195
+
196
+ if(isset($tab['span_class']))
197
+ {
198
+ $span_class.=$tab['span_class'];
199
+ }
200
+ if(isset($tab['span_style']))
201
+ {
202
+ $span_style.=$tab['span_style'];
203
+ }
204
+ if(isset($tab['can_delete']))
205
+ {
206
+ $class.=' delete';
207
+ }
208
+ if(isset($tab['transparency']))
209
+ {
210
+ $class.=' wpvivid-transparency-tab';
211
+ }
212
+
213
+ echo '<a id="wpvivid_tab_'.esc_attr($tab['slug']).'" class="'.esc_attr($class).'" style="'.esc_attr($style).'">';
214
+
215
+ if(isset($tab['can_delete']))
216
+ {
217
+ echo '<span class="'.esc_attr($span_class).'" style="'.esc_attr($span_style).'"></span><span style="padding-right: 1em;">'.esc_attr($tab['title']).'</span>';
218
+ if(isset($tab['redirect']))
219
+ {
220
+ echo '<div class="nav-tab-delete-img-addon" redirect="'.esc_attr($tab['redirect']).'">
221
+ <span class="dashicons dashicons-no-alt wpvivid-dashicons-grey" style="width: 15px; height: 15px; font-size: 15px; padding-top: 0.4em;">
222
+ </div>';
223
+ }
224
+ else
225
+ {
226
+ echo '<div class="nav-tab-delete-img-addon">
227
+ <span class="dashicons dashicons-no-alt wpvivid-dashicons-grey" style="width: 15px; height: 15px; font-size: 15px; padding-top: 0.4em;">
228
+ </div>';
229
+ }
230
+ }
231
+ else
232
+ {
233
+ echo '<span class="'.esc_attr($span_class).'" style="'.esc_attr($span_style).'"></span><span>'.esc_attr($tab['title']).'</span>';
234
+ }
235
+ echo '</a>';
236
+ }
237
+ }
238
+
239
+ public function display_page()
240
+ {
241
+ $first=true;
242
+ foreach ($this->tabs as $tab)
243
+ {
244
+ //delete
245
+ /*$style='display: none;';
246
+ if($first)
247
+ {
248
+ if(isset($tab['hide']))
249
+ {
250
+
251
+ }
252
+ else
253
+ {
254
+ $style='';
255
+ $first=false;
256
+ }
257
+ }*/
258
+ if(isset($tab['div_style']))
259
+ {
260
+ $style = $tab['div_style'];
261
+ }
262
+ else{
263
+ $style='display: none;';
264
+ }
265
+
266
+ $class='wpvivid-one-coloum wpvivid-tabcontent ';
267
+ $class.=$this->container_id.'-content';
268
+ echo '<div id="wpvivid_page_'.esc_attr($tab['slug']).'" class="'.esc_attr($class).'" style="'.esc_attr($style).'">';
269
+ call_user_func($tab['page']);
270
+ echo '</div>';
271
+ }
272
+ }
273
+ }
includes/staging/class-wpvivid-staging.php CHANGED
@@ -256,7 +256,7 @@ class WPvivid_Staging_Free
256
  $menu['tab']= 'admin.php?page='.apply_filters('wpvivid_white_label_plugin_name', 'wpvivid-staging');
257
  $menu['href']=$admin_url . 'admin.php?page='.apply_filters('wpvivid_white_label_plugin_name', 'wpvivid-staging');
258
  $menu['capability']='administrator';
259
- $menu['index']=2;
260
  $toolbar_menus[$menu['parent']]['child'][$menu['id']]=$menu;
261
  return $toolbar_menus;
262
  }
@@ -268,7 +268,7 @@ class WPvivid_Staging_Free
268
  $submenu['menu_title']=__('Staging', 'wpvivid-backuprestore');
269
  $submenu['capability']='administrator';
270
  $submenu['menu_slug']=strtolower(sprintf('%s-staging', apply_filters('wpvivid_white_label_slug', 'wpvivid')));
271
- $submenu['index']=2;
272
  $submenu['function']=array($this, 'display_plugin_setup_page');
273
  $submenus[$submenu['menu_slug']]=$submenu;
274
  return $submenus;
@@ -2382,8 +2382,8 @@ class WPvivid_Staging_Free
2382
 
2383
 
2384
  $task = new WPvivid_Staging_Task();
2385
- $task->set_memory_limit();
2386
  $task->setup_task($option);
 
2387
  $task->update_action_time('create_time');
2388
  $this->log->CreateLogFile($task->get_log_file_name(), 'no_folder', 'staging');
2389
  $this->log->WriteLog('Start creating staging site.', 'notice');
256
  $menu['tab']= 'admin.php?page='.apply_filters('wpvivid_white_label_plugin_name', 'wpvivid-staging');
257
  $menu['href']=$admin_url . 'admin.php?page='.apply_filters('wpvivid_white_label_plugin_name', 'wpvivid-staging');
258
  $menu['capability']='administrator';
259
+ $menu['index']=3;
260
  $toolbar_menus[$menu['parent']]['child'][$menu['id']]=$menu;
261
  return $toolbar_menus;
262
  }
268
  $submenu['menu_title']=__('Staging', 'wpvivid-backuprestore');
269
  $submenu['capability']='administrator';
270
  $submenu['menu_slug']=strtolower(sprintf('%s-staging', apply_filters('wpvivid_white_label_slug', 'wpvivid')));
271
+ $submenu['index']=3;
272
  $submenu['function']=array($this, 'display_plugin_setup_page');
273
  $submenus[$submenu['menu_slug']]=$submenu;
274
  return $submenus;
2382
 
2383
 
2384
  $task = new WPvivid_Staging_Task();
 
2385
  $task->setup_task($option);
2386
+ $task->set_memory_limit();
2387
  $task->update_action_time('create_time');
2388
  $this->log->CreateLogFile($task->get_log_file_name(), 'no_folder', 'staging');
2389
  $this->log->WriteLog('Start creating staging site.', 'notice');
includes/upload-cleaner/class-wpvivid-uploads-scanner.php CHANGED
@@ -909,6 +909,22 @@ class WPvivid_Uploads_Scanner
909
  }
910
 
911
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
912
  }
913
 
914
  return $files;
909
  }
910
 
911
  }
912
+
913
+ if(isset($custom_fields['picture']))
914
+ {
915
+ if ( is_string( $custom_fields['picture'] ) && ! empty( $custom_fields['picture'] ) )
916
+ {
917
+ $id=$custom_fields['picture'];
918
+ $files=array_merge($files,$this->get_img_from_id($id));
919
+ }
920
+ else if(is_array( $custom_fields['picture'] )&& ! empty( $custom_fields['picture'] ))
921
+ {
922
+ foreach ($custom_fields['picture'] as $id)
923
+ {
924
+ $files=array_merge($files,$this->get_img_from_id($id));
925
+ }
926
+ }
927
+ }
928
  }
929
 
930
  return $files;
readme.txt CHANGED
@@ -2,21 +2,23 @@
2
  Contributors: wpvivid
3
  Tags: move, clone, migrate, staging, backup, restore, auto backup, cloud backup
4
  Requires at least: 4.5
5
- Tested up to: 6.0.1
6
  Requires PHP: 5.3
7
- Stable tag: 0.9.77
8
  License: GPLv3 or later
9
  License URI: https://www.gnu.org/licenses/gpl-3.0.en.html
10
 
11
- Migrate, staging, backup WP.
12
 
13
  == Description ==
14
- WPvivid Backup Plugin offers backup, migration, and staging as basic features, and is integrating more and more elegant features, such as unused images cleaner etc.
15
 
16
  Create a staging site on a subdirectory to safely test WordPress, plugins, themes and website changes.
17
 
18
  Clone and migrate a copy of WP site to a new host (a new domain), schedule backups, send backups to leading remote storage, clean unused images before backup and migration. All in one backup & migration plugin.
19
 
 
 
20
  == WPvivid Backup for MainWP ==
21
  [WPvivid Backup for MainWP](https://wpvivid.com/wpvivid-backup-for-mainwp) is now available to download.
22
  This extension allows you to set up and control WPvivid Backup Free and Pro for all child sites directly from your MainWP dashboard.
@@ -86,6 +88,7 @@ The pro version also supports Wasabi, pCloud, Backblaze and more are coming soon
86
  * Create A Staging Site
87
  * Upload Backups to Restore or Migrate
88
  * Unused Images Cleaner
 
89
  * Schedule Automated Backups
90
  * Restore A Backup with One Click
91
  * Create A Manual Backup
@@ -198,6 +201,11 @@ Thank you so much for translating WPvivid Backup Plugin to your languages!
198
  * [Yordan Soares](https://profiles.wordpress.org/yordansoares/) (Spanish(all locales))
199
  * [Chun-Chih Cheng](https://www.facebook.com/groups/wordpresstwhant) (Chinese (Taiwan))
200
  == Changelog ==
 
 
 
 
 
201
  = 0.9.77 =
202
  - Updated: Transferred files will be deleted automatically when auto migration fails.
203
  - Fixed a vulnerability in the plugin code.
2
  Contributors: wpvivid
3
  Tags: move, clone, migrate, staging, backup, restore, auto backup, cloud backup
4
  Requires at least: 4.5
5
+ Tested up to: 6.0.2
6
  Requires PHP: 5.3
7
+ Stable tag: 0.9.78
8
  License: GPLv3 or later
9
  License URI: https://www.gnu.org/licenses/gpl-3.0.en.html
10
 
11
+ Migrate, staging, backup WP and database snapshots.
12
 
13
  == Description ==
14
+ WPvivid Backup Plugin offers backup, migration, and staging as basic features, and is integrating more and more elegant features, such as unused images cleaner, database snapshots etc.
15
 
16
  Create a staging site on a subdirectory to safely test WordPress, plugins, themes and website changes.
17
 
18
  Clone and migrate a copy of WP site to a new host (a new domain), schedule backups, send backups to leading remote storage, clean unused images before backup and migration. All in one backup & migration plugin.
19
 
20
+ Create a snapshot for a WordPress database quickly before testing database related changes.
21
+
22
  == WPvivid Backup for MainWP ==
23
  [WPvivid Backup for MainWP](https://wpvivid.com/wpvivid-backup-for-mainwp) is now available to download.
24
  This extension allows you to set up and control WPvivid Backup Free and Pro for all child sites directly from your MainWP dashboard.
88
  * Create A Staging Site
89
  * Upload Backups to Restore or Migrate
90
  * Unused Images Cleaner
91
+ * Database Snapshots
92
  * Schedule Automated Backups
93
  * Restore A Backup with One Click
94
  * Create A Manual Backup
201
  * [Yordan Soares](https://profiles.wordpress.org/yordansoares/) (Spanish(all locales))
202
  * [Chun-Chih Cheng](https://www.facebook.com/groups/wordpresstwhant) (Chinese (Taiwan))
203
  == Changelog ==
204
+ = 0.9.78 =
205
+ - Added an option to create quick database snapshots.
206
+ - Added a check for siteurl and home in a restore process.
207
+ - Fixed: Some used images were falsely scanned as unused.
208
+ - Fixed some bugs in the plugin code and optimized the plugin code.
209
  = 0.9.77 =
210
  - Updated: Transferred files will be deleted automatically when auto migration fails.
211
  - Fixed a vulnerability in the plugin code.
wpvivid-backuprestore.php CHANGED
@@ -7,7 +7,7 @@
7
  * @wordpress-plugin
8
  * Plugin Name: WPvivid Backup Plugin
9
  * Description: Clone or copy WP sites then move or migrate them to new host (new domain), schedule backups, transfer backups to leading remote storage. All in one.
10
- * Version: 0.9.77
11
  * Author: WPvivid Team
12
  * Author URI: https://wpvivid.com
13
  * License: GPL-3.0+
@@ -21,7 +21,7 @@ if ( ! defined( 'WPINC' ) ) {
21
  die;
22
  }
23
 
24
- define( 'WPVIVID_PLUGIN_VERSION', '0.9.77' );
25
  //
26
  define('WPVIVID_RESTORE_INIT','init');
27
  define('WPVIVID_RESTORE_READY','ready');
7
  * @wordpress-plugin
8
  * Plugin Name: WPvivid Backup Plugin
9
  * Description: Clone or copy WP sites then move or migrate them to new host (new domain), schedule backups, transfer backups to leading remote storage. All in one.
10
+ * Version: 0.9.78
11
  * Author: WPvivid Team
12
  * Author URI: https://wpvivid.com
13
  * License: GPL-3.0+
21
  die;
22
  }
23
 
24
+ define( 'WPVIVID_PLUGIN_VERSION', '0.9.78' );
25
  //
26
  define('WPVIVID_RESTORE_INIT','init');
27
  define('WPVIVID_RESTORE_READY','ready');