Optimize Database after Deleting Revisions - Version 1.0.2

Version Description

No Upgrade Notice available.

Download this release

Release Info

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

Code changes from version 1.0.1 to 1.0.2

Files changed (4) hide show
  1. readme.txt +15 -11
  2. rvg-optimize-db.php +5 -4
  3. trunk/readme.txt +45 -0
  4. trunk/rvg-optimize-db.php +103 -0
readme.txt CHANGED
@@ -3,24 +3,27 @@
3
  Contributors: Rolf van Gelder
4
  Donate link: http://cagewebdev.com
5
  Plugin Name: Optimize Database after Deleting Revisions
6
- Plugin URI: http://cagewebdev.com/wp-plugins
7
  Tags: wp, database, delete, revisions, optimize, posts, pages
8
  Author URI: http://cagewebdev.com
9
  Author: Rolf van Gelder
10
  Requires at least: 2.0
11
  Tested up to: 3.2.1
12
- Stable tag: 1.0.1
13
- Version: 1.0.1
14
 
15
  == Description ==
16
 
17
- This plugin is a 'one click' database optimizer. It deletes the redundant revisions of posts and pages and then optimizes all Wordpress database tables.
18
- http://cagewebdev.com/
 
19
 
20
  == Installation ==
21
 
22
- 1. Upload `rvg-optimize-db.php` to the `/wp-content/plugins/` directory
23
- 2. Activate the plugin through the 'Plugins' menu in WordPress
 
 
24
 
25
  == Upgrade Notice ==
26
 
@@ -32,10 +35,11 @@ No Screenshots available.
32
 
33
  == Changelog ==
34
 
35
- 1.0 11/22/2011 Initial release
36
- 1.0.1 11/24/2011 A few updates for the readme.txt file
 
37
 
38
  == Frequently Asked Questions ==
39
 
40
- Q: How do I run this plugin?
41
- A: In the WordPress ADMIN panel go to 'Settings'. Click on 'Optimize Database'. Et voila!
3
  Contributors: Rolf van Gelder
4
  Donate link: http://cagewebdev.com
5
  Plugin Name: Optimize Database after Deleting Revisions
6
+ Plugin URI: http://cagewebdev.com/index.php/optimize-database-after-deleting-revisions-wordpress-plugin
7
  Tags: wp, database, delete, revisions, optimize, posts, pages
8
  Author URI: http://cagewebdev.com
9
  Author: Rolf van Gelder
10
  Requires at least: 2.0
11
  Tested up to: 3.2.1
12
+ Stable tag: 1.0.2
13
+ Version: 1.0.2
14
 
15
  == Description ==
16
 
17
+ <p>This plugin is a 'one click' database optimizer.</p>
18
+ <p>It deletes the redundant revisions of posts and pages and then optimizes all Wordpress database tables.</p>
19
+ <p>http://cagewebdev.com/</p>
20
 
21
  == Installation ==
22
 
23
+ <ol>
24
+ <li>Upload `rvg-optimize-db.php` to the `/wp-content/plugins/` directory</li>
25
+ <li>Activate the plugin through the 'Plugins' menu in WordPress</li>
26
+ </ol>
27
 
28
  == Upgrade Notice ==
29
 
35
 
36
  == Changelog ==
37
 
38
+ <p>1.0 11/22/2011 Initial release</p>
39
+ <p>1.0.1 11/24/2011 A few updates for the readme.txt file</p>
40
+ <p>1.0.2 12/02/2011 Some minor updates</p>
41
 
42
  == Frequently Asked Questions ==
43
 
44
+ <p>Q: How do I run this plugin?</p>
45
+ <p>A: In the WordPress ADMIN panel go to 'Settings'. Click on 'Optimize Database'. Et voila!</p>
rvg-optimize-db.php CHANGED
@@ -1,21 +1,22 @@
1
  <?php
 
2
  /**
3
  * @package Optimize Database after Deleting Revisions
4
- * @version 1.0.1
5
  */
6
  /*
7
  Plugin Name: Optimize Database after Deleting Revisions
8
  Plugin URI: http://cagewebdev.com
9
  Description: Optimizes the Wordpress Database after Deleting Revisions
10
  Author: Rolf van Gelder
11
- Version: 1.0.1
12
  Author URI: http://cagewebdev.com
13
  */
14
  ?>
15
  <?php
