Optimize Database after Deleting Revisions - Version 2.1

Version Description

[01/04/2013] = * Bug fix: keeping a maximum number of revisions didn't work correctly

Download this release

Release Info

Developer cageehv
Plugin Icon 128x128 Optimize Database after Deleting Revisions
Version 2.1
Comparing to
See all releases

Code changes from version 2.0 to 2.1

Files changed (2) hide show
  1. readme.txt +7 -4
  2. rvg-optimize-db.php +10 -8
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
7
  Author URI: http://cagewebdev.com
8
  Author: CAGE Web Design | Rolf van Gelder, Eindhoven, The Netherlands
9
- Requires at least: 2.0
10
  Tested up to: 3.5
11
- Stable tag: 2.0
12
- Version: 2.0
13
 
14
  == Description ==
15
 
@@ -46,12 +46,15 @@ http://wordpress.org/extend/plugins/rvg-optimize-database/
46
  * Change the settings (if needed) in the WP Admin Panel » Settings » Optimize DB Options
47
 
48
  == Screenshots ==
 
49
  1. Optimize Database after Deleting Revisions - Options
50
  2. Run the Optimizer
51
 
52
-
53
  == Changelog ==
54
 
 
 
 
55
  = 2.0 [12/18/2012] =
56
  * NEW: Logging of the Optimizations (optional)
57
  * NEW: Scheduling Optimizations for Automatic Execution (optional)
6
  Tags: database, delete, revisions, optimize, post, posts, page, pages, clean, clean up, trash, spam, trashed, spammed, database size
7
  Author URI: http://cagewebdev.com
8
  Author: CAGE Web Design | Rolf van Gelder, Eindhoven, The Netherlands
9
+ Requires at least: 2.1
10
  Tested up to: 3.5
11
+ Stable tag: 2.1
12
+ Version: 2.1
13
 
14
  == Description ==
15
 
46
  * Change the settings (if needed) in the WP Admin Panel » Settings » Optimize DB Options
47
 
48
  == Screenshots ==
49
+
50
  1. Optimize Database after Deleting Revisions - Options
51
  2. Run the Optimizer
52
 
 
53
  == Changelog ==
54
 
55
+ = 2.1 [01/04/2013] =
56
+ * Bug fix: keeping a maximum number of revisions didn't work correctly
57
+
58
  = 2.0 [12/18/2012] =
59
  * NEW: Logging of the Optimizations (optional)
60
  * NEW: Scheduling Optimizations for Automatic Execution (optional)
rvg-optimize-db.php CHANGED
@@ -1,16 +1,16 @@
1
  <?php
2
- $odb_version = '2.0';
3
- $odb_release_date = '12/18/2012';
4
  /**
5
  * @package Optimize Database after Deleting Revisions
6
- * @version 2.0
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: Rolf van Gelder, Eindhoven, The Netherlands
13
- Version: 2.0
14
  Author URI: http://cagewebdev.com
15
  */
16
  ?>
@@ -402,7 +402,7 @@ function rvg_optimize_db()
402
  </tr>
403
  <?php
404
  // LOOP THROUGH THE REVISIONS AND DELETE THEM
405
- $total_deleted = rvg_delete_revisions($results, true);
406
  ?>
407
  <tr>
408
  <td colspan="3" align="right" style="border-top:solid 1px #999;font-weight:bold;">total number of revisions deleted</td>
@@ -669,7 +669,7 @@ function rvg_optimize_db_cron()
669
 
670
  if(count($results)>0)
671
  // WE HAVE TRASH TO DELETE!
672
- $total_deleted = rvg_delete_trash($results, false);
673
 
674
  } // if($clear_trash == 'Y')
675
 
@@ -718,12 +718,13 @@ function rvg_optimize_db_cron()
718
  DELETE THE REVISIONS
719
 
720
  *********************************************************************************************/
721
- function rvg_delete_revisions($results, $display)
722
  {
723
  global $wpdb;
724
 
725
  $nr = 1;
726
  $total_deleted = 0;
 
727
  for($i=0; $i<count($results); $i++)
728
  { $nr_to_delete = $results[$i]->cnt - $max_revisions;
729
  $total_deleted += $nr_to_delete;
@@ -967,7 +968,7 @@ td {
967
  </head>
968
  <body>
969
  <div id="header">
970
- <h2><a href="http://cagewebdev.com/index.php/optimize-database-after-deleting-revisions-wordpress-plugin/" target="_blank">Optimize Database after Deleting Revisions v2.0</a></h2>
971
  A WordPress Plugin by <a href="http://cagewebdev.com" target="_blank"><strong>CAGE Web Design | Rolf van Gelder</strong></a>, Eindhoven, The Netherlands</strong>
972
  </div>
973
  <table width="100%" border="0" cellspacing="6" cellpadding="1">
@@ -1030,6 +1031,7 @@ function rvg_get_revisions($max_revisions)
1030
  HAVING COUNT(*) > ".$max_revisions."
1031
  ORDER BY UCASE(`post_title`)
1032
  ";
 
1033
  return $wpdb -> get_results($sql);
1034
 
1035
  } // rvg_get_revisions()
1
  <?php
2
+ $odb_version = '2.1';
3
+ $odb_release_date = '01/04/2013';
4
  /**
5
  * @package Optimize Database after Deleting Revisions
6
+ * @version 2.1
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: Rolf van Gelder, Eindhoven, The Netherlands
13
+ Version: 2.1
14
  Author URI: http://cagewebdev.com
15
  */
16
  ?>
402
  </tr>
403
  <?php
404
  // LOOP THROUGH THE REVISIONS AND DELETE THEM
405
+ $total_deleted = rvg_delete_revisions($results, true, $max_revisions);
406
  ?>
407
  <tr>
408
  <td colspan="3" align="right" style="border-top:solid 1px #999;font-weight:bold;">total number of revisions deleted</td>
669
 
670
  if(count($results)>0)
671
  // WE HAVE TRASH TO DELETE!
672
+ $total_deleted = rvg_delete_trash($results, false, $max_revisions);
673
 
674
  } // if($clear_trash == 'Y')
675
 
718
  DELETE THE REVISIONS
719
 
720
  *********************************************************************************************/
721
+ function rvg_delete_revisions($results, $display, $max_revisions)
722
  {
723
  global $wpdb;
724
 
725
  $nr = 1;
726
  $total_deleted = 0;
727
+
728
  for($i=0; $i<count($results); $i++)
729
  { $nr_to_delete = $results[$i]->cnt - $max_revisions;
730
  $total_deleted += $nr_to_delete;
968
  </head>
969
  <body>
970
  <div id="header">
971
+ <h2><a href="http://cagewebdev.com/index.php/optimize-database-after-deleting-revisions-wordpress-plugin/" target="_blank">Optimize Database after Deleting Revisions v2.1</a></h2>
972
  A WordPress Plugin by <a href="http://cagewebdev.com" target="_blank"><strong>CAGE Web Design | Rolf van Gelder</strong></a>, Eindhoven, The Netherlands</strong>
973
  </div>
974
  <table width="100%" border="0" cellspacing="6" cellpadding="1">
1031
  HAVING COUNT(*) > ".$max_revisions."
1032
  ORDER BY UCASE(`post_title`)
1033
  ";
1034
+ // echo $sql.'<br />';
1035
  return $wpdb -> get_results($sql);
1036
 
1037
  } // rvg_get_revisions()