Version Description
- FIXED: Invalid plugin head 'This plugin has an invalid header.'
Download this release
Release Info
Developer | GamerZ |
Plugin | WP-Sweep |
Version | 1.0.10 |
Comparing to | |
See all releases |
Code changes from version 1.0.7 to 1.0.10
- admin.php +524 -518
- class-command.php +106 -0
- index.php +1 -1
- js/wp-sweep.js +79 -79
- readme.txt +19 -6
- uninstall.php +11 -6
- wp-sweep.php +919 -863
admin.php
CHANGED
@@ -1,19 +1,22 @@
|
|
1 |
<?php
|
2 |
-
### Exit if accessed directly
|
3 |
-
if ( ! defined( 'ABSPATH' ) ) exit;
|
4 |
|
5 |
-
|
|
|
|
|
|
|
|
|
|
|
6 |
$current_page = admin_url( 'tools.php?page=' . plugin_basename( 'wp-sweep/admin.php' ) );
|
7 |
$message = '';
|
8 |
|
9 |
-
|
10 |
-
if( ! empty( $_GET['sweep'] ) ) {
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
}
|
15 |
|
16 |
-
|
17 |
$total_posts = WPSweep::get_instance()->total_count( 'posts' );
|
18 |
$total_postmeta = WPSweep::get_instance()->total_count( 'postmeta' );
|
19 |
$total_comments = WPSweep::get_instance()->total_count( 'comments' );
|
@@ -27,7 +30,7 @@ $total_termmeta = WPSweep::get_instance()->total_count( 'termmeta' )
|
|
27 |
$total_options = WPSweep::get_instance()->total_count( 'options' );
|
28 |
$total_tables = WPSweep::get_instance()->total_count( 'tables' );
|
29 |
|
30 |
-
|
31 |
$revisions = WPSweep::get_instance()->count( 'revisions' );
|
32 |
$auto_drafts = WPSweep::get_instance()->count( 'auto_drafts' );
|
33 |
$deleted_posts = WPSweep::get_instance()->count( 'deleted_posts' );
|
@@ -37,7 +40,7 @@ $oembed_postmeta = WPSweep::get_instance()->count( 'oembed_postmeta'
|
|
37 |
|
38 |
$unapproved_comments = WPSweep::get_instance()->count( 'unapproved_comments' );
|
39 |
$spam_comments = WPSweep::get_instance()->count( 'spam_comments' );
|
40 |
-
$deleted_comments = WPSweep::get_instance()->count( 'deleted_comments' )
|
41 |
$orphan_commentmeta = WPSweep::get_instance()->count( 'orphan_commentmeta' );
|
42 |
$duplicated_commentmeta = WPSweep::get_instance()->count( 'duplicated_commentmeta' );
|
43 |
|
@@ -50,514 +53,517 @@ $orphan_termmeta = WPSweep::get_instance()->count( 'orphan_termmeta'
|
|
50 |
$duplicated_termmeta = WPSweep::get_instance()->count( 'duplicated_termmeta' );
|
51 |
|
52 |
$transient_options = WPSweep::get_instance()->count( 'transient_options' );
|
|
|
53 |
?>
|
54 |
<style type="text/css">
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
</style>
|
65 |
<div class="wrap">
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
|
198 |
-
|
199 |
-
|
200 |
-
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
-
|
205 |
-
|
206 |
-
|
207 |
-
|
208 |
-
|
209 |
-
|
210 |
-
|
211 |
-
|
212 |
-
|
213 |
-
|
214 |
-
|
215 |
-
|
216 |
-
|
217 |
-
|
218 |
-
|
219 |
-
|
220 |
-
|
221 |
-
|
222 |
-
|
223 |
-
|
224 |
-
|
225 |
-
|
226 |
-
|
227 |
-
|
228 |
-
|
229 |
-
|
230 |
-
|
231 |
-
|
232 |
-
|
233 |
-
|
234 |
-
|
235 |
-
|
236 |
-
|
237 |
-
|
238 |
-
|
239 |
-
|
240 |
-
|
241 |
-
|
242 |
-
|
243 |
-
|
244 |
-
|
245 |
-
|
246 |
-
|
247 |
-
|
248 |
-
|
249 |
-
|
250 |
-
|
251 |
-
|
252 |
-
|
253 |
-
|
254 |
-
|
255 |
-
|
256 |
-
|
257 |
-
|
258 |
-
|
259 |
-
|
260 |
-
|
261 |
-
|
262 |
-
|
263 |
-
|
264 |
-
|
265 |
-
|
266 |
-
|
267 |
-
|
268 |
-
|
269 |
-
|
270 |
-
|
271 |
-
|
272 |
-
|
273 |
-
|
274 |
-
|
275 |
-
|
276 |
-
|
277 |
-
|
278 |
-
|
279 |
-
|
280 |
-
|
281 |
-
|
282 |
-
|
283 |
-
|
284 |
-
|
285 |
-
|
286 |
-
|
287 |
-
|
288 |
-
|
289 |
-
|
290 |
-
|
291 |
-
|
292 |
-
|
293 |
-
|
294 |
-
|
295 |
-
|
296 |
-
|
297 |
-
|
298 |
-
|
299 |
-
|
300 |
-
|
301 |
-
|
302 |
-
|
303 |
-
|
304 |
-
|
305 |
-
|
306 |
-
|
307 |
-
|
308 |
-
|
309 |
-
|
310 |
-
|
311 |
-
|
312 |
-
|
313 |
-
|
314 |
-
|
315 |
-
|
316 |
-
|
317 |
-
|
318 |
-
|
319 |
-
|
320 |
-
|
321 |
-
|
322 |
-
|
323 |
-
|
324 |
-
|
325 |
-
|
326 |
-
|
327 |
-
|
328 |
-
|
329 |
-
|
330 |
-
|
331 |
-
|
332 |
-
|
333 |
-
|
334 |
-
|
335 |
-
|
336 |
-
|
337 |
-
|
338 |
-
|
339 |
-
|
340 |
-
|
341 |
-
|
342 |
-
|
343 |
-
|
344 |
-
|
345 |
-
|
346 |
-
|
347 |
-
|
348 |
-
|
349 |
-
|
350 |
-
|
351 |
-
|
352 |
-
|
353 |
-
|
354 |
-
|
355 |
-
|
356 |
-
|
357 |
-
|
358 |
-
|
359 |
-
|
360 |
-
|
361 |
-
|
362 |
-
|
363 |
-
|
364 |
-
|
365 |
-
|
366 |
-
|
367 |
-
|
368 |
-
|
369 |
-
|
370 |
-
|
371 |
-
|
372 |
-
|
373 |
-
|
374 |
-
|
375 |
-
|
376 |
-
|
377 |
-
|
378 |
-
|
379 |
-
|
380 |
-
|
381 |
-
|
382 |
-
|
383 |
-
|
384 |
-
|
385 |
-
|
386 |
-
|
387 |
-
|
388 |
-
|
389 |
-
|
390 |
-
|
391 |
-
|
392 |
-
|
393 |
-
|
394 |
-
|
395 |
-
|
396 |
-
|
397 |
-
|
398 |
-
|
399 |
-
|
400 |
-
|
401 |
-
|
402 |
-
|
403 |
-
|
404 |
-
|
405 |
-
|
406 |
-
|
407 |
-
|
408 |
-
|
409 |
-
|
410 |
-
|
411 |
-
|
412 |
-
|
413 |
-
|
414 |
-
|
415 |
-
|
416 |
-
|
417 |
-
|
418 |
-
|
419 |
-
|
420 |
-
|
421 |
-
|
422 |
-
|
423 |
-
|
424 |
-
|
425 |
-
|
426 |
-
|
427 |
-
|
428 |
-
|
429 |
-
|
430 |
-
|
431 |
-
|
432 |
-
|
433 |
-
|
434 |
-
|
435 |
-
|
436 |
-
|
437 |
-
|
438 |
-
|
439 |
-
|
440 |
-
|
441 |
-
|
442 |
-
|
443 |
-
|
444 |
-
|
445 |
-
|
446 |
-
|
447 |
-
|
448 |
-
|
449 |
-
|
450 |
-
|
451 |
-
|
452 |
-
|
453 |
-
|
454 |
-
|
455 |
-
|
456 |
-
|
457 |
-
|
458 |
-
|
459 |
-
|
460 |
-
|
461 |
-
|
462 |
-
|
463 |
-
|
464 |
-
|
465 |
-
|
466 |
-
|
467 |
-
|
468 |
-
|
469 |
-
|
470 |
-
|
471 |
-
|
472 |
-
|
473 |
-
|
474 |
-
|
475 |
-
|
476 |
-
|
477 |
-
|
478 |
-
|
479 |
-
|
480 |
-
|
481 |
-
|
482 |
-
|
483 |
-
|
484 |
-
|
485 |
-
|
486 |
-
|
487 |
-
|
488 |
-
|
489 |
-
|
490 |
-
|
491 |
-
|
492 |
-
|
493 |
-
|
494 |
-
|
495 |
-
|
496 |
-
|
497 |
-
|
498 |
-
|
499 |
-
|
500 |
-
|
501 |
-
|
502 |
-
|
503 |
-
|
504 |
-
|
505 |
-
|
506 |
-
|
507 |
-
|
508 |
-
|
509 |
-
|
510 |
-
|
511 |
-
|
512 |
-
|
513 |
-
|
514 |
-
|
515 |
-
|
516 |
-
|
517 |
-
|
518 |
-
|
519 |
-
|
520 |
-
|
521 |
-
|
522 |
-
|
523 |
-
|
524 |
-
|
525 |
-
|
526 |
-
|
527 |
-
|
528 |
-
|
529 |
-
|
530 |
-
|
531 |
-
|
532 |
-
|
533 |
-
|
534 |
-
|
535 |
-
|
536 |
-
|
537 |
-
|
538 |
-
|
539 |
-
|
540 |
-
|
541 |
-
|
542 |
-
|
543 |
-
|
544 |
-
|
545 |
-
|
546 |
-
|
547 |
-
|
548 |
-
|
549 |
-
|
550 |
-
|
551 |
-
|
552 |
-
|
553 |
-
|
554 |
-
|
555 |
-
|
556 |
-
|
557 |
-
|
558 |
-
|
559 |
-
|
560 |
-
|
561 |
-
|
562 |
-
|
563 |
-
</
|
|
|
|
1 |
<?php
|
|
|
|
|
2 |
|
3 |
+
// Exit if accessed directly
|
4 |
+
if ( ! defined( 'ABSPATH' ) ) {
|
5 |
+
exit;
|
6 |
+
}
|
7 |
+
|
8 |
+
// Variables
|
9 |
$current_page = admin_url( 'tools.php?page=' . plugin_basename( 'wp-sweep/admin.php' ) );
|
10 |
$message = '';
|
11 |
|
12 |
+
// Sweeping
|
13 |
+
if ( ! empty( $_GET['sweep'] ) ) {
|
14 |
+
if ( check_admin_referer( 'wp_sweep_' . $_GET['sweep'] ) ) {
|
15 |
+
$message = WPSweep::get_instance()->sweep( $_GET['sweep'] );
|
16 |
+
}
|
17 |
}
|
18 |
|
19 |
+
// Database Table Status
|
20 |
$total_posts = WPSweep::get_instance()->total_count( 'posts' );
|
21 |
$total_postmeta = WPSweep::get_instance()->total_count( 'postmeta' );
|
22 |
$total_comments = WPSweep::get_instance()->total_count( 'comments' );
|
30 |
$total_options = WPSweep::get_instance()->total_count( 'options' );
|
31 |
$total_tables = WPSweep::get_instance()->total_count( 'tables' );
|
32 |
|
33 |
+
// Count
|
34 |
$revisions = WPSweep::get_instance()->count( 'revisions' );
|
35 |
$auto_drafts = WPSweep::get_instance()->count( 'auto_drafts' );
|
36 |
$deleted_posts = WPSweep::get_instance()->count( 'deleted_posts' );
|
40 |
|
41 |
$unapproved_comments = WPSweep::get_instance()->count( 'unapproved_comments' );
|
42 |
$spam_comments = WPSweep::get_instance()->count( 'spam_comments' );
|
43 |
+
$deleted_comments = WPSweep::get_instance()->count( 'deleted_comments' );
|
44 |
$orphan_commentmeta = WPSweep::get_instance()->count( 'orphan_commentmeta' );
|
45 |
$duplicated_commentmeta = WPSweep::get_instance()->count( 'duplicated_commentmeta' );
|
46 |
|
53 |
$duplicated_termmeta = WPSweep::get_instance()->count( 'duplicated_termmeta' );
|
54 |
|
55 |
$transient_options = WPSweep::get_instance()->count( 'transient_options' );
|
56 |
+
|
57 |
?>
|
58 |
<style type="text/css">
|
59 |
+
.table-sweep thead th {
|
60 |
+
width: 12%;
|
61 |
+
}
|
62 |
+
.table-sweep thead th.col-sweep-details {
|
63 |
+
width: 56%;
|
64 |
+
}
|
65 |
+
.table-sweep thead th.col-sweep-action {
|
66 |
+
width: 20%;
|
67 |
+
}
|
68 |
</style>
|
69 |
<div class="wrap">
|
70 |
+
<h2><?php _e( 'WP-Sweep', 'wp-sweep' ); ?></h2>
|
71 |
+
<div class="notice notice-warning">
|
72 |
+
<p>
|
73 |
+
<?php printf( __( 'Before you do any sweep, please <a href="%1$s" target="%2$s">backup your database</a> first because any sweep done is irreversible.', 'wp-sweep' ), 'https://wordpress.org/plugins/wp-dbmanager/', '_blank' ); ?>
|
74 |
+
</p>
|
75 |
+
</div>
|
76 |
+
<p>
|
77 |
+
<?php printf( __( 'For performance reasons, only %s items will be shown if you click Details', 'wp-sweep' ), number_format_i18n( WPSweep::get_instance()->limit_details ) ); ?>
|
78 |
+
</p>
|
79 |
+
<h3><?php _e( 'Post Sweep', 'wp-sweep' ); ?></h3>
|
80 |
+
<p><?php printf( __( 'There are a total of <strong class="attention"><span class="sweep-count-type-posts">%1$s</span> Posts</strong> and <strong class="attention"><span class="sweep-count-type-postmeta">%2$s</span> Post Meta</strong>.', 'wp-sweep' ), number_format_i18n( $total_posts ), number_format_i18n( $total_postmeta ) ); ?></p>
|
81 |
+
<div class="sweep-message"></div>
|
82 |
+
<table class="widefat table-sweep">
|
83 |
+
<thead>
|
84 |
+
<tr>
|
85 |
+
<th class="col-sweep-details"><?php _e( 'Details', 'wp-sweep' ); ?></th>
|
86 |
+
<th class="col-sweep-count"><?php _e( 'Count', 'wp-sweep' ); ?></th>
|
87 |
+
<th class="col-sweep-percent"><?php _e( '% Of', 'wp-sweep' ); ?></th>
|
88 |
+
<th class="col-sweep-action"><?php _e( 'Action', 'wp-sweep' ); ?></th>
|
89 |
+
</tr>
|
90 |
+
</thead>
|
91 |
+
<tbody>
|
92 |
+
<tr>
|
93 |
+
<td>
|
94 |
+
<strong><?php _e( 'Revisions', 'wp-sweep' ); ?></strong>
|
95 |
+
<p class="sweep-details" style="display: none;"></p>
|
96 |
+
</td>
|
97 |
+
<td>
|
98 |
+
<span class="sweep-count"><?php echo number_format_i18n( $revisions ); ?></span>
|
99 |
+
</td>
|
100 |
+
<td>
|
101 |
+
<span class="sweep-percentage"><?php echo WPSweep::get_instance()->format_percentage( $revisions, $total_posts ); ?></span>
|
102 |
+
</td>
|
103 |
+
<td>
|
104 |
+
<?php if ( ! empty( $revisions ) ) : ?>
|
105 |
+
<button data-action="sweep" data-sweep_name="revisions" data-sweep_type="posts" data-nonce="<?php echo wp_create_nonce( 'wp_sweep_revisions' ); ?>" class="button button-primary btn-sweep"><?php _e( 'Sweep', 'wp-sweep' ); ?></button>
|
106 |
+
<button data-action="sweep_details" data-sweep_name="revisions" data-sweep_type="posts" data-nonce="<?php echo wp_create_nonce( 'wp_sweep_details_revisions' ); ?>" class="button btn-sweep-details"><?php _e( 'Details', 'wp-sweep' ); ?></button>
|
107 |
+
<?php else : ?>
|
108 |
+
<?php _e( 'N/A', 'wp-sweep' ); ?>
|
109 |
+
<?php endif; ?>
|
110 |
+
</td>
|
111 |
+
</tr>
|
112 |
+
<tr class="alternate">
|
113 |
+
<td>
|
114 |
+
<strong><?php _e( 'Auto Drafts', 'wp-sweep' ); ?></strong>
|
115 |
+
<p class="sweep-details" style="display: none;"></p>
|
116 |
+
</td>
|
117 |
+
<td>
|
118 |
+
<span class="sweep-count"><?php echo number_format_i18n( $auto_drafts ); ?></span>
|
119 |
+
</td>
|
120 |
+
<td>
|
121 |
+
<span class="sweep-percentage"><?php echo WPSweep::get_instance()->format_percentage( $auto_drafts, $total_posts ); ?></span>
|
122 |
+
</td>
|
123 |
+
<td>
|
124 |
+
<?php if ( ! empty( $auto_drafts ) ) : ?>
|
125 |
+
<button data-action="sweep" data-sweep_name="auto_drafts" data-sweep_type="posts" data-nonce="<?php echo wp_create_nonce( 'wp_sweep_auto_drafts' ); ?>" class="button button-primary btn-sweep"><?php _e( 'Sweep', 'wp-sweep' ); ?></button>
|
126 |
+
<button data-action="sweep_details" data-sweep_name="auto_drafts" data-sweep_type="posts" data-nonce="<?php echo wp_create_nonce( 'wp_sweep_details_auto_drafts' ); ?>" class="button btn-sweep-details"><?php _e( 'Details', 'wp-sweep' ); ?></button>
|
127 |
+
<?php else : ?>
|
128 |
+
<?php _e( 'N/A', 'wp-sweep' ); ?>
|
129 |
+
<?php endif; ?>
|
130 |
+
</td>
|
131 |
+
</tr>
|
132 |
+
<tr>
|
133 |
+
<td>
|
134 |
+
<strong><?php _e( 'Deleted Posts', 'wp-sweep' ); ?></strong>
|
135 |
+
<p class="sweep-details" style="display: none;"></p>
|
136 |
+
</td>
|
137 |
+
<td>
|
138 |
+
<span class="sweep-count"><?php echo number_format_i18n( $deleted_posts ); ?></span>
|
139 |
+
</td>
|
140 |
+
<td>
|
141 |
+
<span class="sweep-percentage"><?php echo WPSweep::get_instance()->format_percentage( $deleted_posts, $total_posts ); ?></span>
|
142 |
+
</td>
|
143 |
+
<td>
|
144 |
+
<?php if ( ! empty( $deleted_posts ) ) : ?>
|
145 |
+
<button data-action="sweep" data-sweep_name="deleted_posts" data-sweep_type="posts" data-nonce="<?php echo wp_create_nonce( 'wp_sweep_deleted_posts' ); ?>" class="button button-primary btn-sweep"><?php _e( 'Sweep', 'wp-sweep' ); ?></button>
|
146 |
+
<button data-action="sweep_details" data-sweep_name="deleted_posts" data-sweep_type="posts" data-nonce="<?php echo wp_create_nonce( 'wp_sweep_details_deleted_posts' ); ?>" class="button btn-sweep-details"><?php _e( 'Details', 'wp-sweep' ); ?></button>
|
147 |
+
<?php else : ?>
|
148 |
+
<?php _e( 'N/A', 'wp-sweep' ); ?>
|
149 |
+
<?php endif; ?>
|
150 |
+
</td>
|
151 |
+
</tr>
|
152 |
+
<tr class="alternate">
|
153 |
+
<td>
|
154 |
+
<strong><?php _e( 'Orphaned Post Meta', 'wp-sweep' ); ?></strong>
|
155 |
+
<p class="sweep-details" style="display: none;"></p>
|
156 |
+
</td>
|
157 |
+
<td>
|
158 |
+
<span class="sweep-count"><?php echo number_format_i18n( $orphan_postmeta ); ?></span>
|
159 |
+
</td>
|
160 |
+
<td>
|
161 |
+
<span class="sweep-percentage"><?php echo WPSweep::get_instance()->format_percentage( $orphan_postmeta, $total_postmeta ); ?></span>
|
162 |
+
</td>
|
163 |
+
<td>
|
164 |
+
<?php if ( ! empty( $orphan_postmeta ) ) : ?>
|
165 |
+
<button data-action="sweep" data-sweep_name="orphan_postmeta" data-sweep_type="postmeta" data-nonce="<?php echo wp_create_nonce( 'wp_sweep_orphan_postmeta' ); ?>" class="button button-primary btn-sweep"><?php _e( 'Sweep', 'wp-sweep' ); ?></button>
|
166 |
+
<button data-action="sweep_details" data-sweep_name="orphan_postmeta" data-sweep_type="postmeta" data-nonce="<?php echo wp_create_nonce( 'wp_sweep_details_orphan_postmeta' ); ?>" class="button btn-sweep-details"><?php _e( 'Details', 'wp-sweep' ); ?></button>
|
167 |
+
<?php else : ?>
|
168 |
+
<?php _e( 'N/A', 'wp-sweep' ); ?>
|
169 |
+
<?php endif; ?>
|
170 |
+
</td>
|
171 |
+
</tr>
|
172 |
+
<tr>
|
173 |
+
<td>
|
174 |
+
<strong><?php _e( 'Duplicated Post Meta', 'wp-sweep' ); ?></strong>
|
175 |
+
<p class="sweep-details" style="display: none;"></p>
|
176 |
+
</td>
|
177 |
+
<td>
|
178 |
+
<span class="sweep-count"><?php echo number_format_i18n( $duplicated_postmeta ); ?></span>
|
179 |
+
</td>
|
180 |
+
<td>
|
181 |
+
<span class="sweep-percentage"><?php echo WPSweep::get_instance()->format_percentage( $duplicated_postmeta, $total_postmeta ); ?></span>
|
182 |
+
</td>
|
183 |
+
<td>
|
184 |
+
<?php if ( ! empty( $duplicated_postmeta ) ) : ?>
|
185 |
+
<button data-action="sweep" data-sweep_name="duplicated_postmeta" data-sweep_type="postmeta" data-nonce="<?php echo wp_create_nonce( 'wp_sweep_duplicated_postmeta' ); ?>" class="button button-primary btn-sweep"><?php _e( 'Sweep', 'wp-sweep' ); ?></button>
|
186 |
+
<button data-action="sweep_details" data-sweep_name="duplicated_postmeta" data-sweep_type="postmeta" data-nonce="<?php echo wp_create_nonce( 'wp_sweep_details_duplicated_postmeta' ); ?>" class="button btn-sweep-details"><?php _e( 'Details', 'wp-sweep' ); ?></button>
|
187 |
+
<?php else : ?>
|
188 |
+
<?php _e( 'N/A', 'wp-sweep' ); ?>
|
189 |
+
<?php endif; ?>
|
190 |
+
</td>
|
191 |
+
</tr>
|
192 |
+
<tr class="alternate">
|
193 |
+
<td>
|
194 |
+
<strong><?php _e( 'oEmbed Caches In Post Meta', 'wp-sweep' ); ?></strong>
|
195 |
+
<p class="sweep-details" style="display: none;"></p>
|
196 |
+
</td>
|
197 |
+
<td>
|
198 |
+
<span class="sweep-count"><?php echo number_format_i18n( $oembed_postmeta ); ?></span>
|
199 |
+
</td>
|
200 |
+
<td>
|
201 |
+
<span class="sweep-percentage"><?php echo WPSweep::get_instance()->format_percentage( $oembed_postmeta, $total_postmeta ); ?></span>
|
202 |
+
</td>
|
203 |
+
<td>
|
204 |
+
<?php if ( ! empty( $oembed_postmeta ) ) : ?>
|
205 |
+
<button data-action="sweep" data-sweep_name="oembed_postmeta" data-sweep_type="postmeta" data-nonce="<?php echo wp_create_nonce( 'wp_sweep_oembed_postmeta' ); ?>" class="button button-primary btn-sweep"><?php _e( 'Sweep', 'wp-sweep' ); ?></button>
|
206 |
+
<button data-action="sweep_details" data-sweep_name="oembed_postmeta" data-sweep_type="postmeta" data-nonce="<?php echo wp_create_nonce( 'wp_sweep_details_oembed_postmeta' ); ?>" class="button btn-sweep-details"><?php _e( 'Details', 'wp-sweep' ); ?></button>
|
207 |
+
<?php else : ?>
|
208 |
+
<?php _e( 'N/A', 'wp-sweep' ); ?>
|
209 |
+
<?php endif; ?>
|
210 |
+
</td>
|
211 |
+
</tr>
|
212 |
+
</tbody>
|
213 |
+
</table>
|
214 |
+
<?php do_action( 'wp_sweep_admin_post_sweep' ); ?>
|
215 |
+
<p> </p>
|
216 |
+
<h3><?php _e( 'Comment Sweep', 'wp-sweep' ); ?></h3>
|
217 |
+
<p><?php printf( __( 'There are a total of <strong class="attention"><span class="sweep-count-type-comments">%1$s</span> Comments</strong> and <strong class="attention"><span class="sweep-count-type-commentmeta">%2$s</span> Comment Meta</strong>.', 'wp-sweep' ), number_format_i18n( $total_comments ), number_format_i18n( $total_commentmeta ) ); ?></p>
|
218 |
+
<div class="sweep-message"></div>
|
219 |
+
<table class="widefat table-sweep">
|
220 |
+
<thead>
|
221 |
+
<tr>
|
222 |
+
<th class="col-sweep-details"><?php _e( 'Details', 'wp-sweep' ); ?></th>
|
223 |
+
<th class="col-sweep-count"><?php _e( 'Count', 'wp-sweep' ); ?></th>
|
224 |
+
<th class="col-sweep-percent"><?php _e( '% Of', 'wp-sweep' ); ?></th>
|
225 |
+
<th class="col-sweep-action"><?php _e( 'Action', 'wp-sweep' ); ?></th>
|
226 |
+
</tr>
|
227 |
+
</thead>
|
228 |
+
<tbody>
|
229 |
+
<tr>
|
230 |
+
<td>
|
231 |
+
<strong><?php _e( 'Unapproved Comments', 'wp-sweep' ); ?></strong>
|
232 |
+
<p class="sweep-details" style="display: none;"></p>
|
233 |
+
</td>
|
234 |
+
<td>
|
235 |
+
<span class="sweep-count"><?php echo number_format_i18n( $unapproved_comments ); ?></span>
|
236 |
+
</td>
|
237 |
+
<td>
|
238 |
+
<span class="sweep-percentage"><?php echo WPSweep::get_instance()->format_percentage( $unapproved_comments, $total_comments ); ?></span>
|
239 |
+
</td>
|
240 |
+
<td>
|
241 |
+
<?php if ( ! empty( $unapproved_comments ) ) : ?>
|
242 |
+
<button data-action="sweep" data-sweep_name="unapproved_comments" data-sweep_type="comments" data-nonce="<?php echo wp_create_nonce( 'wp_sweep_unapproved_comments' ); ?>" class="button button-primary btn-sweep"><?php _e( 'Sweep', 'wp-sweep' ); ?></button>
|
243 |
+
<button data-action="sweep_details" data-sweep_name="unapproved_comments" data-sweep_type="comments" data-nonce="<?php echo wp_create_nonce( 'wp_sweep_details_unapproved_comments' ); ?>" class="button btn-sweep-details"><?php _e( 'Details', 'wp-sweep' ); ?></button>
|
244 |
+
<?php else : ?>
|
245 |
+
<?php _e( 'N/A', 'wp-sweep' ); ?>
|
246 |
+
<?php endif; ?>
|
247 |
+
</td>
|
248 |
+
</tr>
|
249 |
+
<tr class="alternate">
|
250 |
+
<td>
|
251 |
+
<strong><?php _e( 'Spammed Comments', 'wp-sweep' ); ?></strong>
|
252 |
+
<p class="sweep-details" style="display: none;"></p>
|
253 |
+
</td>
|
254 |
+
<td>
|
255 |
+
<span class="sweep-count"><?php echo number_format_i18n( $spam_comments ); ?></span>
|
256 |
+
</td>
|
257 |
+
<td>
|
258 |
+
<span class="sweep-percentage"><?php echo WPSweep::get_instance()->format_percentage( $spam_comments, $total_comments ); ?></span>
|
259 |
+
</td>
|
260 |
+
<td>
|
261 |
+
<?php if ( ! empty( $spam_comments ) ) : ?>
|
262 |
+
<button data-action="sweep" data-sweep_name="spam_comments" data-sweep_type="comments" data-nonce="<?php echo wp_create_nonce( 'wp_sweep_spam_comments' ); ?>" class="button button-primary btn-sweep"><?php _e( 'Sweep', 'wp-sweep' ); ?></button>
|
263 |
+
<button data-action="sweep_details" data-sweep_name="spam_comments" data-sweep_type="comments" data-nonce="<?php echo wp_create_nonce( 'wp_sweep_details_spam_comments' ); ?>" class="button btn-sweep-details"><?php _e( 'Details', 'wp-sweep' ); ?></button>
|
264 |
+
<?php else : ?>
|
265 |
+
<?php _e( 'N/A', 'wp-sweep' ); ?>
|
266 |
+
<?php endif; ?>
|
267 |
+
</td>
|
268 |
+
</tr>
|
269 |
+
<tr>
|
270 |
+
<td>
|
271 |
+
<strong><?php _e( 'Deleted Comments', 'wp-sweep' ); ?></strong>
|
272 |
+
<p class="sweep-details" style="display: none;"></p>
|
273 |
+
</td>
|
274 |
+
<td>
|
275 |
+
<span class="sweep-count"><?php echo number_format_i18n( $deleted_comments ); ?></span>
|
276 |
+
</td>
|
277 |
+
<td>
|
278 |
+
<span class="sweep-percentage"><?php echo WPSweep::get_instance()->format_percentage( $deleted_comments, $total_comments ); ?></span>
|
279 |
+
</td>
|
280 |
+
<td>
|
281 |
+
<?php if ( ! empty( $deleted_comments ) ) : ?>
|
282 |
+
<button data-action="sweep" data-sweep_name="deleted_comments" data-sweep_type="comments" data-nonce="<?php echo wp_create_nonce( 'wp_sweep_deleted_comments' ); ?>" class="button button-primary btn-sweep"><?php _e( 'Sweep', 'wp-sweep' ); ?></button>
|
283 |
+
<button data-action="sweep_details" data-sweep_name="deleted_comments" data-sweep_type="comments" data-nonce="<?php echo wp_create_nonce( 'wp_sweep_details_deleted_comments' ); ?>" class="button btn-sweep-details"><?php _e( 'Details', 'wp-sweep' ); ?></button>
|
284 |
+
<?php else : ?>
|
285 |
+
<?php _e( 'N/A', 'wp-sweep' ); ?>
|
286 |
+
<?php endif; ?>
|
287 |
+
</td>
|
288 |
+
</tr>
|
289 |
+
<tr class="alternate">
|
290 |
+
<td>
|
291 |
+
<strong><?php _e( 'Orphaned Comment Meta', 'wp-sweep' ); ?></strong>
|
292 |
+
<p class="sweep-details" style="display: none;"></p>
|
293 |
+
</td>
|
294 |
+
<td>
|
295 |
+
<span class="sweep-count"><?php echo number_format_i18n( $orphan_commentmeta ); ?></span>
|
296 |
+
</td>
|
297 |
+
<td>
|
298 |
+
<span class="sweep-percentage"><?php echo WPSweep::get_instance()->format_percentage( $orphan_commentmeta, $total_commentmeta ); ?></span>
|
299 |
+
</td>
|
300 |
+
<td>
|
301 |
+
<?php if ( ! empty( $orphan_commentmeta ) ) : ?>
|
302 |
+
<button data-action="sweep" data-sweep_name="orphan_commentmeta" data-sweep_type="commentmeta" data-nonce="<?php echo wp_create_nonce( 'wp_sweep_orphan_commentmeta' ); ?>" class="button button-primary btn-sweep"><?php _e( 'Sweep', 'wp-sweep' ); ?></button>
|
303 |
+
<button data-action="sweep_details" data-sweep_name="orphan_commentmeta" data-sweep_type="commentmeta" data-nonce="<?php echo wp_create_nonce( 'wp_sweep_details_orphan_commentmeta' ); ?>" class="button btn-sweep-details"><?php _e( 'Details', 'wp-sweep' ); ?></button>
|
304 |
+
<?php else : ?>
|
305 |
+
<?php _e( 'N/A', 'wp-sweep' ); ?>
|
306 |
+
<?php endif; ?>
|
307 |
+
</td>
|
308 |
+
</tr>
|
309 |
+
<tr>
|
310 |
+
<td>
|
311 |
+
<strong><?php _e( 'Duplicated Comment Meta', 'wp-sweep' ); ?></strong>
|
312 |
+
<p class="sweep-details" style="display: none;"></p>
|
313 |
+
</td>
|
314 |
+
<td>
|
315 |
+
<span class="sweep-count"><?php echo number_format_i18n( $duplicated_commentmeta ); ?></span>
|
316 |
+
</td>
|
317 |
+
<td>
|
318 |
+
<span class="sweep-percentage"><?php echo WPSweep::get_instance()->format_percentage( $duplicated_commentmeta, $total_commentmeta ); ?></span>
|
319 |
+
</td>
|
320 |
+
<td>
|
321 |
+
<?php if ( ! empty( $duplicated_commentmeta ) ) : ?>
|
322 |
+
<button data-action="sweep" data-sweep_name="duplicated_commentmeta" data-sweep_type="commentmeta" data-nonce="<?php echo wp_create_nonce( 'wp_sweep_duplicated_commentmeta' ); ?>" class="button button-primary btn-sweep"><?php _e( 'Sweep', 'wp-sweep' ); ?></button>
|
323 |
+
<button data-action="sweep_details" data-sweep_name="duplicated_commentmeta" data-sweep_type="commentmeta" data-nonce="<?php echo wp_create_nonce( 'wp_sweep_details_duplicated_commentmeta' ); ?>" class="button btn-sweep-details"><?php _e( 'Details', 'wp-sweep' ); ?></button>
|
324 |
+
<?php else : ?>
|
325 |
+
<?php _e( 'N/A', 'wp-sweep' ); ?>
|
326 |
+
<?php endif; ?>
|
327 |
+
</td>
|
328 |
+
</tr>
|
329 |
+
</tbody>
|
330 |
+
</table>
|
331 |
+
<?php do_action( 'wp_sweep_admin_comment_sweep' ); ?>
|
332 |
+
<p> </p>
|
333 |
+
<h3><?php _e( 'User Sweep', 'wp-sweep' ); ?></h3>
|
334 |
+
<p><?php printf( __( 'There are a total of <strong class="attention"><span class="sweep-count-type-users">%1$s</span> Users</strong> and <strong class="attention"><span class="sweep-count-type-usermeta">%2$s</span> User Meta</strong>.', 'wp-sweep' ), number_format_i18n( $total_users ), number_format_i18n( $total_usermeta ) ); ?></p>
|
335 |
+
<div class="sweep-message"></div>
|
336 |
+
<table class="widefat table-sweep">
|
337 |
+
<thead>
|
338 |
+
<tr>
|
339 |
+
<th class="col-sweep-details"><?php _e( 'Details', 'wp-sweep' ); ?></th>
|
340 |
+
<th class="col-sweep-count"><?php _e( 'Count', 'wp-sweep' ); ?></th>
|
341 |
+
<th class="col-sweep-percent"><?php _e( '% Of', 'wp-sweep' ); ?></th>
|
342 |
+
<th class="col-sweep-action"><?php _e( 'Action', 'wp-sweep' ); ?></th>
|
343 |
+
</tr>
|
344 |
+
</thead>
|
345 |
+
<tbody>
|
346 |
+
<tr>
|
347 |
+
<td>
|
348 |
+
<strong><?php _e( 'Orphaned User Meta', 'wp-sweep' ); ?></strong>
|
349 |
+
<p class="sweep-details" style="display: none;"></p>
|
350 |
+
</td>
|
351 |
+
<td>
|
352 |
+
<span class="sweep-count"><?php echo number_format_i18n( $orphan_usermeta ); ?></span>
|
353 |
+
</td>
|
354 |
+
<td>
|
355 |
+
<span class="sweep-percentage"><?php echo WPSweep::get_instance()->format_percentage( $orphan_usermeta, $total_usermeta ); ?></span>
|
356 |
+
</td>
|
357 |
+
<td>
|
358 |
+
<?php if ( ! empty( $orphan_usermeta ) ) : ?>
|
359 |
+
<button data-action="sweep" data-sweep_name="orphan_usermeta" data-sweep_type="usermeta" data-nonce="<?php echo wp_create_nonce( 'wp_sweep_orphan_usermeta' ); ?>" class="button button-primary btn-sweep"><?php _e( 'Sweep', 'wp-sweep' ); ?></button>
|
360 |
+
<button data-action="sweep_details" data-sweep_name="orphan_usermeta" data-sweep_type="usermeta" data-nonce="<?php echo wp_create_nonce( 'wp_sweep_details_orphan_usermeta' ); ?>" class="button btn-sweep-details"><?php _e( 'Details', 'wp-sweep' ); ?></button>
|
361 |
+
<?php else : ?>
|
362 |
+
<?php _e( 'N/A', 'wp-sweep' ); ?>
|
363 |
+
<?php endif; ?>
|
364 |
+
</td>
|
365 |
+
</tr>
|
366 |
+
<tr class="alternate">
|
367 |
+
<td>
|
368 |
+
<strong><?php _e( 'Duplicated User Meta', 'wp-sweep' ); ?></strong>
|
369 |
+
<p class="sweep-details" style="display: none;"></p>
|
370 |
+
</td>
|
371 |
+
<td>
|
372 |
+
<span class="sweep-count"><?php echo number_format_i18n( $duplicated_usermeta ); ?></span>
|
373 |
+
</td>
|
374 |
+
<td>
|
375 |
+
<span class="sweep-percentage"><?php echo WPSweep::get_instance()->format_percentage( $duplicated_usermeta, $total_usermeta ); ?></span>
|
376 |
+
</td>
|
377 |
+
<td>
|
378 |
+
<?php if ( ! empty( $duplicated_usermeta ) ) : ?>
|
379 |
+
<button data-action="sweep" data-sweep_name="duplicated_usermeta" data-sweep_type="usermeta" data-nonce="<?php echo wp_create_nonce( 'wp_sweep_duplicated_usermeta' ); ?>" class="button button-primary btn-sweep"><?php _e( 'Sweep', 'wp-sweep' ); ?></button>
|
380 |
+
<button data-action="sweep_details" data-sweep_name="duplicated_usermeta" data-sweep_type="usermeta" data-nonce="<?php echo wp_create_nonce( 'wp_sweep_details_duplicated_usermeta' ); ?>" class="button btn-sweep-details"><?php _e( 'Details', 'wp-sweep' ); ?></button>
|
381 |
+
<?php else : ?>
|
382 |
+
<?php _e( 'N/A', 'wp-sweep' ); ?>
|
383 |
+
<?php endif; ?>
|
384 |
+
</td>
|
385 |
+
</tr>
|
386 |
+
</tbody>
|
387 |
+
</table>
|
388 |
+
<?php do_action( 'wp_sweep_admin_user_sweep' ); ?>
|
389 |
+
<p> </p>
|
390 |
+
<h3><?php _e( 'Term Sweep', 'wp-sweep' ); ?></h3>
|
391 |
+
<p><?php printf( __( 'There are a total of <strong class="attention "><span class="sweep-count-type-terms">%1$s</span> Terms</strong>, <strong class="attention "><span class="sweep-count-type-termmeta">%2$s</span> Term Meta</strong>, <strong class="attention"><span class="sweep-count-type-term_taxonomy">%3$s</span> Term Taxonomy</strong> and <strong class="attention"><span class="sweep-count-type-term_relationships">%4$s</span> Term Relationships</strong>.', 'wp-sweep' ), number_format_i18n( $total_terms ), number_format_i18n( $total_termmeta ), number_format_i18n( $total_term_taxonomy ), number_format_i18n( $total_term_relationships ) ); ?></p>
|
392 |
+
<div class="sweep-message"></div>
|
393 |
+
<table class="widefat table-sweep">
|
394 |
+
<thead>
|
395 |
+
<tr>
|
396 |
+
<th class="col-sweep-details"><?php _e( 'Details', 'wp-sweep' ); ?></th>
|
397 |
+
<th class="col-sweep-count"><?php _e( 'Count', 'wp-sweep' ); ?></th>
|
398 |
+
<th class="col-sweep-percent"><?php _e( '% Of', 'wp-sweep' ); ?></th>
|
399 |
+
<th class="col-sweep-action"><?php _e( 'Action', 'wp-sweep' ); ?></th>
|
400 |
+
</tr>
|
401 |
+
</thead>
|
402 |
+
<tbody>
|
403 |
+
<tr>
|
404 |
+
<td>
|
405 |
+
<strong><?php _e( 'Orphaned Term Meta', 'wp-sweep' ); ?></strong>
|
406 |
+
<p class="sweep-details" style="display: none;"></p>
|
407 |
+
</td>
|
408 |
+
<td>
|
409 |
+
<span class="sweep-count"><?php echo number_format_i18n( $orphan_termmeta ); ?></span>
|
410 |
+
</td>
|
411 |
+
<td>
|
412 |
+
<span class="sweep-percentage"><?php echo WPSweep::get_instance()->format_percentage( $orphan_termmeta, $total_termmeta ); ?></span>
|
413 |
+
</td>
|
414 |
+
<td>
|
415 |
+
<?php if ( ! empty( $orphan_termmeta ) ) : ?>
|
416 |
+
<button data-action="sweep" data-sweep_name="orphan_termmeta" data-sweep_type="termmeta" data-nonce="<?php echo wp_create_nonce( 'wp_sweep_orphan_termmeta' ); ?>" class="button button-primary btn-sweep"><?php _e( 'Sweep', 'wp-sweep' ); ?></button>
|
417 |
+
<button data-action="sweep_details" data-sweep_name="orphan_termmeta" data-sweep_type="termmeta" data-nonce="<?php echo wp_create_nonce( 'wp_sweep_details_orphan_termmeta' ); ?>" class="button btn-sweep-details"><?php _e( 'Details', 'wp-sweep' ); ?></button>
|
418 |
+
<?php else : ?>
|
419 |
+
<?php _e( 'N/A', 'wp-sweep' ); ?>
|
420 |
+
<?php endif; ?>
|
421 |
+
</td>
|
422 |
+
</tr>
|
423 |
+
<tr class="alternate">
|
424 |
+
<td>
|
425 |
+
<strong><?php _e( 'Duplicated Term Meta', 'wp-sweep' ); ?></strong>
|
426 |
+
<p class="sweep-details" style="display: none;"></p>
|
427 |
+
</td>
|
428 |
+
<td>
|
429 |
+
<span class="sweep-count"><?php echo number_format_i18n( $duplicated_termmeta ); ?></span>
|
430 |
+
</td>
|
431 |
+
<td>
|
432 |
+
<span class="sweep-percentage"><?php echo WPSweep::get_instance()->format_percentage( $duplicated_termmeta, $total_termmeta ); ?></span>
|
433 |
+
</td>
|
434 |
+
<td>
|
435 |
+
<?php if ( ! empty( $duplicated_termmeta ) ) : ?>
|
436 |
+
<button data-action="sweep" data-sweep_name="duplicated_termmeta" data-sweep_type="termmeta" data-nonce="<?php echo wp_create_nonce( 'wp_sweep_duplicated_termmeta' ); ?>" class="button button-primary btn-sweep"><?php _e( 'Sweep', 'wp-sweep' ); ?></button>
|
437 |
+
<button data-action="sweep_details" data-sweep_name="duplicated_termmeta" data-sweep_type="termmeta" data-nonce="<?php echo wp_create_nonce( 'wp_sweep_details_duplicated_termmeta' ); ?>" class="button btn-sweep-details"><?php _e( 'Details', 'wp-sweep' ); ?></button>
|
438 |
+
<?php else : ?>
|
439 |
+
<?php _e( 'N/A', 'wp-sweep' ); ?>
|
440 |
+
<?php endif; ?>
|
441 |
+
</td>
|
442 |
+
</tr>
|
443 |
+
<tr>
|
444 |
+
<td>
|
445 |
+
<strong><?php _e( 'Orphaned Term Relationship', 'wp-sweep' ); ?></strong>
|
446 |
+
<p class="sweep-details" style="display: none;"></p>
|
447 |
+
</td>
|
448 |
+
<td>
|
449 |
+
<span class="sweep-count"><?php echo number_format_i18n( $orphan_term_relationships ); ?></span>
|
450 |
+
</td>
|
451 |
+
<td>
|
452 |
+
<span class="sweep-percentage"><?php echo WPSweep::get_instance()->format_percentage( $orphan_term_relationships, $total_term_relationships ); ?></span>
|
453 |
+
</td>
|
454 |
+
<td>
|
455 |
+
<?php if ( ! empty( $orphan_term_relationships ) ) : ?>
|
456 |
+
<button data-action="sweep" data-sweep_name="orphan_term_relationships" data-sweep_type="term_relationships" data-nonce="<?php echo wp_create_nonce( 'wp_sweep_orphan_term_relationships' ); ?>" class="button button-primary btn-sweep"><?php _e( 'Sweep', 'wp-sweep' ); ?></button>
|
457 |
+
<button data-action="sweep_details" data-sweep_name="orphan_term_relationships" data-sweep_type="term_relationships" data-nonce="<?php echo wp_create_nonce( 'wp_sweep_details_orphan_term_relationships' ); ?>" class="button btn-sweep-details"><?php _e( 'Details', 'wp-sweep' ); ?></button>
|
458 |
+
<?php else : ?>
|
459 |
+
<?php _e( 'N/A', 'wp-sweep' ); ?>
|
460 |
+
<?php endif; ?>
|
461 |
+
</td>
|
462 |
+
</tr>
|
463 |
+
<tr class="alternate">
|
464 |
+
<td>
|
465 |
+
<strong><?php _e( 'Unused Terms', 'wp-sweep' ); ?></strong>
|
466 |
+
<p><?php _e( 'Note that some unused terms might belong to draft posts that have not been published yet. Only sweep this when you do not have any draft posts.', 'wp-sweep' ); ?></p>
|
467 |
+
<p class="sweep-details" style="display: none;"></p>
|
468 |
+
</td>
|
469 |
+
<td>
|
470 |
+
<span class="sweep-count"><?php echo number_format_i18n( $unused_terms ); ?></span>
|
471 |
+
</td>
|
472 |
+
<td>
|
473 |
+
<span class="sweep-percentage"><?php echo WPSweep::get_instance()->format_percentage( $unused_terms, $total_terms ); ?></span>
|
474 |
+
</td>
|
475 |
+
<td>
|
476 |
+
<?php if ( ! empty( $unused_terms ) ) : ?>
|
477 |
+
<button data-action="sweep" data-sweep_name="unused_terms" data-sweep_type="terms" data-nonce="<?php echo wp_create_nonce( 'wp_sweep_unused_terms' ); ?>" class="button button-primary btn-sweep"><?php _e( 'Sweep', 'wp-sweep' ); ?></button>
|
478 |
+
<button data-action="sweep_details" data-sweep_name="unused_terms" data-sweep_type="terms" data-nonce="<?php echo wp_create_nonce( 'wp_sweep_details_unused_terms' ); ?>" class="button btn-sweep-details"><?php _e( 'Details', 'wp-sweep' ); ?></button>
|
479 |
+
<?php else : ?>
|
480 |
+
<?php _e( 'N/A', 'wp-sweep' ); ?>
|
481 |
+
<?php endif; ?>
|
482 |
+
</td>
|
483 |
+
</tr>
|
484 |
+
</tbody>
|
485 |
+
</table>
|
486 |
+
<?php do_action( 'wp_sweep_admin_term_sweep' ); ?>
|
487 |
+
<p> </p>
|
488 |
+
<h3><?php _e( 'Option Sweep', 'wp-sweep' ); ?></h3>
|
489 |
+
<p><?php printf( __( 'There are a total of <strong class="attention"><span class="sweep-count-type-options">%s</span> Options</strong>.', 'wp-sweep' ), number_format_i18n( $total_options ) ); ?></p>
|
490 |
+
<div class="sweep-message"></div>
|
491 |
+
<table class="widefat table-sweep">
|
492 |
+
<thead>
|
493 |
+
<tr>
|
494 |
+
<th class="col-sweep-details"><?php _e( 'Details', 'wp-sweep' ); ?></th>
|
495 |
+
<th class="col-sweep-count"><?php _e( 'Count', 'wp-sweep' ); ?></th>
|
496 |
+
<th class="col-sweep-percent"><?php _e( '% Of', 'wp-sweep' ); ?></th>
|
497 |
+
<th class="col-sweep-action"><?php _e( 'Action', 'wp-sweep' ); ?></th>
|
498 |
+
</tr>
|
499 |
+
</thead>
|
500 |
+
<tbody>
|
501 |
+
<tr>
|
502 |
+
<td>
|
503 |
+
<strong><?php _e( 'Transient Options', 'wp-sweep' ); ?></strong>
|
504 |
+
<p class="sweep-details" style="display: none;"></p>
|
505 |
+
</td>
|
506 |
+
<td>
|
507 |
+
<span class="sweep-count"><?php echo number_format_i18n( $transient_options ); ?></span>
|
508 |
+
</td>
|
509 |
+
<td>
|
510 |
+
<span class="sweep-percentage"><?php echo WPSweep::get_instance()->format_percentage( $transient_options, $total_options ); ?></span>
|
511 |
+
</td>
|
512 |
+
<td>
|
513 |
+
<?php if ( ! empty( $transient_options ) ) : ?>
|
514 |
+
<button data-action="sweep" data-sweep_name="transient_options" data-sweep_type="options" data-nonce="<?php echo wp_create_nonce( 'wp_sweep_transient_options' ); ?>" class="button button-primary btn-sweep"><?php _e( 'Sweep', 'wp-sweep' ); ?></button>
|
515 |
+
<button data-action="sweep_details" data-sweep_name="transient_options" data-sweep_type="options" data-nonce="<?php echo wp_create_nonce( 'wp_sweep_details_transient_options' ); ?>" class="button btn-sweep-details"><?php _e( 'Details', 'wp-sweep' ); ?></button>
|
516 |
+
<?php else : ?>
|
517 |
+
<?php _e( 'N/A', 'wp-sweep' ); ?>
|
518 |
+
<?php endif; ?>
|
519 |
+
</td>
|
520 |
+
</tr>
|
521 |
+
</tbody>
|
522 |
+
</table>
|
523 |
+
<?php do_action( 'wp_sweep_admin_option_sweep' ); ?>
|
524 |
+
<p> </p>
|
525 |
+
<h3><?php _e( 'Database Sweep', 'wp-sweep' ); ?></h3>
|
526 |
+
<p><?php printf( __( 'There are a total of <strong class="attention"><span class="sweep-count-type-tables">%s</span> Tables</strong>.', 'wp-sweep' ), number_format_i18n( $total_tables ) ); ?></p>
|
527 |
+
<div class="sweep-message"></div>
|
528 |
+
<table class="widefat table-sweep">
|
529 |
+
<thead>
|
530 |
+
<tr>
|
531 |
+
<th class="col-sweep-details"><?php _e( 'Details', 'wp-sweep' ); ?></th>
|
532 |
+
<th class="col-sweep-count"><?php _e( 'Count', 'wp-sweep' ); ?></th>
|
533 |
+
<th class="col-sweep-percent"><?php _e( '% Of', 'wp-sweep' ); ?></th>
|
534 |
+
<th class="col-sweep-action"><?php _e( 'Action', 'wp-sweep' ); ?></th>
|
535 |
+
</tr>
|
536 |
+
</thead>
|
537 |
+
<tbody>
|
538 |
+
<tr>
|
539 |
+
<td>
|
540 |
+
<strong><?php _e( 'Optimize Tables', 'wp-sweep' ); ?></strong>
|
541 |
+
<p class="sweep-details" style="display: none;"></p>
|
542 |
+
</td>
|
543 |
+
<td>
|
544 |
+
<span class="sweep-count"><?php echo number_format_i18n( $total_tables ); ?></span>
|
545 |
+
</td>
|
546 |
+
<td>
|
547 |
+
<?php _e( 'N/A', 'wp-sweep' ); ?>
|
548 |
+
</td>
|
549 |
+
<td>
|
550 |
+
<?php if ( ! empty( $total_tables ) ) : ?>
|
551 |
+
<button data-action="sweep" data-sweep_name="optimize_database" data-sweep_type="tables" data-nonce="<?php echo wp_create_nonce( 'wp_sweep_optimize_database' ); ?>" class="button button-primary btn-sweep"><?php _e( 'Sweep', 'wp-sweep' ); ?></button>
|
552 |
+
<button data-action="sweep_details" data-sweep_name="optimize_database" data-sweep_type="tables" data-nonce="<?php echo wp_create_nonce( 'wp_sweep_details_optimize_database' ); ?>" class="button btn-sweep-details"><?php _e( 'Details', 'wp-sweep' ); ?></button>
|
553 |
+
<?php else : ?>
|
554 |
+
<?php _e( 'N/A', 'wp-sweep' ); ?>
|
555 |
+
<?php endif; ?>
|
556 |
+
</td>
|
557 |
+
</tr>
|
558 |
+
</tbody>
|
559 |
+
</table>
|
560 |
+
<?php do_action( 'wp_sweep_admin_database_sweep' ); ?>
|
561 |
+
<p> </p>
|
562 |
+
<h3><?php _e( 'Sweep All', 'wp-sweep' ); ?></h3>
|
563 |
+
<p><?php _e( 'Note that some unused terms might belong to draft posts that have not been published yet. Only sweep all when you do not have any draft posts.', 'wp-sweep' ); ?></p>
|
564 |
+
<div class="sweep-all">
|
565 |
+
<p style="text-align: center;">
|
566 |
+
<button class="button button-primary btn-sweep-all"><?php _e( 'Sweep All', 'wp-sweep' ); ?></button>
|
567 |
+
</p>
|
568 |
+
</div>
|
569 |
+
</div>
|
class-command.php
ADDED
@@ -0,0 +1,106 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class WPSweep_Command extends WP_CLI_Command {
|
4 |
+
/**
|
5 |
+
* Clean up unused, orphaned and duplicated data in your WordPress
|
6 |
+
*
|
7 |
+
* ## OPTIONS
|
8 |
+
*
|
9 |
+
* [--all]
|
10 |
+
* Sweep all the orphaned data at once.
|
11 |
+
*
|
12 |
+
* Name of the items selected individually
|
13 |
+
* Available Items =
|
14 |
+
* revisions
|
15 |
+
* auto_drafts
|
16 |
+
* deleted_posts
|
17 |
+
* unapproved_comments
|
18 |
+
* spam_comments
|
19 |
+
* deleted_comments
|
20 |
+
* transient_options
|
21 |
+
* orphan_postmeta
|
22 |
+
* orphan_commentmeta
|
23 |
+
* orphan_usermeta
|
24 |
+
* orphan_termmeta
|
25 |
+
* orphan_term_relationships
|
26 |
+
* unused_terms
|
27 |
+
* duplicated_postmeta
|
28 |
+
* duplicated_commentmeta
|
29 |
+
* duplicated_usermeta
|
30 |
+
* duplicated_termmeta
|
31 |
+
* optimize_database
|
32 |
+
* oembed_postmet
|
33 |
+
*
|
34 |
+
* ## EXAMPLES
|
35 |
+
*
|
36 |
+
* 1. wp sweep --all
|
37 |
+
* - Run Sweep for all the items.
|
38 |
+
* 2. wp sweep revisions
|
39 |
+
* - Sweep only Revision
|
40 |
+
* 3. wp sweep revisions auto_drafts deleted_posts unapproved_comments spam_comments deleted_comments transient_options orphan_postmeta orphan_commentmeta orphan_usermeta orphan_termmeta orphan_term_relationships unused_terms duplicated_postmeta duplicated_commentmeta duplicated_usermeta duplicated_termmeta optimize_database oembed_postmet
|
41 |
+
* - Sweep the selected items
|
42 |
+
*
|
43 |
+
*
|
44 |
+
*/
|
45 |
+
public function __invoke( $args, $assoc_args ) {
|
46 |
+
|
47 |
+
$items = array();
|
48 |
+
|
49 |
+
$default_items = array(
|
50 |
+
'0' => 'revisions',
|
51 |
+
'1' => 'auto_drafts',
|
52 |
+
'2' => 'deleted_posts',
|
53 |
+
'3' => 'unapproved_comments',
|
54 |
+
'4' => 'spam_comments',
|
55 |
+
'5' => 'deleted_comments',
|
56 |
+
'6' => 'transient_options',
|
57 |
+
'7' => 'orphan_postmeta',
|
58 |
+
'8' => 'orphan_commentmeta',
|
59 |
+
'9' => 'orphan_usermeta',
|
60 |
+
'10' => 'orphan_termmeta',
|
61 |
+
'11' => 'orphan_term_relationships',
|
62 |
+
'12' => 'unused_terms',
|
63 |
+
'13' => 'duplicated_postmeta',
|
64 |
+
'14' => 'duplicated_commentmeta',
|
65 |
+
'15' => 'duplicated_usermeta',
|
66 |
+
'16' => 'duplicated_termmeta',
|
67 |
+
'17' => 'optimize_database',
|
68 |
+
'18' => 'oembed_postmeta',
|
69 |
+
);
|
70 |
+
|
71 |
+
if ( isset( $assoc_args['all'] ) && true == $assoc_args['all'] ) {
|
72 |
+
$this->run_sweep( $default_items );
|
73 |
+
WP_CLI::success( 'Sweep Complete' );
|
74 |
+
|
75 |
+
return;
|
76 |
+
} else {
|
77 |
+
foreach ( $default_items as $key => $item ) {
|
78 |
+
if ( in_array( $item, $args ) ) {
|
79 |
+
array_push( $items, $item );
|
80 |
+
}
|
81 |
+
}
|
82 |
+
|
83 |
+
$this->run_sweep( $items );
|
84 |
+
WP_CLI::success( 'Sweep Complete!' );
|
85 |
+
|
86 |
+
return;
|
87 |
+
}
|
88 |
+
|
89 |
+
}
|
90 |
+
|
91 |
+
public function run_sweep( $items ) {
|
92 |
+
|
93 |
+
$sweep = new WPSweep();
|
94 |
+
|
95 |
+
foreach ( $items as $key => $value ) {
|
96 |
+
$count = $sweep->count( $value );
|
97 |
+
if ( 0 !== $count && '0' !== $count ) {
|
98 |
+
$message = $sweep->sweep( $value );
|
99 |
+
WP_CLI::success( $message );
|
100 |
+
}
|
101 |
+
}
|
102 |
+
|
103 |
+
}
|
104 |
+
}
|
105 |
+
|
106 |
+
WP_CLI::add_command( 'sweep', 'WPSweep_Command' );
|
index.php
CHANGED
@@ -1,2 +1,2 @@
|
|
1 |
<?php
|
2 |
-
# Silence is golden.
|
1 |
<?php
|
2 |
+
# Silence is golden.
|
js/wp-sweep.js
CHANGED
@@ -1,95 +1,95 @@
|
|
1 |
(function ($) {
|
2 |
-
|
3 |
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
|
67 |
-
|
68 |
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
|
83 |
-
|
84 |
Page closing confirmation
|
85 |
https://developer.mozilla.org/en-US/docs/DOM/Mozilla_event_reference/beforeunload
|
86 |
*/
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
|
95 |
-
})(jQuery);
|
1 |
(function ($) {
|
2 |
+
'use strict';
|
3 |
|
4 |
+
$(function () {
|
5 |
+
var $body = $( 'body' ),
|
6 |
+
sweep = function($node) {
|
7 |
+
var $row = $node.parents( 'tr' );
|
8 |
|
9 |
+
// Add Active
|
10 |
+
$body.addClass( 'sweep-active' );
|
11 |
+
// Add Disabled
|
12 |
+
$node.prop( 'disabled', true ).text( wp_sweep.text_sweeping );
|
13 |
|
14 |
+
return $.get(ajaxurl, { action: $node.data( 'action' ), sweep_name: $node.data( 'sweep_name' ), sweep_type: $node.data( 'sweep_type' ), '_wpnonce': $node.data( 'nonce' ) }, function(data) {
|
15 |
+
if (data.success) {
|
16 |
+
var count = parseInt( data.data.count, 10 );
|
17 |
+
// Count Col
|
18 |
+
$( '.sweep-count', $row ).text( count.toLocaleString() );
|
19 |
+
// % Of Col
|
20 |
+
$( '.sweep-percentage', $row ).text( data.data.percentage );
|
21 |
+
// Action Col
|
22 |
+
if (count === 0) {
|
23 |
+
$node.parent( 'td' ).html( wp_sweep.text_na );
|
24 |
+
}
|
25 |
+
// Stats
|
26 |
+
$.each(data.data.stats, function(key, value) {
|
27 |
+
$( '.sweep-count-type-' + key ).text( parseInt( value, 10 ).toLocaleString() );
|
28 |
+
});
|
29 |
+
// Message
|
30 |
+
$row.parents( '.table-sweep' ).prev( '.sweep-message' ).html( '<div class="updated"><p>' + data.data.sweep + '</p></div>' );
|
31 |
+
// Hide Sweep Details
|
32 |
+
$( '.sweep-details', $row ).html( '' ).hide();
|
33 |
+
// Remove Active
|
34 |
+
$body.removeClass( 'sweep-active' );
|
35 |
+
// Remove Disabled
|
36 |
+
$node.prop( 'disabled', false ).text( wp_sweep.text_sweep );
|
37 |
+
}
|
38 |
+
});
|
39 |
+
};
|
40 |
|
41 |
+
$( '.btn-sweep' ).click(function(evt) {
|
42 |
+
evt.preventDefault();
|
43 |
+
sweep( $( this ) );
|
44 |
+
});
|
45 |
|
46 |
+
$( '.btn-sweep-details' ).click(function(evt) {
|
47 |
+
evt.preventDefault();
|
48 |
+
var $node = $( this );
|
49 |
|
50 |
+
$.get(ajaxurl, { action: $node.data( 'action' ), sweep_name: $node.data( 'sweep_name' ), sweep_type: $node.data( 'sweep_type' ), '_wpnonce': $node.data( 'nonce' ) }, function(data) {
|
51 |
+
if (data.success) {
|
52 |
+
if (data.data.length > 0) {
|
53 |
+
var html = '';
|
54 |
+
$.each(data.data, function(i, n) {
|
55 |
+
html += '<li>' + n + '</li>';
|
56 |
+
});
|
57 |
+
$( '.sweep-details', $node.parents( 'tr' ) ).html( '<ol>' + html + '</ol>' ).show();
|
58 |
+
}
|
59 |
+
}
|
60 |
+
});
|
61 |
+
});
|
62 |
|
63 |
+
$( '.btn-sweep-all' ).click(function(evt) {
|
64 |
+
evt.preventDefault();
|
65 |
+
var $node = $( this ), $btn_sweep = $( '.btn-sweep' ), sweep_all;
|
66 |
|
67 |
+
$node.prop( 'disabled', true ).text( wp_sweep.text_sweeping );
|
68 |
|
69 |
+
sweep_all = $btn_sweep.toArray().reduce(function(current, next) {
|
70 |
+
return current.then(function() {
|
71 |
+
return sweep( $( next ) );
|
72 |
+
});
|
73 |
+
}, $().promise());
|
74 |
|
75 |
+
sweep_all.done(function() {
|
76 |
+
// Remove Active
|
77 |
+
$body.removeClass( 'sweep-active' );
|
78 |
+
// Remove Disabled
|
79 |
+
$node.prop( 'disabled', false ).text( wp_sweep.text_sweep_all );
|
80 |
+
});
|
81 |
+
});
|
82 |
|
83 |
+
/*
|
84 |
Page closing confirmation
|
85 |
https://developer.mozilla.org/en-US/docs/DOM/Mozilla_event_reference/beforeunload
|
86 |
*/
|
87 |
+
$( window ).on('beforeunload', function (e) {
|
88 |
+
if ($body.hasClass( 'sweep-active' )) {
|
89 |
+
(e || window.event).returnValue = wp_sweep.text_close_warning; // Gecko and Trident
|
90 |
+
return wp_sweep.text_close_warning; // Gecko and WebKit
|
91 |
+
}
|
92 |
+
});
|
93 |
+
});
|
94 |
|
95 |
+
})(jQuery);
|
readme.txt
CHANGED
@@ -1,10 +1,13 @@
|
|
1 |
=== WP-Sweep ===
|
|
|
|
|
|
|
2 |
Contributors: GamerZ
|
3 |
-
Donate link:
|
4 |
Tags: sweep, clean, cleanup, clean up, optimize, orphan, unused, duplicated, posts, post meta, comments, comment meta, users, user meta, terms, term meta, term relationships, revisions, auto drafts, transient, database, tables, oembed
|
5 |
Requires at least: 4.4
|
6 |
-
Tested up to: 4.
|
7 |
-
Stable tag: 1.0.
|
8 |
License: GPLv2 or later
|
9 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
|
@@ -49,9 +52,6 @@ Following delete functions are used:
|
|
49 |
* delete_transient()
|
50 |
* delete_site_transient()
|
51 |
|
52 |
-
= Build Status =
|
53 |
-
[![Build Status](https://travis-ci.org/lesterchan/wp-sweep.svg?branch=master)](https://travis-ci.org/lesterchan/wp-sweep)
|
54 |
-
|
55 |
= Development =
|
56 |
* [https://github.com/lesterchan/wp-sweep](https://github.com/lesterchan/wp-sweep "https://github.com/lesterchan/wp-sweep")
|
57 |
|
@@ -62,6 +62,19 @@ Following delete functions are used:
|
|
62 |
I spent most of my free time creating, updating, maintaining and supporting these plugins, if you really love my plugins and could spare me a couple of bucks, I will really appreciate it. If not feel free to use it without any obligations.
|
63 |
|
64 |
== Changelog ==
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
65 |
= 1.0.7 =
|
66 |
* FIXES: Use custom query to delete Orphaned Term Relationship if wp_remove_object_terms() fails
|
67 |
|
1 |
=== WP-Sweep ===
|
2 |
+
|
3 |
+
[![Build Status](https://travis-ci.org/lesterchan/wp-sweep.svg?branch=master)](https://travis-ci.org/lesterchan/wp-sweep) [![Code Climate](https://codeclimate.com/github/lesterchan/wp-sweep/badges/gpa.svg)](https://codeclimate.com/github/lesterchan/wp-sweep) [![Issue Count](https://codeclimate.com/github/lesterchan/wp-sweep/badges/issue_count.svg)](https://codeclimate.com/github/lesterchan/wp-sweep)
|
4 |
+
|
5 |
Contributors: GamerZ
|
6 |
+
Donate link: https://lesterchan.net/site/donation/
|
7 |
Tags: sweep, clean, cleanup, clean up, optimize, orphan, unused, duplicated, posts, post meta, comments, comment meta, users, user meta, terms, term meta, term relationships, revisions, auto drafts, transient, database, tables, oembed
|
8 |
Requires at least: 4.4
|
9 |
+
Tested up to: 4.7
|
10 |
+
Stable tag: 1.0.10
|
11 |
License: GPLv2 or later
|
12 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
13 |
|
52 |
* delete_transient()
|
53 |
* delete_site_transient()
|
54 |
|
|
|
|
|
|
|
55 |
= Development =
|
56 |
* [https://github.com/lesterchan/wp-sweep](https://github.com/lesterchan/wp-sweep "https://github.com/lesterchan/wp-sweep")
|
57 |
|
62 |
I spent most of my free time creating, updating, maintaining and supporting these plugins, if you really love my plugins and could spare me a couple of bucks, I will really appreciate it. If not feel free to use it without any obligations.
|
63 |
|
64 |
== Changelog ==
|
65 |
+
= 1.0.10 =
|
66 |
+
* FIXED: Invalid plugin head 'This plugin has an invalid header.'
|
67 |
+
|
68 |
+
= 1.0.9 =
|
69 |
+
* NEW: Support for Codeclimate
|
70 |
+
* FIXES: Uses `get_sites()` on WordPress 4.6. This should fix deprecated notices.
|
71 |
+
* FIXES: Fixes translation placeholder count. Props @pedro-mendonca.
|
72 |
+
* FIXES: Use `manage_options` capability as it conflicts with Admin Menu Editor on multisite installs. Props @EusebiuOprinoiu.
|
73 |
+
|
74 |
+
= 1.0.8 =
|
75 |
+
* NEW: Added wp_sweep_excluded_taxonomies filter to allow more than just link_category taxonomy
|
76 |
+
* NEW: Support for WP-CLI `wp sweep`
|
77 |
+
|
78 |
= 1.0.7 =
|
79 |
* FIXES: Use custom query to delete Orphaned Term Relationship if wp_remove_object_terms() fails
|
80 |
|
uninstall.php
CHANGED
@@ -2,15 +2,19 @@
|
|
2 |
/*
|
3 |
* Uninstall WP-Sweep
|
4 |
*/
|
5 |
-
if ( !defined( 'WP_UNINSTALL_PLUGIN' ) )
|
6 |
-
exit
|
|
|
|
|
|
|
7 |
|
8 |
if ( is_multisite() ) {
|
9 |
-
$ms_sites = wp_get_sites();
|
10 |
|
11 |
-
if( 0 < sizeof( $ms_sites ) ) {
|
12 |
foreach ( $ms_sites as $ms_site ) {
|
13 |
-
|
|
|
14 |
plugin_uninstalled();
|
15 |
}
|
16 |
}
|
@@ -26,4 +30,5 @@ if ( is_multisite() ) {
|
|
26 |
* @access public
|
27 |
* @return void
|
28 |
*/
|
29 |
-
function plugin_uninstalled() {
|
|
2 |
/*
|
3 |
* Uninstall WP-Sweep
|
4 |
*/
|
5 |
+
if ( ! defined( 'WP_UNINSTALL_PLUGIN' ) ) {
|
6 |
+
exit;
|
7 |
+
}
|
8 |
+
|
9 |
+
|
10 |
|
11 |
if ( is_multisite() ) {
|
12 |
+
$ms_sites = function_exists( 'get_sites' ) ? get_sites() : wp_get_sites();
|
13 |
|
14 |
+
if ( 0 < sizeof( $ms_sites ) ) {
|
15 |
foreach ( $ms_sites as $ms_site ) {
|
16 |
+
$blog_id = class_exists( 'WP_Site' ) ? $ms_site->blog_id : $ms_site['blog_id'];
|
17 |
+
switch_to_blog( $blog_id );
|
18 |
plugin_uninstalled();
|
19 |
}
|
20 |
}
|
30 |
* @access public
|
31 |
* @return void
|
32 |
*/
|
33 |
+
function plugin_uninstalled() {
|
34 |
+
}
|
wp-sweep.php
CHANGED
@@ -1,29 +1,30 @@
|
|
1 |
<?php
|
2 |
/*
|
3 |
Plugin Name: WP-Sweep
|
4 |
-
Plugin URI:
|
5 |
Description: WP-Sweep allows you to clean up unused, orphaned and duplicated data in your WordPress. It cleans up revisions, auto drafts, unapproved comments, spam comments, trashed comments, orphan post meta, orphan comment meta, orphan user meta, orphan term relationships, unused terms, duplicated post meta, duplicated comment meta, duplicated user meta and transient options. It also optimizes your database tables.
|
6 |
-
Version: 1.0.
|
7 |
Author: Lester 'GaMerZ' Chan
|
8 |
-
Author URI:
|
9 |
Text Domain: wp-sweep
|
10 |
License: GPL2
|
11 |
*/
|
12 |
|
13 |
-
/*
|
|
|
14 |
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
*/
|
28 |
|
29 |
/**
|
@@ -31,7 +32,7 @@ License: GPL2
|
|
31 |
*
|
32 |
* @since 1.0.0
|
33 |
*/
|
34 |
-
define( 'WP_SWEEP_VERSION', '1.0.
|
35 |
|
36 |
/**
|
37 |
* WP-Sweep class
|
@@ -39,854 +40,909 @@ define( 'WP_SWEEP_VERSION', '1.0.6' );
|
|
39 |
* @since 1.0.0
|
40 |
*/
|
41 |
class WPSweep {
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
|
198 |
-
|
199 |
-
|
200 |
-
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
-
|
205 |
-
|
206 |
-
|
207 |
-
|
208 |
-
|
209 |
-
|
210 |
-
|
211 |
-
|
212 |
-
|
213 |
-
|
214 |
-
|
215 |
-
|
216 |
-
|
217 |
-
|
218 |
-
|
219 |
-
|
220 |
-
|
221 |
-
|
222 |
-
|
223 |
-
|
224 |
-
|
225 |
-
|
226 |
-
|
227 |
-
|
228 |
-
|
229 |
-
|
230 |
-
|
231 |
-
|
232 |
-
|
233 |
-
|
234 |
-
|
235 |
-
|
236 |
-
|
237 |
-
|
238 |
-
|
239 |
-
|
240 |
-
|
241 |
-
|
242 |
-
|
243 |
-
|
244 |
-
|
245 |
-
|
246 |
-
|
247 |
-
|
248 |
-
|
249 |
-
|
250 |
-
|
251 |
-
|
252 |
-
|
253 |
-
|
254 |
-
|
255 |
-
|
256 |
-
|
257 |
-
|
258 |
-
|
259 |
-
|
260 |
-
|
261 |
-
|
262 |
-
|
263 |
-
|
264 |
-
|
265 |
-
|
266 |
-
|
267 |
-
|
268 |
-
|
269 |
-
|
270 |
-
|
271 |
-
|
272 |
-
|
273 |
-
|
274 |
-
|
275 |
-
|
276 |
-
|
277 |
-
|
278 |
-
|
279 |
-
|
280 |
-
|
281 |
-
|
282 |
-
|
283 |
-
|
284 |
-
|
285 |
-
|
286 |
-
|
287 |
-
|
288 |
-
|
289 |
-
|
290 |
-
|
291 |
-
|
292 |
-
|
293 |
-
|
294 |
-
|
295 |
-
|
296 |
-
|
297 |
-
|
298 |
-
|
299 |
-
|
300 |
-
|
301 |
-
|
302 |
-
|
303 |
-
|
304 |
-
|
305 |
-
|
306 |
-
|
307 |
-
|
308 |
-
|
309 |
-
|
310 |
-
|
311 |
-
|
312 |
-
|
313 |
-
|
314 |
-
|
315 |
-
|
316 |
-
|
317 |
-
|
318 |
-
|
319 |
-
|
320 |
-
|
321 |
-
|
322 |
-
|
323 |
-
|
324 |
-
|
325 |
-
|
326 |
-
|
327 |
-
|
328 |
-
|
329 |
-
|
330 |
-
|
331 |
-
|
332 |
-
|
333 |
-
|
334 |
-
|
335 |
-
|
336 |
-
|
337 |
-
|
338 |
-
|
339 |
-
|
340 |
-
|
341 |
-
|
342 |
-
|
343 |
-
|
344 |
-
|
345 |
-
|
346 |
-
|
347 |
-
|
348 |
-
|
349 |
-
|
350 |
-
|
351 |
-
|
352 |
-
|
353 |
-
|
354 |
-
|
355 |
-
|
356 |
-
|
357 |
-
|
358 |
-
|
359 |
-
|
360 |
-
|
361 |
-
|
362 |
-
|
363 |
-
|
364 |
-
|
365 |
-
|
366 |
-
|
367 |
-
|
368 |
-
|
369 |
-
|
370 |
-
|
371 |
-
|
372 |
-
|
373 |
-
|
374 |
-
|
375 |
-
|
376 |
-
|
377 |
-
|
378 |
-
|
379 |
-
|
380 |
-
|
381 |
-
|
382 |
-
|
383 |
-
|
384 |
-
|
385 |
-
|
386 |
-
|
387 |
-
|
388 |
-
|
389 |
-
|
390 |
-
|
391 |
-
|
392 |
-
|
393 |
-
|
394 |
-
|
395 |
-
|
396 |
-
|
397 |
-
|
398 |
-
|
399 |
-
|
400 |
-
|
401 |
-
|
402 |
-
|
403 |
-
|
404 |
-
|
405 |
-
|
406 |
-
|
407 |
-
|
408 |
-
|
409 |
-
|
410 |
-
|
411 |
-
|
412 |
-
|
413 |
-
|
414 |
-
|
415 |
-
|
416 |
-
|
417 |
-
|
418 |
-
|
419 |
-
|
420 |
-
|
421 |
-
|
422 |
-
|
423 |
-
|
424 |
-
|
425 |
-
|
426 |
-
|
427 |
-
|
428 |
-
|
429 |
-
|
430 |
-
|
431 |
-
|
432 |
-
|
433 |
-
|
434 |
-
|
435 |
-
|
436 |
-
|
437 |
-
|
438 |
-
|
439 |
-
|
440 |
-
|
441 |
-
|
442 |
-
|
443 |
-
|
444 |
-
|
445 |
-
|
446 |
-
|
447 |
-
|
448 |
-
|
449 |
-
|
450 |
-
|
451 |
-
|
452 |
-
|
453 |
-
|
454 |
-
|
455 |
-
|
456 |
-
|
457 |
-
|
458 |
-
|
459 |
-
|
460 |
-
|
461 |
-
|
462 |
-
|
463 |
-
|
464 |
-
|
465 |
-
|
466 |
-
|
467 |
-
|
468 |
-
|
469 |
-
|
470 |
-
|
471 |
-
|
472 |
-
|
473 |
-
|
474 |
-
|
475 |
-
|
476 |
-
|
477 |
-
|
478 |
-
|
479 |
-
|
480 |
-
|
481 |
-
|
482 |
-
|
483 |
-
|
484 |
-
|
485 |
-
|
486 |
-
|
487 |
-
|
488 |
-
|
489 |
-
|
490 |
-
|
491 |
-
|
492 |
-
|
493 |
-
|
494 |
-
|
495 |
-
|
496 |
-
|
497 |
-
|
498 |
-
|
499 |
-
|
500 |
-
|
501 |
-
|
502 |
-
|
503 |
-
|
504 |
-
|
505 |
-
|
506 |
-
|
507 |
-
|
508 |
-
|
509 |
-
|
510 |
-
|
511 |
-
|
512 |
-
|
513 |
-
|
514 |
-
|
515 |
-
|
516 |
-
|
517 |
-
|
518 |
-
|
519 |
-
|
520 |
-
|
521 |
-
|
522 |
-
|
523 |
-
|
524 |
-
|
525 |
-
|
526 |
-
|
527 |
-
|
528 |
-
|
529 |
-
|
530 |
-
|
531 |
-
|
532 |
-
|
533 |
-
|
534 |
-
|
535 |
-
|
536 |
-
|
537 |
-
|
538 |
-
|
539 |
-
|
540 |
-
|
541 |
-
|
542 |
-
|
543 |
-
|
544 |
-
|
545 |
-
|
546 |
-
|
547 |
-
|
548 |
-
|
549 |
-
|
550 |
-
|
551 |
-
|
552 |
-
|
553 |
-
|
554 |
-
|
555 |
-
|
556 |
-
|
557 |
-
|
558 |
-
|
559 |
-
|
560 |
-
|
561 |
-
|
562 |
-
|
563 |
-
|
564 |
-
|
565 |
-
|
566 |
-
|
567 |
-
|
568 |
-
|
569 |
-
|
570 |
-
|
571 |
-
|
572 |
-
|
573 |
-
|
574 |
-
|
575 |
-
|
576 |
-
|
577 |
-
|
578 |
-
|
579 |
-
|
580 |
-
|
581 |
-
|
582 |
-
|
583 |
-
|
584 |
-
|
585 |
-
|
586 |
-
|
587 |
-
|
588 |
-
|
589 |
-
|
590 |
-
|
591 |
-
|
592 |
-
|
593 |
-
|
594 |
-
|
595 |
-
|
596 |
-
|
597 |
-
|
598 |
-
|
599 |
-
|
600 |
-
|
601 |
-
|
602 |
-
|
603 |
-
|
604 |
-
|
605 |
-
|
606 |
-
|
607 |
-
|
608 |
-
|
609 |
-
|
610 |
-
|
611 |
-
|
612 |
-
|
613 |
-
|
614 |
-
|
615 |
-
|
616 |
-
|
617 |
-
|
618 |
-
|
619 |
-
|
620 |
-
|
621 |
-
|
622 |
-
|
623 |
-
|
624 |
-
|
625 |
-
|
626 |
-
|
627 |
-
|
628 |
-
|
629 |
-
|
630 |
-
|
631 |
-
|
632 |
-
|
633 |
-
|
634 |
-
|
635 |
-
|
636 |
-
|
637 |
-
|
638 |
-
|
639 |
-
|
640 |
-
|
641 |
-
|
642 |
-
|
643 |
-
|
644 |
-
|
645 |
-
|
646 |
-
|
647 |
-
|
648 |
-
|
649 |
-
|
650 |
-
|
651 |
-
|
652 |
-
|
653 |
-
|
654 |
-
|
655 |
-
|
656 |
-
|
657 |
-
|
658 |
-
|
659 |
-
|
660 |
-
|
661 |
-
|
662 |
-
|
663 |
-
|
664 |
-
|
665 |
-
|
666 |
-
|
667 |
-
|
668 |
-
|
669 |
-
|
670 |
-
|
671 |
-
|
672 |
-
|
673 |
-
|
674 |
-
|
675 |
-
|
676 |
-
|
677 |
-
|
678 |
-
|
679 |
-
|
680 |
-
|
681 |
-
|
682 |
-
|
683 |
-
|
684 |
-
|
685 |
-
|
686 |
-
|
687 |
-
|
688 |
-
|
689 |
-
|
690 |
-
|
691 |
-
|
692 |
-
|
693 |
-
|
694 |
-
|
695 |
-
|
696 |
-
|
697 |
-
|
698 |
-
|
699 |
-
|
700 |
-
|
701 |
-
|
702 |
-
|
703 |
-
|
704 |
-
|
705 |
-
|
706 |
-
|
707 |
-
|
708 |
-
|
709 |
-
|
710 |
-
|
711 |
-
|
712 |
-
|
713 |
-
|
714 |
-
|
715 |
-
|
716 |
-
|
717 |
-
|
718 |
-
|
719 |
-
|
720 |
-
|
721 |
-
|
722 |
-
|
723 |
-
|
724 |
-
|
725 |
-
|
726 |
-
|
727 |
-
|
728 |
-
|
729 |
-
|
730 |
-
|
731 |
-
|
732 |
-
|
733 |
-
|
734 |
-
|
735 |
-
|
736 |
-
|
737 |
-
|
738 |
-
|
739 |
-
|
740 |
-
|
741 |
-
|
742 |
-
|
743 |
-
|
744 |
-
|
745 |
-
|
746 |
-
|
747 |
-
|
748 |
-
|
749 |
-
|
750 |
-
|
751 |
-
|
752 |
-
|
753 |
-
|
754 |
-
|
755 |
-
|
756 |
-
|
757 |
-
|
758 |
-
|
759 |
-
|
760 |
-
|
761 |
-
|
762 |
-
|
763 |
-
|
764 |
-
|
765 |
-
|
766 |
-
|
767 |
-
|
768 |
-
|
769 |
-
|
770 |
-
|
771 |
-
|
772 |
-
|
773 |
-
|
774 |
-
|
775 |
-
|
776 |
-
|
777 |
-
|
778 |
-
|
779 |
-
|
780 |
-
|
781 |
-
|
782 |
-
|
783 |
-
|
784 |
-
|
785 |
-
|
786 |
-
|
787 |
-
|
788 |
-
|
789 |
-
|
790 |
-
|
791 |
-
|
792 |
-
|
793 |
-
|
794 |
-
|
795 |
-
|
796 |
-
|
797 |
-
|
798 |
-
|
799 |
-
|
800 |
-
|
801 |
-
|
802 |
-
|
803 |
-
|
804 |
-
|
805 |
-
|
806 |
-
|
807 |
-
|
808 |
-
|
809 |
-
|
810 |
-
|
811 |
-
|
812 |
-
|
813 |
-
|
814 |
-
|
815 |
-
|
816 |
-
|
817 |
-
|
818 |
-
|
819 |
-
|
820 |
-
|
821 |
-
|
822 |
-
|
823 |
-
|
824 |
-
|
825 |
-
|
826 |
-
|
827 |
-
|
828 |
-
|
829 |
-
|
830 |
-
|
831 |
-
|
832 |
-
|
833 |
-
|
834 |
-
|
835 |
-
|
836 |
-
|
837 |
-
|
838 |
-
|
839 |
-
|
840 |
-
|
841 |
-
|
842 |
-
|
843 |
-
|
844 |
-
|
845 |
-
|
846 |
-
|
847 |
-
|
848 |
-
|
849 |
-
|
850 |
-
|
851 |
-
|
852 |
-
|
853 |
-
|
854 |
-
|
855 |
-
|
856 |
-
|
857 |
-
|
858 |
-
|
859 |
-
|
860 |
-
|
861 |
-
|
862 |
-
|
863 |
-
|
864 |
-
|
865 |
-
|
866 |
-
|
867 |
-
|
868 |
-
|
869 |
-
|
870 |
-
|
871 |
-
|
872 |
-
|
873 |
-
|
874 |
-
|
875 |
-
|
876 |
-
|
877 |
-
|
878 |
-
|
879 |
-
|
880 |
-
|
881 |
-
|
882 |
-
|
883 |
-
|
884 |
-
|
885 |
-
|
886 |
-
|
887 |
-
|
888 |
-
|
889 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
890 |
}
|
891 |
|
892 |
/**
|
1 |
<?php
|
2 |
/*
|
3 |
Plugin Name: WP-Sweep
|
4 |
+
Plugin URI: https://lesterchan.net/portfolio/programming/php/
|
5 |
Description: WP-Sweep allows you to clean up unused, orphaned and duplicated data in your WordPress. It cleans up revisions, auto drafts, unapproved comments, spam comments, trashed comments, orphan post meta, orphan comment meta, orphan user meta, orphan term relationships, unused terms, duplicated post meta, duplicated comment meta, duplicated user meta and transient options. It also optimizes your database tables.
|
6 |
+
Version: 1.0.10
|
7 |
Author: Lester 'GaMerZ' Chan
|
8 |
+
Author URI: https://lesterchan.net
|
9 |
Text Domain: wp-sweep
|
10 |
License: GPL2
|
11 |
*/
|
12 |
|
13 |
+
/*
|
14 |
+
Copyright 2017 Lester Chan (email : lesterchan@gmail.com)
|
15 |
|
16 |
+
This program is free software; you can redistribute it and/or modify
|
17 |
+
it under the terms of the GNU General Public License, version 2, as
|
18 |
+
published by the Free Software Foundation.
|
19 |
|
20 |
+
This program is distributed in the hope that it will be useful,
|
21 |
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
22 |
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
23 |
+
GNU General Public License for more details.
|
24 |
|
25 |
+
You should have received a copy of the GNU General Public License
|
26 |
+
along with this program; if not, write to the Free Software
|
27 |
+
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
28 |
*/
|
29 |
|
30 |
/**
|
32 |
*
|
33 |
* @since 1.0.0
|
34 |
*/
|
35 |
+
define( 'WP_SWEEP_VERSION', '1.0.10' );
|
36 |
|
37 |
/**
|
38 |
* WP-Sweep class
|
40 |
* @since 1.0.0
|
41 |
*/
|
42 |
class WPSweep {
|
43 |
+
/**
|
44 |
+
* Limit the number of items to show for sweep details
|
45 |
+
*
|
46 |
+
* @since 1.0.3
|
47 |
+
*
|
48 |
+
* @access public
|
49 |
+
* @var int
|
50 |
+
*/
|
51 |
+
public $limit_details = 500;
|
52 |
+
|
53 |
+
/**
|
54 |
+
* Static instance
|
55 |
+
*
|
56 |
+
* @since 1.0.0
|
57 |
+
*
|
58 |
+
* @access private
|
59 |
+
* @var $instance
|
60 |
+
*/
|
61 |
+
private static $instance;
|
62 |
+
|
63 |
+
/**
|
64 |
+
* Constructor method
|
65 |
+
*
|
66 |
+
* @since 1.0.0
|
67 |
+
*
|
68 |
+
* @access public
|
69 |
+
*/
|
70 |
+
public function __construct() {
|
71 |
+
// Add Plugin Hooks
|
72 |
+
add_action( 'plugins_loaded', array( $this, 'add_hooks' ) );
|
73 |
+
|
74 |
+
// Load Translation
|
75 |
+
load_plugin_textdomain( 'wp-sweep' );
|
76 |
+
|
77 |
+
// Plugin Activation/Deactivation
|
78 |
+
register_activation_hook( __FILE__, array( $this, 'plugin_activation' ) );
|
79 |
+
register_deactivation_hook( __FILE__, array( $this, 'plugin_deactivation' ) );
|
80 |
+
}
|
81 |
+
|
82 |
+
/**
|
83 |
+
* Initializes the plugin object and returns its instance
|
84 |
+
*
|
85 |
+
* @since 1.0.0
|
86 |
+
*
|
87 |
+
* @access public
|
88 |
+
* @return object The plugin object instance
|
89 |
+
*/
|
90 |
+
public static function get_instance() {
|
91 |
+
if ( ! isset( self::$instance ) ) {
|
92 |
+
self::$instance = new self();
|
93 |
+
}
|
94 |
+
return self::$instance;
|
95 |
+
}
|
96 |
+
|
97 |
+
/**
|
98 |
+
* Init this plugin
|
99 |
+
*
|
100 |
+
* @since 1.0.0
|
101 |
+
*
|
102 |
+
* @access public
|
103 |
+
* @return void
|
104 |
+
*/
|
105 |
+
public function init() {
|
106 |
+
// include class for WP CLI command
|
107 |
+
if ( defined( 'WP_CLI' ) ) {
|
108 |
+
require __DIR__ . '/class-command.php';
|
109 |
+
}
|
110 |
+
}
|
111 |
+
|
112 |
+
/**
|
113 |
+
* Adds all the plugin hooks
|
114 |
+
*
|
115 |
+
* @since 1.0.0
|
116 |
+
*
|
117 |
+
* @access public
|
118 |
+
* @return void
|
119 |
+
*/
|
120 |
+
public function add_hooks() {
|
121 |
+
// Actions
|
122 |
+
add_action( 'init', array( $this, 'init' ) );
|
123 |
+
add_action( 'admin_menu', array( $this, 'admin_menu' ) );
|
124 |
+
add_action( 'admin_enqueue_scripts', array( $this, 'admin_enqueue_scripts' ) );
|
125 |
+
add_action( 'wp_ajax_sweep_details', array( $this, 'ajax_sweep_details' ) );
|
126 |
+
add_action( 'wp_ajax_sweep', array( $this, 'ajax_sweep' ) );
|
127 |
+
}
|
128 |
+
|
129 |
+
/**
|
130 |
+
* Enqueue JS/CSS files used for admin
|
131 |
+
*
|
132 |
+
* @since 1.0.3
|
133 |
+
*
|
134 |
+
* @access public
|
135 |
+
* @param string $hook
|
136 |
+
* @return void
|
137 |
+
*/
|
138 |
+
public function admin_enqueue_scripts( $hook ) {
|
139 |
+
if ( 'wp-sweep/admin.php' !== $hook ) {
|
140 |
+
return;
|
141 |
+
}
|
142 |
+
|
143 |
+
if ( defined( 'WP_DEBUG' ) && WP_DEBUG ) {
|
144 |
+
wp_enqueue_script( 'wp-sweep', plugins_url( 'wp-sweep/js/wp-sweep.js' ), array( 'jquery' ) , WP_SWEEP_VERSION, true );
|
145 |
+
} else {
|
146 |
+
wp_enqueue_script( 'wp-sweep', plugins_url( 'wp-sweep/js/wp-sweep.min.js' ), array( 'jquery' ) , WP_SWEEP_VERSION, true );
|
147 |
+
}
|
148 |
+
|
149 |
+
wp_localize_script( 'wp-sweep', 'wp_sweep', array(
|
150 |
+
'text_close_warning' => __( 'Sweeping is in progress. If you leave now, the process won\'t be completed.', 'wp-sweep' ),
|
151 |
+
'text_sweep' => __( 'Sweep', 'wp-sweep' ),
|
152 |
+
'text_sweep_all' => __( 'Sweep All', 'wp-sweep' ),
|
153 |
+
'text_sweeping' => __( 'Sweeping ...', 'wp-sweep' ),
|
154 |
+
'text_na' => __( 'N/A', 'wp-sweep' ),
|
155 |
+
) );
|
156 |
+
}
|
157 |
+
|
158 |
+
/**
|
159 |
+
* Admin menu
|
160 |
+
*
|
161 |
+
* @since 1.0.3
|
162 |
+
*
|
163 |
+
* @access public
|
164 |
+
* @return void
|
165 |
+
*/
|
166 |
+
public function admin_menu() {
|
167 |
+
add_management_page( __( 'Sweep', 'wp-sweep' ), __( 'Sweep', 'wp-sweep' ), 'manage_options', 'wp-sweep/admin.php' );
|
168 |
+
}
|
169 |
+
|
170 |
+
|
171 |
+
/**
|
172 |
+
* Sweep Details loaded via AJAX
|
173 |
+
*
|
174 |
+
* @since 1.0.3
|
175 |
+
*
|
176 |
+
* @access public
|
177 |
+
* @return void
|
178 |
+
*/
|
179 |
+
public function ajax_sweep_details() {
|
180 |
+
if ( ! empty( $_GET['action'] )
|
181 |
+
&& 'sweep_details' === $_GET['action']
|
182 |
+
&& ! empty( $_GET['sweep_name'] )
|
183 |
+
&& ! empty( $_GET['sweep_type'] )
|
184 |
+
) {
|
185 |
+
// Verify Referer
|
186 |
+
if ( ! check_admin_referer( 'wp_sweep_details_' . $_GET['sweep_name'] ) ) {
|
187 |
+
wp_send_json_error( array(
|
188 |
+
'error' => __( 'Failed to verify referrer.', 'wp-sweep' ),
|
189 |
+
) );
|
190 |
+
} else {
|
191 |
+
wp_send_json_success( $this->details( $_GET['sweep_name'] ) );
|
192 |
+
}
|
193 |
+
}
|
194 |
+
}
|
195 |
+
|
196 |
+
/**
|
197 |
+
* Sweep via AJAX
|
198 |
+
*
|
199 |
+
* @since 1.0.3
|
200 |
+
*
|
201 |
+
* @access public
|
202 |
+
* @return void
|
203 |
+
*/
|
204 |
+
public function ajax_sweep() {
|
205 |
+
if ( ! empty( $_GET['action'] )
|
206 |
+
&& 'sweep' === $_GET['action']
|
207 |
+
&& ! empty( $_GET['sweep_name'] )
|
208 |
+
&& ! empty( $_GET['sweep_type'] )
|
209 |
+
) {
|
210 |
+
// Verify Referer
|
211 |
+
if ( ! check_admin_referer( 'wp_sweep_' . $_GET['sweep_name'] ) ) {
|
212 |
+
wp_send_json_error( array(
|
213 |
+
'error' => __( 'Failed to verify referrer.', 'wp-sweep' ),
|
214 |
+
) );
|
215 |
+
} else {
|
216 |
+
$sweep = $this->sweep( $_GET['sweep_name'] );
|
217 |
+
$count = $this->count( $_GET['sweep_name'] );
|
218 |
+
$total_count = $this->total_count( $_GET['sweep_type'] );
|
219 |
+
$total_stats = array();
|
220 |
+
switch ( $_GET['sweep_type'] ) {
|
221 |
+
case 'posts':
|
222 |
+
case 'postmeta':
|
223 |
+
$total_stats = array( 'posts' => $this->total_count( 'posts' ), 'postmeta' => $this->total_count( 'postmeta' ) );
|
224 |
+
break;
|
225 |
+
case 'comments':
|
226 |
+
case 'commentmeta':
|
227 |
+
$total_stats = array( 'comments' => $this->total_count( 'comments' ), 'commentmeta' => $this->total_count( 'commentmeta' ) );
|
228 |
+
break;
|
229 |
+
case 'users':
|
230 |
+
case 'usermeta':
|
231 |
+
$total_stats = array( 'users' => $this->total_count( 'users' ), 'usermeta' => $this->total_count( 'usermeta' ) );
|
232 |
+
break;
|
233 |
+
case 'term_relationships':
|
234 |
+
case 'term_taxonomy':
|
235 |
+
case 'terms':
|
236 |
+
case 'termmeta':
|
237 |
+
$total_stats = array( 'term_relationships' => $this->total_count( 'term_relationships' ), 'term_taxonomy' => $this->total_count( 'term_taxonomy' ), 'terms' => $this->total_count( 'terms' ), 'termmeta' => $this->total_count( 'termmeta' ) );
|
238 |
+
break;
|
239 |
+
case 'options':
|
240 |
+
$total_stats = array( 'options' => $this->total_count( 'options' ) );
|
241 |
+
break;
|
242 |
+
case 'tables':
|
243 |
+
$total_stats = array( 'tables' => $this->total_count( 'tables' ) );
|
244 |
+
break;
|
245 |
+
}
|
246 |
+
|
247 |
+
wp_send_json_success( array(
|
248 |
+
'sweep' => $sweep,
|
249 |
+
'count' => $count,
|
250 |
+
'total' => $total_count,
|
251 |
+
'percentage' => $this->format_percentage( $count, $total_count ),
|
252 |
+
'stats' => $total_stats,
|
253 |
+
) );
|
254 |
+
}
|
255 |
+
}
|
256 |
+
}
|
257 |
+
|
258 |
+
/**
|
259 |
+
* Count the number of total items belonging to each sweep
|
260 |
+
*
|
261 |
+
* @since 1.0.0
|
262 |
+
*
|
263 |
+
* @access public
|
264 |
+
* @param string $name
|
265 |
+
* @return int Number of items belonging to each sweep
|
266 |
+
*/
|
267 |
+
public function total_count( $name ) {
|
268 |
+
global $wpdb;
|
269 |
+
|
270 |
+
$count = 0;
|
271 |
+
|
272 |
+
switch ( $name ) {
|
273 |
+
case 'posts':
|
274 |
+
$count = $wpdb->get_var( "SELECT COUNT(*) FROM $wpdb->posts" );
|
275 |
+
break;
|
276 |
+
case 'postmeta':
|
277 |
+
$count = $wpdb->get_var( "SELECT COUNT(*) FROM $wpdb->postmeta" );
|
278 |
+
break;
|
279 |
+
case 'comments':
|
280 |
+
$count = $wpdb->get_var( "SELECT COUNT(*) FROM $wpdb->comments" );
|
281 |
+
break;
|
282 |
+
case 'commentmeta':
|
283 |
+
$count = $wpdb->get_var( "SELECT COUNT(*) FROM $wpdb->commentmeta" );
|
284 |
+
break;
|
285 |
+
case 'users':
|
286 |
+
$count = $wpdb->get_var( "SELECT COUNT(*) FROM $wpdb->users" );
|
287 |
+
break;
|
288 |
+
case 'usermeta':
|
289 |
+
$count = $wpdb->get_var( "SELECT COUNT(*) FROM $wpdb->usermeta" );
|
290 |
+
break;
|
291 |
+
case 'term_relationships':
|
292 |
+
$count = $wpdb->get_var( "SELECT COUNT(*) FROM $wpdb->term_relationships" );
|
293 |
+
break;
|
294 |
+
case 'term_taxonomy':
|
295 |
+
$count = $wpdb->get_var( "SELECT COUNT(*) FROM $wpdb->term_taxonomy" );
|
296 |
+
break;
|
297 |
+
case 'terms':
|
298 |
+
$count = $wpdb->get_var( "SELECT COUNT(*) FROM $wpdb->terms" );
|
299 |
+
break;
|
300 |
+
case 'termmeta':
|
301 |
+
$count = $wpdb->get_var( "SELECT COUNT(*) FROM $wpdb->termmeta" );
|
302 |
+
break;
|
303 |
+
case 'options':
|
304 |
+
$count = $wpdb->get_var( "SELECT COUNT(*) FROM $wpdb->options" );
|
305 |
+
break;
|
306 |
+
case 'tables':
|
307 |
+
$count = sizeof( $wpdb->get_col( 'SHOW TABLES' ) );
|
308 |
+
break;
|
309 |
+
}
|
310 |
+
|
311 |
+
return apply_filters( 'wp_sweep_total_count', $count, $name );
|
312 |
+
}
|
313 |
+
|
314 |
+
/**
|
315 |
+
* Count the number of items belonging to each sweep
|
316 |
+
*
|
317 |
+
* @since 1.0.0
|
318 |
+
*
|
319 |
+
* @access public
|
320 |
+
* @param string $name
|
321 |
+
* @return int Number of items belonging to each sweep
|
322 |
+
*/
|
323 |
+
public function count( $name ) {
|
324 |
+
global $wpdb;
|
325 |
+
|
326 |
+
$count = 0;
|
327 |
+
|
328 |
+
switch ( $name ) {
|
329 |
+
case 'revisions':
|
330 |
+
$count = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(ID) FROM $wpdb->posts WHERE post_type = %s", 'revision' ) );
|
331 |
+
break;
|
332 |
+
case 'auto_drafts':
|
333 |
+
$count = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(ID) FROM $wpdb->posts WHERE post_status = %s", 'auto-draft' ) );
|
334 |
+
break;
|
335 |
+
case 'deleted_posts':
|
336 |
+
$count = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(ID) FROM $wpdb->posts WHERE post_status = %s", 'trash' ) );
|
337 |
+
break;
|
338 |
+
case 'unapproved_comments':
|
339 |
+
$count = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(comment_ID) FROM $wpdb->comments WHERE comment_approved = %s", '0' ) );
|
340 |
+
break;
|
341 |
+
case 'spam_comments':
|
342 |
+
$count = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(comment_ID) FROM $wpdb->comments WHERE comment_approved = %s", 'spam' ) );
|
343 |
+
break;
|
344 |
+
case 'deleted_comments':
|
345 |
+
$count = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(comment_ID) FROM $wpdb->comments WHERE (comment_approved = %s OR comment_approved = %s)", 'trash', 'post-trashed' ) );
|
346 |
+
break;
|
347 |
+
case 'transient_options':
|
348 |
+
$count = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(option_id) FROM $wpdb->options WHERE option_name LIKE(%s)", '%_transient_%' ) );
|
349 |
+
break;
|
350 |
+
case 'orphan_postmeta':
|
351 |
+
$count = $wpdb->get_var( "SELECT COUNT(meta_id) FROM $wpdb->postmeta WHERE post_id NOT IN (SELECT ID FROM $wpdb->posts)" );
|
352 |
+
break;
|
353 |
+
case 'orphan_commentmeta':
|
354 |
+
$count = $wpdb->get_var( "SELECT COUNT(meta_id) FROM $wpdb->commentmeta WHERE comment_id NOT IN (SELECT comment_ID FROM $wpdb->comments)" );
|
355 |
+
break;
|
356 |
+
case 'orphan_usermeta':
|
357 |
+
$count = $wpdb->get_var( "SELECT COUNT(umeta_id) FROM $wpdb->usermeta WHERE user_id NOT IN (SELECT ID FROM $wpdb->users)" );
|
358 |
+
break;
|
359 |
+
case 'orphan_termmeta':
|
360 |
+
$count = $wpdb->get_var( "SELECT COUNT(meta_id) FROM $wpdb->termmeta WHERE term_id NOT IN (SELECT term_id FROM $wpdb->terms)" );
|
361 |
+
break;
|
362 |
+
case 'orphan_term_relationships':
|
363 |
+
$count = $wpdb->get_var( "SELECT COUNT(object_id) FROM $wpdb->term_relationships AS tr INNER JOIN $wpdb->term_taxonomy AS tt ON tr.term_taxonomy_id = tt.term_taxonomy_id WHERE tt.taxonomy NOT IN ('" . implode( '\',\'', $this->get_excluded_taxonomies() ) . "') AND tr.object_id NOT IN (SELECT ID FROM $wpdb->posts)" );
|
364 |
+
break;
|
365 |
+
case 'unused_terms':
|
366 |
+
$count = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(t.term_id) FROM $wpdb->terms AS t INNER JOIN $wpdb->term_taxonomy AS tt ON t.term_id = tt.term_id WHERE tt.count = %d AND t.term_id NOT IN (" . implode( ',', $this->get_excluded_termids() ) . ')', 0 ) );
|
367 |
+
break;
|
368 |
+
case 'duplicated_postmeta':
|
369 |
+
$query = $wpdb->get_col( $wpdb->prepare( "SELECT COUNT(meta_id) AS count FROM $wpdb->postmeta GROUP BY post_id, meta_key, meta_value HAVING count > %d", 1 ) );
|
370 |
+
if ( is_array( $query ) ) {
|
371 |
+
$count = array_sum( array_map( 'intval', $query ) );
|
372 |
+
}
|
373 |
+
break;
|
374 |
+
case 'duplicated_commentmeta':
|
375 |
+
$query = $wpdb->get_col( $wpdb->prepare( "SELECT COUNT(meta_id) AS count FROM $wpdb->commentmeta GROUP BY comment_id, meta_key, meta_value HAVING count > %d", 1 ) );
|
376 |
+
if ( is_array( $query ) ) {
|
377 |
+
$count = array_sum( array_map( 'intval', $query ) );
|
378 |
+
}
|
379 |
+
break;
|
380 |
+
case 'duplicated_usermeta':
|
381 |
+
$query = $wpdb->get_col( $wpdb->prepare( "SELECT COUNT(umeta_id) AS count FROM $wpdb->usermeta GROUP BY user_id, meta_key, meta_value HAVING count > %d", 1 ) );
|
382 |
+
if ( is_array( $query ) ) {
|
383 |
+
$count = array_sum( array_map( 'intval', $query ) );
|
384 |
+
}
|
385 |
+
break;
|
386 |
+
case 'duplicated_termmeta':
|
387 |
+
$query = $wpdb->get_col( $wpdb->prepare( "SELECT COUNT(meta_id) AS count FROM $wpdb->termmeta GROUP BY term_id, meta_key, meta_value HAVING count > %d", 1 ) );
|
388 |
+
if ( is_array( $query ) ) {
|
389 |
+
$count = array_sum( array_map( 'intval', $query ) );
|
390 |
+
}
|
391 |
+
break;
|
392 |
+
case 'optimize_database':
|
393 |
+
$count = sizeof( $wpdb->get_col( 'SHOW TABLES' ) );
|
394 |
+
break;
|
395 |
+
case 'oembed_postmeta':
|
396 |
+
$count = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(meta_id) FROM $wpdb->postmeta WHERE meta_key LIKE(%s)", '%_oembed_%' ) );
|
397 |
+
break;
|
398 |
+
}
|
399 |
+
|
400 |
+
return apply_filters( 'wp_sweep_count', $count, $name );
|
401 |
+
}
|
402 |
+
|
403 |
+
/**
|
404 |
+
* Return more details about a sweep
|
405 |
+
*
|
406 |
+
* @since 1.0.3
|
407 |
+
*
|
408 |
+
* @access public
|
409 |
+
* @param string $name
|
410 |
+
* @return int Number of items belonging to each sweep
|
411 |
+
*/
|
412 |
+
public function details( $name ) {
|
413 |
+
global $wpdb;
|
414 |
+
|
415 |
+
$details = array();
|
416 |
+
|
417 |
+
switch ( $name ) {
|
418 |
+
case 'revisions':
|
419 |
+
$details = $wpdb->get_col( $wpdb->prepare( "SELECT post_title FROM $wpdb->posts WHERE post_type = %s LIMIT %d", 'revision', $this->limit_details ) );
|
420 |
+
break;
|
421 |
+
case 'auto_drafts':
|
422 |
+
$details = $wpdb->get_col( $wpdb->prepare( "SELECT post_title FROM $wpdb->posts WHERE post_status = %s LIMIT %d", 'auto-draft', $this->limit_details ) );
|
423 |
+
break;
|
424 |
+
case 'deleted_posts':
|
425 |
+
$details = $wpdb->get_col( $wpdb->prepare( "SELECT post_title FROM $wpdb->posts WHERE post_status = %s LIMIT %d", 'trash', $this->limit_details ) );
|
426 |
+
break;
|
427 |
+
case 'unapproved_comments':
|
428 |
+
$details = $wpdb->get_col( $wpdb->prepare( "SELECT comment_author FROM $wpdb->comments WHERE comment_approved = %s LIMIT %d", '0', $this->limit_details ) );
|
429 |
+
break;
|
430 |
+
case 'spam_comments':
|
431 |
+
$details = $wpdb->get_col( $wpdb->prepare( "SELECT comment_author FROM $wpdb->comments WHERE comment_approved = %s LIMIT %d", 'spam', $this->limit_details ) );
|
432 |
+
break;
|
433 |
+
case 'deleted_comments':
|
434 |
+
$details = $wpdb->get_col( $wpdb->prepare( "SELECT comment_author FROM $wpdb->comments WHERE (comment_approved = %s OR comment_approved = %s) LIMIT %d", 'trash', 'post-trashed', $this->limit_details ) );
|
435 |
+
break;
|
436 |
+
case 'transient_options':
|
437 |
+
$details = $wpdb->get_col( $wpdb->prepare( "SELECT option_name FROM $wpdb->options WHERE option_name LIKE(%s) LIMIT %d", '%_transient_%', $this->limit_details ) );
|
438 |
+
break;
|
439 |
+
case 'orphan_postmeta':
|
440 |
+
$details = $wpdb->get_col( $wpdb->prepare( "SELECT meta_key FROM $wpdb->postmeta WHERE post_id NOT IN (SELECT ID FROM $wpdb->posts) LIMIT %d", $this->limit_details ) );
|
441 |
+
break;
|
442 |
+
case 'orphan_commentmeta':
|
443 |
+
$details = $wpdb->get_col( $wpdb->prepare( "SELECT meta_key FROM $wpdb->commentmeta WHERE comment_id NOT IN (SELECT comment_ID FROM $wpdb->comments) LIMIT %d", $this->limit_details ) );
|
444 |
+
break;
|
445 |
+
case 'orphan_usermeta':
|
446 |
+
$details = $wpdb->get_col( $wpdb->prepare( "SELECT meta_key FROM $wpdb->usermeta WHERE user_id NOT IN (SELECT ID FROM $wpdb->users) LIMIT %d", $this->limit_details ) );
|
447 |
+
break;
|
448 |
+
case 'orphan_termmeta':
|
449 |
+
$details = $wpdb->get_col( $wpdb->prepare( "SELECT meta_key FROM $wpdb->termmeta WHERE term_id NOT IN (SELECT term_id FROM $wpdb->terms) LIMIT %d", $this->limit_details ) );
|
450 |
+
break;
|
451 |
+
case 'orphan_term_relationships':
|
452 |
+
$details = $wpdb->get_col( $wpdb->prepare( "SELECT tt.taxonomy FROM $wpdb->term_relationships AS tr INNER JOIN $wpdb->term_taxonomy AS tt ON tr.term_taxonomy_id = tt.term_taxonomy_id WHERE tt.taxonomy NOT IN ('" . implode( '\',\'', $this->get_excluded_taxonomies() ) . "') AND tr.object_id NOT IN (SELECT ID FROM $wpdb->posts) LIMIT %d", $this->limit_details ) );
|
453 |
+
break;
|
454 |
+
case 'unused_terms':
|
455 |
+
$details = $wpdb->get_col( $wpdb->prepare( "SELECT t.name FROM $wpdb->terms AS t INNER JOIN $wpdb->term_taxonomy AS tt ON t.term_id = tt.term_id WHERE tt.count = %d AND t.term_id NOT IN (" . implode( ',', $this->get_excluded_termids() ) . ') LIMIT %d', 0, $this->limit_details ) );
|
456 |
+
break;
|
457 |
+
case 'duplicated_postmeta':
|
458 |
+
$query = $wpdb->get_results( $wpdb->prepare( "SELECT COUNT(meta_id) AS count, meta_key FROM $wpdb->postmeta GROUP BY post_id, meta_key, meta_value HAVING count > %d LIMIT %d", 1, $this->limit_details ) );
|
459 |
+
$details = array();
|
460 |
+
if ( $query ) {
|
461 |
+
foreach ( $query as $meta ) {
|
462 |
+
$details[] = $meta->meta_key;
|
463 |
+
}
|
464 |
+
}
|
465 |
+
break;
|
466 |
+
case 'duplicated_commentmeta':
|
467 |
+
$query = $wpdb->get_results( $wpdb->prepare( "SELECT COUNT(meta_id) AS count, meta_key FROM $wpdb->commentmeta GROUP BY comment_id, meta_key, meta_value HAVING count > %d LIMIT %d", 1, $this->limit_details ) );
|
468 |
+
$details = array();
|
469 |
+
if ( $query ) {
|
470 |
+
foreach ( $query as $meta ) {
|
471 |
+
$details[] = $meta->meta_key;
|
472 |
+
}
|
473 |
+
}
|
474 |
+
break;
|
475 |
+
case 'duplicated_usermeta':
|
476 |
+
$query = $wpdb->get_results( $wpdb->prepare( "SELECT COUNT(umeta_id) AS count, meta_key FROM $wpdb->usermeta GROUP BY user_id, meta_key, meta_value HAVING count > %d LIMIT %d", 1, $this->limit_details ) );
|
477 |
+
$details = array();
|
478 |
+
if ( $query ) {
|
479 |
+
foreach ( $query as $meta ) {
|
480 |
+
$details[] = $meta->meta_key;
|
481 |
+
}
|
482 |
+
}
|
483 |
+
break;
|
484 |
+
case 'duplicated_termmeta':
|
485 |
+
$query = $wpdb->get_results( $wpdb->prepare( "SELECT COUNT(meta_id) AS count, meta_key FROM $wpdb->termmeta GROUP BY term_id, meta_key, meta_value HAVING count > %d LIMIT %d", 1, $this->limit_details ) );
|
486 |
+
$details = array();
|
487 |
+
if ( $query ) {
|
488 |
+
foreach ( $query as $meta ) {
|
489 |
+
$details[] = $meta->meta_key;
|
490 |
+
}
|
491 |
+
}
|
492 |
+
break;
|
493 |
+
case 'optimize_database':
|
494 |
+
$details = $wpdb->get_col( 'SHOW TABLES' );
|
495 |
+
break;
|
496 |
+
case 'oembed_postmeta':
|
497 |
+
$details = $wpdb->get_col( $wpdb->prepare( "SELECT meta_key FROM $wpdb->postmeta WHERE meta_key LIKE(%s) LIMIT %d", '%_oembed_%', $this->limit_details ) );
|
498 |
+
break;
|
499 |
+
}
|
500 |
+
|
501 |
+
return apply_filters( 'wp_sweep_details', $details, $name );
|
502 |
+
}
|
503 |
+
|
504 |
+
/**
|
505 |
+
* Does the sweeping/cleaning up
|
506 |
+
*
|
507 |
+
* @since 1.0.0
|
508 |
+
*
|
509 |
+
* @access public
|
510 |
+
* @param string $name
|
511 |
+
* @return string Processed message
|
512 |
+
*/
|
513 |
+
public function sweep( $name ) {
|
514 |
+
global $wpdb;
|
515 |
+
|
516 |
+
$message = '';
|
517 |
+
|
518 |
+
switch ( $name ) {
|
519 |
+
case 'revisions':
|
520 |
+
$query = $wpdb->get_col( $wpdb->prepare( "SELECT ID FROM $wpdb->posts WHERE post_type = %s", 'revision' ) );
|
521 |
+
if ( $query ) {
|
522 |
+
foreach ( $query as $id ) {
|
523 |
+
wp_delete_post_revision( intval( $id ) );
|
524 |
+
}
|
525 |
+
|
526 |
+
$message = sprintf( __( '%s Revisions Processed', 'wp-sweep' ), number_format_i18n( sizeof( $query ) ) );
|
527 |
+
}
|
528 |
+
break;
|
529 |
+
case 'auto_drafts':
|
530 |
+
$query = $wpdb->get_col( $wpdb->prepare( "SELECT ID FROM $wpdb->posts WHERE post_status = %s", 'auto-draft' ) );
|
531 |
+
if ( $query ) {
|
532 |
+
foreach ( $query as $id ) {
|
533 |
+
wp_delete_post( intval( $id ), true );
|
534 |
+
}
|
535 |
+
|
536 |
+
$message = sprintf( __( '%s Auto Drafts Processed', 'wp-sweep' ), number_format_i18n( sizeof( $query ) ) );
|
537 |
+
}
|
538 |
+
break;
|
539 |
+
case 'deleted_posts':
|
540 |
+
$query = $wpdb->get_col( $wpdb->prepare( "SELECT ID FROM $wpdb->posts WHERE post_status = %s", 'trash' ) );
|
541 |
+
if ( $query ) {
|
542 |
+
foreach ( $query as $id ) {
|
543 |
+
wp_delete_post( $id, true );
|
544 |
+
}
|
545 |
+
|
546 |
+
$message = sprintf( __( '%s Deleted Posts Processed', 'wp-sweep' ), number_format_i18n( sizeof( $query ) ) );
|
547 |
+
}
|
548 |
+
break;
|
549 |
+
case 'unapproved_comments':
|
550 |
+
$query = $wpdb->get_col( $wpdb->prepare( "SELECT comment_ID FROM $wpdb->comments WHERE comment_approved = %s", '0' ) );
|
551 |
+
if ( $query ) {
|
552 |
+
foreach ( $query as $id ) {
|
553 |
+
wp_delete_comment( intval( $id ), true );
|
554 |
+
}
|
555 |
+
|
556 |
+
$message = sprintf( __( '%s Unapproved Comments Processed', 'wp-sweep' ), number_format_i18n( sizeof( $query ) ) );
|
557 |
+
}
|
558 |
+
break;
|
559 |
+
case 'spam_comments':
|
560 |
+
$query = $wpdb->get_col( $wpdb->prepare( "SELECT comment_ID FROM $wpdb->comments WHERE comment_approved = %s", 'spam' ) );
|
561 |
+
if ( $query ) {
|
562 |
+
foreach ( $query as $id ) {
|
563 |
+
wp_delete_comment( intval( $id ), true );
|
564 |
+
}
|
565 |
+
|
566 |
+
$message = sprintf( __( '%s Spam Comments Processed', 'wp-sweep' ), number_format_i18n( sizeof( $query ) ) );
|
567 |
+
}
|
568 |
+
break;
|
569 |
+
case 'deleted_comments':
|
570 |
+
$query = $wpdb->get_col( $wpdb->prepare( "SELECT comment_ID FROM $wpdb->comments WHERE (comment_approved = %s OR comment_approved = %s)", 'trash', 'post-trashed' ) );
|
571 |
+
if ( $query ) {
|
572 |
+
foreach ( $query as $id ) {
|
573 |
+
wp_delete_comment( intval( $id ), true );
|
574 |
+
}
|
575 |
+
|
576 |
+
$message = sprintf( __( '%s Trash Comments Processed', 'wp-sweep' ), number_format_i18n( sizeof( $query ) ) );
|
577 |
+
}
|
578 |
+
break;
|
579 |
+
case 'transient_options':
|
580 |
+
$query = $wpdb->get_col( $wpdb->prepare( "SELECT option_name FROM $wpdb->options WHERE option_name LIKE(%s)", '%_transient_%' ) );
|
581 |
+
if ( $query ) {
|
582 |
+
foreach ( $query as $option_name ) {
|
583 |
+
if ( strpos( $option_name, '_site_transient_' ) !== false ) {
|
584 |
+
delete_site_transient( str_replace( '_site_transient_', '', $option_name ) );
|
585 |
+
} else {
|
586 |
+
delete_transient( str_replace( '_transient_', '', $option_name ) );
|
587 |
+
}
|
588 |
+
}
|
589 |
+
|
590 |
+
$message = sprintf( __( '%s Transient Options Processed', 'wp-sweep' ), number_format_i18n( sizeof( $query ) ) );
|
591 |
+
}
|
592 |
+
break;
|
593 |
+
case 'orphan_postmeta':
|
594 |
+
$query = $wpdb->get_results( "SELECT post_id, meta_key FROM $wpdb->postmeta WHERE post_id NOT IN (SELECT ID FROM $wpdb->posts)" );
|
595 |
+
if ( $query ) {
|
596 |
+
foreach ( $query as $meta ) {
|
597 |
+
$post_id = intval( $meta->post_id );
|
598 |
+
if ( 0 === $post_id ) {
|
599 |
+
$wpdb->query( $wpdb->prepare( "DELETE FROM $wpdb->postmeta WHERE post_id = %d AND meta_key = %s", $post_id, $meta->meta_key ) );
|
600 |
+
} else {
|
601 |
+
delete_post_meta( $post_id, $meta->meta_key );
|
602 |
+
}
|
603 |
+
}
|
604 |
+
|
605 |
+
$message = sprintf( __( '%s Orphaned Post Meta Processed', 'wp-sweep' ), number_format_i18n( sizeof( $query ) ) );
|
606 |
+
}
|
607 |
+
break;
|
608 |
+
case 'orphan_commentmeta':
|
609 |
+
$query = $wpdb->get_results( "SELECT comment_id, meta_key FROM $wpdb->commentmeta WHERE comment_id NOT IN (SELECT comment_ID FROM $wpdb->comments)" );
|
610 |
+
if ( $query ) {
|
611 |
+
foreach ( $query as $meta ) {
|
612 |
+
$comment_id = intval( $meta->comment_id );
|
613 |
+
if ( 0 === $comment_id ) {
|
614 |
+
$wpdb->query( $wpdb->prepare( "DELETE FROM $wpdb->commentmeta WHERE comment_id = %d AND meta_key = %s", $comment_id, $meta->meta_key ) );
|
615 |
+
} else {
|
616 |
+
delete_comment_meta( $comment_id, $meta->meta_key );
|
617 |
+
}
|
618 |
+
}
|
619 |
+
|
620 |
+
$message = sprintf( __( '%s Orphaned Comment Meta Processed', 'wp-sweep' ), number_format_i18n( sizeof( $query ) ) );
|
621 |
+
}
|
622 |
+
break;
|
623 |
+
case 'orphan_usermeta':
|
624 |
+
$query = $wpdb->get_results( "SELECT user_id, meta_key FROM $wpdb->usermeta WHERE user_id NOT IN (SELECT ID FROM $wpdb->users)" );
|
625 |
+
if ( $query ) {
|
626 |
+
foreach ( $query as $meta ) {
|
627 |
+
$user_id = intval( $meta->user_id );
|
628 |
+
if ( 0 === $user_id ) {
|
629 |
+
$wpdb->query( $wpdb->prepare( "DELETE FROM $wpdb->usermeta WHERE user_id = %d AND meta_key = %s", $user_id, $meta->meta_key ) );
|
630 |
+
} else {
|
631 |
+
delete_user_meta( $user_id, $meta->meta_key );
|
632 |
+
}
|
633 |
+
}
|
634 |
+
|
635 |
+
$message = sprintf( __( '%s Orphaned User Meta Processed', 'wp-sweep' ), number_format_i18n( sizeof( $query ) ) );
|
636 |
+
}
|
637 |
+
break;
|
638 |
+
case 'orphan_termmeta':
|
639 |
+
$query = $wpdb->get_results( "SELECT term_id, meta_key FROM $wpdb->termmeta WHERE term_id NOT IN (SELECT term_id FROM $wpdb->terms)" );
|
640 |
+
if ( $query ) {
|
641 |
+
foreach ( $query as $meta ) {
|
642 |
+
$term_id = intval( $meta->term_id );
|
643 |
+
if ( 0 === $term_id ) {
|
644 |
+
$wpdb->query( $wpdb->prepare( "DELETE FROM $wpdb->termmeta WHERE term_id = %d AND meta_key = %s", $term_id, $meta->meta_key ) );
|
645 |
+
} else {
|
646 |
+
delete_term_meta( $term_id, $meta->meta_key );
|
647 |
+
}
|
648 |
+
}
|
649 |
+
|
650 |
+
$message = sprintf( __( '%s Orphaned Term Meta Processed', 'wp-sweep' ), number_format_i18n( sizeof( $query ) ) );
|
651 |
+
}
|
652 |
+
break;
|
653 |
+
case 'orphan_term_relationships':
|
654 |
+
$query = $wpdb->get_results( "SELECT tr.object_id, tr.term_taxonomy_id, tt.term_id, tt.taxonomy FROM $wpdb->term_relationships AS tr INNER JOIN $wpdb->term_taxonomy AS tt ON tr.term_taxonomy_id = tt.term_taxonomy_id WHERE tt.taxonomy NOT IN ('" . implode( '\',\'', $this->get_excluded_taxonomies() ) . "') AND tr.object_id NOT IN (SELECT ID FROM $wpdb->posts)" );
|
655 |
+
if ( $query ) {
|
656 |
+
foreach ( $query as $tax ) {
|
657 |
+
$wp_remove_object_terms = wp_remove_object_terms( intval( $tax->object_id ), intval( $tax->term_id ), $tax->taxonomy );
|
658 |
+
if ( true !== $wp_remove_object_terms ) {
|
659 |
+
$wpdb->query( $wpdb->prepare( "DELETE FROM $wpdb->term_relationships WHERE object_id = %d AND term_taxonomy_id = %d", $tax->object_id, $tax->term_taxonomy_id ) );
|
660 |
+
}
|
661 |
+
}
|
662 |
+
|
663 |
+
$message = sprintf( __( '%s Orphaned Term Relationships Processed', 'wp-sweep' ), number_format_i18n( sizeof( $query ) ) );
|
664 |
+
}
|
665 |
+
break;
|
666 |
+
case 'unused_terms':
|
667 |
+
$query = $wpdb->get_results( $wpdb->prepare( "SELECT tt.term_taxonomy_id, t.term_id, tt.taxonomy FROM $wpdb->terms AS t INNER JOIN $wpdb->term_taxonomy AS tt ON t.term_id = tt.term_id WHERE tt.count = %d AND t.term_id NOT IN (" . implode( ',', $this->get_excluded_termids() ) . ')', 0 ) );
|
668 |
+
if ( $query ) {
|
669 |
+
$check_wp_terms = false;
|
670 |
+
foreach ( $query as $tax ) {
|
671 |
+
if ( taxonomy_exists( $tax->taxonomy ) ) {
|
672 |
+
wp_delete_term( intval( $tax->term_id ), $tax->taxonomy );
|
673 |
+
} else {
|
674 |
+
$wpdb->query( $wpdb->prepare( "DELETE FROM $wpdb->term_taxonomy WHERE term_taxonomy_id = %d", intval( $tax->term_taxonomy_id ) ) );
|
675 |
+
$check_wp_terms = true;
|
676 |
+
}
|
677 |
+
}
|
678 |
+
// We need this for invalid taxonomies
|
679 |
+
if ( $check_wp_terms ) {
|
680 |
+
$wpdb->get_results( "DELETE FROM $wpdb->terms WHERE term_id NOT IN (SELECT term_id FROM $wpdb->term_taxonomy)" );
|
681 |
+
}
|
682 |
+
|
683 |
+
$message = sprintf( __( '%s Unused Terms Processed', 'wp-sweep' ), number_format_i18n( sizeof( $query ) ) );
|
684 |
+
}
|
685 |
+
break;
|
686 |
+
case 'duplicated_postmeta':
|
687 |
+
$query = $wpdb->get_results( $wpdb->prepare( "SELECT GROUP_CONCAT(meta_id ORDER BY meta_id DESC) AS ids, post_id, COUNT(*) AS count FROM $wpdb->postmeta GROUP BY post_id, meta_key, meta_value HAVING count > %d", 1 ) );
|
688 |
+
if ( $query ) {
|
689 |
+
foreach ( $query as $meta ) {
|
690 |
+
$ids = array_map( 'intval', explode( ',', $meta->ids ) );
|
691 |
+
array_pop( $ids );
|
692 |
+
$wpdb->query( $wpdb->prepare( "DELETE FROM $wpdb->postmeta WHERE meta_id IN (" . implode( ',', $ids ) . ') AND post_id = %d', intval( $meta->post_id ) ) );
|
693 |
+
}
|
694 |
+
|
695 |
+
$message = sprintf( __( '%s Duplicated Post Meta Processed', 'wp-sweep' ), number_format_i18n( sizeof( $query ) ) );
|
696 |
+
}
|
697 |
+
break;
|
698 |
+
case 'duplicated_commentmeta':
|
699 |
+
$query = $wpdb->get_results( $wpdb->prepare( "SELECT GROUP_CONCAT(meta_id ORDER BY meta_id DESC) AS ids, comment_id, COUNT(*) AS count FROM $wpdb->commentmeta GROUP BY comment_id, meta_key, meta_value HAVING count > %d", 1 ) );
|
700 |
+
if ( $query ) {
|
701 |
+
foreach ( $query as $meta ) {
|
702 |
+
$ids = array_map( 'intval', explode( ',', $meta->ids ) );
|
703 |
+
array_pop( $ids );
|
704 |
+
$wpdb->query( $wpdb->prepare( "DELETE FROM $wpdb->commentmeta WHERE meta_id IN (" . implode( ',', $ids ) . ') AND comment_id = %d', intval( $meta->comment_id ) ) );
|
705 |
+
}
|
706 |
+
|
707 |
+
$message = sprintf( __( '%s Duplicated Comment Meta Processed', 'wp-sweep' ), number_format_i18n( sizeof( $query ) ) );
|
708 |
+
}
|
709 |
+
break;
|
710 |
+
case 'duplicated_usermeta':
|
711 |
+
$query = $wpdb->get_results( $wpdb->prepare( "SELECT GROUP_CONCAT(umeta_id ORDER BY umeta_id DESC) AS ids, user_id, COUNT(*) AS count FROM $wpdb->usermeta GROUP BY user_id, meta_key, meta_value HAVING count > %d", 1 ) );
|
712 |
+
if ( $query ) {
|
713 |
+
foreach ( $query as $meta ) {
|
714 |
+
$ids = array_map( 'intval', explode( ',', $meta->ids ) );
|
715 |
+
array_pop( $ids );
|
716 |
+
$wpdb->query( $wpdb->prepare( "DELETE FROM $wpdb->usermeta WHERE umeta_id IN (" . implode( ',', $ids ) . ') AND user_id = %d', intval( $meta->user_id ) ) );
|
717 |
+
}
|
718 |
+
|
719 |
+
$message = sprintf( __( '%s Duplicated User Meta Processed', 'wp-sweep' ), number_format_i18n( sizeof( $query ) ) );
|
720 |
+
}
|
721 |
+
break;
|
722 |
+
case 'duplicated_termmeta':
|
723 |
+
$query = $wpdb->get_results( $wpdb->prepare( "SELECT GROUP_CONCAT(meta_id ORDER BY meta_id DESC) AS ids, term_id, COUNT(*) AS count FROM $wpdb->termmeta GROUP BY term_id, meta_key, meta_value HAVING count > %d", 1 ) );
|
724 |
+
if ( $query ) {
|
725 |
+
foreach ( $query as $meta ) {
|
726 |
+
$ids = array_map( 'intval', explode( ',', $meta->ids ) );
|
727 |
+
array_pop( $ids );
|
728 |
+
$wpdb->query( $wpdb->prepare( "DELETE FROM $wpdb->termmeta WHERE meta_id IN (" . implode( ',', $ids ) . ') AND term_id = %d', intval( $meta->term_id ) ) );
|
729 |
+
}
|
730 |
+
|
731 |
+
$message = sprintf( __( '%s Duplicated Term Meta Processed', 'wp-sweep' ), number_format_i18n( sizeof( $query ) ) );
|
732 |
+
}
|
733 |
+
break;
|
734 |
+
case 'optimize_database':
|
735 |
+
$query = $wpdb->get_col( 'SHOW TABLES' );
|
736 |
+
if ( $query ) {
|
737 |
+
$tables = implode( ',', $query );
|
738 |
+
$wpdb->query( "OPTIMIZE TABLE $tables" );
|
739 |
+
$message = sprintf( __( '%s Tables Processed', 'wp-sweep' ), number_format_i18n( sizeof( $query ) ) );
|
740 |
+
}
|
741 |
+
break;
|
742 |
+
case 'oembed_postmeta':
|
743 |
+
$query = $wpdb->get_results( $wpdb->prepare( "SELECT post_id, meta_key FROM $wpdb->postmeta WHERE meta_key LIKE(%s)", '%_oembed_%' ) );
|
744 |
+
if ( $query ) {
|
745 |
+
foreach ( $query as $meta ) {
|
746 |
+
$post_id = intval( $meta->post_id );
|
747 |
+
if ( 0 === $post_id ) {
|
748 |
+
$wpdb->query( $wpdb->prepare( "DELETE FROM $wpdb->postmeta WHERE post_id = %d AND meta_key = %s", $post_id, $meta->meta_key ) );
|
749 |
+
} else {
|
750 |
+
delete_post_meta( $post_id, $meta->meta_key );
|
751 |
+
}
|
752 |
+
}
|
753 |
+
|
754 |
+
$message = sprintf( __( '%s oEmbed Caches In Post Meta Processed', 'wp-sweep' ), number_format_i18n( sizeof( $query ) ) );
|
755 |
+
}
|
756 |
+
break;
|
757 |
+
}
|
758 |
+
|
759 |
+
return apply_filters( 'wp_sweep_sweep', $message, $name );
|
760 |
+
}
|
761 |
+
|
762 |
+
/**
|
763 |
+
* Format number to percentage, taking care of division by 0.
|
764 |
+
* Props @barisunver https://github.com/barisunver
|
765 |
+
*
|
766 |
+
* @since 1.0.2
|
767 |
+
*
|
768 |
+
* @access public
|
769 |
+
* @param int $current
|
770 |
+
* @param int $total
|
771 |
+
* @return string Number in percentage
|
772 |
+
*/
|
773 |
+
public function format_percentage( $current, $total ) {
|
774 |
+
return ( $total > 0 ? round( ( $current / $total ) * 100, 2 ) : 0 ) . '%';
|
775 |
+
}
|
776 |
+
|
777 |
+
/**
|
778 |
+
* Get excluded taxonomies
|
779 |
+
*
|
780 |
+
* @since 1.0.8
|
781 |
+
*
|
782 |
+
* @access private
|
783 |
+
* @return array Excluded taxonomies
|
784 |
+
*/
|
785 |
+
private function get_excluded_taxonomies() {
|
786 |
+
$excluded_taxonomies = array();
|
787 |
+
$excluded_taxonomies[] = 'link_category';
|
788 |
+
|
789 |
+
return apply_filters( 'wp_sweep_excluded_taxonomies', $excluded_taxonomies );
|
790 |
+
}
|
791 |
+
|
792 |
+
/**
|
793 |
+
* Get excluded term IDs
|
794 |
+
*
|
795 |
+
* @since 1.0.3
|
796 |
+
*
|
797 |
+
* @access private
|
798 |
+
* @return array Excluded term IDs
|
799 |
+
*/
|
800 |
+
private function get_excluded_termids() {
|
801 |
+
$default_term_ids = $this->get_default_taxonomy_termids();
|
802 |
+
if ( ! is_array( $default_term_ids ) ) {
|
803 |
+
$default_term_ids = array();
|
804 |
+
}
|
805 |
+
$parent_term_ids = $this->get_parent_termids();
|
806 |
+
if ( ! is_array( $parent_term_ids ) ) {
|
807 |
+
$parent_term_ids = array();
|
808 |
+
}
|
809 |
+
return array_merge( $default_term_ids, $parent_term_ids );
|
810 |
+
}
|
811 |
+
|
812 |
+
/**
|
813 |
+
* Get all default taxonomy term IDs
|
814 |
+
*
|
815 |
+
* @since 1.0.3
|
816 |
+
*
|
817 |
+
* @access private
|
818 |
+
* @return array Default taxonomy term IDs
|
819 |
+
*/
|
820 |
+
private function get_default_taxonomy_termids() {
|
821 |
+
$taxonomies = get_taxonomies();
|
822 |
+
$default_term_ids = array();
|
823 |
+
if ( $taxonomies ) {
|
824 |
+
$tax = array_keys( $taxonomies );
|
825 |
+
if ( $tax ) {
|
826 |
+
foreach ( $tax as $t ) {
|
827 |
+
$term_id = intval( get_option( 'default_' . $t ) );
|
828 |
+
if ( $term_id > 0 ) {
|
829 |
+
$default_term_ids[] = $term_id;
|
830 |
+
}
|
831 |
+
}
|
832 |
+
}
|
833 |
+
}
|
834 |
+
return $default_term_ids;
|
835 |
+
}
|
836 |
+
|
837 |
+
/**
|
838 |
+
* Get terms that has a parent term
|
839 |
+
*
|
840 |
+
* @since 1.0.3
|
841 |
+
*
|
842 |
+
* @access private
|
843 |
+
* @return array Parent term IDs
|
844 |
+
*/
|
845 |
+
private function get_parent_termids() {
|
846 |
+
global $wpdb;
|
847 |
+
return $wpdb->get_col( $wpdb->prepare( "SELECT tt.parent FROM $wpdb->terms AS t INNER JOIN $wpdb->term_taxonomy AS tt ON t.term_id = tt.term_id WHERE tt.parent > %d", 0 ) );
|
848 |
+
}
|
849 |
+
|
850 |
+
/**
|
851 |
+
* Wrapper to get WordPress Multisite
|
852 |
+
*
|
853 |
+
* @since 1.0.9
|
854 |
+
*
|
855 |
+
* @access private
|
856 |
+
* @return array
|
857 |
+
*/
|
858 |
+
private function get_sites() {
|
859 |
+
return function_exists( 'get_sites' ) ? get_sites() : wp_get_sites();
|
860 |
+
}
|
861 |
+
|
862 |
+
/**
|
863 |
+
* Wrapper to get WordPress Multisite ID
|
864 |
+
*
|
865 |
+
* @since 1.0.9
|
866 |
+
*
|
867 |
+
* @access private
|
868 |
+
* @param WP_Site $ms_site
|
869 |
+
* @return int
|
870 |
+
*/
|
871 |
+
private function get_site_blog_id( $ms_site ) {
|
872 |
+
return class_exists( 'WP_Site' ) ? $ms_site->blog_id : $ms_site['blog_id'];
|
873 |
+
}
|
874 |
+
|
875 |
+
/**
|
876 |
+
* What to do when the plugin is being deactivated
|
877 |
+
*
|
878 |
+
* @since 1.0.0
|
879 |
+
*
|
880 |
+
* @access public
|
881 |
+
* @param boolean $network_wide
|
882 |
+
* @return void
|
883 |
+
*/
|
884 |
+
public function plugin_activation( $network_wide ) {
|
885 |
+
if ( is_multisite() && $network_wide ) {
|
886 |
+
$ms_sites = $this->get_sites();
|
887 |
+
|
888 |
+
if ( 0 < sizeof( $ms_sites ) ) {
|
889 |
+
foreach ( $ms_sites as $ms_site ) {
|
890 |
+
switch_to_blog( $this->get_site_blog_id( $ms_site ) );
|
891 |
+
$this->plugin_activated();
|
892 |
+
restore_current_blog();
|
893 |
+
}
|
894 |
+
}
|
895 |
+
} else {
|
896 |
+
$this->plugin_activated();
|
897 |
+
}
|
898 |
+
}
|
899 |
+
|
900 |
+
/**
|
901 |
+
* Perform plugin activation tasks
|
902 |
+
*
|
903 |
+
* @since 1.0.0
|
904 |
+
*
|
905 |
+
* @access private
|
906 |
+
* @return void
|
907 |
+
*/
|
908 |
+
private function plugin_activated() {
|
909 |
+
}
|
910 |
+
|
911 |
+
/**
|
912 |
+
* What to do when the plugin is being activated
|
913 |
+
*
|
914 |
+
* @since 1.0.0
|
915 |
+
*
|
916 |
+
* @access public
|
917 |
+
* @param boolean $network_wide
|
918 |
+
* @return void
|
919 |
+
*/
|
920 |
+
public function plugin_deactivation( $network_wide ) {
|
921 |
+
if ( is_multisite() && $network_wide ) {
|
922 |
+
$ms_sites = $this->get_sites();
|
923 |
+
|
924 |
+
if ( 0 < sizeof( $ms_sites ) ) {
|
925 |
+
foreach ( $ms_sites as $ms_site ) {
|
926 |
+
switch_to_blog( $this->get_site_blog_id( $ms_site ) );
|
927 |
+
$this->plugin_deactivated();
|
928 |
+
restore_current_blog();
|
929 |
+
}
|
930 |
+
}
|
931 |
+
} else {
|
932 |
+
$this->plugin_deactivated();
|
933 |
+
}
|
934 |
+
}
|
935 |
+
|
936 |
+
/**
|
937 |
+
* Perform plugin deactivation tasks
|
938 |
+
*
|
939 |
+
* @since 1.0.0
|
940 |
+
*
|
941 |
+
* @access private
|
942 |
+
* @return void
|
943 |
+
*/
|
944 |
+
private function plugin_deactivated() {
|
945 |
+
}
|
946 |
}
|
947 |
|
948 |
/**
|