Optimize Database after Deleting Revisions - Version 2.2.1

Version Description

[01/17/2013] = * Bug fix: fixed some debug warnings

Download this release

Release Info

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

Code changes from version 2.2 to 2.2.1

Files changed (2) hide show
  1. readme.txt +7 -4
  2. rvg-optimize-db.php +38 -27
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.2
10
  Tested up to: 3.5
11
- Stable tag: 2.2
12
- Version: 2.2
13
 
14
  == Description ==
15
 
@@ -44,10 +44,13 @@ http://wordpress.org/extend/plugins/rvg-optimize-database/
44
 
45
  * Upload the Plugin to the `/wp-content/plugins/` directory
46
  * Activate the plugin in the WP Admin Panel » Plugins
47
- * Change the settings (if needed) in the WP Admin Panel » Tools » Optimize Database
48
 
49
  == Changelog ==
50
 
 
 
 
51
  = 2.2 [01/11/2013] =
52
  * NEW: 'Orphan Postmeta items' will be automatically deleted
53
  * NEW: the possibility to exclude tables from Optimization (for instance for 'heavy traffic' tables)
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.2.1
10
  Tested up to: 3.5
11
+ Stable tag: 2.2.1
12
+ Version: 2.2.1
13
 
14
  == Description ==
15
 
44
 
45
  * Upload the Plugin to the `/wp-content/plugins/` directory
46
  * Activate the plugin in the WP Admin Panel » Plugins
47
+ * Change the settings (if needed) in the WP Admin Panel » Settings » Optimize DB Options.
48
 
49
  == Changelog ==
50
 
51
+ = 2.2.1 [01/17/2013] =
52
+ * Bug fix: fixed some debug warnings
53
+
54
  = 2.2 [01/11/2013] =
55
  * NEW: 'Orphan Postmeta items' will be automatically deleted
56
  * NEW: the possibility to exclude tables from Optimization (for instance for 'heavy traffic' tables)
rvg-optimize-db.php CHANGED
@@ -1,16 +1,16 @@
1
  <?php
2
- $odb_version = '2.2';
3
- $odb_release_date = '01/11/2013';
4
  /**
5
  * @package Optimize Database after Deleting Revisions
6
- * @version 2.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: Rolf van Gelder, Eindhoven, The Netherlands
13
- Version: 2.2
14
  Author URI: http://cagewebdev.com
15
  */
16
  ?>
@@ -91,7 +91,8 @@ function rvg_odb_options_page() {
91
  # RVG_WP_ONLY IS DEPRECIATED FROM v2.2
92
  rvg_fix_wp_only();
93
 
94
- if($_REQUEST['delete_log'] == "Y") @unlink(dirname(__FILE__).'/rvg-optimize-db-log.html');
 
95
 
96
  // SAVE THE OPTIONS
97
  if (isset($_POST['info_update']))
@@ -116,23 +117,29 @@ function rvg_odb_options_page() {
116
  }
117
  }
118
 
119
- $rvg_odb_number = trim($_POST['rvg_odb_number']);
120
- update_option('rvg_odb_number', $rvg_odb_number);
 
 
121
 
122
  $rvg_clear_trash = 'N';
123
- if($_POST['rvg_clear_trash'] == 'Y') $rvg_clear_trash = 'Y';
 
124
  update_option('rvg_clear_trash', $rvg_clear_trash);
125
 
126
  $rvg_clear_spam = 'N';
127
- if($_POST['rvg_clear_spam'] == 'Y') $rvg_clear_spam = 'Y';
 
128
  update_option('rvg_clear_spam', $rvg_clear_spam);
129
 
130
  $rvg_odb_logging_on = 'N';
131
- if($_POST['rvg_odb_logging_on'] == 'Y') $rvg_odb_logging_on = 'Y';
 
132
  update_option('rvg_odb_logging_on', $rvg_odb_logging_on);
133
 
134
  $rvg_odb_schedule = '';
135
- if($_POST['rvg_odb_schedule']) $rvg_odb_schedule = $_POST['rvg_odb_schedule'];
 
136
  update_option('rvg_odb_schedule', $rvg_odb_schedule);
137
 
138
  // CLEAR CURRENT SCHEDULE (IF ANY)
@@ -185,7 +192,7 @@ function rvg_odb_options_page() {
185
  <?php
186
  if($rvg_clear_trash == 'Y') $rvg_clear_trash_checked = ' checked="checked"'; else $rvg_clear_trash_checked = '';
187
  if($rvg_clear_spam == 'Y') $rvg_clear_spam_checked = ' checked="checked"'; else $rvg_clear_spam_checked = '';
188
- if($rvg_odb_logging_on == 'Y') $rvg_odb_logging_on_checked = ' checked="checked"'; else $rvg_odb_logging_on = '';
189
  ?>
190
  <blockquote>
191
  <fieldset class='options'>
@@ -255,8 +262,9 @@ if($rvg_odb_logging_on == 'Y') $rvg_odb_logging_on_checked = ' checked="checke
255
  FROM $wpdb->options
256
  WHERE `option_name` = 'rvg_ex_".$row[0]."'
257
  ";
258
- $results = $wpdb -> get_results($sql);
259
- if($results[0]->option_value == 'excluded') $cb_checked = ' checked';
 
260
  echo '<td width="25%" style="font-weight:'.$style.'"><input id="cb_'.$row[0].'" name="cb_'.$row[0].'" type="checkbox" value="1" '.$cb_checked.' /> '.$row[0].'</td>'."\n";
261
  } # while($row = mysql_fetch_row($names))
