Optimize Database after Deleting Revisions - Version 1.3.2

Version Description

No Upgrade Notice available.

Download this release

Release Info

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

Code changes from version 1.3.1 to 1.3.2

Files changed (2) hide show
  1. readme.txt +3 -2
  2. rvg-optimize-db.php +48 -17
readme.txt CHANGED
@@ -9,8 +9,8 @@ Author URI: http://cagewebdev.com
9
  Author: Rolf van Gelder, Eindhoven, The Netherlands
10
  Requires at least: 2.0
11
  Tested up to: 3.4.2
12
- Stable tag: 1.3.1
13
- Version: 1.3.1
14
 
15
  == Description ==
16
 
@@ -55,6 +55,7 @@ No Screenshots available.
55
  <p><b>1.2</b> 10/03/2012 Major update: new options 'delete trash', 'delete spam', 'only optimize WordPress tables'</p>
56
  <p><b>1.3</b> 10/06/2012 Extra button for starting optimization, shows savings (in bytes) now</p>
57
  <p><b>1.3.1</b> 10/07/2012 Minor changes</p>
 
58
 
59
  == Frequently Asked Questions ==
60
 
9
  Author: Rolf van Gelder, Eindhoven, The Netherlands
10
  Requires at least: 2.0
11
  Tested up to: 3.4.2
12
+ Stable tag: 1.3.2
13
+ Version: 1.3.2
14
 
15
  == Description ==
16
 
55
  <p><b>1.2</b> 10/03/2012 Major update: new options 'delete trash', 'delete spam', 'only optimize WordPress tables'</p>
56
  <p><b>1.3</b> 10/06/2012 Extra button for starting optimization, shows savings (in bytes) now</p>
57
  <p><b>1.3.1</b> 10/07/2012 Minor changes</p>
58
+ <p><b>1.3.2</b> 11/14/2012 Shows more information about the optimized tables + other minor changes</p>
59
 
60
  == Frequently Asked Questions ==
61
 
rvg-optimize-db.php CHANGED
@@ -1,16 +1,16 @@
1
  <?php
2
- $version = '1.3.1';
3
- $release_date = '10/07/2012';
4
  /**
5
  * @package Optimize Database after Deleting Revisions
6
- * @version 1.3.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 Deleting Revisions - <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: 1.3.1
14
  Author URI: http://cagewebdev.com
15
  */
16
  ?>
@@ -47,7 +47,7 @@ add_action( 'admin_menu', 'rvg_odb_admin_menu' );
47
 
48
  *********************************************************************************************/
