Advanced Database Cleaner - Version 1.3.7

Version Description

  • Adding "clean trash-posts"
  • Updating FAQ
  • Updating readme file
  • Tested up to: 4.4
Download this release

Release Info

Developer symptote
Plugin Icon 128x128 Advanced Database Cleaner
Version 1.3.7
Comparing to
See all releases

Code changes from version 1.3.6 to 1.3.7

README.txt CHANGED
@@ -1,35 +1,37 @@
1
  === Advanced Database Cleaner ===
2
  Contributors: symptote
3
  Donate Link: http://www.sigmaplugin.com/donation
4
- Tags: plugin, plugins, plugin wordpress, wordpress, database cleaner, clean database, database clean, database, clean, clean-up, clean up, cleanup, cleaner, delete orphan data, orphan data, delete revisions, delete revision, revision, delete draft, draft, delete trash, trash, delete spam, spam, delete auto draft, auto draft, delete postmeta, postmeta, delete commentmeta, commentmeta, delete relationships, relationships, delete transient feed, transient feed, optimize database, database optimize, database optimizer, optimize, optimizer, reset database, database reset, reset, admin, widget, schedule, scheduler, schedule clean-up, schedule optimize, multisite, multi-site, network, cron, cron job, clean cron, clean scheduled tasks, view cron, view cron job, view scheduled tasks
5
  Requires at least: 3.0.0
6
- Tested up to: 4.3
7
- Stable tag: 1.3.6
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
11
- Clean up your database by deleting unused data such as 'revision', optimize your database, or reset it to its initial state, etc.
12
 
13
  == Description ==
14
 
15
- Advanced Database Cleaner is a must-have plugin that cleans and optimizes your WP database.
 
 
16
 
17
  = Main Features =
18
- * Removes unused data such as "revision", "draft", "auto draft", "moderated comments", "spam comments", "trash comments", "orphan postmeta", "orphan commentmeta", "orphan relationships", "dashboard transient feed" [optional]
19
- * Optimizes your Wordpress database. This will help you reducing storage space and improving efficiency when accessing your tables [optional]
20
- * Resets your database back to its original state. This will help you making a fresh installation and skip the "5 minutes wordpress installation steps" [optional]
21
- * Allows you choose what data should be cleaned and what data should not [optional]
22
- * Schedules the clean-up to run automatically hourly, twice a day, daily, weekly or monthly [optional]
23
- * Schedules the optimization of database to run automatically hourly, twice a day, daily, weekly or monthly [optional]
24
- * View and clean cron (scheduled tasks) [optional]
25
  * Supports multisite installation
26
 
27
  = Multisite Support =
28
  * The plugin supports multisite wordpress installations
29
- * You can 'Network Activate' the plugin or activate it in each site separately
30
  * The main site can clean and optimize all tables for all sites in the network
31
- * Other sites in the network can only clean and optimize their own tables in the database
32
- * The reset of the database can be executed from the main site only (we believe that your database is precious)
33
 
34
  == Installation ==
35
 
@@ -56,6 +58,12 @@ This section describes how to install the plugin and get it working.
56
 
57
  == Changelog ==
58
 
 
 
 
 
 
 
59
  = 1.3.6 =
60
  * Fixing a problem in donate button
61
  * Using _e() and __() for all texts in the plugin
@@ -115,9 +123,6 @@ Optimizing your database will reclaim unused space in your tables, which will re
115
  = Is it safe to clean the cron (scheduled tasks)? =
116
  A scheduled task enables plugins to execute some actions at specified times, without having to manually execute code at that time. Wordpress itself uses some scheduled tasks to perform some regular actions. However, some scheduled tasks may not be removed even if the responsible plugins are deleted from your wordpress installation. As you know, not all plugins care about the housekeeping of your wordpress. Hence, deleting these unnecessary tasks may help in cleaning your site. It should be noted that cleaning scheduled tasks is safe as long as you know what tasks to clean. If your are not sure, it is better to not clean any task.
117
 
118
- = Is this plugin compatible with multisite? =
119
- Yes, it is compatible with multisite.
120
-
121
  = What does mean "Revision"? What sql code is used to clean it? =
122
  WordPress stores a record (called "revision") of each saved draft or published update. This system allows you to see what changes were made in each post and page over time. However, this can lead to a lot of unnecessary overhead in your WordPress database, which consumes a lot of space. The sql query used by the plugin to clean all revisions is:
123
  `DELETE FROM posts WHERE post_type = 'revision'`
@@ -158,5 +163,11 @@ Sometimes the wp_term_relationships table becomes bloated with many orphaned rel
158
  Transient are a way for storing cached data temporarily in your database by given it a name and a timeframe after which it will expire and be deleted. The sql query used by the plugin to clean dashboard transient feed is:
159
  `DELETE FROM 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_%'`
160
 
 
 
 
 
 
 
161
  = Does this plugin cleans itself after the uninstall? =
162
  Yes, the plugin cleans itself and removes any data used to store its settings.
1
  === Advanced Database Cleaner ===
2
  Contributors: symptote
3
  Donate Link: http://www.sigmaplugin.com/donation
4
+ Tags: plugin, plugin wordpress, database cleaner, clean database, database clean, database, clean, clean-up, clean up, cleanup, cleaner, delete orphan data, orphan data, delete revisions, delete revision, revision, delete draft, draft, delete trash, delete trash posts, trash post, trash, delete spam, spam, delete auto draft, auto draft, delete postmeta, postmeta, delete commentmeta, commentmeta, delete relationships, relationships, delete transient feed, transient feed, optimize database, database optimize, database optimizer, optimize, optimizer, reset database, database reset, reset, admin, widget, schedule, scheduler, schedule clean-up, schedule optimize, multisite, multi-site, network, cron, cron job, clean cron, clean scheduled tasks, view cron, view cron job, view scheduled tasks
5
  Requires at least: 3.0.0
6
+ Tested up to: 4.4
7
+ Stable tag: 1.3.7
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
11
+ Clean up your database by deleting unused data such as revisions, optimize your database, or reset it to its initial state, etc.
12
 
13
  == Description ==
14
 
15
+ If you have been using WordPress for a while, then you should think absolutely about a clean up. Indeed, your database may be full of garbage that make your site sluggish and bloated, such as: revisions, drafts, spam comments, etc. You should clean this unnecessary data to reduce the size of your database and improve efficiency when accessing tables. In addition, your backup files will be quicker and smaller.
16
+
17
+ 'Advanced Database Cleaner' is a must-have plugin that cleans and optimizes your WordPress database.
18
 
19
  = Main Features =
20
+ * Removes unused data such as "revision", "draft", "auto draft", "trash posts", "moderated comments", "spam comments", "trash comments", "orphan postmeta", "orphan commentmeta", "orphan relationships", "dashboard transient feed"
21
+ * Optimizes the database and improves its efficiency
22
+ * View and clean cron (scheduled tasks)
23
+ * Resets your database back to its original state
24
+ * Allows you choose what data should be cleaned
25
+ * Schedules the clean-up of database to run automatically
26
+ * Schedules the optimization of database to run automatically
27
  * Supports multisite installation
28
 
29
  = Multisite Support =
30
  * The plugin supports multisite wordpress installations
31
+ * 'Network Activate' the plugin or activate it in each site separately
32
  * The main site can clean and optimize all tables for all sites in the network
33
+ * Other sites in the network can only clean and optimize their own tables
34
+ * The reset of the database can be executed from the main site only
35
 
36
  == Installation ==
37
 
58
 
59
  == Changelog ==
60
 
61
+ = 1.3.7 =
62
+ * Adding "clean trash-posts"
63
+ * Updating FAQ
64
+ * Updating readme file
65
+ * Tested up to: 4.4
66
+
67
  = 1.3.6 =
68
  * Fixing a problem in donate button
69
  * Using _e() and __() for all texts in the plugin
123
  = Is it safe to clean the cron (scheduled tasks)? =
124
  A scheduled task enables plugins to execute some actions at specified times, without having to manually execute code at that time. Wordpress itself uses some scheduled tasks to perform some regular actions. However, some scheduled tasks may not be removed even if the responsible plugins are deleted from your wordpress installation. As you know, not all plugins care about the housekeeping of your wordpress. Hence, deleting these unnecessary tasks may help in cleaning your site. It should be noted that cleaning scheduled tasks is safe as long as you know what tasks to clean. If your are not sure, it is better to not clean any task.
125
 
 
 
 
126
  = What does mean "Revision"? What sql code is used to clean it? =
127
  WordPress stores a record (called "revision") of each saved draft or published update. This system allows you to see what changes were made in each post and page over time. However, this can lead to a lot of unnecessary overhead in your WordPress database, which consumes a lot of space. The sql query used by the plugin to clean all revisions is:
128
  `DELETE FROM posts WHERE post_type = 'revision'`
163
  Transient are a way for storing cached data temporarily in your database by given it a name and a timeframe after which it will expire and be deleted. The sql query used by the plugin to clean dashboard transient feed is:
