Optimize Database after Deleting Revisions - Version 2.8.1

Version Description

[07/31/2014] = * CHANGE: changed the 'edit_themes' capability back to 'administrator'-role * BUG FIX: no table names beside checkboxes (rewrote it, so it should work for every site now)

Download this release

Release Info

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

Code changes from version 2.8 to 2.8.1

Files changed (2) hide show
  1. readme.txt +7 -4
  2. rvg-optimize-db.php +29 -27
readme.txt CHANGED
@@ -8,8 +8,8 @@ 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.9.1
11
- Stable tag: 2.8
12
- Version: 2.8
13
  License: GPLv2 or later
14
 
15
  == Description ==
@@ -45,12 +45,11 @@ http://cagewebdev.com/index.php/optimize-database-after-deleting-revisions-wordp
45
  http://wordpress.org/extend/plugins/rvg-optimize-database/
46
 
47
  = Disclaimer =
48
- No warranty, use at own risk!
49
 
50
  = Other plugins by Rolf van Gelder =
51
  Rocket Reader (Speed reader)
52
  http://wordpress.org/plugins/rocket-reader-speed-reader/
53
-
54
  Order your Posts Manually
55
  http://wordpress.org/plugins/order-your-posts-manually/
56
 
@@ -62,6 +61,10 @@ http://wordpress.org/plugins/order-your-posts-manually/
62
 
63
  == Changelog ==
64
 
 
 
 
 
65
  = 2.8 [07/30/2014] =
66
  * CHANGE: 'administrator'-role changed to 'edit_themes'-capability
67
  * BUG FIX: no table names beside checkboxes
8
  Author: CAGE Web Design | Rolf van Gelder, Eindhoven, The Netherlands
9
  Requires at least: 2.0
10
  Tested up to: 3.9.1
11
+ Stable tag: 2.8.1
12
+ Version: 2.8.1
13
  License: GPLv2 or later
14
 
15
  == Description ==
45
  http://wordpress.org/extend/plugins/rvg-optimize-database/
46
 
47
  = Disclaimer =
48
+ NO WARRANTY, USE IT AT YOUR OWN RISK!
49
 
50
  = Other plugins by Rolf van Gelder =
51
  Rocket Reader (Speed reader)
52
  http://wordpress.org/plugins/rocket-reader-speed-reader/
 
53
  Order your Posts Manually
54
  http://wordpress.org/plugins/order-your-posts-manually/
55
 
61
 
62
  == Changelog ==
63
 
64
+ = 2.8.1 [07/31/2014] =
65
+ * CHANGE: changed the 'edit_themes' capability back to 'administrator'-role
66
+ * BUG FIX: no table names beside checkboxes (rewrote it, so it should work for every site now)
67
+
68
  = 2.8 [07/30/2014] =
69
  * CHANGE: 'administrator'-role changed to 'edit_themes'-capability
70
  * BUG FIX: no table names beside checkboxes
rvg-optimize-db.php CHANGED
@@ -1,16 +1,16 @@
1
  <?php
2
- $odb_version = '2.8';
3
- $odb_release_date = '07/30/2014';
4
  /**
5
  * @package Optimize Database after Deleting Revisions
6
- * @version 2.8
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.8
14
  Author URI: http://cagewebdev.com
15
  */
16
 
@@ -21,9 +21,10 @@ Author URI: http://cagewebdev.com
21
  *********************************************************************************************/
22
  function optimize_db_main()
23
  { if (function_exists('add_management_page'))
24
- { // add_management_page(__('Optimize Database'), __('Optimize Database'), 'administrator','rvg-optimize-db.php', 'rvg_optimize_db');
25
- # v2.8: 'administrator' role changed to 'edit_themes' capability
26
- add_management_page(__('Optimize Database'), __('Optimize Database'), 'edit_themes', 'rvg-optimize-db.php', 'rvg_optimize_db');
 
27
  }
28
  }
29
  add_action('admin_menu', 'optimize_db_main');
@@ -350,10 +351,10 @@ if($rvg_odb_logging_on == 'Y') $rvg_odb_logging_on_checked = ' checked="checke
350
  </table></td>
351
  </tr>
352
  <?php
353
- # v2.7.8
354
- $names = $wpdb->get_results("SHOW TABLES FROM `".DB_NAME."`");
355
- # v2.8
356
- $dbname = 'Tables_in_'.strtolower(DB_NAME);
357
  ?>
