WP Clean Up - Version 1.2.1

Version Description

  • It allows you to remove "revision" "draft" "auto draft" "moderated comments" "spam comments" "trash comments" "orphan postmeta" "orphan commentmeta" "orphan relationships" "dashboard transient feed"
Download this release

Release Info

Developer acalbert
Plugin Icon wp plugin WP Clean Up
Version 1.2.1
Comparing to
See all releases

Code changes from version 1.2.0 to 1.2.1

lang/wp-clean-up-zh_CN.mo CHANGED
Binary file
lang/wp-clean-up-zh_CN.po CHANGED
@@ -2,8 +2,8 @@ msgid ""
2
  msgstr ""
3
  "Project-Id-Version: WP-Clean-Up Languages\n"
4
  "Report-Msgid-Bugs-To: \n"
5
- "POT-Creation-Date: 2012-12-07 15:29+0800\n"
6
- "PO-Revision-Date: 2012-12-07 15:29+0800\n"
7
  "Last-Translator: 夜光 <berttung(#)gmail.com>\n"
8
  "Language-Team: 玻璃泉BoLiQuan.COM <berttung(#)gmail.com>\n"
9
  "MIME-Version: 1.0\n"
@@ -20,100 +20,136 @@ msgstr ""
20
  msgid "Settings"
21
  msgstr "设置"
22
 
23
- #: F:\xampp\htdocs\wordpress\wp-content\plugins\wp-clean-up/wp_clean_up_admin.php:78
24
  msgid "All revisions deleted!"
25
  msgstr "所有修订版本已删除!"
26
 
27
- #: F:\xampp\htdocs\wordpress\wp-content\plugins\wp-clean-up/wp_clean_up_admin.php:83
28
  msgid "All drafts deleted!"
29
  msgstr "所有草稿已删除!"
30
 
31
- #: F:\xampp\htdocs\wordpress\wp-content\plugins\wp-clean-up/wp_clean_up_admin.php:88
32
  msgid "All autodrafts deleted!"
33
  msgstr "所有自动草稿已删除!"
34
 
35
- #: F:\xampp\htdocs\wordpress\wp-content\plugins\wp-clean-up/wp_clean_up_admin.php:93
36
  msgid "All moderated comments deleted!"
37
  msgstr "所有待审评论已删除!"
38
 
39
- #: F:\xampp\htdocs\wordpress\wp-content\plugins\wp-clean-up/wp_clean_up_admin.php:98
40
  msgid "All spam comments deleted!"
41
  msgstr "所有垃圾评论已删除!"
42
 
43
- #: F:\xampp\htdocs\wordpress\wp-content\plugins\wp-clean-up/wp_clean_up_admin.php:103
44
  msgid "All trash comments deleted!"
45
  msgstr "所有回收站评论已删除!"
46
 
47
- #: F:\xampp\htdocs\wordpress\wp-content\plugins\wp-clean-up/wp_clean_up_admin.php:113
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
48
  msgid "All redundant data deleted!"
49
  msgstr "所有冗余数据已删除!"
50
 
51
- #: F:\xampp\htdocs\wordpress\wp-content\plugins\wp-clean-up/wp_clean_up_admin.php:117
52
  msgid "Database Optimized!"
53
  msgstr "数据库已优化!"
54
 
55
- #: F:\xampp\htdocs\wordpress\wp-content\plugins\wp-clean-up/wp_clean_up_admin.php:129
56
  msgid "Type"
57
  msgstr "类型"
58
 
59
- #: F:\xampp\htdocs\wordpress\wp-content\plugins\wp-clean-up/wp_clean_up_admin.php:130
60
  msgid "Count"
61
  msgstr "数量"
62
 
63
- #: F:\xampp\htdocs\wordpress\wp-content\plugins\wp-clean-up/wp_clean_up_admin.php:131
64
  msgid "Operate"
65
  msgstr "操作"
66
 
67
- #: F:\xampp\htdocs\wordpress\wp-content\plugins\wp-clean-up/wp_clean_up_admin.php:137
68
  msgid "Revision"
69
  msgstr "修订版本"
70
 
71
- #: F:\xampp\htdocs\wordpress\wp-content\plugins\wp-clean-up/wp_clean_up_admin.php:145
72
- #: F:\xampp\htdocs\wordpress\wp-content\plugins\wp-clean-up/wp_clean_up_admin.php:159
73
- #: F:\xampp\htdocs\wordpress\wp-content\plugins\wp-clean-up/wp_clean_up_admin.php:173
74
- #: F:\xampp\htdocs\wordpress\wp-content\plugins\wp-clean-up/wp_clean_up_admin.php:187
75
- #: F:\xampp\htdocs\wordpress\wp-content\plugins\wp-clean-up/wp_clean_up_admin.php:201
76
- #: F:\xampp\htdocs\wordpress\wp-content\plugins\wp-clean-up/wp_clean_up_admin.php:215
 
 
 
 
77
  msgid "Delete"