262
  ?>
@@ -284,8 +292,9 @@ function rvg_optimize_db()
284
  {
285
  global $wpdb, $odb_version, $table_prefix;
286
 
287
- if($_REQUEST['action'] == "delete_log")
288
- @unlink(dirname(__FILE__).'/rvg-optimize-db-log.html');
 
289
 
290
  /****************************************************************************************
291
 
@@ -339,7 +348,7 @@ function rvg_optimize_db()
339
  $rvg_odb_schedule_txt = 'EVERY FIVE MINUTES';
340
 
341
  $nextrun = '';
342
- if(!$rvg_odb_schedule_txt)
343
  { $rvg_odb_schedule_txt = 'NOT SCHEDULED';
344
  }
345
  else
@@ -362,9 +371,9 @@ function rvg_optimize_db()
362
  <div style="padding-left:8px;">
363
  <h2>Optimize your WordPress Database</h2>
364
  <?php
365
- if($_REQUEST['action'] == "delete_log")
366
- { echo '<div class="updated" style="position:relative;left:-15px;"><p><strong>Optimize Database after Deleting Revisions - LOG FILE DELETED</strong></p></div>';
367
- }
368
  ?>
369
  <p><span style="font-style:italic;"><a href="http://cagewebdev.com/index.php/optimize-database-after-deleting-revisions-wordpress-plugin/" target="_blank" style="font-weight:bold;">Optimize Database after Deleting Revisions v<?php echo $odb_version?></a> - A WordPress Plugin by <a href="http://cagewebdev.com/" target="_blank" style="font-weight:bold;">CAGE Web Design</a> | <a href="http://cage.nl/" target="_blank" style="font-weight:bold;">Rolf van Gelder</a>, Eindhoven, The Netherlands</span></p>
370
  <p>Current options:<br />
@@ -404,20 +413,22 @@ function rvg_optimize_db()
404
  }
405
  ?>
406
  <?php
407
- if($_REQUEST['action'] != 'run')
 
 
408
  {
409
  ?>
410
  &nbsp;
411
  <input class="button-primary button-large" type="button" name="start_optimization" value="Start Optimization" onclick="self.location='tools.php?page=rvg-optimize-db.php&action=run'" style="font-weight:bold;" />
412
- <?php
413
  }
414
  ?>
415
  </p>
416
  </div>
417
  <?php
418
- if($_REQUEST['action'] != 'run')
419
- { return;
420
- }
421
  ?>
422
  <h2 style="padding-left:8px;">Starting Optimization...</h2>
423
  <?php
@@ -943,7 +954,7 @@ function rvg_delete_orphans($display)
943
  $sql_delete = "
944
  SELECT COUNT(*) cnt
945
  FROM $wpdb->postmeta pm
946
- WHERE pm.post_id NOT IN (SELECT p.ID FROM $wpdb->posts)
947
  ";
948
  $results = $wpdb -> get_results($sql_delete);
949
 
@@ -952,7 +963,7 @@ function rvg_delete_orphans($display)
952
  if($total_deleted > 0)
953
  { $sql_delete = "
954
  DELETE FROM $wpdb->postmeta pm
955
- WHERE pm.post_id NOT IN (SELECT p.ID FROM $wpdb->posts)
956
  ";
957
  $wpdb -> get_results($sql_delete);
958
  }
1
  <?php
2
+ $odb_version = '2.2.1';
3
+ $odb_release_date = '01/17/2013';
4
  /**
5
  * @package Optimize Database after Deleting Revisions
6
+ * @version 2.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.2.1
14
  Author URI: http://cagewebdev.com
15
  */
16
  ?>
91
  # RVG_WP_ONLY IS DEPRECIATED FROM v2.2
92
  rvg_fix_wp_only();
93
 
94
+ if(isset($_REQUEST['delete_log']))
95
+ if($_REQUEST['delete_log'] == "Y") @unlink(dirname(__FILE__).'/rvg-optimize-db-log.html');
96
 
97
  // SAVE THE OPTIONS
98
  if (isset($_POST['info_update']))
117
  }
118
  }
119
 
120
+ if(isset($_POST['rvg_odb_number']))
121
+ { $rvg_odb_number = trim($_POST['rvg_odb_number']);
122
+ update_option('rvg_odb_number', $rvg_odb_number);
123
+ }
124
 
125
  $rvg_clear_trash = 'N';
126
+ if(isset($_POST['rvg_clear_trash']))
127
+ $rvg_clear_trash = $_POST['rvg_clear_trash'];
128
  update_option('rvg_clear_trash', $rvg_clear_trash);
129
 
130
  $rvg_clear_spam = 'N';