358
  <tr>
359
  <td colspan="4" valign="top"><table id="table_list" width="100%" border="0" cellspacing="0" cellpadding="4" style="display:block;">
@@ -365,8 +366,8 @@ if($rvg_odb_logging_on == 'Y') $rvg_odb_logging_on_checked = ' checked="checke
365
  <?php
366
  $c = 0;
367
  $t = 0;
368
- # v2.7.8
369
- for ($i=0; $i<count($names); $i++)
370
  { $t++;
371
  $c++;
372
  if($c>4)
@@ -376,19 +377,19 @@ if($rvg_odb_logging_on == 'Y') $rvg_odb_logging_on_checked = ' checked="checke
376
  }
377
  $style = 'normal';
378
  // WORDPRESS TABLE?
379
- if(substr($names[$i]->$dbname,0,strlen($table_prefix)) == $table_prefix) $style = 'bold;color:#00F;';
380
 
381
  $cb_checked = '';
382
  $sql = "
383
  SELECT `option_value`
384
  FROM $wpdb->options
385
- WHERE `option_name` = 'rvg_ex_".$names[$i]->$dbname."'
386
  ";
387
  $results = $wpdb -> get_results($sql);
388
  if(isset($results[0]->option_value))
389
  if($results[0]->option_value == 'excluded') $cb_checked = ' checked';
390
- echo '<td width="25%" style="font-weight:'.$style.'"><input id="cb_'.$names[$i]->$dbname.'" name="cb_'.$names[$i]->$dbname.'" type="checkbox" value="1" '.$cb_checked.' /> '.$names[$i]->$dbname.'</td>'."\n";
391
- } # for ($i=0; $i<count($names); $i++)
392
  ?>
393
  </tr>
394
  </table></td>
@@ -1347,19 +1348,20 @@ function rvg_optimize_tables($display)
1347
  {
1348
  global $wpdb, $table_prefix;
1349
 
1350
- # v2.7.8
1351
- $names = $wpdb->get_results("SHOW TABLES FROM `".DB_NAME."`");
1352
- # v2.8
1353
- $dbname = 'Tables_in_'.strtolower(DB_NAME);
 
1354
  $cnt = 0;
1355
- for ($i=0; $i<count($names); $i++)
1356
  {
1357
- $excluded = get_option('rvg_ex_'.$names[$i]->$dbname);
1358
 
1359
  if(!$excluded)
1360
  { # TABLE NOT EXCLUDED
1361
  $cnt++;
1362
- $query = "OPTIMIZE TABLE ".$names[$i]->$dbname;
1363
  $result = $wpdb -> get_results($query);
1364
 
1365
  // v2.7.5
@@ -1369,7 +1371,7 @@ function rvg_optimize_tables($display)
1369
  ) AS size, table_rows
1370
  FROM information_schema.TABLES
1371
  WHERE table_schema = '".strtolower(DB_NAME)."'
1372
- AND table_name = '".$names[$i]->$dbname."'
1373
  ";
1374
 
1375
  $table_info = $wpdb -> get_results($sql);
@@ -1379,7 +1381,7 @@ function rvg_optimize_tables($display)
1379
  ?>
1380
  <tr>
1381
  <td align="right" valign="top"><?php echo $cnt?>.</td>
1382
- <td valign="top" style="font-weight:bold;"><?php echo $names[$i]->$dbname ?></td>
1383
  <td valign="top"><?php echo $result[0]->Msg_text ?></td>
1384
  <td valign="top"><?php echo $table_info[0]->engine ?></td>
1385
  <td align="right" valign="top"><?php echo $table_info[0]->table_rows ?></td>
@@ -1388,7 +1390,7 @@ function rvg_optimize_tables($display)
1388
  <?php
1389
  } // if($display)
1390
  } // if(!$excluded)
1391
- } // for ($i=0; $i<count($names); $i++)
1392
  return $cnt;
1393
 
1394
  } // rvg_optimize_tables ()
1
  <?php
2
+ $odb_version = '2.8.1';
3
+ $odb_release_date = '07/31/2014';
4
  /**
5
  * @package Optimize Database after Deleting Revisions
6
+ * @version 2.8.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: CAGE Web Design | Rolf van Gelder, Eindhoven, The Netherlands
13
+ Version: 2.8.1
14
  Author URI: http://cagewebdev.com
15
  */