78
  msgstr "删除"
79
 
80
- #: F:\xampp\htdocs\wordpress\wp-content\plugins\wp-clean-up/wp_clean_up_admin.php:151
81
  msgid "Draft"
82
  msgstr "草稿"
83
 
84
- #: F:\xampp\htdocs\wordpress\wp-content\plugins\wp-clean-up/wp_clean_up_admin.php:165
85
  msgid "Auto Draft"
86
  msgstr "自动草稿"
87
 
88
- #: F:\xampp\htdocs\wordpress\wp-content\plugins\wp-clean-up/wp_clean_up_admin.php:179
89
  msgid "Moderated Comments"
90
  msgstr "待审评论"
91
 
92
- #: F:\xampp\htdocs\wordpress\wp-content\plugins\wp-clean-up/wp_clean_up_admin.php:193
93
  msgid "Spam Comments"
94
  msgstr "垃圾评论"
95
 
96
- #: F:\xampp\htdocs\wordpress\wp-content\plugins\wp-clean-up/wp_clean_up_admin.php:207
97
  msgid "Trash Comments"
98
  msgstr "回收站评论"
99
 
100
- #: F:\xampp\htdocs\wordpress\wp-content\plugins\wp-clean-up/wp_clean_up_admin.php:225
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
101
  msgid "Delete All"
102
  msgstr "删除所有"
103
 
104
- #: F:\xampp\htdocs\wordpress\wp-content\plugins\wp-clean-up/wp_clean_up_admin.php:233
105
  msgid "Table"
106
  msgstr "数据表"
107
 
108
- #: F:\xampp\htdocs\wordpress\wp-content\plugins\wp-clean-up/wp_clean_up_admin.php:234
109
  msgid "Size"
110
  msgstr "大小"
111
 
112
- #: F:\xampp\htdocs\wordpress\wp-content\plugins\wp-clean-up/wp_clean_up_admin.php:269
113
  msgid "Total"
114
  msgstr "总计"
115
 
116
- #: F:\xampp\htdocs\wordpress\wp-content\plugins\wp-clean-up/wp_clean_up_admin.php:277
117
  msgid "Optimize"
118
  msgstr "优化数据库"
119
 
2
  msgstr ""
3
  "Project-Id-Version: WP-Clean-Up Languages\n"
4
  "Report-Msgid-Bugs-To: \n"
5
+ "POT-Creation-Date: 2012-12-12 17:44+0800\n"
6
+ "PO-Revision-Date: 2012-12-12 17:49+0800\n"
7
  "Last-Translator: 夜光 <berttung(#)gmail.com>\n"
8
  "Language-Team: 玻璃泉BoLiQuan.COM <berttung(#)gmail.com>\n"
9
  "MIME-Version: 1.0\n"
20
  msgid "Settings"
21
  msgstr "设置"
22
 
23
+ #: F:\xampp\htdocs\wordpress\wp-content\plugins\wp-clean-up/wp_clean_up_admin.php:112
24
  msgid "All revisions deleted!"
25
  msgstr "所有修订版本已删除!"
26
 
27
+ #: F:\xampp\htdocs\wordpress\wp-content\plugins\wp-clean-up/wp_clean_up_admin.php:117
28
  msgid "All drafts deleted!"
29
  msgstr "所有草稿已删除!"
30
 
31
+ #: F:\xampp\htdocs\wordpress\wp-content\plugins\wp-clean-up/wp_clean_up_admin.php:122
32
  msgid "All autodrafts deleted!"
33
  msgstr "所有自动草稿已删除!"
34
 
35
+ #: F:\xampp\htdocs\wordpress\wp-content\plugins\wp-clean-up/wp_clean_up_admin.php:127
36
  msgid "All moderated comments deleted!"
37
  msgstr "所有待审评论已删除!"
38
 
39
+ #: F:\xampp\htdocs\wordpress\wp-content\plugins\wp-clean-up/wp_clean_up_admin.php:132
40
  msgid "All spam comments deleted!"
41
  msgstr "所有垃圾评论已删除!"
42
 