16
  function optimize_db_main()
17
  { if (function_exists('add_options_page')) {
18
- add_options_page('Optimize Database', 'Optimize Database',8, 'rvg-optimize-db.php', 'rvg_optimize_db');
19
  }
20
  }
21
  add_action('admin_menu', 'optimize_db_main');
@@ -25,7 +26,7 @@ function rvg_optimize_db()
25
  global $wpdb;
26
 
27
  echo '<h2 style="padding-left:5px;">Optimizing your WordPress database</h2>';
28
- echo '<span style="padding-left:5px;font-style:italic;">rvg-optimize-db v1.0 - A WordPress Plugin by Rolf van Gelder</span><br /><br />';
29
 
30
  /***********************************
31
  DELETE REVISIONS
1
  <?php
2
+ $version = '1.0.2';
3
  /**
4
  * @package Optimize Database after Deleting Revisions
5
+ * @version 1.0.2
6
  */
7
  /*
8
  Plugin Name: Optimize Database after Deleting Revisions
9
  Plugin URI: http://cagewebdev.com
10
  Description: Optimizes the Wordpress Database after Deleting Revisions
11
  Author: Rolf van Gelder
12
+ Version: 1.0.2
13
  Author URI: http://cagewebdev.com
14
  */
15
  ?>
16
  <?php
17
  function optimize_db_main()
18
  { if (function_exists('add_options_page')) {
19
+ add_options_page('Optimize Database', 'Optimize Database',8 ,'rvg-optimize-db.php', 'rvg_optimize_db');
20
  }
21
  }
22
  add_action('admin_menu', 'optimize_db_main');
26
  global $wpdb;
27
 
28
  echo '<h2 style="padding-left:5px;">Optimizing your WordPress database</h2>';
29
+ echo '<span style="padding-left:5px;font-style:italic;">rvg-optimize-db v'.$version.' - A WordPress Plugin by Rolf van Gelder</span><br /><br />';
30
 
