Version Description
[07/22/2013] = * NEW: deletion of unused tags (optional)
Download this release
Release Info
Developer | cageehv |
Plugin | Optimize Database after Deleting Revisions |
Version | 2.6 |
Comparing to | |
See all releases |
Code changes from version 2.5.1 to 2.6
- readme.txt +11 -4
- rvg-optimize-db.php +130 -33
readme.txt
CHANGED
@@ -6,10 +6,10 @@ Plugin URI: http://cagewebdev.com/index.php/optimize-database-after-deleting-rev
|
|
6 |
Tags: database, delete, revisions, optimize, post, posts, page, pages, clean, clean up, trash, spam, trashed, spammed, database size, scheduler
|
7 |
Author URI: http://cagewebdev.com
|
8 |
Author: CAGE Web Design | Rolf van Gelder, Eindhoven, The Netherlands
|
9 |
-
Requires at least: 2.
|
10 |
-
Tested up to: 3.5.
|
11 |
-
Stable tag: 2.
|
12 |
-
Version: 2.
|
13 |
|
14 |
== Description ==
|
15 |
|
@@ -19,6 +19,7 @@ This plugin is a 'One Click' WordPress Database Cleaner / Optimizer.
|
|
19 |
* Deletes redundant revisions of posts and pages (you optionally can keep an 'x'-amount of the most recent revisions)
|
20 |
* Deletes trashed posts, pages and comments (optional)
|
21 |
* Deletes spammed comments (optional)
|
|
|
22 |
* Deletes 'orphan postmeta items'
|
23 |
* Optimizes the database tables (optionally you can exclude certain tables from optimization)
|
24 |
* Creates a log file of the optimizations (optional)
|
@@ -41,6 +42,9 @@ http://cagewebdev.com/index.php/optimize-database-after-deleting-revisions-wordp
|
|
41 |
= Download URL =
|
42 |
http://wordpress.org/extend/plugins/rvg-optimize-database/
|
43 |
|
|
|
|
|
|
|
44 |
== Installation ==
|
45 |
|
46 |
* Upload the Plugin to the `/wp-content/plugins/` directory
|
@@ -49,6 +53,9 @@ http://wordpress.org/extend/plugins/rvg-optimize-database/
|
|
49 |
|
50 |
== Changelog ==
|
51 |
|
|
|
|
|
|
|
52 |
= 2.5.1 [05/24/2013] =
|
53 |
* BUG FIX: some short tags removed
|
54 |
* CHANGE: schedule time is only relevant and therefore only shown for 'daily' and 'weekly' schedules
|
6 |
Tags: database, delete, revisions, optimize, post, posts, page, pages, clean, clean up, trash, spam, trashed, spammed, database size, scheduler
|
7 |
Author URI: http://cagewebdev.com
|
8 |
Author: CAGE Web Design | Rolf van Gelder, Eindhoven, The Netherlands
|
9 |
+
Requires at least: 2.6
|
10 |
+
Tested up to: 3.5.2
|
11 |
+
Stable tag: 2.6
|
12 |
+
Version: 2.6
|
13 |
|
14 |
== Description ==
|
15 |
|
19 |
* Deletes redundant revisions of posts and pages (you optionally can keep an 'x'-amount of the most recent revisions)
|
20 |
* Deletes trashed posts, pages and comments (optional)
|
21 |
* Deletes spammed comments (optional)
|
22 |
+
* Deletes unused tags (optional)
|
23 |
* Deletes 'orphan postmeta items'
|
24 |
* Optimizes the database tables (optionally you can exclude certain tables from optimization)
|
25 |
* Creates a log file of the optimizations (optional)
|
42 |
= Download URL =
|
43 |
http://wordpress.org/extend/plugins/rvg-optimize-database/
|
44 |
|
45 |
+
= Disclaimer =
|
46 |
+
No warranty, use at own risk!
|
47 |
+
|
48 |
== Installation ==
|
49 |
|
50 |
* Upload the Plugin to the `/wp-content/plugins/` directory
|
53 |
|
54 |
== Changelog ==
|
55 |
|
56 |
+
= 2.6 [07/22/2013] =
|
57 |
+
* NEW: deletion of unused tags (optional)
|
58 |
+
|
59 |
= 2.5.1 [05/24/2013] =
|
60 |
* BUG FIX: some short tags removed
|
61 |
* CHANGE: schedule time is only relevant and therefore only shown for 'daily' and 'weekly' schedules
|
rvg-optimize-db.php
CHANGED
@@ -1,16 +1,16 @@
|
|
1 |
<?php
|
2 |
-
$odb_version = '2.
|
3 |
-
$odb_release_date = '
|
4 |
/**
|
5 |
* @package Optimize Database after Deleting Revisions
|
6 |
-
* @version 2.
|
7 |
*/
|
8 |
/*
|
9 |
Plugin Name: Optimize Database after Deleting Revisions
|
10 |
Plugin URI: http://cagewebdev.com/index.php/optimize-database-after-deleting-revisions-wordpress-plugin/
|
11 |
Description: Optimizes the Wordpress Database after Cleaning it out - <a href="options-general.php?page=rvg_odb_admin"><strong>plug in options</strong></a>
|
12 |
Author: CAGE Web Design | Rolf van Gelder, Eindhoven, The Netherlands
|
13 |
-
Version: 2.
|
14 |
Author URI: http://cagewebdev.com
|
15 |
*/
|
16 |
?>
|
@@ -51,7 +51,7 @@ function rvg_odb_admin_bar()
|
|
51 |
{ global $wp_admin_bar;
|
52 |
if ( !is_super_admin() || !is_admin_bar_showing() ) return;
|
53 |
$siteurl = site_url('/');
|
54 |
-
$wp_admin_bar->add_menu( array('id' => 'optimize','title' => __(
|
55 |
}
|
56 |
$rvg_odb_adminbar = get_option('rvg_odb_adminbar');
|
57 |
if($rvg_odb_adminbar == "Y") add_action( 'wp_before_admin_bar_render', 'rvg_odb_admin_bar' );
|
@@ -70,11 +70,6 @@ function rvg_extra_schedules( $schedules ) {
|
|
70 |
'interval' => 604800,
|
71 |
'display' => __('Once Weekly')
|
72 |
);
|
73 |
-
// 5 MINUTES FOR TESTING
|
74 |
-
/* $schedules['test'] = array(
|
75 |
-
'interval' => 300,
|
76 |
-
'display' => __('Test')
|
77 |
-
); */
|
78 |
return $schedules;
|
79 |
}
|
80 |
add_filter( 'cron_schedules', 'rvg_extra_schedules' );
|
@@ -105,14 +100,15 @@ function rvg_activate_plugin()
|
|
105 |
CREATE THE OPTIONS PAGE
|
106 |
|
107 |
*********************************************************************************************/
|
108 |
-
function rvg_odb_options_page()
|
|
|
109 |
global $odb_version, $odb_release_date, $wpdb, $table_prefix;
|
110 |
|
111 |
$timezone_format = _x('YmdGis', 'timezone date format');
|
112 |
$current_datetime = date_i18n($timezone_format);
|
113 |
$current_date = substr($current_datetime, 0, 8);
|
114 |
$current_hour = substr($current_datetime, 8, 2);
|
115 |
-
|
116 |
# jQuery FRAMEWORK
|
117 |
echo '<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>';
|
118 |
|
@@ -160,6 +156,11 @@ function rvg_odb_options_page() {
|
|
160 |
$rvg_clear_spam = $_POST['rvg_clear_spam'];
|
161 |
update_option('rvg_clear_spam', $rvg_clear_spam);
|
162 |
|
|
|
|
|
|
|
|
|
|
|
163 |
$rvg_odb_adminbar = 'N';
|
164 |
if(isset($_POST['rvg_odb_adminbar']))
|
165 |
$rvg_odb_adminbar = $_POST['rvg_odb_adminbar'];
|
@@ -218,6 +219,9 @@ function rvg_odb_options_page() {
|
|
218 |
|
219 |
$rvg_clear_spam = get_option('rvg_clear_spam');
|
220 |
if(!$rvg_clear_spam) $rvg_clear_spam = 'N';
|
|
|
|
|
|
|
221 |
|
222 |
$rvg_odb_logging_on = get_option('rvg_odb_logging_on');
|
223 |
if(!$rvg_odb_logging_on) $rvg_odb_logging_on = 'N';
|
@@ -261,6 +265,7 @@ function schedule_changed()
|
|
261 |
if($rvg_odb_adminbar == 'Y') $rvg_odb_adminbar_checked = ' checked="checked"'; else $rvg_odb_adminbar_checked = '';
|
262 |
if($rvg_clear_trash == 'Y') $rvg_clear_trash_checked = ' checked="checked"'; else $rvg_clear_trash_checked = '';
|
263 |
if($rvg_clear_spam == 'Y') $rvg_clear_spam_checked = ' checked="checked"'; else $rvg_clear_spam_checked = '';
|
|
|
264 |
if($rvg_odb_logging_on == 'Y') $rvg_odb_logging_on_checked = ' checked="checked"'; else $rvg_odb_logging_on_checked = '';
|
265 |
?>
|
266 |
<blockquote>
|
@@ -281,6 +286,10 @@ if($rvg_odb_logging_on == 'Y') $rvg_odb_logging_on_checked = ' checked="checke
|
|
281 |
<td width="50%" align="right" valign="top"><span style="font-weight:bold;">Delete all spammed items</span></td>
|
282 |
<td width="50%" valign="top"><input name="rvg_clear_spam" type="checkbox" value="Y" <?php echo $rvg_clear_spam_checked?> /></td>
|
283 |
</tr>
|
|
|
|
|
|
|
|
|
284 |
<tr>
|
285 |
<td width="50%" align="right" valign="top"><span style="font-weight:bold;">Keep a log</span></td>
|
286 |
<td width="50%" valign="top"><input name="rvg_odb_logging_on" type="checkbox" value="Y" <?php echo $rvg_odb_logging_on_checked?> /></td>
|
@@ -380,7 +389,8 @@ if($rvg_odb_logging_on == 'Y') $rvg_odb_logging_on_checked = ' checked="checke
|
|
380 |
|
381 |
/********************************************************************************************
|
382 |
|
383 |
-
MAIN FUNCTION
|
|
|
384 |
|
385 |
*********************************************************************************************/
|
386 |
function rvg_optimize_db()
|
@@ -421,6 +431,13 @@ function rvg_optimize_db()
|
|
421 |
}
|
422 |
$clear_spam_yn = ($clear_spam == 'N') ? 'NO' : 'YES';
|
423 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
424 |
$rvg_odb_logging_on = get_option('rvg_odb_logging_on');
|
425 |
if(!$rvg_odb_logging_on)
|
426 |
{ $rvg_odb_logging_on = 'N';
|
@@ -478,6 +495,7 @@ function rvg_optimize_db()
|
|
478 |
<strong>Maximum number of - most recent - revisions to keep per post / page:</strong> <span style="font-weight:bold;color:#00F;"><?php echo $max_revisions?></span><br />
|
479 |
<strong>Delete trashed items:</strong> <span style="font-weight:bold;color:#00F;"><?php echo $clear_trash_yn?></span><br />
|
480 |
<strong>Delete spammed items:</strong> <span style="font-weight:bold;color:#00F;"><?php echo $clear_spam_yn?></span><br />
|
|
|
481 |
<strong>Keep a log:</strong> <span style="font-weight:bold;color:#00F;"><?php echo $rvg_odb_logging_on_yn?></span><br />
|
482 |
<strong>Number of excluded tables:</strong> <span style="font-weight:bold;color:#00F;"><?php echo $number_excluded?></span><br />
|
483 |
<strong>Scheduler:</strong> <span style="font-weight:bold;color:#00F;"><?php echo $rvg_odb_schedule_txt?></span>
|
@@ -684,6 +702,47 @@ function rvg_optimize_db()
|
|
684 |
// NUMBER OF SPAM DELETED FOR LOG FILE
|
685 |
$log_arr["spam"] = $total_deleted;
|
686 |
?>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
687 |
<?php
|
688 |
/****************************************************************************************
|
689 |
|
@@ -699,7 +758,7 @@ function rvg_optimize_db()
|
|
699 |
<span style="font-weight:bold;color:#000;padding-left:8px;">~~~~~</span>
|
700 |
<table border="0" cellspacing="8" cellpadding="2">
|
701 |
<tr>
|
702 |
-
<td colspan="4"><span style="font-weight:bold;color:#00F;">NUMBER POSTMETA ORPHANS DELETED:</span> <span style="font-weight:bold;"><?php echo $total_deleted;?></span></td>
|
703 |
</tr>
|
704 |
</table>
|
705 |
<?php
|
@@ -833,6 +892,12 @@ function rvg_optimize_db_cron()
|
|
833 |
update_option('rvg_clear_spam', $clear_spam);
|
834 |
}
|
835 |
|
|
|
|
|
|
|
|
|
|
|
|
|
836 |
// GET THE SIZE OF THE DATABASE BEFORE OPTIMIZATION
|
837 |
$start_size = rvg_get_db_size();
|
838 |
|
@@ -876,10 +941,18 @@ function rvg_optimize_db_cron()
|
|
876 |
$total_deleted = rvg_delete_spam($results, false);
|
877 |
|
878 |
} // if($clear_spam == 'Y')
|
879 |
-
|
880 |
// NUMBER OF SPAM DELETED FOR LOG FILE
|
881 |
$log_arr["spam"] = $total_deleted;
|
882 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
883 |
// DELETE ORPHANS
|
884 |
$total_deleted = rvg_delete_orphans(false);
|
885 |
// NUMBER OF ORPHANS DELETED (FOR LOG FILE)
|
@@ -1056,6 +1129,27 @@ function rvg_delete_spam($results, $display)
|
|
1056 |
} // rvg_delete_spam()
|
1057 |
?>
|
1058 |
<?php
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1059 |
/********************************************************************************************
|
1060 |
|
1061 |
DELETE ORPHAN POSTMETA RECORDS
|
@@ -1256,19 +1350,21 @@ td {
|
|
1256 |
</div>
|
1257 |
<table width="100%" border="0" cellspacing="6" cellpadding="1">
|
1258 |
<tr>
|
1259 |
-
<th width="
|
1260 |
-
<th width="
|
1261 |
revisions</th>
|
1262 |
-
<th width="
|
1263 |
trash</th>
|
1264 |
-
<th width="
|
1265 |
spam</th>
|
1266 |
-
<th width="
|
|
|
|
|
1267 |
orphans</th>
|
1268 |
-
<th width="
|
1269 |
-
<th width="
|
1270 |
-
<th width="
|
1271 |
-
<th width="
|
1272 |
</tr>
|
1273 |
</table>
|
1274 |
';
|
@@ -1280,15 +1376,16 @@ td {
|
|
1280 |
$html = '
|
1281 |
<table width="100%" border="0" cellspacing="6" cellpadding="0">
|
1282 |
<tr>
|
1283 |
-
<td width="
|
1284 |
-
<td width="
|
1285 |
-
<td width="
|
1286 |
-
<td width="
|
1287 |
-
<td width="
|
1288 |
-
<td width="
|
1289 |
-
<td width="
|
1290 |
-
<td width="
|
1291 |
-
<td width="
|
|
|
1292 |
</tr>
|
1293 |
</table>
|
1294 |
';
|
1 |
<?php
|
2 |
+
$odb_version = '2.6';
|
3 |
+
$odb_release_date = '07/22/2013';
|
4 |
/**
|
5 |
* @package Optimize Database after Deleting Revisions
|
6 |
+
* @version 2.6
|
7 |
*/
|
8 |
/*
|
9 |
Plugin Name: Optimize Database after Deleting Revisions
|
10 |
Plugin URI: http://cagewebdev.com/index.php/optimize-database-after-deleting-revisions-wordpress-plugin/
|
11 |
Description: Optimizes the Wordpress Database after Cleaning it out - <a href="options-general.php?page=rvg_odb_admin"><strong>plug in options</strong></a>
|
12 |
Author: CAGE Web Design | Rolf van Gelder, Eindhoven, The Netherlands
|
13 |
+
Version: 2.6
|
14 |
Author URI: http://cagewebdev.com
|
15 |
*/
|
16 |
?>
|
51 |
{ global $wp_admin_bar;
|
52 |
if ( !is_super_admin() || !is_admin_bar_showing() ) return;
|
53 |
$siteurl = site_url('/');
|
54 |
+
$wp_admin_bar->add_menu( array('id' => 'optimize','title' => __('Optimize DB (1 click)'),'href' => __($siteurl.'wp-admin/tools.php?page=rvg-optimize-db.php&action=run') ) );
|
55 |
}
|
56 |
$rvg_odb_adminbar = get_option('rvg_odb_adminbar');
|
57 |
if($rvg_odb_adminbar == "Y") add_action( 'wp_before_admin_bar_render', 'rvg_odb_admin_bar' );
|
70 |
'interval' => 604800,
|
71 |
'display' => __('Once Weekly')
|
72 |
);
|
|
|
|
|
|
|
|
|
|
|
73 |
return $schedules;
|
74 |
}
|
75 |
add_filter( 'cron_schedules', 'rvg_extra_schedules' );
|
100 |
CREATE THE OPTIONS PAGE
|
101 |
|
102 |
*********************************************************************************************/
|
103 |
+
function rvg_odb_options_page()
|
104 |
+
{
|
105 |
global $odb_version, $odb_release_date, $wpdb, $table_prefix;
|
106 |
|
107 |
$timezone_format = _x('YmdGis', 'timezone date format');
|
108 |
$current_datetime = date_i18n($timezone_format);
|
109 |
$current_date = substr($current_datetime, 0, 8);
|
110 |
$current_hour = substr($current_datetime, 8, 2);
|
111 |
+
|
112 |
# jQuery FRAMEWORK
|
113 |
echo '<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>';
|
114 |
|
156 |
$rvg_clear_spam = $_POST['rvg_clear_spam'];
|
157 |
update_option('rvg_clear_spam', $rvg_clear_spam);
|
158 |
|
159 |
+
$rvg_clear_tags = 'N';
|
160 |
+
if(isset($_POST['rvg_clear_tags']))
|
161 |
+
$rvg_clear_tags = $_POST['rvg_clear_tags'];
|
162 |
+
update_option('rvg_clear_tags', $rvg_clear_tags);
|
163 |
+
|
164 |
$rvg_odb_adminbar = 'N';
|
165 |
if(isset($_POST['rvg_odb_adminbar']))
|
166 |
$rvg_odb_adminbar = $_POST['rvg_odb_adminbar'];
|
219 |
|
220 |
$rvg_clear_spam = get_option('rvg_clear_spam');
|
221 |
if(!$rvg_clear_spam) $rvg_clear_spam = 'N';
|
222 |
+
|
223 |
+
$rvg_clear_tags = get_option('rvg_clear_tags');
|
224 |
+
if(!$rvg_clear_tags) $rvg_clear_tags = 'N';
|
225 |
|
226 |
$rvg_odb_logging_on = get_option('rvg_odb_logging_on');
|
227 |
if(!$rvg_odb_logging_on) $rvg_odb_logging_on = 'N';
|
265 |
if($rvg_odb_adminbar == 'Y') $rvg_odb_adminbar_checked = ' checked="checked"'; else $rvg_odb_adminbar_checked = '';
|
266 |
if($rvg_clear_trash == 'Y') $rvg_clear_trash_checked = ' checked="checked"'; else $rvg_clear_trash_checked = '';
|
267 |
if($rvg_clear_spam == 'Y') $rvg_clear_spam_checked = ' checked="checked"'; else $rvg_clear_spam_checked = '';
|
268 |
+
if($rvg_clear_tags == 'Y') $rvg_clear_tags_checked = ' checked="checked"'; else $rvg_clear_tags_checked = '';
|
269 |
if($rvg_odb_logging_on == 'Y') $rvg_odb_logging_on_checked = ' checked="checked"'; else $rvg_odb_logging_on_checked = '';
|
270 |
?>
|
271 |
<blockquote>
|
286 |
<td width="50%" align="right" valign="top"><span style="font-weight:bold;">Delete all spammed items</span></td>
|
287 |
<td width="50%" valign="top"><input name="rvg_clear_spam" type="checkbox" value="Y" <?php echo $rvg_clear_spam_checked?> /></td>
|
288 |
</tr>
|
289 |
+
<tr>
|
290 |
+
<td width="50%" align="right" valign="top"><span style="font-weight:bold;">Delete unused tags</span></td>
|
291 |
+
<td width="50%" valign="top"><input name="rvg_clear_tags" type="checkbox" value="Y" <?php echo $rvg_clear_tags_checked?> /></td>
|
292 |
+
</tr>
|
293 |
<tr>
|
294 |
<td width="50%" align="right" valign="top"><span style="font-weight:bold;">Keep a log</span></td>
|
295 |
<td width="50%" valign="top"><input name="rvg_odb_logging_on" type="checkbox" value="Y" <?php echo $rvg_odb_logging_on_checked?> /></td>
|
389 |
|
390 |
/********************************************************************************************
|
391 |
|
392 |
+
MAIN FUNCTION
|
393 |
+
FOR DELETING REVISIONS, TRASH, SPAM, TAGS ORPHANS AND OPTIMIZING DATABASE TABLES
|
394 |
|
395 |
*********************************************************************************************/
|
396 |
function rvg_optimize_db()
|
431 |
}
|
432 |
$clear_spam_yn = ($clear_spam == 'N') ? 'NO' : 'YES';
|
433 |
|
434 |
+
$clear_tags = get_option('rvg_clear_tags');
|
435 |
+
if(!$clear_tags)
|
436 |
+
{ $clear_tags = 'N';
|
437 |
+
update_option('rvg_clear_tags', $clear_tags);
|
438 |
+
}
|
439 |
+
$clear_tags_yn = ($clear_tags == 'N') ? 'NO' : 'YES';
|
440 |
+
|
441 |
$rvg_odb_logging_on = get_option('rvg_odb_logging_on');
|
442 |
if(!$rvg_odb_logging_on)
|
443 |
{ $rvg_odb_logging_on = 'N';
|
495 |
<strong>Maximum number of - most recent - revisions to keep per post / page:</strong> <span style="font-weight:bold;color:#00F;"><?php echo $max_revisions?></span><br />
|
496 |
<strong>Delete trashed items:</strong> <span style="font-weight:bold;color:#00F;"><?php echo $clear_trash_yn?></span><br />
|
497 |
<strong>Delete spammed items:</strong> <span style="font-weight:bold;color:#00F;"><?php echo $clear_spam_yn?></span><br />
|
498 |
+
<strong>Delete unused tags:</strong> <span style="font-weight:bold;color:#00F;"><?php echo $clear_tags_yn?></span><br />
|
499 |
<strong>Keep a log:</strong> <span style="font-weight:bold;color:#00F;"><?php echo $rvg_odb_logging_on_yn?></span><br />
|
500 |
<strong>Number of excluded tables:</strong> <span style="font-weight:bold;color:#00F;"><?php echo $number_excluded?></span><br />
|
501 |
<strong>Scheduler:</strong> <span style="font-weight:bold;color:#00F;"><?php echo $rvg_odb_schedule_txt?></span>
|
702 |
// NUMBER OF SPAM DELETED FOR LOG FILE
|
703 |
$log_arr["spam"] = $total_deleted;
|
704 |
?>
|
705 |
+
<?php
|
706 |
+
/****************************************************************************************
|
707 |
+
|
708 |
+
DELETE UNUSED TAGS
|
709 |
+
|
710 |
+
******************************************************************************************/
|
711 |
+
?>
|
712 |
+
<?php
|
713 |
+
if($clear_tags == 'Y')
|
714 |
+
{
|
715 |
+
// DELETE UNUSED TAGS
|
716 |
+
$total_deleted = rvg_delete_tags();
|
717 |
+
|
718 |
+
if($total_deleted>0)
|
719 |
+
{ // TAGS DELETED
|
720 |
+
?>
|
721 |
+
<span style="font-weight:bold;color:#000;padding-left:8px;">~~~~~</span>
|
722 |
+
<table border="0" cellspacing="8" cellpadding="2">
|
723 |
+
<tr>
|
724 |
+
<td><span style="font-weight:bold;color:#00F;">NUMBER OF UNUSED TAGS DELETED:</span> <span style="font-weight:bold;"><?php echo $total_deleted;?></span></td>
|
725 |
+
</tr>
|
726 |
+
</table>
|
727 |
+
<?php
|
728 |
+
}
|
729 |
+
else
|
730 |
+
{
|
731 |
+
?>
|
732 |
+
<span style="font-weight:bold;color:#000;padding-left:8px;">~~~~~</span>
|
733 |
+
<table border="0" cellspacing="8" cellpadding="2">
|
734 |
+
<tr>
|
735 |
+
<td style="font-weight:bold;color:#21759b;">No UNUSED TAGS found to delete...</td>
|
736 |
+
</tr>
|
737 |
+
</table>
|
738 |
+
<?php
|
739 |
+
} // if(count($results)>0)
|
740 |
+
|
741 |
+
} // if($clear_tags == 'Y')
|
742 |
+
|
743 |
+
// NUMBER OF tags DELETED FOR LOG FILE
|
744 |
+
$log_arr["tags"] = $total_deleted;
|
745 |
+
?>
|
746 |
<?php
|
747 |
/****************************************************************************************
|
748 |
|
758 |
<span style="font-weight:bold;color:#000;padding-left:8px;">~~~~~</span>
|
759 |
<table border="0" cellspacing="8" cellpadding="2">
|
760 |
<tr>
|
761 |
+
<td colspan="4"><span style="font-weight:bold;color:#00F;">NUMBER OF POSTMETA ORPHANS DELETED:</span> <span style="font-weight:bold;"><?php echo $total_deleted;?></span></td>
|
762 |
</tr>
|
763 |
</table>
|
764 |
<?php
|
892 |
update_option('rvg_clear_spam', $clear_spam);
|
893 |
}
|
894 |
|
895 |
+
$clear_tags = get_option('rvg_clear_tags');
|
896 |
+
if(!$clear_tags)
|
897 |
+
{ $clear_tags = 'N';
|
898 |
+
update_option('rvg_clear_tags', $clear_tags);
|
899 |
+
}
|
900 |
+
|
901 |
// GET THE SIZE OF THE DATABASE BEFORE OPTIMIZATION
|
902 |
$start_size = rvg_get_db_size();
|
903 |
|
941 |
$total_deleted = rvg_delete_spam($results, false);
|
942 |
|
943 |
} // if($clear_spam == 'Y')
|
944 |
+
|
945 |
// NUMBER OF SPAM DELETED FOR LOG FILE
|
946 |
$log_arr["spam"] = $total_deleted;
|
947 |
|
948 |
+
if($clear_tags == "Y")
|
949 |
+
{ // DELETE UNUSED TAGS
|
950 |
+
$total_deleted = rvg_delete_tags();
|
951 |
+
}
|
952 |
+
|
953 |
+
// NUMBER OF DELETED TAGS FOR LOG FILE
|
954 |
+
$log_arr["tags"] = $total_deleted;
|
955 |
+
|
956 |
// DELETE ORPHANS
|
957 |
$total_deleted = rvg_delete_orphans(false);
|
958 |
// NUMBER OF ORPHANS DELETED (FOR LOG FILE)
|
1129 |
} // rvg_delete_spam()
|
1130 |
?>
|
1131 |
<?php
|
1132 |
+
/********************************************************************************************
|
1133 |
+
|
1134 |
+
DELETE UNUSED TAGS
|
1135 |
+
|
1136 |
+
*********************************************************************************************/
|
1137 |
+
function rvg_delete_tags()
|
1138 |
+
{
|
1139 |
+
$total_deleted = 0;
|
1140 |
+
|
1141 |
+
$tags = get_terms('post_tag', array('hide_empty' => 0));
|
1142 |
+
for($i=0; $i<count($tags); $i++)
|
1143 |
+
if($tags[$i]->count < 1)
|
1144 |
+
{ $total_deleted++;
|
1145 |
+
// echo $tags[$i]->term_id.' '.$tags[$i]->name.'<br />';
|
1146 |
+
wp_delete_term($tags[$i]->term_id,'post_tag');
|
1147 |
+
}
|
1148 |
+
|
1149 |
+
return $total_deleted;
|
1150 |
+
} // rvg_delete_tags()
|
1151 |
+
?>
|
1152 |
+
<?php
|
1153 |
/********************************************************************************************
|
1154 |
|
1155 |
DELETE ORPHAN POSTMETA RECORDS
|
1350 |
</div>
|
1351 |
<table width="100%" border="0" cellspacing="6" cellpadding="1">
|
1352 |
<tr>
|
1353 |
+
<th width="10%" align="left" valign="top">time</th>
|
1354 |
+
<th width="10%" align="right" valign="top">deleted<br />
|
1355 |
revisions</th>
|
1356 |
+
<th width="10%" align="right" valign="top">deleted<br />
|
1357 |
trash</th>
|
1358 |
+
<th width="10%" align="right" valign="top">deleted<br />
|
1359 |
spam</th>
|
1360 |
+
<th width="10%" align="right" valign="top">deleted<br />
|
1361 |
+
tags</th>
|
1362 |
+
<th width="10%" align="right" valign="top">deleted<br />
|
1363 |
orphans</th>
|
1364 |
+
<th width="10%" align="right" valign="top">nr of optimized tables</th>
|
1365 |
+
<th width="10%" align="right" valign="top">database size BEFORE</th>
|
1366 |
+
<th width="10%" align="right" valign="top">database size AFTER</th>
|
1367 |
+
<th width="10%" align="right" valign="top">SAVINGS</th>
|
1368 |
</tr>
|
1369 |
</table>
|
1370 |
';
|
1376 |
$html = '
|
1377 |
<table width="100%" border="0" cellspacing="6" cellpadding="0">
|
1378 |
<tr>
|
1379 |
+
<td width="10%" valign="top"><strong>'.$log_arr["time"].'</strong></td>
|
1380 |
+
<td width="10%" align="right" valign="top">'.$log_arr["revisions"].'</td>
|
1381 |
+
<td width="10%" align="right" valign="top">'.$log_arr["trash"].'</td>
|
1382 |
+
<td width="10%" align="right" valign="top">'.$log_arr["spam"].'</td>
|
1383 |
+
<td width="10%" align="right" valign="top">'.$log_arr["tags"].'</td>
|
1384 |
+
<td width="10%" align="right" valign="top">'.$log_arr["orphans"].'</td>
|
1385 |
+
<td width="10%" align="right" valign="top">'.$log_arr["tables"].'</td>
|
1386 |
+
<td width="10%" align="right" valign="top">'.$log_arr["before"].'</td>
|
1387 |
+
<td width="10%" align="right" valign="top">'.$log_arr["after"].'</td>
|
1388 |
+
<td width="10%" align="right" valign="top">'.$log_arr["savings"].'</td>
|
1389 |
</tr>
|
1390 |
</table>
|
1391 |
';
|