43
+ #: F:\xampp\htdocs\wordpress\wp-content\plugins\wp-clean-up/wp_clean_up_admin.php:137
44
  msgid "All trash comments deleted!"
45
  msgstr "所有回收站评论已删除!"
46
 
47
+ #: F:\xampp\htdocs\wordpress\wp-content\plugins\wp-clean-up/wp_clean_up_admin.php:142
48
+ msgid "All orphan postmeta deleted!"
49
+ msgstr "所有孤立的文章元信息已删除!"
50
+
51
+ #: F:\xampp\htdocs\wordpress\wp-content\plugins\wp-clean-up/wp_clean_up_admin.php:147
52
+ msgid "All orphan commentmeta deleted!"
53
+ msgstr "所有孤立的评论元信息已删除!"
54
+
55
+ #: F:\xampp\htdocs\wordpress\wp-content\plugins\wp-clean-up/wp_clean_up_admin.php:152
56
+ msgid "All orphan relationships deleted!"
57
+ msgstr "所有孤立的关系信息已删除!"
58
+
59
+ #: F:\xampp\htdocs\wordpress\wp-content\plugins\wp-clean-up/wp_clean_up_admin.php:157
60
+ msgid "All dashboard transient feed deleted!"
61
+ msgstr "所有控制板订阅缓存已删除!"
62
+
63
+ #: F:\xampp\htdocs\wordpress\wp-content\plugins\wp-clean-up/wp_clean_up_admin.php:171
64
  msgid "All redundant data deleted!"
65
  msgstr "所有冗余数据已删除!"
66
 
67
+ #: F:\xampp\htdocs\wordpress\wp-content\plugins\wp-clean-up/wp_clean_up_admin.php:175
68
  msgid "Database Optimized!"
69
  msgstr "数据库已优化!"
70
 
71
+ #: F:\xampp\htdocs\wordpress\wp-content\plugins\wp-clean-up/wp_clean_up_admin.php:187
72
  msgid "Type"
73
  msgstr "类型"
74
 
75
+ #: F:\xampp\htdocs\wordpress\wp-content\plugins\wp-clean-up/wp_clean_up_admin.php:188
76
  msgid "Count"
77
  msgstr "数量"
78
 
79
+ #: F:\xampp\htdocs\wordpress\wp-content\plugins\wp-clean-up/wp_clean_up_admin.php:189
80
  msgid "Operate"
81
  msgstr "操作"
82
 
83
+ #: F:\xampp\htdocs\wordpress\wp-content\plugins\wp-clean-up/wp_clean_up_admin.php:195
84
  msgid "Revision"
85
  msgstr "修订版本"
86
 
87
+ #: F:\xampp\htdocs\wordpress\wp-content\plugins\wp-clean-up/wp_clean_up_admin.php:203
88
+ #: F:\xampp\htdocs\wordpress\wp-content\plugins\wp-clean-up/wp_clean_up_admin.php:217
89
+ #: F:\xampp\htdocs\wordpress\wp-content\plugins\wp-clean-up/wp_clean_up_admin.php:231
90
+ #: F:\xampp\htdocs\wordpress\wp-content\plugins\wp-clean-up/wp_clean_up_admin.php:245
91
+ #: F:\xampp\htdocs\wordpress\wp-content\plugins\wp-clean-up/wp_clean_up_admin.php:259
92
+ #: F:\xampp\htdocs\wordpress\wp-content\plugins\wp-clean-up/wp_clean_up_admin.php:273
93
+ #: F:\xampp\htdocs\wordpress\wp-content\plugins\wp-clean-up/wp_clean_up_admin.php:287
94
+ #: F:\xampp\htdocs\wordpress\wp-content\plugins\wp-clean-up/wp_clean_up_admin.php:301
95
+ #: F:\xampp\htdocs\wordpress\wp-content\plugins\wp-clean-up/wp_clean_up_admin.php:315
96
+ #: F:\xampp\htdocs\wordpress\wp-content\plugins\wp-clean-up/wp_clean_up_admin.php:329
97
  msgid "Delete"
98
  msgstr "删除"
99
 
100
+ #: F:\xampp\htdocs\wordpress\wp-content\plugins\wp-clean-up/wp_clean_up_admin.php:209
101
  msgid "Draft"
102
  msgstr "草稿"
103
 
104
+ #: F:\xampp\htdocs\wordpress\wp-content\plugins\wp-clean-up/wp_clean_up_admin.php:223
105
  msgid "Auto Draft"
106
  msgstr "自动草稿"
107
 