164
  `DELETE FROM 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_%'`
165
 
166
+ = Is this plugin compatible with multisite? =
167
+ Yes, it is compatible with multisite.
168
+
169
+ = Is this plugin compatible with SharDB, HyperDB or Multi-DB? =
170
+ Actually the plugin is not supposed to be compatible with SharDB, HyperDB or Multi-DB. We will try to make it compatible in coming releases.
171
+
172
  = Does this plugin cleans itself after the uninstall? =
173
  Yes, the plugin cleans itself and removes any data used to store its settings.
advanced-db-cleaner.php CHANGED
@@ -3,26 +3,22 @@ defined( 'ABSPATH' ) or die( 'No direct access allowed' );
3
 
4
  /*
5
  Plugin Name: Advanced Database Cleaner
6
- Description: Clean up your database by deleting unused data such as 'revision', optimize your database, or reset it to its initial state, etc.
7
- Version: 1.3.6
8
  Author: Younes JFR.
9
  Contributors: symptote
10
  Text Domain: advanced-db-cleaner
11
- Domain Path: /languages/
12
  License: GPLv2 or later
13
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
14
  */
15
 
16
- /********************************************************************
17
- * Define common variables
18
- ********************************************************************/
19
- if (!defined("ADB_CLEANER_PLUGIN_VERSION")) define("ADB_CLEANER_PLUGIN_VERSION", "1.3.6");
20
  if (!defined("ADB_CLEANER_PLUGIN_BASENAME")) define("ADB_CLEANER_PLUGIN_BASENAME", plugin_basename(__FILE__));
21
  if (!defined("ADB_CLEANER_PLUGIN_DIR")) define("ADB_CLEANER_PLUGIN_DIR", plugins_url() .'/'. dirname(plugin_basename(__FILE__)));
22
 
23
- /********************************************************************
24
- * Add 'settings' link under the plugin name in plugins page
25
- ********************************************************************/
26
  add_filter('plugin_action_links_' . ADB_CLEANER_PLUGIN_BASENAME, 'db_cleaner_add_action_links');
27
  function db_cleaner_add_action_links($links){
28
  $adc_settings_link = '<a href = "options-general.php?page=' . ADB_CLEANER_PLUGIN_BASENAME . '">' . __('Settings', 'advanced-db-cleaner') . '</a>';
@@ -30,26 +26,20 @@ function db_cleaner_add_action_links($links){
30
  return $links;
31
  }
32
 
33
- /********************************************************************
34
- * Add 'Database Cleaner' to Wordpress settings menu
35
- ********************************************************************/
36
  add_action('admin_menu', 'adv_db_cleaner_add_admin_menu');
37
  function adv_db_cleaner_add_admin_menu() {
38
  $hook_adv_db_cleaner = add_options_page('Advanced DB Cleaner Options', 'Database Cleaner','manage_options', __FILE__, 'adv_db_cleaner_page');
39
  add_action('admin_print_styles-' . $hook_adv_db_cleaner, 'adv_db_cleaner_enqueue_styles');
40
  }
41
 
42
- /********************************************************************
43
- * Register stylesheet
44
- ********************************************************************/
45
  add_action('admin_init', 'adv_db_cleaner_register_styles' );
46
  function adv_db_cleaner_register_styles() {
47
  wp_register_style('adv_db_cleaner_css', ADB_CLEANER_PLUGIN_DIR . '/css/style.css');
48
  }
49
 
50
- /********************************************************************
51
- * Enqueue stylesheet
52
- ********************************************************************/
53
  function adv_db_cleaner_enqueue_styles() {
54
  wp_enqueue_style( 'adv_db_cleaner_css' );
55
  }
@@ -73,9 +63,7 @@ function aDBc_additional_schedules($schedules){
73
  return $schedules;
74
  }
75
 
76
- /********************************************************************
77
- * (RE)-schedule tasks after (RE)-activation or update of the plugin
78
- ********************************************************************/
79
  register_activation_hook(__FILE__, 'aDBc_activate_plugin');
80
  add_action('aDBc_optimize_scheduler', 'adv_db_cleaner_optimize');
81
  add_action('aDBc_clean_scheduler', 'aDBc_cleanAll');
@@ -107,13 +95,11 @@ function aDBc_activate_plugin($network_wide){
107
  if($aDBc_clean_schedule && $aDBc_clean_schedule != 'no_schedule'){
108
  if(!wp_next_scheduled('aDBc_clean_scheduler'))
109
  wp_schedule_event(time()+60, $aDBc_clean_schedule, 'aDBc_clean_scheduler');
110
- }
111
  }
112
  }
113
 
114
- /********************************************************************
115
- * Clear current scheduled tasks (if any) when deactivated
116
- ********************************************************************/
117
  register_deactivation_hook(__FILE__, 'aDBc_deactivate_plugin' );
118
  function aDBc_deactivate_plugin($network_wide){
119
  global $wpdb;
@@ -131,9 +117,7 @@ function aDBc_deactivate_plugin($network_wide){
131
  }
132
  }
133
 
134
- /********************************************************************
135
- * Clear scheduled tasks + options if UNINSTALL
136
- ********************************************************************/
137
  register_uninstall_hook(__FILE__, 'aDBc_uninstall');
138
  function aDBc_uninstall(){
139
  global $wpdb;
@@ -155,9 +139,7 @@ function aDBc_uninstall(){
155
  }
156
  }
157
 
158
- /********************************************************************
159
- * The admin page content
160
- ********************************************************************/
161
  function adv_db_cleaner_page(){
162
  ?>
163
  <div class="wrap">
@@ -225,10 +207,10 @@ function adv_db_cleaner_page(){
225
  <div class="tabBox">
226
  <?php
227
  $aDBc_tab_list = array(
228
- array("id"=>"aDBc-clean", "title"=>__('Clean Database', 'advanced-db-cleaner')),
229
- array("id"=>"aDBc-optimize", "title"=>__('Optimize Database', 'advanced-db-cleaner')),
230
- array("id"=>"aDBc-cron", "title"=>__('Clean Cron', 'advanced-db-cleaner')),
231
- array("id"=>"aDBc-reset", "title"=>__('Reset Database', 'advanced-db-cleaner'))
232
  );
233
  foreach ($aDBc_tab_list as $key => $value){
234
  $checked = "";
@@ -236,7 +218,8 @@ function adv_db_cleaner_page(){
236
  || (isset($_POST["aDBc_optimize_form"]) && $value["id"] == "aDBc-optimize")
237
  || (isset($_POST["aDBc_optimize_schedule_form"]) && $value["id"] == "aDBc-optimize")
238
  || (isset($_POST["aDBc_clean_cron_form"]) && $value["id"] == "aDBc-cron")
239
- || (isset($_POST["aDBc_reset_form"]) && $value["id"] == "aDBc-reset")){
 
240
  $checked = 'checked = "checked"';
241
  }
242
  echo '<input '.$checked.' type="radio" id="'.$value["id"].'" name="tabGroup1">'."\n";
@@ -251,7 +234,7 @@ function adv_db_cleaner_page(){
251
  </div>
252
  <div class="tab3">
253
  <?php include_once 'includes/clean-cron.php'; ?>
254
- </div>
255
  <div class="tab4">
256
  <?php
257
  if(is_main_site()){
@@ -262,19 +245,16 @@ function adv_db_cleaner_page(){
262
  echo "</div>";
263
  }
264
  ?>
265
- </div>
266
  </div>
267
  <div class="aDBcSidebar">
268
  <?php include_once 'includes/sidebar.php'; ?>
269
  </div>
270
  </div>
271
  </div>
272
- <?php
273
  }
274
- /***************************************************************
275
- *
276
- * Get functions
277
- *
278
- ***************************************************************/
279
  include_once 'includes/functions.php';
280
  ?>
3
 
4
  /*
5
  Plugin Name: Advanced Database Cleaner
6
+ Description: Clean up your database by deleting unused data such as revisions, optimize your database, or reset it to its initial state, etc.
7
+ Version: 1.3.7
8
  Author: Younes JFR.
9
  Contributors: symptote
10
  Text Domain: advanced-db-cleaner
11
+ Domain Path: /languages
12
  License: GPLv2 or later
13
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
14
  */
15
 
16
+ /** Define common variables */
17
+ if (!defined("ADB_CLEANER_PLUGIN_VERSION")) define("ADB_CLEANER_PLUGIN_VERSION", "1.3.7");
 
 
18
  if (!defined("ADB_CLEANER_PLUGIN_BASENAME")) define("ADB_CLEANER_PLUGIN_BASENAME", plugin_basename(__FILE__));
19
  if (!defined("ADB_CLEANER_PLUGIN_DIR")) define("ADB_CLEANER_PLUGIN_DIR", plugins_url() .'/'. dirname(plugin_basename(__FILE__)));
20
 
21
+ /** Add 'settings' link under the plugin name in plugins page */
 
 
22
  add_filter('plugin_action_links_' . ADB_CLEANER_PLUGIN_BASENAME, 'db_cleaner_add_action_links');
23
  function db_cleaner_add_action_links($links){
24
  $adc_settings_link = '<a href = "options-general.php?page=' . ADB_CLEANER_PLUGIN_BASENAME . '">' . __('Settings', 'advanced-db-cleaner') . '</a>';
26
  return $links;
27
  }
28
 
29
+ /** Add 'Database Cleaner' to Wordpress settings menu */
 
 
30
  add_action('admin_menu', 'adv_db_cleaner_add_admin_menu');
31
  function adv_db_cleaner_add_admin_menu() {
32
  $hook_adv_db_cleaner = add_options_page('Advanced DB Cleaner Options', 'Database Cleaner','manage_options', __FILE__, 'adv_db_cleaner_page');
33
  add_action('admin_print_styles-' . $hook_adv_db_cleaner, 'adv_db_cleaner_enqueue_styles');
34
  }
35
 
36
+ /** Register stylesheet */
 
 
37
  add_action('admin_init', 'adv_db_cleaner_register_styles' );
38
  function adv_db_cleaner_register_styles() {
39
  wp_register_style('adv_db_cleaner_css', ADB_CLEANER_PLUGIN_DIR . '/css/style.css');
40
  }
41
 
42
+ /** Enqueue stylesheet */
 
 
43
  function adv_db_cleaner_enqueue_styles() {
44
  wp_enqueue_style( 'adv_db_cleaner_css' );
45
  }
63
  return $schedules;
64
  }
65
 
66
+ /** (RE)-schedule tasks after (RE)-activation or update of the plugin */
 
 
67
  register_activation_hook(__FILE__, 'aDBc_activate_plugin');
68
  add_action('aDBc_optimize_scheduler', 'adv_db_cleaner_optimize');
69
  add_action('aDBc_clean_scheduler', 'aDBc_cleanAll');
95
  if($aDBc_clean_schedule && $aDBc_clean_schedule != 'no_schedule'){
96
  if(!wp_next_scheduled('aDBc_clean_scheduler'))
97
  wp_schedule_event(time()+60, $aDBc_clean_schedule, 'aDBc_clean_scheduler');
98
+ }
99
  }
100
  }
101
 
102
+ /** Clear current scheduled tasks (if any) when deactivated */
 
 
103
  register_deactivation_hook(__FILE__, 'aDBc_deactivate_plugin' );
104
  function aDBc_deactivate_plugin($network_wide){
105
  global $wpdb;
117
  }
118
  }