131
+ if(isset($_POST['rvg_clear_spam']))
132
+ $rvg_clear_spam = $_POST['rvg_clear_spam'];
133
  update_option('rvg_clear_spam', $rvg_clear_spam);
134
 
135
  $rvg_odb_logging_on = 'N';
136
+ if(isset($_POST['rvg_odb_logging_on']))
137
+ $rvg_odb_logging_on = $_POST['rvg_odb_logging_on'];
138
  update_option('rvg_odb_logging_on', $rvg_odb_logging_on);
139
 
140
  $rvg_odb_schedule = '';
141
+ if(isset($_POST['rvg_odb_schedule']))
142
+ $rvg_odb_schedule = $_POST['rvg_odb_schedule'];
143
  update_option('rvg_odb_schedule', $rvg_odb_schedule);
144
 
145
  // CLEAR CURRENT SCHEDULE (IF ANY)
192
  <?php
193
  if($rvg_clear_trash == 'Y') $rvg_clear_trash_checked = ' checked="checked"'; else $rvg_clear_trash_checked = '';
194
  if($rvg_clear_spam == 'Y') $rvg_clear_spam_checked = ' checked="checked"'; else $rvg_clear_spam_checked = '';
195
+ if($rvg_odb_logging_on == 'Y') $rvg_odb_logging_on_checked = ' checked="checked"'; else $rvg_odb_logging_on_checked = '';
196
  ?>
197
  <blockquote>
198
  <fieldset class='options'>
262
  FROM $wpdb->options
263
  WHERE `option_name` = 'rvg_ex_".$row[0]."'
264
  ";
265
+ $results = $wpdb -> get_results($sql);
266
+ if(isset($results[0]->option_value))
267
+ if($results[0]->option_value == 'excluded') $cb_checked = ' checked';
268
  echo '<td width="25%" style="font-weight:'.$style.'"><input id="cb_'.$row[0].'" name="cb_'.$row[0].'" type="checkbox" value="1" '.$cb_checked.' /> '.$row[0].'</td>'."\n";
269
  } # while($row = mysql_fetch_row($names))
270
  ?>
292
  {
293
  global $wpdb, $odb_version, $table_prefix;
294
 
295
+ if(isset($_REQUEST['action']))
296
+ if($_REQUEST['action'] == "delete_log")
297
+ @unlink(dirname(__FILE__).'/rvg-optimize-db-log.html');
298
 
299
  /****************************************************************************************
300
 
348
  $rvg_odb_schedule_txt = 'EVERY FIVE MINUTES';
349
 
350
  $nextrun = '';
351
+ if(!isset($rvg_odb_schedule_txt))
352
  { $rvg_odb_schedule_txt = 'NOT SCHEDULED';
353
  }
354
  else
371
  <div style="padding-left:8px;">
372
  <h2>Optimize your WordPress Database</h2>
373
  <?php
374
+ if(isset($_REQUEST['action']))
375
+ if($_REQUEST['action'] == "delete_log")
376
+ echo '<div class="updated" style="position:relative;left:-15px;"><p><strong>Optimize Database after Deleting Revisions - LOG FILE DELETED</strong></p></div>';
377
  ?>
378
  <p><span style="font-style:italic;"><a href="http://cagewebdev.com/index.php/optimize-database-after-deleting-revisions-wordpress-plugin/" target="_blank" style="font-weight:bold;">Optimize Database after Deleting Revisions v<?php echo $odb_version?></a> - A WordPress Plugin by <a href="http://cagewebdev.com/" target="_blank" style="font-weight:bold;">CAGE Web Design</a> | <a href="http://cage.nl/" target="_blank" style="font-weight:bold;">Rolf van Gelder</a>, Eindhoven, The Netherlands</span></p>
379
  <p>Current options:<br />
413
  }
414
  ?>
415
  <?php
416
+ $action = '';
417
+ if(isset($_REQUEST['action'])) $action = $_REQUEST['action'];
418
+ if($action != 'run')
419
  {
420
  ?>
421
  &nbsp;
422
  <input class="button-primary button-large" type="button" name="start_optimization" value="Start Optimization" onclick="self.location='tools.php?page=rvg-optimize-db.php&action=run'" style="font-weight:bold;" />
423
+ <?php
424
  }
425
  ?>
426
  </p>
427
  </div>
428
  <?php
429
+ $action = '';
430
+ if(isset($_REQUEST['action'])) $action = $_REQUEST['action'];
431
+ if($action != 'run') return;
432
  ?>
433
  <h2 style="padding-left:8px;">Starting Optimization...</h2>
434
  <?php
954
  $sql_delete = "
955
  SELECT COUNT(*) cnt
956
  FROM $wpdb->postmeta pm
957
+ WHERE pm.post_id NOT IN (SELECT ID FROM $wpdb->posts)
958
  ";
959
  $results = $wpdb -> get_results($sql_delete);
960
 
963
  if($total_deleted > 0)
964
  { $sql_delete = "
965
  DELETE FROM $wpdb->postmeta pm
966
+ WHERE pm.post_id NOT IN (SELECT ID FROM $wpdb->posts)
967
  ";
968
  $wpdb -> get_results($sql_delete);
969
  }