Version Description
[03/02/2016] = * NEW: Custom field 'keep_revisions', for excluding the deletion of revisions for specific posts/pages * NEW: Run the optimization from a Unix crontab (if possible)
Download this release
Release Info
Developer | cageehv |
Plugin | Optimize Database after Deleting Revisions |
Version | 4.1.4 |
Comparing to | |
See all releases |
Code changes from version 4.1.3 to 4.1.4
- classes/odb-cleaner.php +24 -14
- classes/odb-displayer.php +20 -15
- readme.txt +23 -7
- rvg-optimize-database.php +8 -6
classes/odb-cleaner.php
CHANGED
@@ -62,7 +62,6 @@ class ODB_Cleaner
|
|
62 |
/****************************************************************************************
|
63 |
* DELETE REVISIONS
|
64 |
****************************************************************************************/
|
65 |
-
// var_dump($odb_class->odb_rvg_options['rvg_revisions']);
|
66 |
if($odb_class->odb_rvg_options['delete_older'] == 'Y' || $odb_class->odb_rvg_options['rvg_revisions'] == 'Y')
|
67 |
{
|
68 |
// FIND REVISIONS
|
@@ -558,7 +557,7 @@ class ODB_Cleaner
|
|
558 |
$res = $wpdb->get_results($sql, ARRAY_A);
|
559 |
|
560 |
for($j=0; $j<count($res); $j++)
|
561 |
-
{ if(isset($res[$j]))
|
562 |
{ $res_arr[$index] = $res[$j];
|
563 |
$res_arr[$index]['site'] = $odb_class->odb_ms_prefixes[$i];
|
564 |
$index++;
|
@@ -593,7 +592,7 @@ class ODB_Cleaner
|
|
593 |
|
594 |
for($i=0; $i<count($odb_class->odb_ms_prefixes); $i++)
|
595 |
{ $sql = sprintf ("
|
596 |
-
SELECT `post_parent`, `post_title`, COUNT(*) cnt
|
597 |
FROM %sposts
|
598 |
WHERE `post_type` = 'revision'
|
599 |
%s
|
@@ -603,9 +602,8 @@ class ODB_Cleaner
|
|
603 |
", $odb_class->odb_ms_prefixes[$i], $where, $max_revisions);
|
604 |
|
605 |
$res = $wpdb->get_results($sql, ARRAY_A);
|
606 |
-
|
607 |
for($j=0; $j<count($res); $j++)
|
608 |
-
{ if(isset($res[$j]))
|
609 |
{ $res_arr[$index] = $res[$j];
|
610 |
$res_arr[$index]['site'] = $odb_class->odb_ms_prefixes[$i];
|
611 |
$index++;
|
@@ -694,15 +692,17 @@ class ODB_Cleaner
|
|
694 |
|
695 |
for($j=0; $j<$nr_to_delete; $j++)
|
696 |
{
|
697 |
-
if(!$
|
698 |
-
|
699 |
-
|
700 |
-
|
701 |
-
|
702 |
-
|
703 |
-
|
704 |
-
|
705 |
-
|
|
|
|
|
706 |
} // for($j=0; $j<$nr_to_delete; $j++)
|
707 |
|
708 |
$nr++;
|
@@ -720,6 +720,16 @@ class ODB_Cleaner
|
|
720 |
} // function odb_delete_revisions()
|
721 |
|
722 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
723 |
/********************************************************************************************
|
724 |
* GET TRASHED POSTS / PAGES AND COMMENTS
|
725 |
********************************************************************************************/
|
62 |
/****************************************************************************************
|
63 |
* DELETE REVISIONS
|
64 |
****************************************************************************************/
|
|
|
65 |
if($odb_class->odb_rvg_options['delete_older'] == 'Y' || $odb_class->odb_rvg_options['rvg_revisions'] == 'Y')
|
66 |
{
|
67 |
// FIND REVISIONS
|
557 |
$res = $wpdb->get_results($sql, ARRAY_A);
|
558 |
|
559 |
for($j=0; $j<count($res); $j++)
|
560 |
+
{ if(isset($res[$j]) && !$this->odb_post_is_excluded($res[$j]['post_parent']))
|
561 |
{ $res_arr[$index] = $res[$j];
|
562 |
$res_arr[$index]['site'] = $odb_class->odb_ms_prefixes[$i];
|
563 |
$index++;
|
592 |
|
593 |
for($i=0; $i<count($odb_class->odb_ms_prefixes); $i++)
|
594 |
{ $sql = sprintf ("
|
595 |
+
SELECT `ID`, `post_parent`, `post_title`, COUNT(*) cnt
|
596 |
FROM %sposts
|
597 |
WHERE `post_type` = 'revision'
|
598 |
%s
|
602 |
", $odb_class->odb_ms_prefixes[$i], $where, $max_revisions);
|
603 |
|
604 |
$res = $wpdb->get_results($sql, ARRAY_A);
|
|
|
605 |
for($j=0; $j<count($res); $j++)
|
606 |
+
{ if(isset($res[$j]) && !$this->odb_post_is_excluded($res[$j]['post_parent']))
|
607 |
{ $res_arr[$index] = $res[$j];
|
608 |
$res_arr[$index]['site'] = $odb_class->odb_ms_prefixes[$i];
|
609 |
$index++;
|
692 |
|
693 |
for($j=0; $j<$nr_to_delete; $j++)
|
694 |
{
|
695 |
+
//if (!$this->odb_post_is_excluded($results_get_posts[$j]['ID']))
|
696 |
+
//{
|
697 |
+
if(!$scheduler) echo $results_get_posts[$j]->post_modified.'<br />';
|
698 |
+
|
699 |
+
$sql_delete = sprintf ("
|
700 |
+
DELETE FROM %sposts
|
701 |
+
WHERE `ID` = %d
|
702 |
+
", $results[$i]['site'], $results_get_posts[$j]->ID);
|
703 |
+
|
704 |
+
$wpdb->get_results($sql_delete);
|
705 |
+
//}
|
706 |
} // for($j=0; $j<$nr_to_delete; $j++)
|
707 |
|
708 |
$nr++;
|
720 |
} // function odb_delete_revisions()
|
721 |
|
722 |
|
723 |
+
/********************************************************************************************
|
724 |
+
* CHECK IF POST IS EXCLUDED BY A CUSTOM FIELD ('keep_revisions')
|
725 |
+
********************************************************************************************/
|
726 |
+
function odb_post_is_excluded($parent_id)
|
727 |
+
{
|
728 |
+
$keep_revisions = get_post_meta($parent_id, 'keep_revisions', true);
|
729 |
+
return ($keep_revisions === 'Y');
|
730 |
+
} // odb_post_is_exclude()
|
731 |
+
|
732 |
+
|
733 |
/********************************************************************************************
|
734 |
* GET TRASHED POSTS / PAGES AND COMMENTS
|
735 |
********************************************************************************************/
|
classes/odb-displayer.php
CHANGED
@@ -128,34 +128,39 @@ class ODB_Displayer
|
|
128 |
function display_start_buttons($action)
|
129 |
{
|
130 |
global $odb_class;
|
131 |
-
|
132 |
-
|
|
|
|
|
133 |
<div id="odb-start-buttons" class="odb-padding-left">
|
134 |
<p>
|
135 |
<input class="button odb-normal" type="button" name="change_options" value="'.__('Change Settings', $odb_class->odb_txt_domain).'" onclick="self.location=\'options-general.php?page=odb_settings_page\'">
|
136 |
-
|
137 |
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
|
142 |
<input class="button odb-normal" type="button" name="view_log" value="'.__('View Log File', $odb_class->odb_txt_domain).'" onclick="window.open(\''.$odb_class->odb_logfile_url.'\')">
|
143 |
|
144 |
<input class="button odb-normal" type="button" name="delete_log" value="'.__('Delete Log File', $odb_class->odb_txt_domain).'" onclick="self.location=\'tools.php?page=rvg-optimize-database&action=delete_log\'">
|
145 |
-
|
146 |
-
|
147 |
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
<input class="button-primary button-large" type="button" name="start_optimization" value="'.__('Start Optimization', $odb_class->odb_txt_domain).'" onclick="self.location=\'tools.php?page=rvg-optimize-database&action=run\'" class="odb-bold" />
|
152 |
-
|
153 |
-
|
154 |
|
155 |
-
|
156 |
</p>
|
157 |
</div><!-- /odb-start-buttons -->
|
158 |
-
|
|
|
|
|
|
|
159 |
} // display_start_buttons()
|
160 |
} // ODB_Displayer
|
161 |
?>
|
128 |
function display_start_buttons($action)
|
129 |
{
|
130 |
global $odb_class;
|
131 |
+
|
132 |
+
if(!defined('RUN_OPTIMIZE_DATABASE'))
|
133 |
+
{
|
134 |
+
echo '
|
135 |
<div id="odb-start-buttons" class="odb-padding-left">
|
136 |
<p>
|
137 |
<input class="button odb-normal" type="button" name="change_options" value="'.__('Change Settings', $odb_class->odb_txt_domain).'" onclick="self.location=\'options-general.php?page=odb_settings_page\'">
|
138 |
+
';
|
139 |
|
140 |
+
if(file_exists($odb_class->odb_plugin_path.'logs/rvg-optimize-db-log.html'))
|
141 |
+
{ // THERE IS A LOG FILE
|
142 |
+
echo '
|
143 |
|
144 |
<input class="button odb-normal" type="button" name="view_log" value="'.__('View Log File', $odb_class->odb_txt_domain).'" onclick="window.open(\''.$odb_class->odb_logfile_url.'\')">
|
145 |
|
146 |
<input class="button odb-normal" type="button" name="delete_log" value="'.__('Delete Log File', $odb_class->odb_txt_domain).'" onclick="self.location=\'tools.php?page=rvg-optimize-database&action=delete_log\'">
|
147 |
+
';
|
148 |
+
} // if(file_exists($this->odb_plugin_path.'logs/rvg-optimize-db-log.html'))
|
149 |
|
150 |
+
if($action != 'run')
|
151 |
+
{ // NOT RUNNING: SHOW START BUTTON
|
152 |
+
echo '
|
153 |
<input class="button-primary button-large" type="button" name="start_optimization" value="'.__('Start Optimization', $odb_class->odb_txt_domain).'" onclick="self.location=\'tools.php?page=rvg-optimize-database&action=run\'" class="odb-bold" />
|
154 |
+
';
|
155 |
+
}
|
156 |
|
157 |
+
echo '
|
158 |
</p>
|
159 |
</div><!-- /odb-start-buttons -->
|
160 |
+
';
|
161 |
+
} else if (RUN_OPTIMIZE_DATABASE)
|
162 |
+
{ echo 'Database optimized!';
|
163 |
+
} // if(!defined('RUN_OPTIMIZE_DATABASE'))
|
164 |
} // display_start_buttons()
|
165 |
} // ODB_Displayer
|
166 |
?>
|
readme.txt
CHANGED
@@ -3,13 +3,13 @@ Contributors: CAGE Web Design | Rolf van Gelder
|
|
3 |
Donate link: http://cagewebdev.com/index.php/donations-odb/
|
4 |
Plugin Name: Optimize Database after Deleting Revisions
|
5 |
Plugin URI: http://cagewebdev.com/index.php/optimize-database-after-deleting-revisions-wordpress-plugin
|
6 |
-
Tags: database, delete, revisions, optimize, post, posts, page, pages, clean, clean up, trash, spam, trashed, spammed, database size, scheduler, transients, unused tags, pingback, trackback
|
7 |
Author URI: http://cagewebdev.com
|
8 |
Author: CAGE Web Design | Rolf van Gelder, Eindhoven, The Netherlands
|
9 |
Requires at least: 2.8
|
10 |
Tested up to: 4.4.2
|
11 |
-
Stable tag: 4.1.
|
12 |
-
Version: 4.1.
|
13 |
License: GPLv2 or later
|
14 |
|
15 |
== Description ==
|
@@ -24,7 +24,7 @@ This plugin is a 'One Click' WordPress Database Cleaner / Optimizer.
|
|
24 |
* Deletes 'expired transients' (optional)
|
25 |
* Deletes 'pingbacks' and 'trackbacks' (optional)
|
26 |
* Deletes 'orphan postmeta items'
|
27 |
-
* Optimizes the database tables (optionally you can exclude certain tables from optimization)
|
28 |
* Creates a log file of the optimizations (optional)
|
29 |
* Optimization can be scheduled to automatically run once hourly, twice daily, once daily or once weekly at a specific time (optional)
|
30 |
* 'Optimize DB (1 click)' link in the admin bar (optional)
|
@@ -34,9 +34,12 @@ This plugin is a 'One Click' WordPress Database Cleaner / Optimizer.
|
|
34 |
= Settings =
|
35 |
You can find the settings page in the WP Admin Panel » Optimize Database -or- via the WP Admin Panel » Optimize Database icon (depends on settings)
|
36 |
|
|
|
|
|
|
|
37 |
= Starting the Optimization =
|
38 |
-
You can start the Optimization in the WP Admin Panel » Optimize Database.<br
|
39 |
-
Note: if you use the Scheduler the Optimization will run automatically!<br
|
40 |
Note: you also can click the 'Optimize DB (1 click)' link in the admin bar (if enabled)
|
41 |
|
42 |
= Multisite Support =
|
@@ -44,6 +47,15 @@ Note: you also can click the 'Optimize DB (1 click)' link in the admin bar (if e
|
|
44 |
* 'Network Activate' the plugin
|
45 |
* You only can configure and run the plugin on the main network site, but it will optimize ALL the sub-sites too!
|
46 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
47 |
= Supported languages =
|
48 |
* Danish [da_DK] - translated by Alexander Leo-Hansen - http://alexanderleohansen.dk
|
49 |
* Dutch [nl_NL] - translated by Rolf van Gelder, CAGE Web Design - http://cagewebdev.com
|
@@ -70,7 +82,7 @@ http://wordpress.org/plugins/rvg-optimize-database/
|
|
70 |
NO WARRANTY, USE IT AT YOUR OWN RISK!
|
71 |
|
72 |
= Plugins by CAGE Web Design | Rolf van Gelder =
|
73 |
-
WordPress plugins created by CAGE Web Design | Rolf van Gelder<br
|
74 |
http://cagewebdev.com/index.php/wordpress-plugins/
|
75 |
|
76 |
== Installation ==
|
@@ -87,6 +99,10 @@ http://cagewebdev.com/index.php/wordpress-plugins/
|
|
87 |
* If you run the plugin from any of the sites, it will cleanup ALL the sites in the network!
|
88 |
|
89 |
== Changelog ==
|
|
|
|
|
|
|
|
|
90 |
= 4.1.3 [02/22/2016] =
|
91 |
* BUG FIX: Saving settings didn't work well for multi-sites
|
92 |
|
3 |
Donate link: http://cagewebdev.com/index.php/donations-odb/
|
4 |
Plugin Name: Optimize Database after Deleting Revisions
|
5 |
Plugin URI: http://cagewebdev.com/index.php/optimize-database-after-deleting-revisions-wordpress-plugin
|
6 |
+
Tags: database, delete, revisions, optimize, post, posts, page, pages, clean, clean up, trash, spam, trashed, spammed, database size, scheduler, transients, unused tags, pingback, trackback, unix cron tab, crontab
|
7 |
Author URI: http://cagewebdev.com
|
8 |
Author: CAGE Web Design | Rolf van Gelder, Eindhoven, The Netherlands
|
9 |
Requires at least: 2.8
|
10 |
Tested up to: 4.4.2
|
11 |
+
Stable tag: 4.1.4
|
12 |
+
Version: 4.1.4
|
13 |
License: GPLv2 or later
|
14 |
|
15 |
== Description ==
|
24 |
* Deletes 'expired transients' (optional)
|
25 |
* Deletes 'pingbacks' and 'trackbacks' (optional)
|
26 |
* Deletes 'orphan postmeta items'
|
27 |
+
* Optimizes the database tables (optionally you can exclude certain tables, or even specific posts/pages, from optimization)
|
28 |
* Creates a log file of the optimizations (optional)
|
29 |
* Optimization can be scheduled to automatically run once hourly, twice daily, once daily or once weekly at a specific time (optional)
|
30 |
* 'Optimize DB (1 click)' link in the admin bar (optional)
|
34 |
= Settings =
|
35 |
You can find the settings page in the WP Admin Panel » Optimize Database -or- via the WP Admin Panel » Optimize Database icon (depends on settings)
|
36 |
|
37 |
+
= Excluding specific posts/pages from deleting revisions =
|
38 |
+
If you want to keep revisions for a specific post/page (no matter what the other settings are), create a custom field named 'keep_revisions' for that post/page and give it the value 'Y'<br>
|
39 |
+
|
40 |
= Starting the Optimization =
|
41 |
+
You can start the Optimization in the WP Admin Panel » Optimize Database.<br>
|
42 |
+
Note: if you use the Scheduler the Optimization will run automatically!<br>
|
43 |
Note: you also can click the 'Optimize DB (1 click)' link in the admin bar (if enabled)
|
44 |
|
45 |
= Multisite Support =
|
47 |
* 'Network Activate' the plugin
|
48 |
* You only can configure and run the plugin on the main network site, but it will optimize ALL the sub-sites too!
|
49 |
|
50 |
+
= Running the plug in from a Unix crontab =
|
51 |
+
In case you cannot use WPCron, but you can edit the Unix crontab:<br><br>
|
52 |
+
Create a .php file, in the root directory of your site, with:<br>
|
53 |
+
<?php<br>
|
54 |
+
define('RUN_OPTIMIZE_DATABASE', true);<br>
|
55 |
+
require_once('wp-load.php');<br>
|
56 |
+
?><br><br>
|
57 |
+
Then, start the .php file from your crontab!<br>
|
58 |
+
|
59 |
= Supported languages =
|
60 |
* Danish [da_DK] - translated by Alexander Leo-Hansen - http://alexanderleohansen.dk
|
61 |
* Dutch [nl_NL] - translated by Rolf van Gelder, CAGE Web Design - http://cagewebdev.com
|
82 |
NO WARRANTY, USE IT AT YOUR OWN RISK!
|
83 |
|
84 |
= Plugins by CAGE Web Design | Rolf van Gelder =
|
85 |
+
WordPress plugins created by CAGE Web Design | Rolf van Gelder<br>
|
86 |
http://cagewebdev.com/index.php/wordpress-plugins/
|
87 |
|
88 |
== Installation ==
|
99 |
* If you run the plugin from any of the sites, it will cleanup ALL the sites in the network!
|
100 |
|
101 |
== Changelog ==
|
102 |
+
= 4.1.4 [03/02/2016] =
|
103 |
+
* NEW: Custom field 'keep_revisions', for excluding the deletion of revisions for specific posts/pages
|
104 |
+
* NEW: Run the optimization from a Unix crontab (if possible)
|
105 |
+
|
106 |
= 4.1.3 [02/22/2016] =
|
107 |
* BUG FIX: Saving settings didn't work well for multi-sites
|
108 |
|
rvg-optimize-database.php
CHANGED
@@ -1,7 +1,7 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
* @package Optimize Database after Deleting Revisions
|
4 |
-
* @version 4.1.
|
5 |
*/
|
6 |
/*
|
7 |
Plugin Name: Optimize Database after Deleting Revisions
|
@@ -10,7 +10,7 @@ Description: Optimizes the Wordpress Database after Cleaning it out
|
|
10 |
Author: CAGE Web Design | Rolf van Gelder, Eindhoven, The Netherlands
|
11 |
Author URI: http://cagewebdev.com
|
12 |
Network: True
|
13 |
-
Version: 4.1.
|
14 |
*/
|
15 |
|
16 |
/********************************************************************************************
|
@@ -25,8 +25,8 @@ $odb_class = new OptimizeDatabase();
|
|
25 |
class OptimizeDatabase
|
26 |
{
|
27 |
// VERSION
|
28 |
-
var $odb_version = '4.1.
|
29 |
-
var $odb_release_date = '02/
|
30 |
|
31 |
// PLUGIN OPTIONS
|
32 |
var $odb_rvg_options = array();
|
@@ -83,7 +83,7 @@ class OptimizeDatabase
|
|
83 |
* INITIALIZE PLUGIN
|
84 |
*******************************************************************************/
|
85 |
function odb_init()
|
86 |
-
{
|
87 |
// LOAD CLASSES
|
88 |
$this->odb_classes();
|
89 |
|
@@ -116,6 +116,8 @@ class OptimizeDatabase
|
|
116 |
{ wp_register_style('odb-style'.$this->odb_version, plugins_url('css/style'.$this->odb_minify.'.css', __FILE__));
|
117 |
wp_enqueue_style('odb-style'.$this->odb_version);
|
118 |
}
|
|
|
|
|
119 |
} // odb_init()
|
120 |
|
121 |
|
@@ -511,7 +513,7 @@ class OptimizeDatabase
|
|
511 |
* START CLEANING / OPTIMIZATION (INITIATED BY THE USER, NOT FROM WP-CRON)
|
512 |
*******************************************************************************/
|
513 |
function odb_start_manually()
|
514 |
-
{
|
515 |
$this->odb_start(false);
|
516 |
} // odb_start_manually()
|
517 |
|
1 |
<?php
|
2 |
/**
|
3 |
* @package Optimize Database after Deleting Revisions
|
4 |
+
* @version 4.1.4
|
5 |
*/
|
6 |
/*
|
7 |
Plugin Name: Optimize Database after Deleting Revisions
|
10 |
Author: CAGE Web Design | Rolf van Gelder, Eindhoven, The Netherlands
|
11 |
Author URI: http://cagewebdev.com
|
12 |
Network: True
|
13 |
+
Version: 4.1.4
|
14 |
*/
|
15 |
|
16 |
/********************************************************************************************
|
25 |
class OptimizeDatabase
|
26 |
{
|
27 |
// VERSION
|
28 |
+
var $odb_version = '4.1.4';
|
29 |
+
var $odb_release_date = '02/29/2016';
|
30 |
|
31 |
// PLUGIN OPTIONS
|
32 |
var $odb_rvg_options = array();
|
83 |
* INITIALIZE PLUGIN
|
84 |
*******************************************************************************/
|
85 |
function odb_init()
|
86 |
+
{
|
87 |
// LOAD CLASSES
|
88 |
$this->odb_classes();
|
89 |
|
116 |
{ wp_register_style('odb-style'.$this->odb_version, plugins_url('css/style'.$this->odb_minify.'.css', __FILE__));
|
117 |
wp_enqueue_style('odb-style'.$this->odb_version);
|
118 |
}
|
119 |
+
|
120 |
+
if(defined('RUN_OPTIMIZE_DATABASE') && RUN_OPTIMIZE_DATABASE == 1) $this->odb_start(true);
|
121 |
} // odb_init()
|
122 |
|
123 |
|
513 |
* START CLEANING / OPTIMIZATION (INITIATED BY THE USER, NOT FROM WP-CRON)
|
514 |
*******************************************************************************/
|
515 |
function odb_start_manually()
|
516 |
+
{
|
517 |
$this->odb_start(false);
|
518 |
} // odb_start_manually()
|
519 |
|