119
 
120
+ /** Clear scheduled tasks + options if UNINSTALL */
 
 
121
  register_uninstall_hook(__FILE__, 'aDBc_uninstall');
122
  function aDBc_uninstall(){
123
  global $wpdb;
139
  }
140
  }
141
 
142
+ /** The admin page content */
 
 
143
  function adv_db_cleaner_page(){
144
  ?>
145
  <div class="wrap">
207
  <div class="tabBox">
208
  <?php
209
  $aDBc_tab_list = array(
210
+ array("id"=>"aDBc-clean", "title"=>__('Clean Database', 'advanced-db-cleaner')),
211
+ array("id"=>"aDBc-optimize","title"=>__('Optimize Database', 'advanced-db-cleaner')),
212
+ array("id"=>"aDBc-cron", "title"=>__('Clean Cron', 'advanced-db-cleaner')),
213
+ array("id"=>"aDBc-reset", "title"=>__('Reset Database', 'advanced-db-cleaner'))
214
  );
215
  foreach ($aDBc_tab_list as $key => $value){
216
  $checked = "";
218
  || (isset($_POST["aDBc_optimize_form"]) && $value["id"] == "aDBc-optimize")
219
  || (isset($_POST["aDBc_optimize_schedule_form"]) && $value["id"] == "aDBc-optimize")
220
  || (isset($_POST["aDBc_clean_cron_form"]) && $value["id"] == "aDBc-cron")
221
+ || (isset($_POST["aDBc_reset_form"]) && $value["id"] == "aDBc-reset")
222
+ ){
223
  $checked = 'checked = "checked"';
224
  }
225
  echo '<input '.$checked.' type="radio" id="'.$value["id"].'" name="tabGroup1">'."\n";
234
  </div>
235
  <div class="tab3">
236
  <?php include_once 'includes/clean-cron.php'; ?>
237
+ </div>
238
  <div class="tab4">
239
  <?php
240
  if(is_main_site()){
245
  echo "</div>";
246
  }
247
  ?>
248
+ </div>
249
  </div>
250
  <div class="aDBcSidebar">
251
  <?php include_once 'includes/sidebar.php'; ?>
252
  </div>
253
  </div>
254
  </div>
255
+ <?php
256
  }
257
+
258
+ /** Get functions */
 
 
 
259
  include_once 'includes/functions.php';
260
  ?>
css/style.css CHANGED
@@ -4,11 +4,19 @@
4
  .marginRight300 {
5
  margin-right: 300px;
6
  }
7
-
8
  .marginTop20 {
9
  margin-top: 20px;
10
  }
11
-
 
 
 
 
 
 
 
 
 
12
  /* ---------------------*/
13
  /* ----- Tabs style ----*/
14
  /* ---------------------*/
@@ -58,26 +66,19 @@
58
  display: block;
59
  min-height: 400px;
60
  }
61
-
62
  /* ---------------------------------*/
63
  /* ----- "Clean DB" tabs styles ----*/
64
  /* ---------------------------------*/
65
-
66
-
67
  /* Style for count numbers */
68
  .aDBcCount {
69
  text-align: right !important;
70
  color: #666 !important;
71
  }
72
-
73
-
74
-
75
-
76
  /* Style for check box */
77
  input[type=checkbox] {
78
  visibility: hidden;
79
  }