31
  /***********************************
32
  DELETE REVISIONS
trunk/readme.txt ADDED
@@ -0,0 +1,45 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ === Plugin Name ===
2
+
3
+ Contributors: Rolf van Gelder
4
+ Donate link: http://cagewebdev.com
5
+ Plugin Name: Optimize Database after Deleting Revisions
6
+ Plugin URI: http://cagewebdev.com/index.php/optimize-database-after-deleting-revisions-wordpress-plugin
7
+ Tags: wp, database, delete, revisions, optimize, posts, pages
8
+ Author URI: http://cagewebdev.com
9
+ Author: Rolf van Gelder
10
+ Requires at least: 2.0
11
+ Tested up to: 3.2.1
12
+ Stable tag: 1.0.2
13
+ Version: 1.0.2
14
+
15
+ == Description ==
16
+
17
+ <p>This plugin is a 'one click' database optimizer.</p>
18
+ <p>It deletes the redundant revisions of posts and pages and then optimizes all Wordpress database tables.</p>
19
+ <p>http://cagewebdev.com/</p>
20
+
21
+ == Installation ==
22
+
23
+ <ol>
24
+ <li>Upload `rvg-optimize-db.php` to the `/wp-content/plugins/` directory</li>
25
+ <li>Activate the plugin through the 'Plugins' menu in WordPress</li>
26
+ </ol>
27
+
28
+ == Upgrade Notice ==
29
+
30
+ No Upgrade Notice available.
31
+
32
+ == Screenshots ==
33
+
34
+ No Screenshots available.
35
+
36
+ == Changelog ==
37
+
38
+ <p>1.0 11/22/2011 Initial release</p>
39
+ <p>1.0.1 11/24/2011 A few updates for the readme.txt file</p>
40
+ <p>1.0.2 12/02/2011 Some minor updates</p>
41
+
42
+ == Frequently Asked Questions ==
43
+
44
+ <p>Q: How do I run this plugin?</p>
45
+ <p>A: In the WordPress ADMIN panel go to 'Settings'. Click on 'Optimize Database'. Et voila!</p>
trunk/rvg-optimize-db.php ADDED
@@ -0,0 +1,103 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ $version = '1.0.2';
3
+ /**
4
+ * @package Optimize Database after Deleting Revisions
5
+ * @version 1.0.2
6
+ */
7
+ /*
8
+ Plugin Name: Optimize Database after Deleting Revisions
9
+ Plugin URI: http://cagewebdev.com
10
+ Description: Optimizes the Wordpress Database after Deleting Revisions
11
+ Author: Rolf van Gelder
12
+ Version: 1.0.2
13
+ Author URI: http://cagewebdev.com
14
+ */
15
+ ?>
16
+ <?php
17
+ function optimize_db_main()
18
+ { if (function_exists('add_options_page')) {
19
+ add_options_page('Optimize Database', 'Optimize Database',8 ,'rvg-optimize-db.php', 'rvg_optimize_db');
20
+ }
21
+ }
22
+ add_action('admin_menu', 'optimize_db_main');
23
+
24
+ function rvg_optimize_db()
25
+ {
26
+ global $wpdb;
27
+
28
+ echo '<h2 style="padding-left:5px;">Optimizing your WordPress database</h2>';
29
+ echo '<span style="padding-left:5px;font-style:italic;">rvg-optimize-db v'.$version.' - A WordPress Plugin by Rolf van Gelder</span><br /><br />';
30
+
31
+ /***********************************
32
+ DELETE REVISIONS
33
+ ***********************************/
34
+ $sql = "SELECT `ID`,`post_date`,`post_title`,`post_modified`
35
+ FROM $wpdb->posts
36
+ WHERE `post_type` = 'revision'
37
+ ORDER BY `ID` DESC";
38
+ $results = $wpdb -> get_results($sql);
39
+ if($results)
40
+ { $cnt = count($results);
41
+ # print_r($results);
42
+ ?>
43
+ <table border="0" cellspacing="5" cellpadding="5">
44
+ <tr>
45
+ <td colspan="3" style="font-weight:bold;color:#00F;">DELETING REVISIONS:</td>
46
+ </tr>
47
+ <?php
48
+ for($i=0;$i<$cnt;$i++)
49
+ { # MULTI LINGUAL?
50
+ $post_title = str_replace('--><!--','--> | <!--',$results[$i]->post_title);
51
+ ?>
52
+ <tr valign="top">
53
+ <td align="right" style="font-weight:bold;"><?=($i+1)?></td>
54
+ <td><?=$results[$i]->post_modified?></td>
55
+ <td style="font-weight:bold;"><?=$post_title?></td>
56
+ </tr>
57
+ <?php
58
+ }
59
+ ?>
60
+ </table>
61
+ <br />
62
+ <?php
63
+ # DELETE THE REVISIONS
64
+ $sql = "DELETE FROM $wpdb->posts WHERE post_type = 'revision'";
65
+ $results = $wpdb -> get_results($sql);
66
+ }
67
+ else
68
+ { echo '<span style="font-weight:bold;color:#00F;padding-left:5px;">NO REVISIONS FOUND!</span><br /><br />';
69
+ } // if($results)
70
+
71
+ /***********************************
72
+ OPTIMIZE TABLES
73
+ ***********************************/
74
+ # GET TABLE NAMES
75
+ $Tables = $wpdb -> get_results('SHOW TABLES IN '.DB_NAME);
76
+ $Tables_in_DB_NAME = 'Tables_in_'.DB_NAME;
77
+ # print_r($Tables);
78
+ ?>
79
+ <table border="0" cellspacing="5" cellpadding="5">
80
+ <tr>
81
+ <td colspan="3" style="font-weight:bold;color:#00F;">OPTIMIZING DATABASE TABLES:</td>
82
+ </tr>
83
+ <?php
84
+ for ($i=0; $i<count($Tables); $i++)
85
+ {
86
+ $query = "OPTIMIZE TABLE ".$Tables[$i]->$Tables_in_DB_NAME;
87
+ $result = $wpdb -> get_results($query);
88
+ # print_r($result);
89
+ ?>
90
+ <tr>
91
+ <td style="font-weight:bold;"><?=$Tables[$i]->$Tables_in_DB_NAME?></td>
92
+ <td style="font-weight:bold;">=&gt;</td>
93
+ <td><?=$result[0]->Msg_text?></td>
94
+ </tr>
95
+ <?php
96
+ }
97
+ $query = "$operation TABLE ";
98
+ ?>
99
+ </table><br />
100
+ <span style="font-weight:bold;color:#00F;padding-left:5px;">DONE!</span>
101
+ <?php
102
+ }
103
+ ?>