108
+ #: F:\xampp\htdocs\wordpress\wp-content\plugins\wp-clean-up/wp_clean_up_admin.php:237
109
  msgid "Moderated Comments"
110
  msgstr "待审评论"
111
 
112
+ #: F:\xampp\htdocs\wordpress\wp-content\plugins\wp-clean-up/wp_clean_up_admin.php:251
113
  msgid "Spam Comments"
114
  msgstr "垃圾评论"
115
 
116
+ #: F:\xampp\htdocs\wordpress\wp-content\plugins\wp-clean-up/wp_clean_up_admin.php:265
117
  msgid "Trash Comments"
118
  msgstr "回收站评论"
119
 
120
+ #: F:\xampp\htdocs\wordpress\wp-content\plugins\wp-clean-up/wp_clean_up_admin.php:279
121
+ msgid "Orphan Postmeta"
122
+ msgstr "孤立的文章元信息"
123
+
124
+ #: F:\xampp\htdocs\wordpress\wp-content\plugins\wp-clean-up/wp_clean_up_admin.php:293
125
+ msgid "Orphan Commentmeta"
126
+ msgstr "孤立的评论元信息"
127
+
128
+ #: F:\xampp\htdocs\wordpress\wp-content\plugins\wp-clean-up/wp_clean_up_admin.php:307
129
+ msgid "Orphan Relationships"
130
+ msgstr "孤立的关系信息"
131
+
132
+ #: F:\xampp\htdocs\wordpress\wp-content\plugins\wp-clean-up/wp_clean_up_admin.php:321
133
+ msgid "Dashboard Transient Feed"
134
+ msgstr "控制板订阅缓存"
135
+
136
+ #: F:\xampp\htdocs\wordpress\wp-content\plugins\wp-clean-up/wp_clean_up_admin.php:339
137
  msgid "Delete All"
138
  msgstr "删除所有"
139
 
140
+ #: F:\xampp\htdocs\wordpress\wp-content\plugins\wp-clean-up/wp_clean_up_admin.php:347
141
  msgid "Table"
142
  msgstr "数据表"
143
 
144
+ #: F:\xampp\htdocs\wordpress\wp-content\plugins\wp-clean-up/wp_clean_up_admin.php:348
145
  msgid "Size"
146
  msgstr "大小"
147
 
148
+ #: F:\xampp\htdocs\wordpress\wp-content\plugins\wp-clean-up/wp_clean_up_admin.php:384
149
  msgid "Total"
150
  msgstr "总计"
151
 
152
+ #: F:\xampp\htdocs\wordpress\wp-content\plugins\wp-clean-up/wp_clean_up_admin.php:392
153
  msgid "Optimize"
154
  msgstr "优化数据库"
155
 
readme.txt CHANGED
@@ -1,18 +1,18 @@
1
  === WP Clean Up ===
2
  Contributors: boliquan
3
  Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=SKA6TPPWSATKG&item_name=BoLiQuan&no_shipping=0&no_note=1&tax=0&currency_code=USD&lc=CA&bn=PP%2dDonationsBF&charset=UTF%2d8
4
- Tags: wp clean up,wp cleanup,clean,cleaner,cleanup,database,mysql,comments,posts,post revisions,delete revision,wp cleaner,optimize,optimize database,revision,draft,auto draft,moderated,spam,trash
5
  License: GPLv2
6
  Requires at least: 2.7
7
- Tested up to: 3.4.2
8
- Stable tag: 1.2.0
9
 
10
  WP Clean Up can help us to clean up the wordpress database by removing "revision" "draft" "auto draft" and so on.
11
 
12
 
13
  == Description ==
14
 
15
- WP Clean Up can help us to clean up the wordpress database by removing "revision" "draft" "auto draft" "moderated comments" "spam comments" "trash comments".
16
  It allows you to optimize your WordPress database without phpMyAdmin.
17
  It adds a settings page to "Dashboard"->"Settings"->"WP Clean Up" where you can clean up the wordpress database.
18
  It allows you to remove the redundant data within few clicks.
@@ -49,6 +49,10 @@ Related Links:
49
 
50
  == Changelog ==
51
 
 
 
 
 
52
  = 1.2.0 =
53
 
54
  * It allows you to optimize your WordPress database without phpMyAdmin
1
  === WP Clean Up ===
2
  Contributors: boliquan
3
  Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=SKA6TPPWSATKG&item_name=BoLiQuan&no_shipping=0&no_note=1&tax=0&currency_code=USD&lc=CA&bn=PP%2dDonationsBF&charset=UTF%2d8
