Version Description
Download this release
Release Info
Developer | ruhanirabin |
Plugin | WP-Optimize |
Version | 0.7.0 |
Comparing to | |
See all releases |
Version 0.7.0
- index.htm +9 -0
- readme.txt +67 -0
- screenshot-1.jpg +0 -0
- screenshot-2.jpg +0 -0
- wp-optimize-admin.php +415 -0
- wp-optimize.gif +0 -0
- wp-optimize.php +46 -0
index.htm
ADDED
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
|
2 |
+
<HTML>
|
3 |
+
<HEAD>
|
4 |
+
<TITLE></TITLE>
|
5 |
+
</HEAD>
|
6 |
+
<BODY>
|
7 |
+
|
8 |
+
</BODY>
|
9 |
+
</HTML>
|
readme.txt
ADDED
@@ -0,0 +1,67 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
=== WP-Optimize ===
|
2 |
+
Contributors: ruhanirabin
|
3 |
+
Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=2732133
|
4 |
+
Tags: comments, spam, optimize, database, revisions, users, security, posts
|
5 |
+
Requires at least: 2.7
|
6 |
+
Tested up to: 2.8.6
|
7 |
+
Stable tag: 0.7.0
|
8 |
+
|
9 |
+
This plugin allows you to clean up your wordpress database and optimize it without phpMyAdmin. Also renames any username.
|
10 |
+
|
11 |
+
== Description ==
|
12 |
+
|
13 |
+
WP-Optimize is a wordpress 2.7++ database cleanup and optimization tool. It doesn't require PhpMyAdmin to optimize your database tables.
|
14 |
+
It allows you to remove post revisions, cleanup post meta data, comments in the spam queue, un-approved comments within few clicks.
|
15 |
+
|
16 |
+
Additionally you can rename any username to another username too.
|
17 |
+
|
18 |
+
|
19 |
+
**Features:**
|
20 |
+
|
21 |
+
* Remove the wordpress post revisions including post meta data garbage
|
22 |
+
* Remove all the comments in the spam queue
|
23 |
+
* Remove all the un-approved comments
|
24 |
+
* Rename one username to another username, it's designed to rename default "Admin" user to something else
|
25 |
+
* Apply mysql optimize commands on your database tables without phpMyAdmin.
|
26 |
+
* Display Database table statistics. Shows how much space can be optimzied and how much space has been cleared.
|
27 |
+
|
28 |
+
|
29 |
+
**How this could help you?**
|
30 |
+
|
31 |
+
* Everytime you save a new post or pages, wordpress creates a revision of that post or page. If you edit a post 6 times you might have 5 copy of that post as revisions. Imagine if your post or pages are long and big. It is a huge number of bytes thats on your MySQL overhead. Now WP-Optimize allows you to optimize and shrink your posts table by removing not necessary post revisions from the database. As example, if you have a post which is approximately 100KB data and you have 5 revisions of that post, the total space wasted is about 500KB. And if you have 100 posts similar to it, you have 50MB database space wasted.
|
32 |
+
* Similar to the scenario described above, there might be thousands of spams and un-approved comments in your comments table, WP-Optimize can clean and remove those in a single click
|
33 |
+
* WP-Optimize reports which database tables have overhead and wasted spaces also it allows you to shrink and get rid of those wasted spaces
|
34 |
+
* Wordpress doesn't allow you to rename existing username which could be a security issue because your default wordpress admin username is "admin", if you read my [Wordpress Security guide article](http://www.ruhanirabin.com/14-tips-prevent-wordpress-get-hacked/), you will know the risks involved. WP-Optimize can rename any existing username to other name
|
35 |
+
|
36 |
+
|
37 |
+
== Installation ==
|
38 |
+
|
39 |
+
* Unzip the archive into your hard drive.
|
40 |
+
* Upload the folder to your wp-content/plugins folder on your web host.
|
41 |
+
* Login to your dashboard and activate the plugin via activate option.
|
42 |
+
* The menu item is under Dashboard>WP-Optimize.
|
43 |
+
|
44 |
+
== Frequently Asked Questions ==
|
45 |
+
|
46 |
+
= Is there any bug in this plugin =
|
47 |
+
|
48 |
+
This is a very primary version of the plugin. So I would recommend you to test it out on your local system.
|
49 |
+
|
50 |
+
= Wordpress logged me out when I rename my username =
|
51 |
+
|
52 |
+
Because you've changed your username, wordpress can't get authentication data from the database. Use your new username and the password you've used before
|
53 |
+
|
54 |
+
== Screenshots ==
|
55 |
+
|
56 |
+
1. Main screen
|
57 |
+
2. Database tables report
|
58 |
+
|
59 |
+
== Changelog ==
|
60 |
+
|
61 |
+
= 0.7 =
|
62 |
+
* Added cleanup of POST META Table along with the revisions
|
63 |
+
* Fixed some minor PHP tags which causes the total numbers to disappear
|
64 |
+
* Now requires MySQL 5.1.x and PHP 5.1.x
|
65 |
+
|
66 |
+
= 0.6.5.1 =
|
67 |
+
* Fix Interface
|
screenshot-1.jpg
ADDED
Binary file
|
screenshot-2.jpg
ADDED
Binary file
|
wp-optimize-admin.php
ADDED
@@ -0,0 +1,415 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
# ---------------------------------- #
|
4 |
+
# prevent file from being accessed directly
|
5 |
+
# ---------------------------------- #
|
6 |
+
if ('wp-optimize-admin.php' == basename($_SERVER['SCRIPT_FILENAME']))
|
7 |
+
die ('Please do not access this file directly. Thanks!');
|
8 |
+
|
9 |
+
if ( !is_admin() ) {
|
10 |
+
Die();
|
11 |
+
}
|
12 |
+
|
13 |
+
if (! defined('WP_CONTENT_DIR'))
|
14 |
+
define('WP_CONTENT_DIR', ABSPATH . 'wp-content');
|
15 |
+
if (! defined('WP_CONTENT_URL'))
|
16 |
+
define('WP_CONTENT_URL', get_option('siteurl') . '/wp-content');
|
17 |
+
|
18 |
+
if (! defined('WP_ADMIN_URL'))
|
19 |
+
define('WP_ADMIN_URL', get_option('siteurl') . '/wp-admin');
|
20 |
+
|
21 |
+
if (! defined('WP_PLUGIN_DIR'))
|
22 |
+
define('WP_PLUGIN_DIR', WP_CONTENT_DIR . '/plugins');
|
23 |
+
if (! defined('WP_PLUGIN_URL'))
|
24 |
+
define('WP_PLUGIN_URL', WP_CONTENT_URL . '/plugins');
|
25 |
+
|
26 |
+
$text = '';
|
27 |
+
$textdomain = 'wp-optimize';
|
28 |
+
|
29 |
+
if (isset($_POST["clean-revisions"])) {
|
30 |
+
$text .= cleanUpSystem('revisions');
|
31 |
+
}
|
32 |
+
|
33 |
+
if (isset($_POST["old_admin"]) && isset($_POST["new_admin"])) {
|
34 |
+
$text .= cleanUpSystem('changeadmin');
|
35 |
+
}
|
36 |
+
|
37 |
+
if (isset($_POST["clean-comments"])) {
|
38 |
+
$text .= cleanUpSystem('spam');
|
39 |
+
}
|
40 |
+
|
41 |
+
if (isset($_POST["unapproved-comments"])) {
|
42 |
+
$text .= cleanUpSystem('unapproved');
|
43 |
+
}
|
44 |
+
|
45 |
+
if (isset($_POST["optimize-db"])) {
|
46 |
+
//$text .= cleanUpSystem('optimize-db');
|
47 |
+
$text .= DB_NAME.__(" Database Optimized!<br>", $textdomain);
|
48 |
+
}
|
49 |
+
|
50 |
+
|
51 |
+
if ($text !==''){
|
52 |
+
echo '<div id="message" class="updated fade">';
|
53 |
+
echo '<strong>'.$text.'</strong></div>';
|
54 |
+
}
|
55 |
+
|
56 |
+
function cleanUpSystem($cleanupType){
|
57 |
+
global $wpdb;
|
58 |
+
$clean = "";
|
59 |
+
|
60 |
+
switch ($cleanupType) {
|
61 |
+
case "revisions":
|
62 |
+
$clean = "DELETE FROM $wpdb->posts WHERE post_type = 'revision'";
|
63 |
+
$revisions = $wpdb->query( $clean );
|
64 |
+
|
65 |
+
$allposts = get_posts('numberposts=-1&orderby=ID&order=ASC&post_type=any&post_status=');
|
66 |
+
$allpost_ids = array();
|
67 |
+
foreach ($allposts as $onepost)
|
68 |
+
$allpost_ids[$onepost->ID] = true;
|
69 |
+
$cleaned_ids = array();
|
70 |
+
$total_cleaned_metas = 0;
|
71 |
+
$postmeta = $wpdb->get_results("SELECT * FROM $wpdb->postmeta", OBJECT);
|
72 |
+
foreach ($postmeta as $meta)
|
73 |
+
if (!isset($allpost_ids[$meta->post_id]) && !isset($cleaned_ids[$meta->post_id])) {
|
74 |
+
$cleaned_metas = $wpdb->query("DELETE FROM $wpdb->postmeta WHERE post_id = '".$meta->post_id."'");
|
75 |
+
$total_cleaned_metas += $cleaned_metas;
|
76 |
+
$cleaned_ids[$meta->post_id] = true;
|
77 |
+
}
|
78 |
+
|
79 |
+
$message .= $revisions.__(' post revisions deleted<br>', $textdomain);
|
80 |
+
break;
|
81 |
+
|
82 |
+
//case "postmeta":
|
83 |
+
|
84 |
+
// $message .= $total_cleaned_metas.__(' postmeta items from revisions and nonexistant posts deleted', $textdomain);
|
85 |
+
// break;
|
86 |
+
|
87 |
+
case "spam":
|
88 |
+
$clean = "DELETE FROM $wpdb->comments WHERE comment_approved = 'spam';";
|
89 |
+
$comments = $wpdb->query( $clean );
|
90 |
+
$message .= $comments.__(' spam comments deleted<br>', $textdomain);
|
91 |
+
break;
|
92 |
+
|
93 |
+
case "unapproved":
|
94 |
+
$clean = "DELETE FROM $wpdb->comments WHERE comment_approved = '0';";
|
95 |
+
$comments = $wpdb->query( $clean );
|
96 |
+
$message .= $comments.__(' unapproved comments deleted<br>', $textdomain);
|
97 |
+
break;
|
98 |
+
|
99 |
+
|
100 |
+
// case "optimize-db":
|
101 |
+
// optimizeTables(true);
|
102 |
+
// $message .= "Database ".DB_NAME." Optimized!<br>";
|
103 |
+
// break;
|
104 |
+
|
105 |
+
case "changeadmin":
|
106 |
+
if (isset($_POST["old_admin"]) && isset($_POST["new_admin"])) {
|
107 |
+
$oldAdmin = $_POST["old_admin"];
|
108 |
+
$newAdmin = $_POST["new_admin"];
|
109 |
+
$clean = "UPDATE $wpdb->users SET user_login = '$newAdmin' WHERE user_login ='$oldAdmin'";
|
110 |
+
$setlogin = $wpdb->query( $clean );
|
111 |
+
if ($setlogin !== 0){
|
112 |
+
$message .= __('Admin username updated<br>', $textdomain);
|
113 |
+
}
|
114 |
+
else{
|
115 |
+
$message .= "";
|
116 |
+
}
|
117 |
+
}
|
118 |
+
else{
|
119 |
+
$message .= __('ADMIN USERNAME NOT UPDATED<br>', $textdomain);
|
120 |
+
}
|
121 |
+
break;
|
122 |
+
|
123 |
+
default:
|
124 |
+
$message .= __('NO Actions Taken<br>', $textdomain);
|
125 |
+
break;
|
126 |
+
} // end of switch
|
127 |
+
return $message;
|
128 |
+
|
129 |
+
|
130 |
+
} // end of function
|
131 |
+
|
132 |
+
|
133 |
+
function getInfo($cleanupType){
|
134 |
+
global $wpdb;
|
135 |
+
$sql = "";
|
136 |
+
|
137 |
+
switch ($cleanupType) {
|
138 |
+
case "revisions":
|
139 |
+
$sql = "SELECT COUNT(*) FROM $wpdb->posts WHERE post_type = 'revision'";
|
140 |
+
$revisions = $wpdb->get_var( $sql );
|
141 |
+
|
142 |
+
//var_dump(!$revisions ==);
|
143 |
+
if(!$revisions == 0 || !$revisions == NULL){
|
144 |
+
$message .= ' '.$revisions.__(' post revisions in your database', $textdomain);
|
145 |
+
}
|
146 |
+
else $message .=' '.__('No post revisions found', $textdomain);
|
147 |
+
break;
|
148 |
+
|
149 |
+
case "spam":
|
150 |
+
$sql = "SELECT COUNT(*) FROM $wpdb->comments WHERE comment_approved = 'spam';";
|
151 |
+
$comments = $wpdb->get_var( $sql );
|
152 |
+
if(!$comments == NULL || !$comments == 0){
|
153 |
+
$message .= ' '.$comments.__(' spam comments found', $textdomain).' | <a href="edit-comments.php?comment_status=spam">'.__(' Review Spams</a>', $textdomain);
|
154 |
+
} else
|
155 |
+
$message .=' '.__('No spam comments found', $textdomain);
|
156 |
+
break;
|
157 |
+
|
158 |
+
case "unapproved":
|
159 |
+
$sql = "SELECT COUNT(*) FROM $wpdb->comments WHERE comment_approved = '0';";
|
160 |
+
$comments = $wpdb->get_var( $sql );
|
161 |
+
if(!$comments == NULL || !$comments == 0){
|
162 |
+
$message .= ' '.$comments.__(' unapproved comments found', $textdomain).' | <a href="edit-comments.php?comment_status=moderated">'.__(' Review Unapproved Comments</a>', $textdomain);;
|
163 |
+
} else
|
164 |
+
$message .= ' '.__('No unapproved comments found', $textdomain);
|
165 |
+
|
166 |
+
break;
|
167 |
+
|
168 |
+
default:
|
169 |
+
$message .= __('nothing', $textdomain);
|
170 |
+
break;
|
171 |
+
} // end of switch
|
172 |
+
return $message;
|
173 |
+
|
174 |
+
|
175 |
+
} // end of function
|
176 |
+
|
177 |
+
?>
|
178 |
+
|
179 |
+
|
180 |
+
<div class="wrap">
|
181 |
+
<?php
|
182 |
+
//echo '<div id="message" class="updated fade">';
|
183 |
+
//echo '<strong>'.$msg.'</strong></div>';
|
184 |
+
//echo '</div>';
|
185 |
+
?>
|
186 |
+
<table width="80%" border="0" cellspacing="0" cellpadding="0">
|
187 |
+
<form action="#" method="post" enctype="multipart/form-data" name="optimize_form" id="optimize_form">
|
188 |
+
<tr>
|
189 |
+
<td> </td>
|
190 |
+
<td> </td>
|
191 |
+
</tr>
|
192 |
+
<tr>
|
193 |
+
<td colspan="2"><img src="<?php _e(WP_PLUGIN_URL) ?>/wp-optimize/wp-optimize.gif" border="0" alt="WP-Optimize Admin" title="WP-Optimize Admin" /></td>
|
194 |
+
</tr>
|
195 |
+
<tr>
|
196 |
+
<td><a href="#report"><?php _e('Tables Report', $textdomain); ?></a></td>
|
197 |
+
<td> </td>
|
198 |
+
</tr>
|
199 |
+
|
200 |
+
|
201 |
+
<tr>
|
202 |
+
<td> </td>
|
203 |
+
<td> </td>
|
204 |
+
</tr>
|
205 |
+
<tr>
|
206 |
+
<td><h3><?php _e('Database Optimization Options',$textdomain); ?></h3></td>
|
207 |
+
</tr>
|
208 |
+
|
209 |
+
<tr>
|
210 |
+
<td width="25%"> </td>
|
211 |
+
<td width="75%"><input name="clean-revisions" id="clean-revisions" type="checkbox" value="" />
|
212 |
+
<?php _e('Remove all Post revisions (Also cleanup Post meta data)', $textdomain); ?><br />
|
213 |
+
<small><?php _e(getInfo('revisions')); ?></small></td>
|
214 |
+
</tr>
|
215 |
+
<tr>
|
216 |
+
<td> </td>
|
217 |
+
<td> </td>
|
218 |
+
</tr>
|
219 |
+
<tr>
|
220 |
+
<td> </td>
|
221 |
+
<td><input name="clean-comments" type="checkbox" value="" />
|
222 |
+
<?php _e('Clean marked Spam comments', $textdomain); ?><br />
|
223 |
+
<small><?php _e(getInfo('spam')); ?></small></td>
|
224 |
+
</tr>
|
225 |
+
<tr>
|
226 |
+
<td> </td>
|
227 |
+
<td> </td>
|
228 |
+
</tr>
|
229 |
+
<tr>
|
230 |
+
<td> </td>
|
231 |
+
<td><input name="unapproved-comments" type="checkbox" value="" />
|
232 |
+
<?php _e('Clean Unapproved comments', $textdomain); ?><br />
|
233 |
+
<small><?php _e(getInfo('unapproved')); ?></small></td>
|
234 |
+
</tr>
|
235 |
+
<tr>
|
236 |
+
<td> </td>
|
237 |
+
<td> </td>
|
238 |
+
</tr>
|
239 |
+
<tr>
|
240 |
+
<td> </td>
|
241 |
+
<td><input name="optimize-db" type="checkbox" value="" />
|
242 |
+
<?php _e('Optimize database tables', $textdomain); ?></td>
|
243 |
+
</tr>
|
244 |
+
<tr>
|
245 |
+
<td> </td>
|
246 |
+
<td> </td>
|
247 |
+
</tr>
|
248 |
+
|
249 |
+
<tr>
|
250 |
+
<td><h3><?php _e('Security Tools',$textdomain); ?></h3></td>
|
251 |
+
</tr>
|
252 |
+
|
253 |
+
<tr>
|
254 |
+
<td><p align="right"><?php _e('Old username:', $textdomain); ?> </p></td>
|
255 |
+
<td><input type="text" name="old_admin" id="old_admin" class="old_admin" size="40" value=""></td>
|
256 |
+
</tr>
|
257 |
+
<tr>
|
258 |
+
<td> </td>
|
259 |
+
<td> </td>
|
260 |
+
</tr>
|
261 |
+
<tr>
|
262 |
+
<td><p align="right"><?php _e('New username:', $textdomain); ?> </p></td>
|
263 |
+
<td><input type="text" name="new_admin" id="new_admin" class="new_admin" size="40" value=""></td>
|
264 |
+
</tr>
|
265 |
+
<tr>
|
266 |
+
<td> </td>
|
267 |
+
<td> </td>
|
268 |
+
</tr>
|
269 |
+
<tr>
|
270 |
+
<td> </td>
|
271 |
+
<td><input class="button-primary" type="submit" name="wp-optimize" value="<?php _e('Process', $textdomain); ?>" /></td>
|
272 |
+
</tr>
|
273 |
+
<tr>
|
274 |
+
<td> </td>
|
275 |
+
<td> </td>
|
276 |
+
</tr>
|
277 |
+
<tr>
|
278 |
+
<td><p align="right"><?php _e('Plugin Homepage', $textdomain); ?> : </p></td>
|
279 |
+
<td><a href="http://www.ruhanirabin.com/wp-optimize/" target="_blank">WP-Optimize</a></td>
|
280 |
+
</tr>
|
281 |
+
<tr>
|
282 |
+
<td><p align="right"><?php _e('RSS Feed', $textdomain); ?> : </p></td>
|
283 |
+
<td><a href="http://feeds2.feedburner.com/RuhaniRabin" target="_blank"><?php _e('Stay updated with RSS feed', $textdomain); ?></a>
|
284 |
+
</td>
|
285 |
+
</tr>
|
286 |
+
<tr>
|
287 |
+
<td><p align="right"><?php _e('Did this helped you out', $textdomain); ?>? : </p></td>
|
288 |
+
<td><a href="https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=2732133" target="_blank"><?php _e('Do you like to donate an amount?', $textdomain); ?></a></td>
|
289 |
+
</tr>
|
290 |
+
|
291 |
+
</form>
|
292 |
+
</table>
|
293 |
+
|
294 |
+
|
295 |
+
<?php
|
296 |
+
|
297 |
+
if (isset($_POST["optimize-db"])) {
|
298 |
+
optimizeTables(true);
|
299 |
+
}
|
300 |
+
else optimizeTables(false);
|
301 |
+
|
302 |
+
?>
|
303 |
+
<?php
|
304 |
+
Function optimizeTables($Optimize=false){
|
305 |
+
?>
|
306 |
+
|
307 |
+
<h3><?php _e('Database Tables Report',$textdomain); ?></h3>
|
308 |
+
<h3><?php _e('Database Name:',$textdomain); ?> '<?php _e(DB_NAME);?>'</h3>
|
309 |
+
<?php if($Optimize){
|
310 |
+
?>
|
311 |
+
|
312 |
+
<p><?php _e('Optimized all the tables found in the database.',$textdomain)?></p>
|
313 |
+
<?php } ?>
|
314 |
+
|
315 |
+
<a name="report"> </a>
|
316 |
+
|
317 |
+
<table class="widefat fixed" cellspacing="0">
|
318 |
+
<thead>
|
319 |
+
<tr>
|
320 |
+
<th scope="col"><?php _e('Table',$textdomain); ?></th>
|
321 |
+
<th scope="col"><?php _e('Size',$textdomain)?></th>
|
322 |
+
<th scope="col"><?php _e('Status',$textdomain); ?></th>
|
323 |
+
<th scope="col"><?php _e('Space Save',$textdomain); ?></th>
|
324 |
+
</tr>
|
325 |
+
</thead>
|
326 |
+
<tfoot>
|
327 |
+
<tr>
|
328 |
+
<th scope="col"><?php _e('Table',$textdomain); ?></th>
|
329 |
+
<th scope="col"><?php _e('Size',$textdomain)?></th>
|
330 |
+
<th scope="col"><?php _e('Status',$textdomain); ?></th>
|
331 |
+
<th scope="col"><?php _e('Space Save',$textdomain); ?></th>
|
332 |
+
</tr>
|
333 |
+
</tfoot>
|
334 |
+
<tbody id="the-list">
|
335 |
+
<?php
|
336 |
+
$alternate = ' class="alternate"';
|
337 |
+
$db_clean = DB_NAME;
|
338 |
+
$tot_data = 0;
|
339 |
+
$tot_idx = 0;
|
340 |
+
$tot_all = 0;
|
341 |
+
$local_query = 'SHOW TABLE STATUS FROM '. DB_NAME;
|
342 |
+
$result = mysql_query($local_query);
|
343 |
+
if (mysql_num_rows($result)){
|
344 |
+
while ($row = mysql_fetch_array($result))
|
345 |
+
{
|
346 |
+
$tot_data = $row['Data_length'];
|
347 |
+
$tot_idx = $row['Index_length'];
|
348 |
+
$total = $tot_data + $tot_idx;
|
349 |
+
$total = $total / 1024 ;
|
350 |
+
$total = round ($total,3);
|
351 |
+
$gain= $row['Data_free'];
|
352 |
+
$gain = $gain / 1024 ;
|
353 |
+
$total_gain += $gain;
|
354 |
+
$gain = round ($gain,3);
|
355 |
+
if (isset($_POST["optimize-db"])) {
|
356 |
+
$local_query = 'OPTIMIZE TABLE '.$row[0];
|
357 |
+
$resultat = mysql_query($local_query);
|
358 |
+
//echo "optimization";
|
359 |
+
}
|
360 |
+
|
361 |
+
if ($gain == 0){
|
362 |
+
echo "<tr". $alternate .">
|
363 |
+
<td class='column-name'>". $row[0] ."</td>
|
364 |
+
<td class='column-name'>". $total ." Kb"."</td>
|
365 |
+
<td class='column-name'>" . __('Already Optimized',$textdomain) . "</td>
|
366 |
+
<td class='column-name'>0 Kb</td>
|
367 |
+
</tr>\n";
|
368 |
+
} else
|
369 |
+
{
|
370 |
+
if (isset($_POST["optimize-db"])) {
|
371 |
+
echo "<tr". $alternate .">
|
372 |
+
<td class='column-name'>". $row[0] ."</td>
|
373 |
+
<td class='column-name'>". $total ." Kb"."</td>
|
374 |
+
<td class='column-name' style=\"color: #0000FF;\">" . __('Optimized',$textdomain) . "</td>
|
375 |
+
<td class='column-name'>". $gain ." Kb</td>
|
376 |
+
</tr>\n";
|
377 |
+
}
|
378 |
+
else {
|
379 |
+
echo "<tr". $alternate .">
|
380 |
+
<td class='column-name'>". $row[0] ."</td>
|
381 |
+
<td class='column-name'>". $total ." Kb"."</td>
|
382 |
+
<td class='column-name' style=\"color: #FF0000;\">" . __('Need to Optimize',$textdomain) . "</td>
|
383 |
+
<td class='column-name'>". $gain ." Kb</td>
|
384 |
+
</tr>\n";
|
385 |
+
}
|
386 |
+
}
|
387 |
+
$alternate = ( empty( $alternate ) ) ? ' class="alternate"' : '';
|
388 |
+
}
|
389 |
+
}
|
390 |
+
?>
|
391 |
+
</tbody>
|
392 |
+
</table>
|
393 |
+
|
394 |
+
<?php if (isset($_POST["optimize-db"])) {
|
395 |
+
?>
|
396 |
+
|
397 |
+
<?php $total_gain = round ($total_gain,3);?>
|
398 |
+
|
399 |
+
<h3><?php _e('Optimization Results:',$textdomain); ?></h3>
|
400 |
+
<p style="color: #0000FF;"><?php _e('Total Space Saved:',$textdomain); ?> <?php echo $total_gain?> Kb</p>
|
401 |
+
<?php } else { ?>
|
402 |
+
<?php $total_gain = round ($total_gain,3); ?>
|
403 |
+
<?php if(!$total_gain==0){ ?>
|
404 |
+
|
405 |
+
<h3><?php _e('Optimization Possibility:',$textdomain); ?></h3>
|
406 |
+
<p style="color: #FF0000;"><?php _e('Total space can be saved:',$textdomain); ?> <?php echo $total_gain?> Kb</p>
|
407 |
+
<?php } ?>
|
408 |
+
<?php
|
409 |
+
}
|
410 |
+
?>
|
411 |
+
|
412 |
+
<?php
|
413 |
+
}
|
414 |
+
?>
|
415 |
+
</div>
|
wp-optimize.gif
ADDED
Binary file
|
wp-optimize.php
ADDED
@@ -0,0 +1,46 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/*
|
3 |
+
Plugin Name: WP-Optimize
|
4 |
+
Plugin URI: http://www.ruhanirabin.com/wp-optimize/
|
5 |
+
Description: This plugin helps you to keep your database clean by removing post revisions and spams in a blaze. allows you to rename your admin name also. Additionally it allows you to run optimize command on your wordpress core tables (use with caution).
|
6 |
+
Version: 0.7.0
|
7 |
+
Author: Ruhani Rabin
|
8 |
+
Author URI: http://www.ruhanirabin.com
|
9 |
+
|
10 |
+
Copyright 2008-2009 Ruhani Rabin (email : get@ruhanirabin.com)
|
11 |
+
|
12 |
+
This program is free software; you can redistribute it and/or modify
|
13 |
+
it under the terms of the GNU General Public License as published by
|
14 |
+
the Free Software Foundation; either version 2 of the License, or
|
15 |
+
(at your option) any later version.
|
16 |
+
|
17 |
+
This program is distributed in the hope that it will be useful,
|
18 |
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
19 |
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
20 |
+
GNU General Public License for more details.
|
21 |
+
|
22 |
+
You should have received a copy of the GNU General Public License
|
23 |
+
along with this program; if not, write to the Free Software
|
24 |
+
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
25 |
+
*/
|
26 |
+
|
27 |
+
# ---------------------------------- #
|
28 |
+
# prevent file from being accessed directly
|
29 |
+
# ---------------------------------- #
|
30 |
+
if ('wp-optimize.php' == basename($_SERVER['SCRIPT_FILENAME']))
|
31 |
+
die ('Please do not access this file directly. Thanks!');
|
32 |
+
|
33 |
+
register_activation_hook(__FILE__,'optimize_admin_actions');
|
34 |
+
|
35 |
+
function optimize_menu(){
|
36 |
+
include 'wp-optimize-admin.php';
|
37 |
+
}
|
38 |
+
|
39 |
+
function optimize_admin_actions()
|
40 |
+
{
|
41 |
+
//add_options_page("WP-Optimize", "WP-Optimize", 10, "WP-Optimize", "optimize_menu");
|
42 |
+
add_submenu_page("index.php", "WP-Optimize", "WP-Optimize", 10, "WP-Optimize", "optimize_menu");
|
43 |
+
}
|
44 |
+
|
45 |
+
add_action('admin_menu', 'optimize_admin_actions');
|
46 |
+
?>
|