49
  function rvg_odb_options_page() {
50
- global $version, $release_date;
51
 
52
  // SAVE THE OPTIONS
53
  if ( isset( $_POST['info_update'] ) ) {
@@ -99,7 +99,7 @@ function rvg_odb_options_page() {
99
  In the WordPress Dashboard go to &lsquo;<strong>Tools</strong>&lsquo;.<br />
100
  Click on &lsquo;<strong>Optimize Database</strong>&lsquo;, then click on the '<strong>Start Optimization</strong>'-button. Et voila! </p>
101
  <p>Plugin version:<br />
102
- <strong>v<?php echo $version ?> (<?php echo $release_date?>)</strong> </p>
103
  <p>Author:<br />
104
  <strong><a href="http://cage.nl/" target="_blank">Rolf van Gelder</a>, <a href="http://cagewebdev.com/" target="_blank">CAGE Web Design</a></strong>, Eindhoven, The Netherlands<br />
105
  <br />
@@ -159,7 +159,7 @@ if($rvg_wp_only == 'Y') $rvg_wp_only_checked = ' checked="checked"'; els
159
  *********************************************************************************************/
160
  function rvg_optimize_db()
161
  {
162
- global $wpdb, $version, $table_prefix;
163
 
164
  /****************************************************************************************
165
 
@@ -197,7 +197,7 @@ function rvg_optimize_db()
197
  ?>
198
  <div style="padding-left:8px;">
199
  <h2>Optimize your WordPress Database</h2>
200
- <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 $version?></a> - A WordPress Plugin by <a href="http://cagewebdev.com/" target="_blank" style="font-weight:bold;">Rolf van Gelder</a>, Eindhoven, The Netherlands</span></p>
201
  <p>Current options:<br />
202
  <strong>Maximum number of - most recent - revisions to keep per post / page:</strong> <span style="font-weight:bold;color:#00F;"><?php echo $max_revisions?></span><br />
203
  <strong>Delete trashed items:</strong> <span style="font-weight:bold;color:#00F;"><?php echo $clear_trash_yn?></span><br />
@@ -210,7 +210,7 @@ if($_REQUEST['action'] != 'run')
210
  <p class="submit">
211
  <input type='button' name='change_options' value='Change Options' onclick="self.location='options-general.php?page=rvg_odb_admin'" style="font-weight:normal;" />
212
  &nbsp;
213
- <input type='button' name='start_optimization' value='Start Optimization' onclick="self.location='tools.php?page=rvg-optimize-db.php&action=run'" style="font-weight:bold;" />
214
  </p>
215
  <?php
216
  }
@@ -481,12 +481,15 @@ if($_REQUEST['action'] != 'run')
481
  <span style="font-weight:bold;color:#000;padding-left:8px;">~~~~~</span>
482
  <table border="0" cellspacing="8" cellpadding="2">
483
  <tr>
484
- <td colspan="3" style="font-weight:bold;color:#00F;">OPTIMIZING DATABASE TABLES:</td>
485
  </tr>
486
  <tr>
487
  <th style="border-bottom:solid 1px #999;" align="right">#</th>
488
  <th style="border-bottom:solid 1px #999;" align="left">table name</th>
489
  <th style="border-bottom:solid 1px #999;" align="left">optimization result</th>
 
 
 
490
  </tr>
491
  <?php
492
  # GET TABLE NAMES
@@ -499,11 +502,23 @@ if($_REQUEST['action'] != 'run')
499
  $cnt++;
500
  $query = "OPTIMIZE TABLE ".$row[0];
501
  $result = $wpdb -> get_results($query);
 
 
 
 
 
 
 
 
 
502
  ?>
503
  <tr>
504
  <td align="right"><?php echo $cnt?>.</td>
505
  <td style="font-weight:bold;"><?php echo $row[0] ?></td>
506
  <td><?php echo $result[0]->Msg_text ?></td>
 
 
 
507
  </tr>
508
  <?php
509
  } // if($wp_only == 'N' || ($wp_only == 'Y' && substr($row[0],0,strlen($table_prefix)) == $table_prefix))
@@ -519,20 +534,20 @@ $end_size = rvg_get_db_size();
519
  <td colspan="2" style="font-weight:bold;color:#00F;">SAVINGS:</td>
520
  </tr>
521
  <tr>
 
522
  <th style="border-bottom:solid 1px #999;">size of the database</th>
523
- <th style="border-bottom:solid 1px #999;" align="left">bytes</th>
524
  </tr>
525
  <tr>
526
- <td>BEFORE optimization</td>
527
- <td style="font-weight:bold;"><?php echo $start_size; ?></td>
528
  </tr>
529
  <tr>
530
- <td>AFTER optimization</td>
531
- <td style="font-weight:bold;"><?php echo $end_size; ?></td>
532
  </tr>
533
  <tr>
534
- <td>TOTAL BYTES SAVED</td>
535
- <td style="font-weight:bold;"><?php echo ($start_size - $end_size); ?></td>
536
  </tr>
537
  </table>
538
  <br />
@@ -562,3 +577,19 @@ function rvg_get_db_size()
562
 
563
  } // rvg_get_db_size()
564
  ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  <?php
2
+ $odb_version = '1.3.2';
3
+ $odb_release_date = '11/14/2012';
4
  /**
5
  * @package Optimize Database after Deleting Revisions
6
+ * @version 1.3.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 Deleting Revisions - <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: 1.3.2
14
  Author URI: http://cagewebdev.com
15
  */
16
  ?>
47
 
48
  *********************************************************************************************/
49
  function rvg_odb_options_page() {
50
+ global $odb_version, $odb_release_date;
51
 
52
  // SAVE THE OPTIONS
53
  if ( isset( $_POST['info_update'] ) ) {
99
  In the WordPress Dashboard go to &lsquo;<strong>Tools</strong>&lsquo;.<br />
100
  Click on &lsquo;<strong>Optimize Database</strong>&lsquo;, then click on the '<strong>Start Optimization</strong>'-button. Et voila! </p>
101
  <p>Plugin version:<br />
102
+ <strong>v<?php echo $odb_version ?> (<?php echo $odb_release_date?>)</strong> </p>
103
  <p>Author:<br />
104
  <strong><a href="http://cage.nl/" target="_blank">Rolf van Gelder</a>, <a href="http://cagewebdev.com/" target="_blank">CAGE Web Design</a></strong>, Eindhoven, The Netherlands<br />
105
  <br />
159
  *********************************************************************************************/
160
  function rvg_optimize_db()
161
  {
162
+ global $wpdb, $odb_version, $table_prefix;
163
 
164
  /****************************************************************************************
165
 
197
  ?>
198
  <div style="padding-left:8px;">
199
  <h2>Optimize your WordPress Database</h2>
200
+ <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;">Rolf van Gelder</a>, Eindhoven, The Netherlands</span></p>
201
  <p>Current options:<br />
202
  <strong>Maximum number of - most recent - revisions to keep per post / page:</strong> <span style="font-weight:bold;color:#00F;"><?php echo $max_revisions?></span><br />
203
  <strong>Delete trashed items:</strong> <span style="font-weight:bold;color:#00F;"><?php echo $clear_trash_yn?></span><br />
210
  <p class="submit">
211
  <input type='button' name='change_options' value='Change Options' onclick="self.location='options-general.php?page=rvg_odb_admin'" style="font-weight:normal;" />
212
  &nbsp;
213
+ <input class="button-primary" type='button' name='start_optimization' value='Start Optimization' onclick="self.location='tools.php?page=rvg-optimize-db.php&action=run'" style="font-weight:bold;" />
214
  </p>
215
  <?php
216
  }
481
  <span style="font-weight:bold;color:#000;padding-left:8px;">~~~~~</span>
482
  <table border="0" cellspacing="8" cellpadding="2">
483
  <tr>
484
+ <td colspan="4" style="font-weight:bold;color:#00F;">OPTIMIZING DATABASE TABLES:</td>
485
  </tr>
486
  <tr>
487
  <th style="border-bottom:solid 1px #999;" align="right">#</th>
488
  <th style="border-bottom:solid 1px #999;" align="left">table name</th>
489
  <th style="border-bottom:solid 1px #999;" align="left">optimization result</th>
490
+ <th style="border-bottom:solid 1px #999;" align="left">engine</th>
491
+ <th style="border-bottom:solid 1px #999;" align="right">table rows</th>
492
+ <th style="border-bottom:solid 1px #999;" align="right">table size</th>
493
  </tr>
494
  <?php
495
  # GET TABLE NAMES
502
  $cnt++;
503
  $query = "OPTIMIZE TABLE ".$row[0];
504
  $result = $wpdb -> get_results($query);
505
+
506
+ $sql = "
507
+ SELECT engine, SUM(data_length + index_length) AS size, table_rows
508
+ FROM information_schema.TABLES
509
+ WHERE table_schema = '".strtolower(DB_NAME)."'
510
+ AND table_name = '".$row[0]."'
511
+ ";
512
+
513
+ $table_info = $wpdb -> get_results($sql);
514
  ?>
515
  <tr>
516
  <td align="right"><?php echo $cnt?>.</td>
517
  <td style="font-weight:bold;"><?php echo $row[0] ?></td>
518
  <td><?php echo $result[0]->Msg_text ?></td>
519
+ <td><?php echo $table_info[0]->engine ?></td>
520
+ <td align="right"><?php echo $table_info[0]->table_rows ?></td>
521
+ <td align="right"><?php echo rvg_format_size($table_info[0]->size) ?></td>
522
  </tr>
523
  <?php
524
  } // if($wp_only == 'N' || ($wp_only == 'Y' && substr($row[0],0,strlen($table_prefix)) == $table_prefix))
534
  <td colspan="2" style="font-weight:bold;color:#00F;">SAVINGS:</td>
535
  </tr>
536
  <tr>
537
+ <th xstyle="border-bottom:solid 1px #999;"></th>
538
  <th style="border-bottom:solid 1px #999;">size of the database</th>
 
539
  </tr>
540
  <tr>
541
+ <td align="right">BEFORE optimization</td>
542
+ <td align="right" style="font-weight:bold;"><?php echo rvg_format_size($start_size,3); ?></td>
543
  </tr>
544
  <tr>
545
+ <td align="right">AFTER optimization</td>
546
+ <td align="right" style="font-weight:bold;"><?php echo rvg_format_size($end_size,3); ?></td>
547
  </tr>
548
  <tr>
549
+ <td align="right" style="font-weight:bold;">TOTAL SAVINGS</td>
550
+ <td align="right" style="font-weight:bold;border-top:solid 1px #999;"><?php echo rvg_format_size(($start_size - $end_size),3); ?></td>
551
  </tr>
552
  </table>
553
  <br />
577
 
578
  } // rvg_get_db_size()
579
  ?>
580
+ <?php
581
+ /********************************************************************************************
582
+
583
+ FORMAT SIZES FROM BYTES TO KB OR MB
584
+
585
+ *********************************************************************************************/
586
+ function rvg_format_size($size, $precision=1)
587
+ {
588
+ if($size>1024*1024)
589
+ $table_size = (round($size / (1024*1024),$precision)).' MB';
590
+ else
591
+ $table_size = (round($size / 1024,$precision)).' KB';
592
+
593
+ return $table_size;
594
+ } // rvg_format_size()
595
+ ?>