4
+ Tags: wp clean up,wp cleanup,clean,cleaner,cleanup,database,mysql,comments,posts,post revisions,delete revision,wp cleaner,optimize,optimize database,revision,draft,auto draft,moderated,spam,trash,postmeta,commentmeta,relationships,transient feed,phpMyAdmin,orphan
5
  License: GPLv2
6
  Requires at least: 2.7
7
+ Tested up to: 3.5
8
+ Stable tag: 1.2.1
9
 
10
  WP Clean Up can help us to clean up the wordpress database by removing "revision" "draft" "auto draft" and so on.
11
 
12
 
13
  == Description ==
14
 
15
+ WP Clean Up can help us to clean up the wordpress database by removing "revision" "draft" "auto draft" "moderated comments" "spam comments" "trash comments" "orphan postmeta" "orphan commentmeta" "orphan relationships" "dashboard transient feed".
16
  It allows you to optimize your WordPress database without phpMyAdmin.
17
  It adds a settings page to "Dashboard"->"Settings"->"WP Clean Up" where you can clean up the wordpress database.
18
  It allows you to remove the redundant data within few clicks.
49
 
50
  == Changelog ==
51
 
52
+ = 1.2.1 =
53
+
54
+ * It allows you to remove "revision" "draft" "auto draft" "moderated comments" "spam comments" "trash comments" "orphan postmeta" "orphan commentmeta" "orphan relationships" "dashboard transient feed"
55
+
56
  = 1.2.0 =
57
 
58
  * It allows you to optimize your WordPress database without phpMyAdmin
