Advanced Database Cleaner - Version 1.3.5

Version Description

  • New feature: Adding "Clean Cron". You can now clean unnecessary scheduled tasks.
  • Updating FAQ
Download this release

Release Info

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

Code changes from version 1.3.1 to 1.3.5

README.txt CHANGED
@@ -1,10 +1,10 @@
1
=== Advanced Database Cleaner ===
2
Contributors: symptote
3
Donate Link: https://www.paypal.com/us/cgi-bin/webscr?cmd=_flow&SESSION=Azq_P8u-Dy9AZSB3bmJFsrGWImHWiCoHtSE8KuC2SNdGQpreQxG8dl2tVZK&dispatch=5885d80a13c0db1f8e263663d3faee8d0b9dcb01a9b6dc564e45f62871326a5e
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
5
Requires at least: 3.0.0
6
Tested up to: 4.3
7
- Stable tag: 1.3.1
8
License: GPLv2 or later
9
License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
@@ -21,6 +21,7 @@ Advanced Database Cleaner is a must-have plugin that cleans and optimizes your W
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
* Supports multisite installation
25
26
= Multisite Support =
@@ -46,14 +47,19 @@ This section describes how to install the plugin and get it working.
46
47
== Screenshots ==
48
49
- 1. Example of dirty database
50
2. Example of cleaned database
51
- 3. Example of dirty tables
52
4. Example of optimized tables
53
- 5. Reset database" admin page screenshot
54
55
== Changelog ==
56
57
= 1.3.1 =
58
* Adding FAQ
59
@@ -97,11 +103,14 @@ This section describes how to install the plugin and get it working.
97
As you use WordPress, your database accumulates a lot of extra data such as revisions, spam comments, trashed comments, etc. Removing this unnecessary data will reduce your database size, speeds up your backup process and speeds up your site also.
98
99
= Is it safe to clean my database? =
100
- Yes, it is. We do not run any code that can break down your site or delete your posts, pages, comments, etc. However, we advise you to create a database backup before cleaning. It is always better to be safe than sorry.
101
102
= What does mean "Optimize my database"? =
103
Optimizing your database will reclaim unused space in your tables, which will reduce storage space and improve efficiency when accessing tables. Optimizing the database can sometimes significantly improve performance, particularly on sites that receive a lot of traffic or have a large amount of content. Optimizing your database is absolutely safe.
104
105
= Is this plugin compatible with multisite? =
106
Yes, it is compatible with multisite.
107
@@ -142,7 +151,7 @@ Sometimes the wp_term_relationships table becomes bloated with many orphaned rel
142
`DELETE FROM term_relationships WHERE term_taxonomy_id=1 AND object_id NOT IN (SELECT id FROM posts)`
143
144
= What does mean "Dashboard transient feed"? What sql code is used to clean it? =
145
- 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 all expired dashboard transient feed meta is:
146
`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_%'`
147
148
= Does this plugin cleans itself after the uninstall? =
1
=== Advanced Database Cleaner ===
2
Contributors: symptote
3
Donate Link: https://www.paypal.com/us/cgi-bin/webscr?cmd=_flow&SESSION=Azq_P8u-Dy9AZSB3bmJFsrGWImHWiCoHtSE8KuC2SNdGQpreQxG8dl2tVZK&dispatch=5885d80a13c0db1f8e263663d3faee8d0b9dcb01a9b6dc564e45f62871326a5e
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.5
8
License: GPLv2 or later
9
License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
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 =
47
48
== Screenshots ==
49
50
+ 1. Example of database not cleaned
51
2. Example of cleaned database
52
+ 3. Example of tables not optimized
53
4. Example of optimized tables
54
+ 5. "View & clean scheduled tasks" admin page screenshot
55
+ 6. "Reset database" admin page screenshot
56
57
== Changelog ==
58
59
+ = 1.3.5 =
60
+ * New feature: Adding "Clean Cron". You can now clean unnecessary scheduled tasks.
61
+ * Updating FAQ
62
+
63
= 1.3.1 =
64
* Adding FAQ
65
103
As you use WordPress, your database accumulates a lot of extra data such as revisions, spam comments, trashed comments, etc. Removing this unnecessary data will reduce your database size, speeds up your backup process and speeds up your site also.
104
105
= Is it safe to clean my database? =
106
+ Yes, it is. We do not run any code that can break down your site or delete your posts, pages, comments, etc. However, we advise you to make a database backup before cleaning. It is always better to be safe than sorry.
107
108
= What does mean "Optimize my database"? =
109
Optimizing your database will reclaim unused space in your tables, which will reduce storage space and improve efficiency when accessing tables. Optimizing the database can sometimes significantly improve performance, particularly on sites that receive a lot of traffic or have a large amount of content. Optimizing your database is absolutely safe.
110
111
+ = Is it safe to clean the cron (scheduled tasks)? =
112
+ 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.
113
+
114
= Is this plugin compatible with multisite? =
115
Yes, it is compatible with multisite.
116
151
`DELETE FROM term_relationships WHERE term_taxonomy_id=1 AND object_id NOT IN (SELECT id FROM posts)`
152
153
= What does mean "Dashboard transient feed"? What sql code is used to clean it? =
154
+ 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:
155
`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_%'`
156
157
= Does this plugin cleans itself after the uninstall? =
advanced-db-cleaner.php CHANGED
@@ -1,10 +1,10 @@
1
<?php
2
- defined( 'ABSPATH' ) or die( 'No script kiddies please!' );
3
4
/*
5
Plugin Name: Advanced Database Cleaner
6
- Description: Clean up your database by deleting unused data such as 'draft', Optimize your database or reset it to its initial state.
7
- Version: 1.3.1
8
Author: Younes JFR.
9
Contributors: symptote
10
Text Domain: advanced-db-cleaner
@@ -16,7 +16,7 @@ License URI: http://www.gnu.org/licenses/gpl-2.0.html
16
/********************************************************************
17
* Define common variables
18
********************************************************************/
19
- if (!defined("ADB_CLEANER_PLUGIN_VERSION")) define("ADB_CLEANER_PLUGIN_VERSION", "1.3.0");
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
@@ -199,6 +199,22 @@ function adv_db_cleaner_page(){
199
wp_schedule_event(time()+60, $_POST['aDBc_clean_schedule'], 'aDBc_clean_scheduler');
200
}
201
$adv_db_cleaner_message = __('The clean-up schedule is saved successfully!', 'advanced-db-cleaner');
202
}
203
// Print message
204
if($adv_db_cleaner_message != ''){
@@ -211,13 +227,15 @@ function adv_db_cleaner_page(){
211
$aDBc_tab_list = array(
212
array("id"=>"aDBc-clean", "title"=>__('Clean Database', 'advanced-db-cleaner')),
213
array("id"=>"aDBc-optimize", "title"=>__('Optimize Database', 'advanced-db-cleaner')),
214
array("id"=>"aDBc-reset", "title"=>__('Reset Database', 'advanced-db-cleaner'))
215
);
216
foreach ($aDBc_tab_list as $key => $value){
217
$checked = "";
218
if($value["id"] == "aDBc-clean"
219
|| (isset($_POST["aDBc_optimize_form"]) && $value["id"] == "aDBc-optimize")
220
- || (isset($_POST["aDBc_optimize_schedule_form"]) && $value["id"] == "aDBc-optimize")
221
|| (isset($_POST["aDBc_reset_form"]) && $value["id"] == "aDBc-reset")){
222
$checked = 'checked = "checked"';
223
}
@@ -232,6 +250,9 @@ function adv_db_cleaner_page(){
232
<?php include_once 'includes/optimize-db.php'; ?>
233
</div>
234
<div class="tab3">
235
<?php
236
if(is_main_site()){
237
include_once 'includes/reset-db.php';
1
<?php
2
+ 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.5
8
Author: Younes JFR.
9
Contributors: symptote
10
Text Domain: advanced-db-cleaner
16
/********************************************************************
17
* Define common variables
18
********************************************************************/
19
+ if (!defined("ADB_CLEANER_PLUGIN_VERSION")) define("ADB_CLEANER_PLUGIN_VERSION", "1.3.5");
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
199
wp_schedule_event(time()+60, $_POST['aDBc_clean_schedule'], 'aDBc_clean_scheduler');
200
}
201
$adv_db_cleaner_message = __('The clean-up schedule is saved successfully!', 'advanced-db-cleaner');
202
+ }elseif(isset($_POST['adbc_cron_hooks'])){
203
+ //Clean cron (scheduled tasks)
204
+ if(function_exists('is_multisite') && is_multisite() && is_main_site()){
205
+ foreach($_POST['adbc_cron_hooks'] as $adbc_cron_hook) {
206
+ // Get the id of the blog and the hook name
207
+ $adbc_blog_id_and_hook = explode("|", $adbc_cron_hook);
208
+ switch_to_blog($adbc_blog_id_and_hook[0]);
209
+ wp_clear_scheduled_hook($adbc_blog_id_and_hook[1]);
210
+ restore_current_blog();
211
+ }
212
+ }else{
213
+ foreach($_POST['adbc_cron_hooks'] as $adbc_cron_hook) {
214
+ wp_clear_scheduled_hook($adbc_cron_hook);
215
+ }
216
+ }
217
+ $adv_db_cleaner_message = __('Cron(s) cleaned successfully!', 'advanced-db-cleaner');
218
}
219
// Print message
220
if($adv_db_cleaner_message != ''){
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 = "";
235
if($value["id"] == "aDBc-clean"
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
}
250
<?php include_once 'includes/optimize-db.php'; ?>
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()){
258
include_once 'includes/reset-db.php';
css/style.css CHANGED
@@ -30,7 +30,7 @@
30
-moz-border-radius: 5px 5px 0 0;
31
-webkit-border-radius: 5px 5px 0 0;
32
border-bottom: 0;
33
- padding: 8px 10px;
34
background-color:#ddd;
35
color: #111;
36
font-size: 13px;
@@ -54,7 +54,7 @@
54
-moz-border-radius: 0 5px 5px 5px;
55
-webkit-border-radius: 0 5px 5px 5px;
56
}
57
- #aDBc-clean:checked ~ .tab1, #aDBc-optimize:checked ~ .tab2, #aDBc-reset:checked ~ .tab3{
58
display: block;
59
min-height: 400px;
60
}
30
-moz-border-radius: 5px 5px 0 0;
31
-webkit-border-radius: 5px 5px 0 0;
32
border-bottom: 0;
33
+ padding: 6px 10px;
34
background-color:#ddd;
35
color: #111;
36
font-size: 13px;
54
-moz-border-radius: 0 5px 5px 5px;
55
-webkit-border-radius: 0 5px 5px 5px;
56
}
57
+ #aDBc-clean:checked ~ .tab1, #aDBc-optimize:checked ~ .tab2, #aDBc-cron:checked ~ .tab3, #aDBc-reset:checked ~ .tab4{
58
display: block;
59
min-height: 400px;
60
}
includes/clean-cron.php ADDED
@@ -0,0 +1,120 @@
1
+ <div class="marginTop20">
2
+ <div style="float: left; margin-right:25px; margin-bottom:40px">
3
+ <form action="" method="post">
4
+ <?php if(function_exists('is_multisite') && is_multisite() && is_main_site()){ ?>
5
+ <div style="margin-bottom:15px;">
6
+ <a class="tooltips" href="#">
7
+ <img src="<?php echo ADB_CLEANER_PLUGIN_DIR . '/images/about.png'?>"/>
8
+ <span>The plugin has detected that you use a multisite installation. This is your main site from which you can manage all scheduled tasks in all sites of your network. Other sites can manage their own scheduled tasks only.</span>
9
+ </a>
10
+ </div>
11
+ <?php } ?>
12
+ <table class="widefat" style="width: 800px; border: 1px solid #eee; box-shadow: 0 0px 0px #ccc;">
13
+ <thead style="background:#f0f5fa; border-bottom:1px solid dashed">
14
+ <tr>
15
+ <th scope="col" style="color:#222; font-size:13px; border-bottom: 0px"><?php _e('Hook name', 'advanced-db-cleaner'); ?></th>
16
+ <?php if(function_exists('is_multisite') && is_multisite() && is_main_site()){ ?>
17
+ <th scope="col" style="color:#222; font-size:13px; border-bottom: 0px"><?php _e('Blog id', 'advanced-db-cleaner'); ?></th>
18
+ <?php } ?>
19
+ <th scope="col" style="color:#222; font-size:13px; border-bottom: 0px"><?php _e('Frequency', 'advanced-db-cleaner'); ?></th>
20
+ <th scope="col" style="font-size:13px; color:#222; border-bottom: 0px;"><?php _e('Next run', 'advanced-db-cleaner'); ?></th>
21
+ <th scope="col" style="font-size:13px; color:#222; border-bottom: 0px;"><?php _e('UTC', 'advanced-db-cleaner'); ?></th>
22
+ <th scope="col" style="text-align:center; color:#222; width: 40px; font-size:13px; border-bottom: 0px"><?php _e('Select','advanced-db-cleaner'); ?></th>
23
+ </tr>
24
+ </thead>
25
+ <tbody>
26
+ <?php
27
+ if(function_exists('is_multisite') && is_multisite() && is_main_site()){
28
+ $blogs_ids = $wpdb->get_col("SELECT blog_id FROM $wpdb->blogs");
29
+ foreach($blogs_ids as $blog_id){
30
+ switch_to_blog($blog_id);
31
+ // Fetch tasks for all blogs
32
+ $cron = _get_cron_array();
33
+ $schedules = wp_get_schedules();
34
+ $date_format = _x( 'M j, Y @ G:i', 'Publish box date format', 'advanced-db-cleaner' );
35
+ foreach ( $cron as $timestamp => $cronhooks ) {
36
+ foreach ( (array) $cronhooks as $hook => $events ) {
37
+ foreach ( (array) $events as $key => $event ) {
38
+ $cron[ $timestamp ][ $hook ][ $key ][ 'date' ] = date_i18n( $date_format, $timestamp );
39
+ }
40
+ }
41
+ }
42
+ foreach ( $cron as $timestamp => $cronhooks ) {
43
+ foreach ( (array) $cronhooks as $hook => $events ) {
44
+ foreach ( (array) $events as $event ) { ?>
45
+ <tr>
46
+ <td><?php echo $hook; ?></td>
47
+ <td><?php echo $blog_id; ?></td>
48
+ <td>
49
+ <?php
50
+ if ( $event[ 'schedule' ] ) {
51
+ echo $schedules [ $event[ 'schedule' ] ][ 'display' ];
52
+ } else {
53
+ ?><em><?php _e('One-off event', 'advanced-db-cleaner'); ?></em><?php
54
+ }
55
+ ?>
56
+ </td>
57
+ <td><?php echo $event[ 'date' ]; ?></td>
58
+ <td><?php echo $timestamp; ?></td>
59
+ <td class="column-name">
60
+ <div class="squaredFour" style="text-align:left; ">
61
+ <input id="aDBc_<?php echo $blog_id. '|' . $hook; ?>" type="checkbox" name="adbc_cron_hooks[]" value="<?php echo $blog_id. '|' . $hook; ?>" />
62
+ <label for="aDBc_<?php echo $blog_id. '|' . $hook; ?>"></label>
63
+ </div>
64
+ </td>
65
+ </tr>
66
+ <?php }
67
+ }
68
+ }
69
+ // Switch back to original blog
70
+ restore_current_blog();
71
+ }
72
+ }else{
73
+ // Fetch tasks for single blog
74
+ $cron = _get_cron_array();
75
+ $schedules = wp_get_schedules();
76
+ $date_format = _x( 'M j, Y @ G:i', 'Publish box date format', 'advanced-db-cleaner' );
77
+ foreach ( $cron as $timestamp => $cronhooks ) {
78
+ foreach ( (array) $cronhooks as $hook => $events ) {
79
+ foreach ( (array) $events as $key => $event ) {
80
+ $cron[ $timestamp ][ $hook ][ $key ][ 'date' ] = date_i18n( $date_format, $timestamp );
81
+ }
82
+ }
83
+ }
84
+ foreach ( $cron as $timestamp => $cronhooks ) {
85
+ foreach ( (array) $cronhooks as $hook => $events ) {
86
+ foreach ( (array) $events as $event ) { ?>
87
+ <tr>
88
+ <td><?php echo $hook; ?></td>
89
+ <td>
90
+ <?php
91
+ if ( $event[ 'schedule' ] ) {
92
+ echo $schedules [ $event[ 'schedule' ] ][ 'display' ];
93
+ } else {
94
+ ?><em><?php _e('One-off event', 'advanced-db-cleaner'); ?></em><?php
95
+ }
96
+ ?>
97
+ </td>
98
+ <td><?php echo $event[ 'date' ]; ?></td>
99
+ <td><?php echo $timestamp; ?></td>
100
+ <td class="column-name">
101
+ <div class="squaredFour" style="text-align:left; ">
102
+ <input id="aDBc_<?php echo $hook; ?>" type="checkbox" name="adbc_cron_hooks[]" value="<?php echo $hook; ?>" />
103
+ <label for="aDBc_<?php echo $hook; ?>"></label>
104
+ </div>
105
+ </td>
106
+ </tr>
107
+ <?php }
108
+ }
109
+ }
110
+ }
111
+ ?>
112
+ </tbody>
113
+ </table>
114
+ <p>
115
+ <input type="hidden" name="aDBc_clean_cron_form" value="" />
116
+ <input type="submit" class="button-primary" value="<?php _e('Clean selected schedules','advanced-db-cleaner'); ?>" />
117
+ </p>
118
+ </form>
119
+ </div>
120
+ </div>
includes/sidebar.php CHANGED
@@ -1,5 +1,5 @@
1
<div>
2
- <center><h2 style="color:#c0c0c0; font-size:18px; font-weight: bold">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>
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>
screenshot-1.png CHANGED
Binary file
screenshot-2.png CHANGED
Binary file
screenshot-3.png CHANGED
Binary file
screenshot-4.png CHANGED
Binary file
screenshot-5.png CHANGED
Binary file
screenshot-6.png ADDED
Binary file