16
 
21
  *********************************************************************************************/
22
  function optimize_db_main()
23
  { if (function_exists('add_management_page'))
24
+ { # v2.8: 'administrator' role changed to 'edit_themes' capability
25
+ // add_management_page(__('Optimize Database'), __('Optimize Database'), 'edit_themes', 'rvg-optimize-db.php', 'rvg_optimize_db');
26
+ # v2.8.1: changed capability back to 'administrator'
27
+ add_management_page(__('Optimize Database'), __('Optimize Database'), 'administrator','rvg-optimize-db.php', 'rvg_optimize_db');
28
  }
29
  }
30
  add_action('admin_menu', 'optimize_db_main');
351
  </table></td>
352
  </tr>
353
  <?php
354
+ # v2.8.1
355
+ $res = mysql_query("SHOW TABLES FROM `".DB_NAME."`");
356
+ $tables = array();
357
+ while($row = mysql_fetch_array($res, MYSQL_NUM)) $tables[] = "$row[0]";
358
  ?>
359
  <tr>
360
  <td colspan="4" valign="top"><table id="table_list" width="100%" border="0" cellspacing="0" cellpadding="4" style="display:block;">
366
  <?php
367
  $c = 0;
368
  $t = 0;
369
+ # v2.8.1
370
+ for ($i=0; $i<count($tables); $i++)
371
  { $t++;
372
  $c++;
373
  if($c>4)
377
  }
378
  $style = 'normal';
379
  // WORDPRESS TABLE?
380
+ if(substr($tables[$i], 0, strlen($table_prefix)) == $table_prefix) $style = 'bold;color:#00F;';
381
 
382
  $cb_checked = '';
383
  $sql = "
384
  SELECT `option_value`
385
  FROM $wpdb->options
386
+ WHERE `option_name` = 'rvg_ex_".$tables[$i]."'
387
  ";
388
  $results = $wpdb -> get_results($sql);
389
  if(isset($results[0]->option_value))
390
  if($results[0]->option_value == 'excluded') $cb_checked = ' checked';
391
+ echo '<td width="25%" style="font-weight:'.$style.'"><input id="cb_'.$tables[$i].'" name="cb_'.$tables[$i].'" type="checkbox" value="1" '.$cb_checked.' /> '.$tables[$i].'</td>'."\n";
392
+ } # for ($i=0; $i<count($tables); $i++)
393
  ?>
394
  </tr>
395
  </table></td>
1348
  {
1349
  global $wpdb, $table_prefix;
1350
 
1351
+ # v2.8.1
1352
+ $res = mysql_query("SHOW TABLES FROM `".DB_NAME."`");
1353
+ $tables = array();
1354
+ while($row = mysql_fetch_array($res, MYSQL_NUM)) $tables[] = "$row[0]";
1355
+
1356
  $cnt = 0;
1357
+ for ($i=0; $i<count($tables); $i++)
1358
  {
1359
+ $excluded = get_option('rvg_ex_'.$tables[$i]);
1360
 
1361
  if(!$excluded)
1362
  { # TABLE NOT EXCLUDED
1363
  $cnt++;
1364
+ $query = "OPTIMIZE TABLE ".$tables[$i];
1365
  $result = $wpdb -> get_results($query);
1366
 
1367
  // v2.7.5
1371
  ) AS size, table_rows
1372
  FROM information_schema.TABLES
1373
  WHERE table_schema = '".strtolower(DB_NAME)."'
1374
+ AND table_name = '".$tables[$i]."'
1375
  ";
1376
 
1377
  $table_info = $wpdb -> get_results($sql);
1381
  ?>
1382
  <tr>
1383
  <td align="right" valign="top"><?php echo $cnt?>.</td>
1384
+ <td valign="top" style="font-weight:bold;"><?php echo $tables[$i] ?></td>
1385
  <td valign="top"><?php echo $result[0]->Msg_text ?></td>
1386
  <td valign="top"><?php echo $table_info[0]->engine ?></td>
1387
  <td align="right" valign="top"><?php echo $table_info[0]->table_rows ?></td>
1390
  <?php
1391
  } // if($display)
1392
  } // if(!$excluded)
1393
+ } // for ($i=0; $i<count($tables); $i++)
1394
  return $cnt;
1395
 
1396
  } // rvg_optimize_tables ()