Optimize Database after Deleting Revisions - Version 5.0

Version Description

[08/14/2020] = * New: Deletion of Duplicated Postmeta entries

Download this release

Release Info

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

Code changes from version 4.9.1 to 5.0

classes/odb-cleaner.php CHANGED
@@ -67,7 +67,8 @@ class ODB_Cleaner {
67
  $odb_class->log_arr["before"] = 0;
68
  $odb_class->log_arr["pingbacks"] = 0;
69
  $odb_class->log_arr["oembeds"] = 0;
70
- $odb_class->log_arr["orphans"] = 0;
 
71
  $odb_class->log_arr["revisions"] = 0;
72
  $odb_class->log_arr["savings"] = 0;
73
  $odb_class->log_arr["spam"] = 0;
@@ -795,6 +796,93 @@ class ODB_Cleaner {
795
  } // if (!$scheduler)
796
  } // if (count($results) > 0)
797
  } // if($odb_class->odb_rvg_options['clear_orphans'] == 'Y')
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
798
  ?>
799
  <div class="odb-found-number">
800
  <?php _e('TOTAL NUMBER OF ITEMS: ', $odb_class->odb_txt_domain);?>
@@ -1909,7 +1997,6 @@ function odb_confirm_delete() {
1909
  WHERE `ID` = %d
1910
  ", $results[$j]['site'], $results[$j]['ID']);
1911
  } else if ($results[$j]['type'] == 'term relationship') {
1912
- //print_r($results[$j]);
1913
  $sql = sprintf ("
1914
  DELETE FROM %sterm_relationships
1915
  WHERE `object_id` = %d
@@ -1924,6 +2011,84 @@ function odb_confirm_delete() {
1924
  } // odb_delete_orphans()
1925
 
1926
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1927
  /********************************************************************************************
1928
  *
1929
  * OPTIMIZE DATABASE TABLES
67
  $odb_class->log_arr["before"] = 0;
68
  $odb_class->log_arr["pingbacks"] = 0;
69
  $odb_class->log_arr["oembeds"] = 0;
70
+ $odb_class->log_arr["orphans"] = 0;
71
+ $odb_class->log_arr["dupmeta"] = 0;
72
  $odb_class->log_arr["revisions"] = 0;
73
  $odb_class->log_arr["savings"] = 0;
74
  $odb_class->log_arr["spam"] = 0;
796
  } // if (!$scheduler)
797
  } // if (count($results) > 0)
798
  } // if($odb_class->odb_rvg_options['clear_orphans'] == 'Y')
799
+
800
+
801
+ /****************************************************************************************
802
+ *
803
+ * DELETE DUPLICATED POSTMETA ITEMS
804
+ *
805
+ ****************************************************************************************/
806
+ if($odb_class->odb_rvg_options['clear_dupmeta'] == 'Y') {
807
+
808
+ // GET DUPLICATED POSTMETA ITEMS
809
+ $results = $this->odb_get_dupmeta($scheduler);
810
+
811
+ if (count($results) > 0) {
812
+ // DUPLICATED ITEMS FOUND
813
+ $this->grand_total += count($results);
814
+
815
+ if ($action == 'analyze_summary' || $action == 'run_summary') {
816
+ if ($action == 'analyze_summary') {
817
+ ?>
818
+ <div class="odb-found-number">
819
+ <?php _e('DUPLICATED POSTMETA ITEMS found to delete: ', $odb_class->odb_txt_domain);?>
820
+ <?php echo count($results) . '<br>';?>
821
+ </div>
822
+ <?php
823
+ } // if ($action == 'analyze_summary')
824
+
825
+ if ($action == 'run_summary') {
826
+ ?>
827
+ <div class="odb-found-number">
828
+ <?php _e('DUPLICATED POSTMETA ITEMS deleted: ', $odb_class->odb_txt_domain);?>
829
+ <?php echo count($results) . '<br>';?>
830
+ </div>
831
+ <?php
832
+ } // if ($action == 'run_summary')
833
+ } // if ($action == 'analyze_summary' || $action == 'run_summary')
834
+
835
+ if ($action == 'analyze_detail' || $action == 'run_detail') {
836
+
837
+ if ($action == 'analyze_detail') {
838
+ $msg1 = __('DUPLICATED POSTMETA ITEMS', $odb_class->odb_txt_domain);
839
+ $msg2 = __('total number of duplicates', $odb_class->odb_txt_domain);
840
+ } else {
841
+ // ACTION = 'RUN_DETAIL'
842
+ $msg1 = __('DELETED POSTMETA ITEMS', $odb_class->odb_txt_domain);
843
+ $msg2 = __('total number of duplicates deleted', $odb_class->odb_txt_domain);
844
+ } // if ($action == 'analyze_detail')
845
+ ?>
846
+ <table border="0" cellspacing="8" cellpadding="2" class="odb-result-table">
847
+ <tr>
848
+ <td colspan="4"><div class="odb-found">
849
+ <?php echo $msg1 ?>
850
+ </div></td>
851
+ </tr>
852
+ <tr>
853
+ <th align="right" class="odb-border-bottom">#</th>
854
+ <th align="left" class="odb-border-bottom"><?php _e('prefix', $odb_class->odb_txt_domain);?></th>
855
+ <th align="left" class="odb-border-bottom"><?php _e('meta_id', $odb_class->odb_txt_domain);?></th>
856
+ <th align="left" class="odb-border-bottom"><?php _e('post_id', $odb_class->odb_txt_domain);?></th>
857
+ <th align="left" class="odb-border-bottom"><?php _e('meta_key', $odb_class->odb_txt_domain);?></th>
858
+ <th align="left" class="odb-border-bottom"><?php _e('meta_value', $odb_class->odb_txt_domain);?></th>
859
+ </tr>
860
+ <?php
861
+ } // if ($action == 'analyze_detail' || $action == 'run_detail')
862
+
863
+ // LOOP THROUGH THE DUPLICATES AND DELETE THEM
864
+ $total_deleted = $this->odb_delete_dupmeta($results, $scheduler, $action);
865
+
866
+ if ($scheduler) $odb_class->log_arr["dupmeta"] = $total_deleted;
867
+
868
+ if ($action == 'run_summary' || $action == 'run_detail') {
869
+ // NUMBER OF DUPLICATES FOR LOG FILE
870
+ $odb_class->log_arr["dupmeta"] = $total_deleted;
871
+ } // if (!$scheduler && ($action == 'run_summary' || $action == 'run_detail')
872
+ ?>
873
+ </table>
874
+ <?php
875
+ } else {
876
+ // NO DUPLICATES FOUND
877
+ if (!$scheduler) {
878
+ ?>
879
+ <div class="odb-not-found">
880
+ <?php _e('No DUPLICATED POSTMETA ITEMS found to delete', $odb_class->odb_txt_domain);?>
881
+ </div>
882
+ <?php
883
+ } // if (!$scheduler)
884
+ } // if (count($results) > 0)
885
+ } // if($odb_class->odb_rvg_options['clear_dupmeta'] == 'Y')
886
  ?>
887
  <div class="odb-found-number">
888
  <?php _e('TOTAL NUMBER OF ITEMS: ', $odb_class->odb_txt_domain);?>
1997
  WHERE `ID` = %d
1998
  ", $results[$j]['site'], $results[$j]['ID']);
1999
  } else if ($results[$j]['type'] == 'term relationship') {
 
2000
  $sql = sprintf ("
2001
  DELETE FROM %sterm_relationships
2002
  WHERE `object_id` = %d
2011
  } // odb_delete_orphans()
2012
 
2013
 
2014
+ /********************************************************************************************
2015
+ *
2016
+ * GET DUPLICATED POSTMETA ITEMS v5.0
2017
+ *
2018
+ ********************************************************************************************/
2019
+ function odb_get_dupmeta() {
2020
+ global $wpdb, $odb_class;
2021
+
2022
+ $res_arr = array();
2023
+
2024
+ // LOOP THROUGH SITES
2025
+ for($i = 0; $i < count($odb_class->odb_ms_prefixes); $i++) {
2026
+ $prefix = $odb_class->odb_ms_prefixes[$i];
2027
+
2028
+ $sql = sprintf ("
2029
+ SELECT '%s' AS site,
2030
+ `meta_id`,
2031
+ `post_id`,
2032
+ `meta_key`,
2033
+ `meta_value`
2034
+ FROM %spostmeta
2035
+ WHERE `meta_id` NOT IN
2036
+ (SELECT * FROM (SELECT MAX(`pm`.`meta_id`)
2037
+ FROM %spostmeta pm
2038
+ GROUP BY `pm`.`post_id`, `pm`.`meta_key`) x)
2039
+ ORDER BY `meta_id`
2040
+ ", $prefix, $prefix, $prefix);
2041
+
2042
+ $results = $wpdb->get_results($sql, ARRAY_A);
2043
+ for ($j = 0; $j < count($results); $j++) {
2044
+ array_push($res_arr, $results[$j]);
2045
+ } // for ($j = 0; $j < count($results); $j++)
2046
+
2047
+ return $res_arr;
2048
+ } // for($i = 0; $i < count($odb_class->odb_ms_prefixes); $i++)
2049
+ } // odb_get_dupmeta()
2050
+
2051
+
2052
+ /********************************************************************************************
2053
+ *
2054
+ * DELETE DUPLICATED POSTMETA ITEMS v5.0
2055
+ *
2056
+ ********************************************************************************************/
2057
+ function odb_delete_dupmeta($results, $scheduler, $action = 'run_detail') {
2058
+
2059
+ global $wpdb, $odb_class;
2060
+
2061
+ $total_deleted = count($results);
2062
+
2063
+ for($i = 0; $i < count($results); $i++) {
2064
+ if (!$scheduler && ($action == 'analyze_detail' || $action == 'run_detail')) {
2065
+ ?>
2066
+ <tr>
2067
+ <td valign="top" align="right"><?php echo ($i + 1); ?></td>
2068
+ <td valign="top" align="left"><?php echo $results[$i]['site']?></td>
2069
+ <td valign="top"><?php echo $results[$i]['meta_id']?></td>
2070
+ <td valign="top"><?php echo $results[$i]['post_id']?></td>
2071
+ <td valign="top" nowrap="nowrap"><?php echo $results[$i]['meta_key']; ?></td>
2072
+ <td valign="top" nowrap="nowrap"><?php echo $results[$i]['meta_value']; ?></td>
2073
+ </tr>
2074
+ <?php
2075
+ } // if (!$scheduler && ($action == 'analyze_detail' || $action == 'run_detail'))
2076
+
2077
+ if ($scheduler || $action == 'run_summary' || $action == 'run_detail') {
2078
+ $sql = "";
2079
+ // DELETE DUPLICATES
2080
+ $sql = sprintf ("
2081
+ DELETE FROM %spostmeta
2082
+ WHERE `meta_id` = %d
2083
+ AND `post_id` = %d
2084
+ ", $results[$i]['site'], $results[$i]['meta_id'], $results[$i]['post_id']);
2085
+ $wpdb->get_results($sql);
2086
+ } // if ($action == 'run_summary' || $action == 'run_detail')
2087
+ } // for($i = 0; $i < count($results); $i++)
2088
+ return $total_deleted;
2089
+ } // odb_delete_dupmeta()
2090
+
2091
+
2092
  /********************************************************************************************
2093
  *
2094
  * OPTIMIZE DATABASE TABLES
classes/odb-logger.php CHANGED
@@ -44,6 +44,7 @@ class ODB_Logger {
44
  odb_pingbacks,
45
  odb_oembeds,
46
  odb_orphans,
 
47
  odb_tables,
48
  odb_before,
49
  odb_after,
@@ -60,6 +61,7 @@ class ODB_Logger {
60
  ". $odb_class->log_arr['pingbacks'] . ",
61
  ". $odb_class->log_arr['oembeds'] . ",
62
  ". $odb_class->log_arr['orphans'] . ",
 
63
  ". $odb_class->log_arr['tables'] . ",
64
  '". $odb_class->log_arr['before'] . "',
65
  '". $odb_class->log_arr['after'] . "',
@@ -120,6 +122,7 @@ class ODB_Logger {
120
  echo '<th align="right">'.__('deleted<br>pingbacks<br>trackbacks','rvg-optimize-database').'</th>';
121
  echo '<th align="right">'.__('deleted<br>oEmbed<br>records','rvg-optimize-database').'</th>';
122
  echo '<th align="right">'.__('deleted<br>orphans','rvg-optimize-database').'</th>';
 
123
  echo '<th align="right">'.__('nr of<br>optimized<br>tables','rvg-optimize-database').'</th>';
124
  echo '<th align="right">'.__('database<br> size<br>BEFORE','rvg-optimize-database').'</th>';
125
  echo '<th align="right">'.__('database<br>size<br>AFTER','rvg-optimize-database').'</th>';
@@ -141,6 +144,7 @@ class ODB_Logger {
141
  echo '<td align="right">' . $this->res[$i]['odb_pingbacks'].'</td>';
142
  echo '<td align="right">' . $this->res[$i]['odb_oembeds'].'</td>';
143
  echo '<td align="right">' . $this->res[$i]['odb_orphans'].'</td>';
 
144
  echo '<td align="right">' . $this->res[$i]['odb_tables'].'</td>';
145
  echo '<td align="right">' . $this->res[$i]['odb_before'].'</td>';
146
  echo '<td align="right">' . $this->res[$i]['odb_after'].'</td>';
@@ -249,6 +253,7 @@ function odb_confirm_delete() {
249
  'odb_transients' => __('deleted transients', $odb_class->odb_txt_domain),
250
  'odb_pingbacks' => __('deleted pingbacks', $odb_class->odb_txt_domain),
251
  'odb_orphans' => __('deleted orphans', $odb_class->odb_txt_domain),
 
252
  'odb_tables' => __('nr of optimized tables', $odb_class->odb_txt_domain),
253
  'odb_before' => __('database size BEFORE', $odb_class->odb_txt_domain),
254
  'odb_after' => __('database size AFTER', $odb_class->odb_txt_domain),
44
  odb_pingbacks,
45
  odb_oembeds,
46
  odb_orphans,
47
+ odb_dupmeta,
48
  odb_tables,
49
  odb_before,
50
  odb_after,
61
  ". $odb_class->log_arr['pingbacks'] . ",
62
  ". $odb_class->log_arr['oembeds'] . ",
63
  ". $odb_class->log_arr['orphans'] . ",
64
+ ". $odb_class->log_arr['dupmeta'] . ",
65
  ". $odb_class->log_arr['tables'] . ",
66
  '". $odb_class->log_arr['before'] . "',
67
  '". $odb_class->log_arr['after'] . "',
122
  echo '<th align="right">'.__('deleted<br>pingbacks<br>trackbacks','rvg-optimize-database').'</th>';
123
  echo '<th align="right">'.__('deleted<br>oEmbed<br>records','rvg-optimize-database').'</th>';
124
  echo '<th align="right">'.__('deleted<br>orphans','rvg-optimize-database').'</th>';
125
+ echo '<th align="right">'.__('deleted<br>dupmeta','rvg-optimize-database').'</th>';
126
  echo '<th align="right">'.__('nr of<br>optimized<br>tables','rvg-optimize-database').'</th>';
127
  echo '<th align="right">'.__('database<br> size<br>BEFORE','rvg-optimize-database').'</th>';
128
  echo '<th align="right">'.__('database<br>size<br>AFTER','rvg-optimize-database').'</th>';
144
  echo '<td align="right">' . $this->res[$i]['odb_pingbacks'].'</td>';
145
  echo '<td align="right">' . $this->res[$i]['odb_oembeds'].'</td>';
146
  echo '<td align="right">' . $this->res[$i]['odb_orphans'].'</td>';
147
+ echo '<td align="right">' . $this->res[$i]['odb_dupmeta'].'</td>';
148
  echo '<td align="right">' . $this->res[$i]['odb_tables'].'</td>';
149
  echo '<td align="right">' . $this->res[$i]['odb_before'].'</td>';
150
  echo '<td align="right">' . $this->res[$i]['odb_after'].'</td>';
253
  'odb_transients' => __('deleted transients', $odb_class->odb_txt_domain),
254
  'odb_pingbacks' => __('deleted pingbacks', $odb_class->odb_txt_domain),
255
  'odb_orphans' => __('deleted orphans', $odb_class->odb_txt_domain),
256
+ 'odb_dupmeta' => __('deleted duplicates', $odb_class->odb_txt_domain),
257
  'odb_tables' => __('nr of optimized tables', $odb_class->odb_txt_domain),
258
  'odb_before' => __('database size BEFORE', $odb_class->odb_txt_domain),
259
  'odb_after' => __('database size AFTER', $odb_class->odb_txt_domain),
includes/settings-page.php CHANGED
@@ -62,6 +62,9 @@ if (isset($_POST['info_update'])) {
62
 
63
  if(isset($_POST['rvg_clear_orphans'])) $this->odb_rvg_options['clear_orphans'] = sanitize_text_field($_POST['rvg_clear_orphans']);
64
  else $this->odb_rvg_options['clear_orphans'] = 'N';
 
 
 
65
 
66
  if(isset($_POST['rvg_odb_logging_on'])) $this->odb_rvg_options['logging_on'] = sanitize_text_field($_POST['rvg_odb_logging_on']);
67
  else $this->odb_rvg_options['logging_on'] = 'N';
@@ -211,6 +214,7 @@ $cb_tags = ($this->odb_rvg_options['clear_tags'] == "Y") ? $c :
211
  $cb_ping = ($this->odb_rvg_options['clear_pingbacks'] == "Y") ? $c : '';
212
  $cb_oembed = ($this->odb_rvg_options['clear_oembed'] == "Y") ? $c : '';
213
  $cb_orphans = ($this->odb_rvg_options['clear_orphans'] == "Y") ? $c : '';
 
214
  $cb_logging = ($this->odb_rvg_options['logging_on'] == "Y") ? $c : '';
215
  $cb_adminbar = ($this->odb_rvg_options['adminbar'] == "Y") ? $c : '';
216
  $cb_adminmenu = ($this->odb_rvg_options['adminmenu'] == "Y") ? $c : '';
@@ -352,7 +356,13 @@ echo '
352
  '.__('Clear orphans',$this->odb_txt_domain).'
353
  </span></td>
354
  <td width="50%" valign="top"><input name="rvg_clear_orphans" type="checkbox" value="Y" '.$cb_orphans.'></td>
355
- </tr>
 
 
 
 
 
 
356
  <tr>
357
  <td align="right" valign="top"><span class="odb-bold">
358
  '. __('Optimize InnoDB tables too',$this->odb_txt_domain).'
62
 
63
  if(isset($_POST['rvg_clear_orphans'])) $this->odb_rvg_options['clear_orphans'] = sanitize_text_field($_POST['rvg_clear_orphans']);
64
  else $this->odb_rvg_options['clear_orphans'] = 'N';
65
+
66
+ if(isset($_POST['rvg_clear_dupmeta'])) $this->odb_rvg_options['clear_dupmeta'] = sanitize_text_field($_POST['rvg_clear_dupmeta']);
67
+ else $this->odb_rvg_options['clear_dupmeta'] = 'N';
68
 
69
  if(isset($_POST['rvg_odb_logging_on'])) $this->odb_rvg_options['logging_on'] = sanitize_text_field($_POST['rvg_odb_logging_on']);
70
  else $this->odb_rvg_options['logging_on'] = 'N';
214
  $cb_ping = ($this->odb_rvg_options['clear_pingbacks'] == "Y") ? $c : '';
215
  $cb_oembed = ($this->odb_rvg_options['clear_oembed'] == "Y") ? $c : '';
216
  $cb_orphans = ($this->odb_rvg_options['clear_orphans'] == "Y") ? $c : '';
217
+ $cb_dupmeta = ($this->odb_rvg_options['clear_dupmeta'] == "Y") ? $c : '';
218
  $cb_logging = ($this->odb_rvg_options['logging_on'] == "Y") ? $c : '';
219
  $cb_adminbar = ($this->odb_rvg_options['adminbar'] == "Y") ? $c : '';
220
  $cb_adminmenu = ($this->odb_rvg_options['adminmenu'] == "Y") ? $c : '';
356
  '.__('Clear orphans',$this->odb_txt_domain).'
357
  </span></td>
358
  <td width="50%" valign="top"><input name="rvg_clear_orphans" type="checkbox" value="Y" '.$cb_orphans.'></td>
359
+ </tr>
360
+ <tr>
361
+ <td width="50%" align="right" valign="top"><span class="odb-bold">
362
+ '.__('Clear duplicated postmeta items',$this->odb_txt_domain).'
363
+ </span></td>
364
+ <td width="50%" valign="top"><input name="rvg_clear_dupmeta" type="checkbox" value="Y" '.$cb_dupmeta.'></td>
365
+ </tr>
366
  <tr>
367
  <td align="right" valign="top"><span class="odb-bold">
368
  '. __('Optimize InnoDB tables too',$this->odb_txt_domain).'
readme.txt CHANGED
@@ -9,9 +9,9 @@ Author: CAGE Web Design | Rolf van Gelder, Eindhoven, The Netherlands
9
  Contributors: cageehv
10
  Requires at least: 2.8
11
  Requires PHP: 5.0
12
- Tested up to: 5.4.1
13
- Stable tag: 4.9.1
14
- Version: 4.9.1
15
  License: GPLv2 or later
16
 
17
  == Description ==
@@ -27,6 +27,7 @@ This plugin is a 'One Click' WordPress Database Cleaner / Optimizer.
27
  * Deletes 'pingbacks' and 'trackbacks' (optional)
28
  * Clears the 'OEMBED cache' (optional)
29
  * Deletes 'orphan postmeta items'
 
30
  * Optimizes the database tables (optionally you can exclude certain tables, or even specific posts/pages, from optimization)
31
  * Creates a log of the optimizations (optional)
32
  * Optimization can be scheduled to automatically run once hourly, twice daily, once daily or once weekly at a specific time (optional)
@@ -111,6 +112,9 @@ http://cagewebdev.com/category/news-tech-art/wordpress/
111
  * If you run the plugin from any of the sites, it will cleanup ALL the sites in the network!
112
 
113
  == Changelog ==
 
 
 
114
  = 4.9.1 [05/17/2020] =
115
  * BUG FIX: Fixed a bug for deleting orphans
116
 
9
  Contributors: cageehv
10
  Requires at least: 2.8
11
  Requires PHP: 5.0
12
+ Tested up to: 5.5
13
+ Stable tag: 5.0
14
+ Version: 5.0
15
  License: GPLv2 or later
16
 
17
  == Description ==
27
  * Deletes 'pingbacks' and 'trackbacks' (optional)
28
  * Clears the 'OEMBED cache' (optional)
29
  * Deletes 'orphan postmeta items'
30
+ * Deletes 'duplicated postmeta items'
31
  * Optimizes the database tables (optionally you can exclude certain tables, or even specific posts/pages, from optimization)
32
  * Creates a log of the optimizations (optional)
33
  * Optimization can be scheduled to automatically run once hourly, twice daily, once daily or once weekly at a specific time (optional)
112
  * If you run the plugin from any of the sites, it will cleanup ALL the sites in the network!
113
 
114
  == Changelog ==
115
+ = 5.0 [08/14/2020] =
116
+ * New: Deletion of Duplicated Postmeta entries
117
+
118
  = 4.9.1 [05/17/2020] =
119
  * BUG FIX: Fixed a bug for deleting orphans
120
 
rvg-optimize-database.php CHANGED
@@ -1,7 +1,7 @@
1
  <?php
2
  /**
3
  * @package Optimize Database after Deleting Revisions
4
- * @version 4.9.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.9.1
14
  */
15
 
16
  /********************************************************************************************
@@ -28,8 +28,8 @@ $odb_class = new OptimizeDatabase();
28
 
29
  class OptimizeDatabase {
30
  // VERSION
31
- var $odb_version = '4.9.1';
32
- var $odb_release_date = '05/17/2020';
33
 
34
  // PLUGIN OPTIONS
35
  var $odb_rvg_options = array();
@@ -116,6 +116,7 @@ class OptimizeDatabase {
116
  `odb_pingbacks` int(11) NOT NULL,
117
  `odb_oembeds` int(11) NOT NULL,
118
  `odb_orphans` int(11) NOT NULL,
 
119
  `odb_tables` int(11) NOT NULL,
120
  `odb_before` varchar(20) NOT NULL,
121
  `odb_after` varchar(20) NOT NULL,
@@ -126,6 +127,21 @@ class OptimizeDatabase {
126
 
127
  // CREATE TABLE
128
  $wpdb->get_results($sql);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
129
 
130
  // GET (MULTI-SITE) NETWORK INFORMATION
131
  $this->odb_multisite_obj->odb_ms_network_info();
@@ -213,7 +229,9 @@ class OptimizeDatabase {
213
  if(!isset($this->odb_rvg_options['clear_oembed']))
214
  $this->odb_rvg_options['clear_oembed'] = 'N';
215
  if(!isset($this->odb_rvg_options['clear_orphans']))
216
- $this->odb_rvg_options['clear_orphans'] = 'N';
 
 
217
  if(!isset($this->odb_rvg_options['clear_spam']))
218
  $this->odb_rvg_options['clear_spam'] = 'N';
219
  if(!isset($this->odb_rvg_options['clear_tags']))
@@ -313,7 +331,13 @@ class OptimizeDatabase {
313
  if($setting) {
314
  $this->odb_rvg_options['rvg_clear_orphans'] = $this->odb_multisite_obj->odb_ms_get_option('rvg_clear_orphans');
315
  $this->odb_multisite_obj->odb_ms_delete_option('rvg_clear_orphans');
316
- }
 
 
 
 
 
 
317
 
318
  $setting = $this->odb_multisite_obj->odb_ms_get_option('rvg_clear_spam');
319
  if($setting) {
1
  <?php
2
  /**
3
  * @package Optimize Database after Deleting Revisions
4
+ * @version 5.0
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: 5.0
14
  */
15
 
16
  /********************************************************************************************
28
 
29
  class OptimizeDatabase {
30
  // VERSION
31
+ var $odb_version = '5.0';
32
+ var $odb_release_date = '08/14/2020';
33
 
34
  // PLUGIN OPTIONS
35
  var $odb_rvg_options = array();
116
  `odb_pingbacks` int(11) NOT NULL,
117
  `odb_oembeds` int(11) NOT NULL,
118
  `odb_orphans` int(11) NOT NULL,
119
+ `odb_dupmeta` int(11) NOT NULL,
120
  `odb_tables` int(11) NOT NULL,
121
  `odb_before` varchar(20) NOT NULL,
122
  `odb_after` varchar(20) NOT NULL,
127
 
128
  // CREATE TABLE
129
  $wpdb->get_results($sql);
130
+
131
+ // FOR VERSION v5.0+
132
+ $sql = "
133
+ SHOW COLUMNS FROM " . $this->odb_logtable_name . " LIKE 'odb_dupmeta'
134
+ ";
135
+ $results = $wpdb->get_results($sql);
136
+
137
+ if (count($results) < 1) {
138
+ // COLUMN DOESN'T EXIST: ADD IT TO THE TABLE v5.0
139
+ $sql = '
140
+ ALTER TABLE ' . $this->odb_logtable_name . '
141
+ ADD `odb_dupmeta` INT(11) AFTER `odb_orphans`
142
+ ';
143
+ $wpdb->get_results($sql);
144
+ }
145
 
146
  // GET (MULTI-SITE) NETWORK INFORMATION
147
  $this->odb_multisite_obj->odb_ms_network_info();
229
  if(!isset($this->odb_rvg_options['clear_oembed']))
230
  $this->odb_rvg_options['clear_oembed'] = 'N';
231
  if(!isset($this->odb_rvg_options['clear_orphans']))
232
+ $this->odb_rvg_options['clear_orphans'] = 'N';
233
+ if(!isset($this->odb_rvg_options['clear_dupmeta']))
234
+ $this->odb_rvg_options['clear_dupmeta'] = 'N';
235
  if(!isset($this->odb_rvg_options['clear_spam']))
236
  $this->odb_rvg_options['clear_spam'] = 'N';
237
  if(!isset($this->odb_rvg_options['clear_tags']))
331
  if($setting) {
332
  $this->odb_rvg_options['rvg_clear_orphans'] = $this->odb_multisite_obj->odb_ms_get_option('rvg_clear_orphans');
333
  $this->odb_multisite_obj->odb_ms_delete_option('rvg_clear_orphans');
334
+ }
335
+
336
+ $setting = $this->odb_multisite_obj->odb_ms_get_option('rvg_clear_dupmeta');
337
+ if($setting) {
338
+ $this->odb_rvg_options['rvg_clear_dupmeta'] = $this->odb_multisite_obj->odb_ms_get_option('rvg_clear_dupmeta');
339
+ $this->odb_multisite_obj->odb_ms_delete_option('rvg_clear_dupmeta');
340
+ }
341
 
342
  $setting = $this->odb_multisite_obj->odb_ms_get_option('rvg_clear_spam');
343
  if($setting) {