80
- /* SQUARED FOUR */
81
  .squaredFour {
82
  position: relative;
83
  text-align: center;
@@ -122,8 +123,9 @@ input[type=checkbox] {
122
  filter: alpha(opacity=100);
123
  opacity: 1;
124
  }
125
-
126
- /* Style for sidebar */
 
127
  .aDBcSidebar {
128
  float:right;
129
  border: 1px solid #ccc;
@@ -141,8 +143,12 @@ input[type=checkbox] {
141
  .aDBcSidebar h2{
142
  font-size:20px;
143
  }
144
-
145
- /* Box warning */
 
 
 
 
146
  .box-warning {
147
  border-radius: 5px;
148
  -moz-border-radius: 5px;
@@ -153,7 +159,6 @@ input[type=checkbox] {
153
  padding: 10px 10px 10px 50px;
154
  margin-top: 20px;
155
  }
156
- /* Info box */
157
  .box-info {
158
  border-radius: 5px;
159
  -moz-border-radius: 5px;
@@ -164,8 +169,6 @@ input[type=checkbox] {
164
  padding: 10px 10px 10px 60px;
165
  margin-top: 20px;
166
  }
167
-
168
- /* Top info box */
169
  .aDBC-topBoxInfo {
170
  clear:both;
171
  border-radius: 5px;
@@ -177,8 +180,6 @@ input[type=checkbox] {
177
  padding: 10px 10px 10px 40px;
178
  max-width: 730px;
179
  }
180
-
181
- /* boxes in tab to inform users about the current option */
182
  .aDBCRightBox{
183
  padding:20px 0px 20px 0px;
184
  margin-bottom:5px;
@@ -188,24 +189,9 @@ input[type=checkbox] {
188
  text-align:justify;
189
  color: #888;
190
  }
191
-
192
- /* For Data already cleaned */
193
- .already-cleaned{
194
- float: left;
195
- background:#f4f4f4;
196
- padding:2px 6px 2px 6px;
197
- border-radius: 8px;
198
- color: #999;
199
- margin: 2px;
200
- font-size: 11px;
201
- }
202
-
203
- /* Support us like image */
204
- .aDBC-supportUs{
205
- background: url("../images/rate.png") no-repeat center right;
206
- }
207
-
208
- /* Tooltip */
209
  a.tooltips {
210
  position: relative;
211
  display: inline;
4
  .marginRight300 {
5
  margin-right: 300px;
6
  }
 
7
  .marginTop20 {
8
  margin-top: 20px;
9
  }
10
+ /* For Data already cleaned */
11
+ .already-cleaned{
12
+ float: left;
13
+ background:#f4f4f4;
14
+ padding:2px 6px 2px 6px;
15
+ border-radius: 8px;
16
+ color: #999;
17
+ margin: 2px;
18
+ font-size: 11px;
19
+ }
20
  /* ---------------------*/
21
  /* ----- Tabs style ----*/
22
  /* ---------------------*/
66
  display: block;
67
  min-height: 400px;
68
  }
 
69
  /* ---------------------------------*/
70
  /* ----- "Clean DB" tabs styles ----*/
71
  /* ---------------------------------*/
 
 
72
  /* Style for count numbers */
73
  .aDBcCount {
74
  text-align: right !important;
75
  color: #666 !important;
76
  }
 
 
 
 
77
  /* Style for check box */
78
  input[type=checkbox] {
79
  visibility: hidden;
80
  }
81
+ /* Checkbox style */
82
  .squaredFour {
83
  position: relative;
84
  text-align: center;
123
  filter: alpha(opacity=100);
124
  opacity: 1;
125
  }
126
+ /* ---------------------------------*/
127
+ /* ------------ Sidebar ------------*/
128
+ /* ---------------------------------*/
129
  .aDBcSidebar {
130
  float:right;
131
  border: 1px solid #ccc;
143
  .aDBcSidebar h2{
144
  font-size:20px;
145
  }
146
+ .aDBC-supportUs{
147
+ background: url("../images/rate.png") no-repeat center right;
148
+ }
149
+ /* ---------------------------------*/
150
+ /* ------------- Boxes -------------*/
151
+ /* ---------------------------------*/
152
  .box-warning {
153
  border-radius: 5px;
154
  -moz-border-radius: 5px;
159
  padding: 10px 10px 10px 50px;
160
  margin-top: 20px;
161
  }
 
162
  .box-info {
163
  border-radius: 5px;
164
  -moz-border-radius: 5px;
169
  padding: 10px 10px 10px 60px;
170
  margin-top: 20px;
171
  }
 
 
172
  .aDBC-topBoxInfo {
173
  clear:both;
174
  border-radius: 5px;
180
  padding: 10px 10px 10px 40px;
181
  max-width: 730px;
182
  }
 
 
183
  .aDBCRightBox{
184
  padding:20px 0px 20px 0px;
185
  margin-bottom:5px;
189
  text-align:justify;
190
  color: #888;
191
  }
192
+ /* ---------------------------------*/
193
+ /* ------------ Tooltip ------------*/
194
+ /* ---------------------------------*/
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
195
  a.tooltips {
196
  position: relative;
197
  display: inline;
includes/clean-cron.php CHANGED
@@ -33,11 +33,11 @@
33
  // Fetch tasks for all blogs
34
  $cron = _get_cron_array();
35
  $schedules = wp_get_schedules();
36
- $date_format = _x( 'M j, Y @ G:i', 'Publish box date format', 'advanced-db-cleaner' );
37
  foreach ( $cron as $timestamp => $cronhooks ) {
38
  foreach ( (array) $cronhooks as $hook => $events ) {
39
  foreach ( (array) $events as $key => $event ) {
40
- $cron[ $timestamp ][ $hook ][ $key ][ 'date' ] = date_i18n( $date_format, $timestamp );
41
  }
42
  }
43
  }
@@ -74,22 +74,22 @@
74
  }else{
75
  // Fetch tasks for single blog
76
  $cron = _get_cron_array();
77
- $schedules = wp_get_schedules();
78
- $date_format = _x( 'M j, Y @ G:i', 'Publish box date format', 'advanced-db-cleaner' );
79
- foreach ( $cron as $timestamp => $cronhooks ) {
80
  foreach ( (array) $cronhooks as $hook => $events ) {
81
  foreach ( (array) $events as $key => $event ) {
82
- $cron[ $timestamp ][ $hook ][ $key ][ 'date' ] = date_i18n( $date_format, $timestamp );
83
  }
84
  }
85
  }
86
- foreach ( $cron as $timestamp => $cronhooks ) {
87
  foreach ( (array) $cronhooks as $hook => $events ) {
88
  foreach ( (array) $events as $event ) { ?>
89
  <tr>
90
  <td><?php echo $hook; ?></td>
91
  <td>
92
- <?php
93
  if ( $event[ 'schedule' ] ) {
94
  echo $schedules [ $event[ 'schedule' ] ][ 'display' ];
95
  } else {
33
  // Fetch tasks for all blogs
34
  $cron = _get_cron_array();
35
  $schedules = wp_get_schedules();
36
+ $date_format = 'M j, Y @ H:i:s';
37
  foreach ( $cron as $timestamp => $cronhooks ) {
38
  foreach ( (array) $cronhooks as $hook => $events ) {
39
  foreach ( (array) $events as $key => $event ) {
40
+ $cron[ $timestamp ][ $hook ][ $key ][ 'date' ] = get_date_from_gmt(date('Y-m-d H:i:s', $timestamp ), $date_format);
41
  }
42
  }
43
  }
74
  }else{
75
  // Fetch tasks for single blog
76
  $cron = _get_cron_array();
77
+ $schedules = wp_get_schedules();
78
+ $date_format = 'M j, Y @ H:i:s';
79
+ foreach ( (array) $cron as $timestamp => $cronhooks ) {
80
  foreach ( (array) $cronhooks as $hook => $events ) {
81
  foreach ( (array) $events as $key => $event ) {
82
+ $cron[ $timestamp ][ $hook ][ $key ][ 'date' ] = get_date_from_gmt(date('Y-m-d H:i:s', $timestamp ), $date_format);
83
  }
84
  }
85
  }
86
+ foreach ( (array) $cron as $timestamp => $cronhooks ) {
87
  foreach ( (array) $cronhooks as $hook => $events ) {
88
  foreach ( (array) $events as $event ) { ?>
89
  <tr>
90
  <td><?php echo $hook; ?></td>
91
  <td>
92
+ <?php
93
  if ( $event[ 'schedule' ] ) {
94
  echo $schedules [ $event[ 'schedule' ] ][ 'display' ];
95
  } else {
includes/clean-db.php CHANGED
@@ -73,7 +73,20 @@ $aDBc_count_unused = adv_db_cleaner_count();
73
  </td>
74
  </tr>
75
  <?php
76
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
77
  if($aDBc_count_unused["moderated"] > 0){ ?>
78
  <tr class="">
79
  <td class="column-name"><?php _e('Moderated Comments','advanced-db-cleaner'); ?></td>
@@ -219,7 +232,19 @@ $aDBc_count_unused = adv_db_cleaner_count();
219
  <input type="hidden" name="aDBc_clean_schedule_form" value="" />
220
  <input style="height:30px" type="submit" class="button-primary" value="<?php _e('Save','advanced-db-cleaner'); ?>" />
221
  </form>
222
- <div style="padding-top:15px; color:#111;">&nbsp;<?php _e('Next run:','advanced-db-cleaner'); ?> <span style="color: green"><?php echo wp_next_scheduled('aDBc_clean_scheduler') == true ? date('Y/m/d H:i:s', wp_next_scheduled('aDBc_clean_scheduler')) : 'Not set'; ?></span></div>
 
 
 
 
 
 
 
 
 
 
 
 
223
  </div>
224
 
225
  <div class="aDBCRightBox">
@@ -232,23 +257,25 @@ $aDBc_count_unused = adv_db_cleaner_count();
232
  if($aDBc_count_unused["revision"] == 0)
233
  echo "<div class='already-cleaned'>". __('Revision','advanced-db-cleaner') ."</div>";
234
  if($aDBc_count_unused["draft"] == 0)
235
- echo "<div class='already-cleaned'>". __('Draft','advanced-db-cleaner') ."</div>";
236
  if($aDBc_count_unused["autodraft"] == 0)
237
- echo "<div class='already-cleaned'>". __('Auto Draft','advanced-db-cleaner') ."</div>";
 
 
238
  if($aDBc_count_unused["postmeta"] == 0)
239
- echo "<div class='already-cleaned'>". __('Postmeta','advanced-db-cleaner') ."</div>";
240
  if($aDBc_count_unused["moderated"] == 0)
241
- echo "<div class='already-cleaned'>". __('Moderated Comments','advanced-db-cleaner') ."</div>";
242
  if($aDBc_count_unused["spam"] == 0)
243
- echo "<div class='already-cleaned'>". __('Spam Comments','advanced-db-cleaner') ."</div>";
244
  if($aDBc_count_unused["trash"] == 0)
245
- echo "<div class='already-cleaned'>". __('Trash Comments','advanced-db-cleaner') ."</div>";
246
  if($aDBc_count_unused["commentmeta"] == 0)
247
- echo "<div class='already-cleaned'>". __('Commentmeta','advanced-db-cleaner') ."</div>";
248
  if($aDBc_count_unused["relationships"] == 0)
249
- echo "<div class='already-cleaned'>". __('Relationships','advanced-db-cleaner') ."</div>";
250
  if($aDBc_count_unused["feed"] == 0)
251
- echo "<div class='already-cleaned'>". __('Dashboard Transient Feed','advanced-db-cleaner') ."</div>";
252
  ?>
253
  <div style="clear:both"></div>
254
  </div>
73
  </td>
74
  </tr>
75
  <?php
76
+ }
77
+ if($aDBc_count_unused["trashposts"] > 0){ ?>
78
+ <tr class="">
79
+ <td class="column-name"><?php _e('Trash posts','advanced-db-cleaner'); ?></td>
80
+ <td class="column-name aDBcCount"><?php echo $aDBc_count_unused["trashposts"]; ?></td>
81
+ <td class="column-name">
82
+ <div class="squaredFour">
83
+ <input id="aDBc_check_trashposts" type="checkbox" name="adbc_post_type[]" value="trash-posts" />
84
+ <label for="aDBc_check_trashposts"></label>
85
+ </div>
86
+ </td>
87
+ </tr>
88
+ <?php
89
+ }
90
  if($aDBc_count_unused["moderated"] > 0){ ?>
91
  <tr class="">
92
  <td class="column-name"><?php _e('Moderated Comments','advanced-db-cleaner'); ?></td>
232
  <input type="hidden" name="aDBc_clean_schedule_form" value="" />
233
  <input style="height:30px" type="submit" class="button-primary" value="<?php _e('Save','advanced-db-cleaner'); ?>" />
234
  </form>
235
+ <div style="padding-top:15px; color:#111;">
236
+ <?php _e('Next run:','advanced-db-cleaner'); ?>
237
+ <span style="color: green">
238
+ <?php
239
+ if(wp_next_scheduled('aDBc_clean_scheduler')){
240
+ $date_format = 'M j, Y @ H:i:s';
241
+ echo get_date_from_gmt(date('Y-m-d H:i:s', wp_next_scheduled('aDBc_clean_scheduler')), $date_format);
242
+ }else{
243
+ echo 'Not set';
244
+ }
245
+ ?>
246
+ </span>
247
+ </div>
248
  </div>
249
 
250
  <div class="aDBCRightBox">
257
  if($aDBc_count_unused["revision"] == 0)
258
  echo "<div class='already-cleaned'>". __('Revision','advanced-db-cleaner') ."</div>";
259
  if($aDBc_count_unused["draft"] == 0)
260
+ echo "<div class='already-cleaned'>". __('Draft','advanced-db-cleaner') ."</div>";
261
  if($aDBc_count_unused["autodraft"] == 0)
262
+ echo "<div class='already-cleaned'>". __('Auto Draft','advanced-db-cleaner') ."</div>";
263
+ if($aDBc_count_unused["trashposts"] == 0)
264
+ echo "<div class='already-cleaned'>". __('Trash posts','advanced-db-cleaner') ."</div>";
265
  if($aDBc_count_unused["postmeta"] == 0)
266
+ echo "<div class='already-cleaned'>". __('Postmeta','advanced-db-cleaner') ."</div>";
267
  if($aDBc_count_unused["moderated"] == 0)
268
+ echo "<div class='already-cleaned'>". __('Moderated Comments','advanced-db-cleaner') ."</div>";
269
  if($aDBc_count_unused["spam"] == 0)
270
+ echo "<div class='already-cleaned'>". __('Spam Comments','advanced-db-cleaner') ."</div>";
271
  if($aDBc_count_unused["trash"] == 0)
272
+ echo "<div class='already-cleaned'>". __('Trash Comments','advanced-db-cleaner') ."</div>";
273
  if($aDBc_count_unused["commentmeta"] == 0)
274
+ echo "<div class='already-cleaned'>". __('Commentmeta','advanced-db-cleaner') ."</div>";
275
  if($aDBc_count_unused["relationships"] == 0)
276
+ echo "<div class='already-cleaned'>". __('Relationships','advanced-db-cleaner') ."</div>";
277
  if($aDBc_count_unused["feed"] == 0)
278
+ echo "<div class='already-cleaned'>". __('Dashboard Transient Feed','advanced-db-cleaner') ."</div>";
279
  ?>
280
  <div style="clear:both"></div>
281
  </div>
includes/functions.php CHANGED
@@ -23,6 +23,11 @@ function adv_db_cleaner($type){
23
  $wpdb->query("DELETE pm FROM $wpdb->postmeta pm LEFT JOIN $wpdb->posts wp ON wp.ID = pm.post_id WHERE wp.ID IS NULL");
24
  $wpdb->query("DELETE FROM $wpdb->term_relationships WHERE term_taxonomy_id=1 AND object_id NOT IN (SELECT id FROM $wpdb->posts)");
25
  break;
 
 
 
 
 
26
  case "moderated":
27
  $wpdb->query("DELETE FROM $wpdb->comments WHERE comment_approved = '0'");
28
  $wpdb->query("DELETE FROM $wpdb->commentmeta WHERE comment_id NOT IN (SELECT comment_id FROM $wpdb->comments)");
@@ -36,7 +41,6 @@ function adv_db_cleaner($type){
36
  $wpdb->query("DELETE FROM $wpdb->commentmeta WHERE comment_id NOT IN (SELECT comment_id FROM $wpdb->comments)");
37
  break;
38
  case "postmeta":
39
- //"DELETE FROM $wpdb->postmeta WHERE NOT EXISTS ( SELECT * FROM $wpdb->posts WHERE $wpdb->postmeta.post_id = $wpdb->posts.ID )";
40
  $wpdb->query("DELETE pm FROM $wpdb->postmeta pm LEFT JOIN $wpdb->posts wp ON wp.ID = pm.post_id WHERE wp.ID IS NULL");
41
  break;
42
  case "commentmeta":
@@ -69,6 +73,11 @@ function adv_db_cleaner($type){
69
  $wpdb->query("DELETE pm FROM $wpdb->postmeta pm LEFT JOIN $wpdb->posts wp ON wp.ID = pm.post_id WHERE wp.ID IS NULL");
70
  $wpdb->query("DELETE FROM $wpdb->term_relationships WHERE term_taxonomy_id=1 AND object_id NOT IN (SELECT id FROM $wpdb->posts)");
71
  break;
 
 
 
 
 
72
  case "moderated":
73
  $wpdb->query("DELETE FROM $wpdb->comments WHERE comment_approved = '0'");
74
  $wpdb->query("DELETE FROM $wpdb->commentmeta WHERE comment_id NOT IN (SELECT comment_id FROM $wpdb->comments)");
@@ -82,7 +91,6 @@ function adv_db_cleaner($type){
82
  $wpdb->query("DELETE FROM $wpdb->commentmeta WHERE comment_id NOT IN (SELECT comment_id FROM $wpdb->comments)");
83
  break;
84
  case "postmeta":
85
- //"DELETE FROM $wpdb->postmeta WHERE NOT EXISTS ( SELECT * FROM $wpdb->posts WHERE $wpdb->postmeta.post_id = $wpdb->posts.ID )";
86
  $wpdb->query("DELETE pm FROM $wpdb->postmeta pm LEFT JOIN $wpdb->posts wp ON wp.ID = pm.post_id WHERE wp.ID IS NULL");
87
  break;
88
  case "commentmeta":
@@ -109,10 +117,10 @@ function aDBc_cleanAll(){
109
  $wpdb->query("DELETE FROM $wpdb->posts WHERE post_type = 'revision'");
110
  $wpdb->query("DELETE FROM $wpdb->posts WHERE post_status = 'draft'");
111
  $wpdb->query("DELETE FROM $wpdb->posts WHERE post_status = 'auto-draft'");
 
112
  $wpdb->query("DELETE FROM $wpdb->comments WHERE comment_approved = '0'");
113
  $wpdb->query("DELETE FROM $wpdb->comments WHERE comment_approved = 'spam'");
114
  $wpdb->query("DELETE FROM $wpdb->comments WHERE comment_approved = 'trash'");
115
- //"DELETE FROM $wpdb->postmeta WHERE NOT EXISTS ( SELECT * FROM $wpdb->posts WHERE $wpdb->postmeta.post_id = $wpdb->posts.ID )";
116
  $wpdb->query("DELETE pm FROM $wpdb->postmeta pm LEFT JOIN $wpdb->posts wp ON wp.ID = pm.post_id WHERE wp.ID IS NULL");
117
  $wpdb->query("DELETE FROM $wpdb->commentmeta WHERE comment_id NOT IN (SELECT comment_id FROM $wpdb->comments)");
118
  $wpdb->query("DELETE FROM $wpdb->term_relationships WHERE term_taxonomy_id=1 AND object_id NOT IN (SELECT id FROM $wpdb->posts)");
@@ -124,10 +132,10 @@ function aDBc_cleanAll(){
124
  $wpdb->query("DELETE FROM $wpdb->posts WHERE post_type = 'revision'");
125
  $wpdb->query("DELETE FROM $wpdb->posts WHERE post_status = 'draft'");
126
  $wpdb->query("DELETE FROM $wpdb->posts WHERE post_status = 'auto-draft'");
 
127
  $wpdb->query("DELETE FROM $wpdb->comments WHERE comment_approved = '0'");
128
  $wpdb->query("DELETE FROM $wpdb->comments WHERE comment_approved = 'spam'");
129
  $wpdb->query("DELETE FROM $wpdb->comments WHERE comment_approved = 'trash'");
130
- //"DELETE FROM $wpdb->postmeta WHERE NOT EXISTS ( SELECT * FROM $wpdb->posts WHERE $wpdb->postmeta.post_id = $wpdb->posts.ID )";
131
  $wpdb->query("DELETE pm FROM $wpdb->postmeta pm LEFT JOIN $wpdb->posts wp ON wp.ID = pm.post_id WHERE wp.ID IS NULL");
132
  $wpdb->query("DELETE FROM $wpdb->commentmeta WHERE comment_id NOT IN (SELECT comment_id FROM $wpdb->comments)");
133
  $wpdb->query("DELETE FROM $wpdb->term_relationships WHERE term_taxonomy_id=1 AND object_id NOT IN (SELECT id FROM $wpdb->posts)");
@@ -138,40 +146,39 @@ function aDBc_cleanAll(){
138
  // This function is used to count unused elements
139
  function adv_db_cleaner_count(){
140
  global $wpdb;
141
- $aDBc_count_total_unused = 0;
142
  // If we are in multi-site installation and in main site then we should process all elements in all tables
143
  if(function_exists('is_multisite') && is_multisite() && is_main_site()){
144
  $blogs_ids = $wpdb->get_col("SELECT blog_id FROM $wpdb->blogs");
145
  foreach($blogs_ids as $blog_id){
146
  switch_to_blog($blog_id);
147
- $aDBc_count_unused["revision"] += $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->posts WHERE post_type = 'revision'");
148
- $aDBc_count_unused["draft"] += $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->posts WHERE post_status = 'draft'");
149
- $aDBc_count_unused["autodraft"] += $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->posts WHERE post_status = 'auto-draft'");
150
- $aDBc_count_unused["moderated"] += $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->comments WHERE comment_approved = '0'");
151
- $aDBc_count_unused["spam"] += $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->comments WHERE comment_approved = 'spam'");
152
- $aDBc_count_unused["trash"] += $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->comments WHERE comment_approved = 'trash'");
153
- //"SELECT COUNT(*) FROM $wpdb->postmeta WHERE NOT EXISTS ( SELECT * FROM $wpdb->posts WHERE $wpdb->postmeta.post_id = $wpdb->posts.ID )";
154
- $aDBc_count_unused["postmeta"] += $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->postmeta pm LEFT JOIN $wpdb->posts wp ON wp.ID = pm.post_id WHERE wp.ID IS NULL");
155
- $aDBc_count_unused["commentmeta"] += $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->commentmeta WHERE comment_id NOT IN (SELECT comment_id FROM $wpdb->comments)");
156
- $aDBc_count_unused["relationships"] += $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->term_relationships WHERE term_taxonomy_id=1 AND object_id NOT IN (SELECT id FROM $wpdb->posts)");
157
- $aDBc_count_unused["feed"] += $wpdb->get_var("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_%'");
158
  restore_current_blog();
159
  }
160
- $aDBc_count_unused["total"] = $aDBc_count_unused["revision"] + $aDBc_count_unused["draft"] + $aDBc_count_unused["autodraft"] + $aDBc_count_unused["moderated"] + $aDBc_count_unused["spam"] + $aDBc_count_unused["trash"] + $aDBc_count_unused["postmeta"] + $aDBc_count_unused["commentmeta"] + $aDBc_count_unused["relationships"] + $aDBc_count_unused["feed"];
161
  }else{
162
  // If we are in single site installation or in multi-site but not in main site, then we should process only current tables
163
- $aDBc_count_unused["revision"] = $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->posts WHERE post_type = 'revision'");
164
- $aDBc_count_unused["draft"] = $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->posts WHERE post_status = 'draft'");
165
- $aDBc_count_unused["autodraft"] = $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->posts WHERE post_status = 'auto-draft'");
166
- $aDBc_count_unused["moderated"] = $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->comments WHERE comment_approved = '0'");
167
- $aDBc_count_unused["spam"] = $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->comments WHERE comment_approved = 'spam'");
168
- $aDBc_count_unused["trash"] = $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->comments WHERE comment_approved = 'trash'");
169
- //"SELECT COUNT(*) FROM $wpdb->postmeta WHERE NOT EXISTS ( SELECT * FROM $wpdb->posts WHERE $wpdb->postmeta.post_id = $wpdb->posts.ID )";
170
- $aDBc_count_unused["postmeta"] = $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->postmeta pm LEFT JOIN $wpdb->posts wp ON wp.ID = pm.post_id WHERE wp.ID IS NULL");
171
- $aDBc_count_unused["commentmeta"] = $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->commentmeta WHERE comment_id NOT IN (SELECT comment_id FROM $wpdb->comments)");
172
- $aDBc_count_unused["relationships"] = $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->term_relationships WHERE term_taxonomy_id=1 AND object_id NOT IN (SELECT id FROM $wpdb->posts)");
173
- $aDBc_count_unused["feed"] = $wpdb->get_var("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_%'");
174
- $aDBc_count_unused["total"] = $aDBc_count_unused["revision"] + $aDBc_count_unused["draft"] + $aDBc_count_unused["autodraft"] + $aDBc_count_unused["moderated"] + $aDBc_count_unused["spam"] + $aDBc_count_unused["trash"] + $aDBc_count_unused["postmeta"] + $aDBc_count_unused["commentmeta"] + $aDBc_count_unused["relationships"] + $aDBc_count_unused["feed"];
175
  }
176
  return $aDBc_count_unused;
177
  }
@@ -180,7 +187,7 @@ function adv_db_cleaner_count(){
180
  function adv_db_cleaner_optimize(){
181
  global $wpdb;
182
  $prefix = str_replace( '_', '\_', $wpdb->prefix );
183
- $adbc_sql = "SELECT table_name, data_free FROM information_schema.tables WHERE table_schema = '".DB_NAME."' and data_free > 0";
184
  if(!is_main_site()){
185
  $adbc_sql = $adbc_sql . " and table_name LIKE '{$prefix}%'";
186
  }
23
  $wpdb->query("DELETE pm FROM $wpdb->postmeta pm LEFT JOIN $wpdb->posts wp ON wp.ID = pm.post_id WHERE wp.ID IS NULL");
24
  $wpdb->query("DELETE FROM $wpdb->term_relationships WHERE term_taxonomy_id=1 AND object_id NOT IN (SELECT id FROM $wpdb->posts)");
25
  break;
26
+ case "trash-posts":
27
+ $wpdb->query("DELETE FROM $wpdb->posts WHERE post_status = 'trash'");
28
+ $wpdb->query("DELETE pm FROM $wpdb->postmeta pm LEFT JOIN $wpdb->posts wp ON wp.ID = pm.post_id WHERE wp.ID IS NULL");
29
+ $wpdb->query("DELETE FROM $wpdb->term_relationships WHERE term_taxonomy_id=1 AND object_id NOT IN (SELECT id FROM $wpdb->posts)");
30
+ break;
31
  case "moderated":
32
  $wpdb->query("DELETE FROM $wpdb->comments WHERE comment_approved = '0'");
33
  $wpdb->query("DELETE FROM $wpdb->commentmeta WHERE comment_id NOT IN (SELECT comment_id FROM $wpdb->comments)");
41
  $wpdb->query("DELETE FROM $wpdb->commentmeta WHERE comment_id NOT IN (SELECT comment_id FROM $wpdb->comments)");
42
  break;
43
  case "postmeta":
 
44
  $wpdb->query("DELETE pm FROM $wpdb->postmeta pm LEFT JOIN $wpdb->posts wp ON wp.ID = pm.post_id WHERE wp.ID IS NULL");
45
  break;
46
  case "commentmeta":
73
  $wpdb->query("DELETE pm FROM $wpdb->postmeta pm LEFT JOIN $wpdb->posts wp ON wp.ID = pm.post_id WHERE wp.ID IS NULL");
74
  $wpdb->query("DELETE FROM $wpdb->term_relationships WHERE term_taxonomy_id=1 AND object_id NOT IN (SELECT id FROM $wpdb->posts)");
75
  break;
76
+ case "trash-posts":
77
+ $wpdb->query("DELETE FROM $wpdb->posts WHERE post_status = 'trash'");
78
+ $wpdb->query("DELETE pm FROM $wpdb->postmeta pm LEFT JOIN $wpdb->posts wp ON wp.ID = pm.post_id WHERE wp.ID IS NULL");
79
+ $wpdb->query("DELETE FROM $wpdb->term_relationships WHERE term_taxonomy_id=1 AND object_id NOT IN (SELECT id FROM $wpdb->posts)");
80
+ break;
81
  case "moderated":
82
  $wpdb->query("DELETE FROM $wpdb->comments WHERE comment_approved = '0'");
83
  $wpdb->query("DELETE FROM $wpdb->commentmeta WHERE comment_id NOT IN (SELECT comment_id FROM $wpdb->comments)");
91
  $wpdb->query("DELETE FROM $wpdb->commentmeta WHERE comment_id NOT IN (SELECT comment_id FROM $wpdb->comments)");
92
  break;
93
  case "postmeta":
 
94
  $wpdb->query("DELETE pm FROM $wpdb->postmeta pm LEFT JOIN $wpdb->posts wp ON wp.ID = pm.post_id WHERE wp.ID IS NULL");
95
  break;
96
  case "commentmeta":
117
  $wpdb->query("DELETE FROM $wpdb->posts WHERE post_type = 'revision'");
118
  $wpdb->query("DELETE FROM $wpdb->posts WHERE post_status = 'draft'");
119
  $wpdb->query("DELETE FROM $wpdb->posts WHERE post_status = 'auto-draft'");
120
+ $wpdb->query("DELETE FROM $wpdb->posts WHERE post_status = 'trash'");
121
  $wpdb->query("DELETE FROM $wpdb->comments WHERE comment_approved = '0'");
122
  $wpdb->query("DELETE FROM $wpdb->comments WHERE comment_approved = 'spam'");
123
  $wpdb->query("DELETE FROM $wpdb->comments WHERE comment_approved = 'trash'");
 
124
  $wpdb->query("DELETE pm FROM $wpdb->postmeta pm LEFT JOIN $wpdb->posts wp ON wp.ID = pm.post_id WHERE wp.ID IS NULL");
125
  $wpdb->query("DELETE FROM $wpdb->commentmeta WHERE comment_id NOT IN (SELECT comment_id FROM $wpdb->comments)");
126
  $wpdb->query("DELETE FROM $wpdb->term_relationships WHERE term_taxonomy_id=1 AND object_id NOT IN (SELECT id FROM $wpdb->posts)");
132
  $wpdb->query("DELETE FROM $wpdb->posts WHERE post_type = 'revision'");
133
  $wpdb->query("DELETE FROM $wpdb->posts WHERE post_status = 'draft'");
134
  $wpdb->query("DELETE FROM $wpdb->posts WHERE post_status = 'auto-draft'");
135
+ $wpdb->query("DELETE FROM $wpdb->posts WHERE post_status = 'trash'");
136
  $wpdb->query("DELETE FROM $wpdb->comments WHERE comment_approved = '0'");
137
  $wpdb->query("DELETE FROM $wpdb->comments WHERE comment_approved = 'spam'");
138
  $wpdb->query("DELETE FROM $wpdb->comments WHERE comment_approved = 'trash'");
 
139
  $wpdb->query("DELETE pm FROM $wpdb->postmeta pm LEFT JOIN $wpdb->posts wp ON wp.ID = pm.post_id WHERE wp.ID IS NULL");
140
  $wpdb->query("DELETE FROM $wpdb->commentmeta WHERE comment_id NOT IN (SELECT comment_id FROM $wpdb->comments)");
141
  $wpdb->query("DELETE FROM $wpdb->term_relationships WHERE term_taxonomy_id=1 AND object_id NOT IN (SELECT id FROM $wpdb->posts)");
146
  // This function is used to count unused elements
147
  function adv_db_cleaner_count(){
148
  global $wpdb;
 
149
  // If we are in multi-site installation and in main site then we should process all elements in all tables
150
  if(function_exists('is_multisite') && is_multisite() && is_main_site()){
151
  $blogs_ids = $wpdb->get_col("SELECT blog_id FROM $wpdb->blogs");
152
  foreach($blogs_ids as $blog_id){
153
  switch_to_blog($blog_id);
154
+ $aDBc_count_unused["revision"] += $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->posts WHERE post_type = 'revision'");
155
+ $aDBc_count_unused["draft"] += $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->posts WHERE post_status = 'draft'");
156
+ $aDBc_count_unused["autodraft"] += $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->posts WHERE post_status = 'auto-draft'");
157
+ $aDBc_count_unused["trashposts"] += $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->posts WHERE post_status = 'trash'");
158
+ $aDBc_count_unused["moderated"] += $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->comments WHERE comment_approved = '0'");
159
+ $aDBc_count_unused["spam"] += $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->comments WHERE comment_approved = 'spam'");
160
+ $aDBc_count_unused["trash"] += $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->comments WHERE comment_approved = 'trash'");
161
+ $aDBc_count_unused["postmeta"] += $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->postmeta pm LEFT JOIN $wpdb->posts wp ON wp.ID = pm.post_id WHERE wp.ID IS NULL");
162
+ $aDBc_count_unused["commentmeta"] += $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->commentmeta WHERE comment_id NOT IN (SELECT comment_id FROM $wpdb->comments)");
163
+ $aDBc_count_unused["relationships"] += $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->term_relationships WHERE term_taxonomy_id=1 AND object_id NOT IN (SELECT id FROM $wpdb->posts)");
164
+ $aDBc_count_unused["feed"] += $wpdb->get_var("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_%'");
165
  restore_current_blog();
166
  }
167
+ $aDBc_count_unused["total"] = $aDBc_count_unused["revision"] + $aDBc_count_unused["draft"] + $aDBc_count_unused["autodraft"] + $aDBc_count_unused["trashposts"] + $aDBc_count_unused["moderated"] + $aDBc_count_unused["spam"] + $aDBc_count_unused["trash"] + $aDBc_count_unused["postmeta"] + $aDBc_count_unused["commentmeta"] + $aDBc_count_unused["relationships"] + $aDBc_count_unused["feed"];
168
  }else{
169
  // If we are in single site installation or in multi-site but not in main site, then we should process only current tables
170
+ $aDBc_count_unused["revision"] = $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->posts WHERE post_type = 'revision'");
171
+ $aDBc_count_unused["draft"] = $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->posts WHERE post_status = 'draft'");
172
+ $aDBc_count_unused["autodraft"] = $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->posts WHERE post_status = 'auto-draft'");
173
+ $aDBc_count_unused["trashposts"] = $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->posts WHERE post_status = 'trash'");
174
+ $aDBc_count_unused["moderated"] = $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->comments WHERE comment_approved = '0'");
175
+ $aDBc_count_unused["spam"] = $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->comments WHERE comment_approved = 'spam'");
176
+ $aDBc_count_unused["trash"] = $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->comments WHERE comment_approved = 'trash'");
177
+ $aDBc_count_unused["postmeta"] = $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->postmeta pm LEFT JOIN $wpdb->posts wp ON wp.ID = pm.post_id WHERE wp.ID IS NULL");
178
+ $aDBc_count_unused["commentmeta"] = $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->commentmeta WHERE comment_id NOT IN (SELECT comment_id FROM $wpdb->comments)");
179
+ $aDBc_count_unused["relationships"] = $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->term_relationships WHERE term_taxonomy_id=1 AND object_id NOT IN (SELECT id FROM $wpdb->posts)");
180
+ $aDBc_count_unused["feed"] = $wpdb->get_var("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_%'");
181
+ $aDBc_count_unused["total"] = $aDBc_count_unused["revision"] + $aDBc_count_unused["draft"] + $aDBc_count_unused["autodraft"] + $aDBc_count_unused["trashposts"] + $aDBc_count_unused["moderated"] + $aDBc_count_unused["spam"] + $aDBc_count_unused["trash"] + $aDBc_count_unused["postmeta"] + $aDBc_count_unused["commentmeta"] + $aDBc_count_unused["relationships"] + $aDBc_count_unused["feed"];
182
  }
183
  return $aDBc_count_unused;
184
  }
187
  function adv_db_cleaner_optimize(){
188
  global $wpdb;
189
  $prefix = str_replace( '_', '\_', $wpdb->prefix );
190
+ $adbc_sql = "SELECT table_name, data_free FROM information_schema.tables WHERE table_schema = '".DB_NAME."' and Engine <> 'InnoDB' and data_free > 0";
191
  if(!is_main_site()){
192
  $adbc_sql = $adbc_sql . " and table_name LIKE '{$prefix}%'";
193
  }
includes/optimize-db.php CHANGED
@@ -26,7 +26,7 @@
26
  $total_tables_to_optimize = 0;
27
  $total_lost = 0;
28
  $prefix = str_replace( '_', '\_', $wpdb->prefix );
29
- $adbc_sql = "SELECT table_name, data_free FROM information_schema.tables WHERE table_schema = '".DB_NAME."' and data_free > 0";
30
  if(!is_main_site()){
31
  $adbc_sql = $adbc_sql . " and table_name LIKE '{$prefix}%'";
32
  }
@@ -96,7 +96,19 @@
96
  <input type="hidden" name="aDBc_optimize_schedule_form" value="" />
97
  <input style="height:30px" type="submit" class="button-primary" value="<?php _e('Save','advanced-db-cleaner'); ?>" />
98
  </form>
99
- <div style="padding-top:15px; color:#111">&nbsp;<?php _e('Next run:','advanced-db-cleaner'); ?> <span style="color: green"><?php echo wp_next_scheduled('aDBc_optimize_scheduler') == true ? date('Y/m/d H:i:s', wp_next_scheduled('aDBc_optimize_scheduler')) : 'Not set'; ?></span></div>
 
 
 
 
 
 
 
 
 
 
 
 
100
  </div>
101
 
102
  <div class="aDBCRightBox">
26
  $total_tables_to_optimize = 0;
27
  $total_lost = 0;
28
  $prefix = str_replace( '_', '\_', $wpdb->prefix );
29
+ $adbc_sql = "SELECT table_name, data_free FROM information_schema.tables WHERE table_schema = '".DB_NAME."' and Engine <> 'InnoDB' and data_free > 0";
30
  if(!is_main_site()){
31
  $adbc_sql = $adbc_sql . " and table_name LIKE '{$prefix}%'";
32
  }
96
  <input type="hidden" name="aDBc_optimize_schedule_form" value="" />
97
  <input style="height:30px" type="submit" class="button-primary" value="<?php _e('Save','advanced-db-cleaner'); ?>" />
98
  </form>
99
+ <div style="padding-top:15px; color:#111;">
100
+ <?php _e('Next run:','advanced-db-cleaner'); ?>
101
+ <span style="color: green">
102
+ <?php
103
+ if(wp_next_scheduled('aDBc_optimize_scheduler')){
104
+ $date_format = 'M j, Y @ H:i:s';
105
+ echo get_date_from_gmt(date('Y-m-d H:i:s', wp_next_scheduled('aDBc_optimize_scheduler')), $date_format);
106
+ }else{
107
+ echo 'Not set';
108
+ }
109
+ ?>
110
+ </span>
111
+ </div>
112
  </div>
113
 
114
  <div class="aDBCRightBox">
includes/reset-db.php CHANGED
@@ -6,11 +6,13 @@ if (!isset($aDBc_admin->user_login ) || $aDBc_admin->user_level < 10 ){
6
  $aDBc_admin_exists = 0;
7
  }
8
  ?>
 
9
  <div class="box-warning">
10
  <span style="color: #EA823A; font-weight:bold"><?php _e('WARNING:','advanced-db-cleaner'); ?></span>
11
  <?php _e('The reset makes a fresh installation of your database. Therefore, ANY data in your database will be lost. This option is used primarily by developers who are testing their websites and who do not want to install wordpress after each test. Please do not use this option if you want to keep your posts and pages.','advanced-db-cleaner'); ?>
12
 
13
  </div>
 
14
  <div class="box-info">
15
  <ul style="list-style: disc outside none;">
16
  <li><?php _e('The reset does not delete or modify any of your plugins files or server files.','advanced-db-cleaner'); ?></li>
@@ -23,8 +25,11 @@ if (!isset($aDBc_admin->user_login ) || $aDBc_admin->user_level < 10 ){
23
  <li><?php _e('After the reset, you will be redirected to the admin login page.','advanced-db-cleaner'); ?></li>
24
  </ul>
25
  </div>
 
26
  <h3 style="color:#32373c; padding-top: 10px"><?php _e('Reset database','advanced-db-cleaner'); ?></h3>
 
27
  <p><?php _e('Type "<strong>reset</strong>" in the confirmation field below to confirm the reset and then click the reset button.','advanced-db-cleaner'); ?></p>
 
28
  <form id="wordpress_reset_form" action="" method="post">
29
  <input type="hidden" name="aDBc_reset_form" value="" />
30
  <input type="text" name="aDBc_reset_comfirmation" value="" />
6
  $aDBc_admin_exists = 0;
7
  }
8
  ?>
9
+
10
  <div class="box-warning">
11
  <span style="color: #EA823A; font-weight:bold"><?php _e('WARNING:','advanced-db-cleaner'); ?></span>
12
  <?php _e('The reset makes a fresh installation of your database. Therefore, ANY data in your database will be lost. This option is used primarily by developers who are testing their websites and who do not want to install wordpress after each test. Please do not use this option if you want to keep your posts and pages.','advanced-db-cleaner'); ?>
13
 
14
  </div>
15
+
16
  <div class="box-info">
17
  <ul style="list-style: disc outside none;">
18
  <li><?php _e('The reset does not delete or modify any of your plugins files or server files.','advanced-db-cleaner'); ?></li>
25
  <li><?php _e('After the reset, you will be redirected to the admin login page.','advanced-db-cleaner'); ?></li>
26
  </ul>
27
  </div>
28
+
29
  <h3 style="color:#32373c; padding-top: 10px"><?php _e('Reset database','advanced-db-cleaner'); ?></h3>
30
+
31
  <p><?php _e('Type "<strong>reset</strong>" in the confirmation field below to confirm the reset and then click the reset button.','advanced-db-cleaner'); ?></p>
32
+
33
  <form id="wordpress_reset_form" action="" method="post">
34
  <input type="hidden" name="aDBc_reset_form" value="" />
35
  <input type="text" name="aDBc_reset_comfirmation" value="" />
includes/sidebar.php CHANGED
@@ -1,5 +1,5 @@
1
  <div>
2
- <center><h2 style="color:#999; font-size:18px;">Advanced Database<br/> Cleaner <?php echo ADB_CLEANER_PLUGIN_VERSION; ?></h2></center>
3
  <p style="text-align: justify"><?php _e('If you love this plugin and would like to make a donation, then you\'re awesome.', 'advanced-db-cleaner'); ?></p>
4
  <p style="text-align:right"><?php _e('Thank you!', 'advanced-db-cleaner'); ?></p>
5
  <center>
@@ -12,26 +12,25 @@
12
  <div style="height: 20px; background-color:#f9f9f9;">
13
  <a style="text-decoration: none" href="https://wordpress.org/support/view/plugin-reviews/advanced-database-cleaner#postform">
14
  <div class="aDBC-supportUs" style="width:250px; height:20px">
15
- <span style="font-size: 13px; color:#777"><?php echo __('Please rate us', 'advanced-db-cleaner'); ?></span>
16
  </div>
17
  </a>
18
  </div>
19
 
20
  <div style="height: 20px; clear:both;">
21
  <div style="float:left">
22
- <span style="font-size: 13px; color:#777"><?php echo __('Having issues?', 'advanced-db-cleaner'); ?></span>
23
-
24
  </div>
25
  <div style="float:right">
26
- <a style="text-decoration: none" href="https://wordpress.org/support/plugin/advanced-database-cleaner"><?php echo __('Create a ticket', 'advanced-db-cleaner'); ?></a>
27
  </div>
28
  </div>
29
 
30
  <div style=" background-color:#f9f9f9; height: 20px; clear:both;">
31
  <div style="float:left">
32
- <span style="font-size: 13px; color:#777"><?php echo __('Developed by:', 'advanced-db-cleaner'); ?></span>
33
  </div>
34
  <div style="float:right">
35
- { <?php _e('Younes JFR', 'advanced-db-cleaner'); ?> }
36
  </div>
37
  </div>
1
  <div>
2
+ <center><h2 style="color:#999; font-size:18px; line-height:26px; font-weight:normal">Advanced Database<br/> Cleaner <?php echo ADB_CLEANER_PLUGIN_VERSION; ?></h2></center>
3
  <p style="text-align: justify"><?php _e('If you love this plugin and would like to make a donation, then you\'re awesome.', 'advanced-db-cleaner'); ?></p>
4
  <p style="text-align:right"><?php _e('Thank you!', 'advanced-db-cleaner'); ?></p>
5
  <center>
12
  <div style="height: 20px; background-color:#f9f9f9;">
13
  <a style="text-decoration: none" href="https://wordpress.org/support/view/plugin-reviews/advanced-database-cleaner#postform">
14
  <div class="aDBC-supportUs" style="width:250px; height:20px">
15
+ <span style="font-size: 13px; color:#777"><?php _e('Please rate us', 'advanced-db-cleaner'); ?></span>
16
  </div>
17
  </a>
18
  </div>
19
 
20
  <div style="height: 20px; clear:both;">
21
  <div style="float:left">
22
+ <span style="font-size: 13px; color:#777"><?php _e('Having issues?', 'advanced-db-cleaner'); ?></span>
 
23
  </div>
24
  <div style="float:right">
25
+ <a style="text-decoration: none" href="https://wordpress.org/support/plugin/advanced-database-cleaner"><?php _e('Create a ticket', 'advanced-db-cleaner'); ?></a>
26
  </div>
27
  </div>
28
 
29
  <div style=" background-color:#f9f9f9; height: 20px; clear:both;">
30
  <div style="float:left">
31
+ <span style="font-size: 13px; color:#777"><?php _e('Developed by:', 'advanced-db-cleaner'); ?></span>
32
  </div>
33
  <div style="float:right">
34
+ <a style="text-decoration: none" href="http://www.wpdatabasecleaner.com" target="_blank">{ Younes JFR. }</a>
35
  </div>
36
  </div>
index.php CHANGED
@@ -1,3 +1,3 @@
1
  <?php
2
- #Silence is golden.
3
  ?>
1
  <?php
2
+ #Silence is golden
3
  ?>