screenshot-1.png CHANGED
Binary file
wp-clean-up.php CHANGED
@@ -2,8 +2,8 @@
2
  /*
3
  Plugin Name: WP Clean Up
4
  Plugin URI: http://boliquan.com/wp-clean-up/
5
- Description: WP Clean Up can help us to clean up the wordpress database by removing "revision" "draft" "auto draft" "moderated comments" "spam comments" "trash comments". It allows you to optimize your WordPress database without phpMyAdmin.
6
- Version: 1.2.0
7
  Author: BoLiQuan
8
  Author URI: http://boliquan.com/
9
  Text Domain: WP-Clean-Up
@@ -14,7 +14,7 @@ function load_wp_clean_up_lang(){
14
  $currentLocale = get_locale();
15
  if(!empty($currentLocale)){
16
  $moFile = dirname(__FILE__) . "/lang/wp-clean-up-" . $currentLocale . ".mo";
17
- if(@file_exists($moFile) && is_readable($moFile)) load_textdomain('WP-Clean-Up', $moFile);
18
  }
19
  }
20
  add_filter('init','load_wp_clean_up_lang');
@@ -26,7 +26,7 @@ function wp_clean_up_settings_link($action_links,$plugin_file){
26
  }
27
  return $action_links;
28
  }
29
- add_filter('plugin_action_links','wp_clean_up_settings_link',10,4);
30
 
31
  if(is_admin()){require_once('wp_clean_up_admin.php');}
32
  ?>
2
  /*
3
  Plugin Name: WP Clean Up
4
  Plugin URI: http://boliquan.com/wp-clean-up/
5
+ Description: WP Clean Up can help us to clean up the wordpress database by removing "revision" "draft" "auto draft" "moderated comments" "spam comments" "trash comments" "orphan postmeta" "orphan commentmeta" "orphan relationships" "dashboard transient feed". It allows you to optimize your WordPress database without phpMyAdmin.
6
+ Version: 1.2.1
7
  Author: BoLiQuan
8
  Author URI: http://boliquan.com/
9
  Text Domain: WP-Clean-Up
14
  $currentLocale = get_locale();
15
  if(!empty($currentLocale)){
16
  $moFile = dirname(__FILE__) . "/lang/wp-clean-up-" . $currentLocale . ".mo";
17
+ if(@file_exists($moFile) && is_readable($moFile)) load_textdomain('WP-Clean-Up',$moFile);
18
  }
19
  }
20
  add_filter('init','load_wp_clean_up_lang');
26
  }
27
  return $action_links;
28
  }
29
+ add_filter('plugin_action_links','wp_clean_up_settings_link',10,2);
30
 
31
  if(is_admin()){require_once('wp_clean_up_admin.php');}
32
  ?>
wp_clean_up_admin.php CHANGED
@@ -37,6 +37,23 @@ function wp_clean_up($type){
37
  $wcu_sql = "DELETE FROM $wpdb->comments WHERE comment_approved = 'trash'";
38
  $wpdb->query($wcu_sql);
39
  break;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
40
  }
41
  }
42
 
@@ -67,10 +84,36 @@ function wp_clean_up_count($type){
67
  $wcu_sql = "SELECT COUNT(*) FROM $wpdb->comments WHERE comment_approved = 'trash'";
68
  $count = $wpdb->get_var($wcu_sql);
69
  break;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
70
  }
71
  return $count;
72
  }
73
 
 
 
 
 
 
 
 
 
 
74
  $wcu_message = '';
75
 
76
  if(isset($_POST['wp_clean_up_revision'])){
@@ -103,6 +146,26 @@ function wp_clean_up_count($type){
103
  $wcu_message = __("All trash comments deleted!","WP-Clean-Up");
104
  }
105
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
106
  if(isset($_POST['wp_clean_up_all'])){
107
  wp_clean_up('revision');
108
  wp_clean_up('draft');
@@ -110,10 +173,15 @@ function wp_clean_up_count($type){
110
  wp_clean_up('moderated');
111
  wp_clean_up('spam');
112
  wp_clean_up('trash');
 
 
 
 
113
  $wcu_message = __("All redundant data deleted!","WP-Clean-Up");
114
  }
115
 
116
  if(isset($_POST['wp_clean_up_optimize'])){
 
117
  $wcu_message = __("Database Optimized!","WP-Clean-Up");
118
  }
119
 
@@ -216,6 +284,62 @@ function wp_clean_up_count($type){
216
  </form>
217
  </td>
218
  </tr>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
219
  </tbody>
220
  </table>
221
  </p>
@@ -238,36 +362,31 @@ function wp_clean_up_count($type){
238
  <?php
239
  $total_size = 0;
240
  $alternate = " class='alternate'";
241
- $wcu_sql = 'SHOW TABLE STATUS FROM '.DB_NAME;
242
  $result = mysql_query($wcu_sql);
243
- if(mysql_num_rows($result)){
244
- while($row = mysql_fetch_assoc($result)){
245
- $table_size = $row['Data_length'] + $row['Index_length'];
246
- $table_size = $table_size / 1024;
247
- $table_size = round($table_size,3);
248
 
249
- $every_size = $row['Data_length'] + $row['Index_length'];
250
- $every_size = $every_size / 1024 ;
251
- $total_size += $every_size;
 
 
252
 
253
- if(isset($_POST['wp_clean_up_optimize'])){
254
- $wcu_sql = 'OPTIMIZE TABLE '.$row['Name'];
255
- mysql_query($wcu_sql);
256
- }
257
 
258
- echo "<tr". $alternate .">
259
- <td class='column-name'>". $row['Name'] ."</td>
260
- <td class='column-name'>". $table_size ." KB"."</td>
261
- </tr>\n";
262
- $alternate = (empty($alternate)) ? " class='alternate'" : "";
263
- }
264
  }
265
  ?>
266
  </tbody>
267
  <tfoot>
268
  <tr>
269
  <th scope="col"><?php _e('Total','WP-Clean-Up'); ?></th>
270
- <th scope="col" style="font-family:Tahoma;"><?php echo round($total_size,3).' KB'; ?></th>
271
  </tr>
272
  </tfoot>
273
  </table>
37
  $wcu_sql = "DELETE FROM $wpdb->comments WHERE comment_approved = 'trash'";
38
  $wpdb->query($wcu_sql);
39
  break;
40
+ case "postmeta":
41
+ $wcu_sql = "DELETE pm FROM $wpdb->postmeta pm LEFT JOIN $wpdb->posts wp ON wp.ID = pm.post_id WHERE wp.ID IS NULL";
42
+ //$wcu_sql = "DELETE FROM $wpdb->postmeta WHERE NOT EXISTS ( SELECT * FROM $wpdb->posts WHERE $wpdb->postmeta.post_id = $wpdb->posts.ID )";
43
+ $wpdb->query($wcu_sql);
44
+ break;
45
+ case "commentmeta":
46
+ $wcu_sql = "DELETE FROM $wpdb->commentmeta WHERE comment_id NOT IN (SELECT comment_id FROM $wpdb->comments)";
47
+ $wpdb->query($wcu_sql);
48
+ break;
49
+ case "relationships":
50
+ $wcu_sql = "DELETE FROM $wpdb->term_relationships WHERE term_taxonomy_id=1 AND object_id NOT IN (SELECT id FROM $wpdb->posts)";
51
+ $wpdb->query($wcu_sql);
52
+ break;
53
+ case "feed":
54
+ $wcu_sql = "DELETE FROM $wpdb->options WHERE option_name LIKE '_site_transient_browser_%' OR option_name LIKE '_site_transient_timeout_browser_%' OR option_name LIKE '_transient_feed_%' OR option_name LIKE '_transient_timeout_feed_%'";
55
+ $wpdb->query($wcu_sql);
56
+ break;
57
  }
58
  }
59
 
84
  $wcu_sql = "SELECT COUNT(*) FROM $wpdb->comments WHERE comment_approved = 'trash'";
85
  $count = $wpdb->get_var($wcu_sql);
86
  break;
87
+ case "postmeta":
88
+ $wcu_sql = "SELECT COUNT(*) FROM $wpdb->postmeta pm LEFT JOIN $wpdb->posts wp ON wp.ID = pm.post_id WHERE wp.ID IS NULL";
89
+ //$wcu_sql = "SELECT COUNT(*) FROM $wpdb->postmeta WHERE NOT EXISTS ( SELECT * FROM $wpdb->posts WHERE $wpdb->postmeta.post_id = $wpdb->posts.ID )";
90
+ $count = $wpdb->get_var($wcu_sql);
91
+ break;
92
+ case "commentmeta":
93
+ $wcu_sql = "SELECT COUNT(*) FROM $wpdb->commentmeta WHERE comment_id NOT IN (SELECT comment_id FROM $wpdb->comments)";
94
+ $count = $wpdb->get_var($wcu_sql);
95
+ break;
96
+ case "relationships":
97
+ $wcu_sql = "SELECT COUNT(*) FROM $wpdb->term_relationships WHERE term_taxonomy_id=1 AND object_id NOT IN (SELECT id FROM $wpdb->posts)";
98
+ $count = $wpdb->get_var($wcu_sql);
99
+ break;
100
+ case "feed":
101
+ $wcu_sql = "SELECT COUNT(*) FROM $wpdb->options WHERE option_name LIKE '_site_transient_browser_%' OR option_name LIKE '_site_transient_timeout_browser_%' OR option_name LIKE '_transient_feed_%' OR option_name LIKE '_transient_timeout_feed_%'";
102
+ $count = $wpdb->get_var($wcu_sql);
103
+ break;
104
  }
105
  return $count;
106
  }
107
 
108
+ function wp_clean_up_optimize(){
109
+ $wcu_sql = 'SHOW TABLE STATUS FROM `'.DB_NAME.'`';
110
+ $result = mysql_query($wcu_sql);
111
+ while($row = mysql_fetch_assoc($result)){
112
+ $wcu_sql = 'OPTIMIZE TABLE '.$row['Name'];
113
+ mysql_query($wcu_sql);
114
+ }
115
+ }
116
+
117
  $wcu_message = '';
118
 
119
  if(isset($_POST['wp_clean_up_revision'])){
146
  $wcu_message = __("All trash comments deleted!","WP-Clean-Up");
147
  }
148
 
149
+ if(isset($_POST['wp_clean_up_postmeta'])){
150
+ wp_clean_up('postmeta');
151
+ $wcu_message = __("All orphan postmeta deleted!","WP-Clean-Up");
152
+ }
153
+
154
+ if(isset($_POST['wp_clean_up_commentmeta'])){
155
+ wp_clean_up('commentmeta');
156
+ $wcu_message = __("All orphan commentmeta deleted!","WP-Clean-Up");
157
+ }
158
+
159
+ if(isset($_POST['wp_clean_up_relationships'])){
160
+ wp_clean_up('relationships');
161
+ $wcu_message = __("All orphan relationships deleted!","WP-Clean-Up");
162
+ }
163
+
164
+ if(isset($_POST['wp_clean_up_feed'])){
165
+ wp_clean_up('feed');
166
+ $wcu_message = __("All dashboard transient feed deleted!","WP-Clean-Up");
167
+ }
168
+
169
  if(isset($_POST['wp_clean_up_all'])){
170
  wp_clean_up('revision');
171
  wp_clean_up('draft');
173
  wp_clean_up('moderated');
174
  wp_clean_up('spam');
175
  wp_clean_up('trash');
176
+ wp_clean_up('postmeta');
177
+ wp_clean_up('commentmeta');
178
+ wp_clean_up('relationships');
179
+ wp_clean_up('feed');
180
  $wcu_message = __("All redundant data deleted!","WP-Clean-Up");
181
  }
182
 
183
  if(isset($_POST['wp_clean_up_optimize'])){
184
+ wp_clean_up_optimize();
185
  $wcu_message = __("Database Optimized!","WP-Clean-Up");
186
  }
187
 
284
  </form>
285
  </td>
286
  </tr>
287
+ <tr class="alternate">
288
+ <td class="column-name">
289
+ <?php _e('Orphan Postmeta','WP-Clean-Up'); ?>
290
+ </td>
291
+ <td class="column-name">
292
+ <?php echo wp_clean_up_count('postmeta'); ?>
293
+ </td>
294
+ <td class="column-name">
295
+ <form action="" method="post">
296
+ <input type="hidden" name="wp_clean_up_postmeta" value="postmeta" />
297
+ <input type="submit" class="<?php if(wp_clean_up_count('postmeta')>0){echo 'button-primary';}else{echo 'button';} ?>" value="<?php _e('Delete','WP-Clean-Up'); ?>" />
298
+ </form>
299
+ </td>
300
+ </tr>
301
+ <tr>
302
+ <td class="column-name">
303
+ <?php _e('Orphan Commentmeta','WP-Clean-Up'); ?>
304
+ </td>
305
+ <td class="column-name">
306
+ <?php echo wp_clean_up_count('commentmeta'); ?>
307
+ </td>
308
+ <td class="column-name">
309
+ <form action="" method="post">
310
+ <input type="hidden" name="wp_clean_up_commentmeta" value="commentmeta" />
311
+ <input type="submit" class="<?php if(wp_clean_up_count('commentmeta')>0){echo 'button-primary';}else{echo 'button';} ?>" value="<?php _e('Delete','WP-Clean-Up'); ?>" />
312
+ </form>
313
+ </td>
314
+ </tr>
315
+ <tr class="alternate">
316
+ <td class="column-name">
317
+ <?php _e('Orphan Relationships','WP-Clean-Up'); ?>
318
+ </td>
319
+ <td class="column-name">
320
+ <?php echo wp_clean_up_count('relationships'); ?>
321
+ </td>
322
+ <td class="column-name">
323
+ <form action="" method="post">
324
+ <input type="hidden" name="wp_clean_up_relationships" value="relationships" />
325
+ <input type="submit" class="<?php if(wp_clean_up_count('relationships')>0){echo 'button-primary';}else{echo 'button';} ?>" value="<?php _e('Delete','WP-Clean-Up'); ?>" />
326
+ </form>
327
+ </td>
328
+ </tr>
329
+ <tr>
330
+ <td class="column-name">
331
+ <?php _e('Dashboard Transient Feed','WP-Clean-Up'); ?>
332
+ </td>
333
+ <td class="column-name">
334
+ <?php echo wp_clean_up_count('feed'); ?>
335
+ </td>
336
+ <td class="column-name">
337
+ <form action="" method="post">
338
+ <input type="hidden" name="wp_clean_up_feed" value="feed" />
339
+ <input type="submit" class="<?php if(wp_clean_up_count('feed')>0){echo 'button-primary';}else{echo 'button';} ?>" value="<?php _e('Delete','WP-Clean-Up'); ?>" />
340
+ </form>
341
+ </td>
342
+ </tr>
343
  </tbody>
344
  </table>
345
  </p>
362
  <?php
363
  $total_size = 0;
364
  $alternate = " class='alternate'";
365
+ $wcu_sql = 'SHOW TABLE STATUS FROM `'.DB_NAME.'`';
366
  $result = mysql_query($wcu_sql);
 
 
 
 
 
367
 
368
+ while($row = mysql_fetch_assoc($result)){
369
+
370
+ $table_size = $row['Data_length'] + $row['Index_length'];
371
+ $table_size = $table_size / 1024;
372
+ $table_size = sprintf("%0.3f",$table_size);
373
 
374
+ $every_size = $row['Data_length'] + $row['Index_length'];
375
+ $every_size = $every_size / 1024;
376
+ $total_size += $every_size;
 
377
 
378
+ echo "<tr". $alternate .">
379
+ <td class='column-name'>". $row['Name'] ."</td>
380
+ <td class='column-name'>". $table_size ." KB"."</td>
381
+ </tr>\n";
382
+ $alternate = (empty($alternate)) ? " class='alternate'" : "";
 
383
  }
384
  ?>
385
  </tbody>
386
  <tfoot>
387
  <tr>
388
  <th scope="col"><?php _e('Total','WP-Clean-Up'); ?></th>
389
+ <th scope="col" style="font-family:Tahoma;"><?php echo sprintf("%0.3f",$total_size).' KB'; ?></th>
390
  </tr>
391
  </tfoot>
392
  </table>