Advanced Database Cleaner - Version 2.0.0

Version Description

  • Some changes to readme.txt file
  • Changing the way the plugin can be translated
  • Correcting __() to some texts
  • Correcting some displaying texts
  • Big change in styles
  • Restructuring the whole code for better performance
  • Creation of the plugin main page: https://sigmaplugin.com/downloads/wordpress-advanced-database-cleaner
  • Adding language translation support
  • Correct the time zone offset for the scheduled tasks
  • Skipping InnoDB tables while optimizing
  • Change size of lost tables data from 'o' to 'KB'
  • Main menu is now under 'Tools' not 'settings'
  • Adding separate left menu (can be disabled)
  • Adding overview page with some useful information
  • Adding settings page
  • "Reset database" is now in a separate plugin (please view our plugins page)
  • Multisite: now only the main site can clean the network
  • New feature: Display/view items before cleaning them (Pro)
  • New feature: view and clean options
  • New feature: Detect orphan options, plugins options, themes options and WP options (Pro)
  • New feature: view and clean cron (scheduled tasks)
  • New feature: Detect orphan tasks, plugins tasks, themes tasks and WP tasks (Pro)
  • New feature: view and clean database tables
  • New feature: Detect orphan tables, plugins tables, themes tables and WP tables (Pro)
Download this release

Release Info

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

Code changes from version 1.3.7 to 2.0.0

Files changed (43) hide show
  1. README.txt +86 -32
  2. advanced-db-cleaner.php +225 -185
  3. css/admin.css +568 -0
  4. css/style.css +0 -227
  5. images/about.png +0 -0
  6. images/check_ok.png +0 -0
  7. images/db_clean.png +0 -0
  8. images/db_not_clean.png +0 -0
  9. images/features.png +0 -0
  10. images/go_back.png +0 -0
  11. images/help.png +0 -0
  12. images/loading_img.gif +0 -0
  13. images/menu-icon.png +0 -0
  14. images/nothing_to_see.png +0 -0
  15. images/notice.png +0 -0
  16. images/order_now.png +0 -0
  17. images/premium_ok.png +0 -0
  18. images/search-icon.png +0 -0
  19. images/see.png +0 -0
  20. images/small_warning.png +0 -0
  21. includes/class_clean_cron.php +256 -0
  22. includes/class_clean_options.php +258 -0
  23. includes/class_clean_tables.php +241 -0
  24. includes/class_general_cleanup.php +242 -0
  25. includes/class_optimize_tables.php +294 -0
  26. includes/clean-cron.php +0 -122
  27. includes/clean-db.php +0 -283
  28. includes/clean_db.php +31 -0
  29. includes/custom-clean-view/class_clean_comment.php +148 -0
  30. includes/custom-clean-view/class_clean_commentmeta.php +136 -0
  31. includes/custom-clean-view/class_clean_dashboard_transient_feed.php +136 -0
  32. includes/custom-clean-view/class_clean_draft_trash.php +150 -0
  33. includes/custom-clean-view/class_clean_postmeta.php +136 -0
  34. includes/custom-clean-view/class_clean_relationships.php +136 -0
  35. includes/custom-clean-view/class_clean_revision.php +136 -0
  36. includes/functions.php +356 -190
  37. includes/optimize-db.php +0 -123
  38. includes/overview_settings.php +139 -0
  39. includes/premium_page.php +51 -0
  40. includes/reset-db.php +0 -39
  41. includes/sidebar.php +30 -24
  42. js/admin.js +65 -0
  43. languages/advanced-db-cleaner.pot +881 -0
README.txt CHANGED
@@ -1,37 +1,56 @@
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
@@ -40,24 +59,54 @@ This section describes how to install the plugin and get it working.
40
= Single site installation =
41
* After extraction, upload the Plugin to your `/wp-content/plugins/` directory
42
* Go to "Dashboard" » "Plugins" and choose 'Activate'
43
- * The plugin page can be accessed via "Dashboard" » "Settings" » "Database Cleaner"
44
45
= Multisite installation =
46
* Login to your primary site and go to "My Sites" » "Network Admin" » "Plugins"
47
* Install the plugin as usual for multisite
48
- * 'Network Activate' the plugin in "My Sites" » "Network Admin" » "Plugins" or let each site activate it separately
49
50
== Screenshots ==
51
52
- 1. Example of database not cleaned
53
- 2. Example of cleaned database
54
- 3. Example of tables not optimized
55
- 4. Example of optimized tables
56
- 5. "View & clean scheduled tasks" admin page screenshot
57
- 6. "Reset database" admin page screenshot
58
59
== Changelog ==
60
61
= 1.3.7 =
62
* Adding "clean trash-posts"
63
* Updating FAQ
@@ -109,6 +158,11 @@ This section describes how to install the plugin and get it working.
109
= 1.0.0 =
110
* First release: Hello world!
111
112
== Frequently Asked Questions ==
113
114
= What does mean "clean my database"? =
@@ -135,8 +189,8 @@ WordPress allows you to save a post or a page without having to publish it immed
135
Wordpress automatically saves your post/page while you are editing it. This is called an auto-draft. If you don't hit the publish/update button, then the post/page will be saved as auto-draft and any modification to your post/page will not be visible in your public site. Over time, you could have multiple auto-drafts that you will never publish and hence you can clean them. The sql query used by the plugin to clean all auto-drafts is:
136
`DELETE FROM posts WHERE post_status = 'auto-draft'`
137
138
- = What does mean "Moderated comment"? What sql code is used to clean it? =
139
- Moderated comments are comments published by users and which are awaiting for your approval before appearing in your site. In some cases, you will have to clean all these comments. The sql query used by the plugin to clean all moderated comments is:
140
`DELETE FROM comments WHERE comment_approved = '0'`
141
142
= What does mean "Spam comment"? What sql code is used to clean it? =
@@ -164,10 +218,10 @@ Transient are a way for storing cached data temporarily in your database by give
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.
1
=== Advanced Database Cleaner ===
2
Contributors: symptote
3
+ Donate Link: https://www.sigmaplugin.com/donation
4
+ Tags: clean, clean up, cleanup, database, optimize
5
+ Requires at least: 3.1.0
6
+ Tested up to: 4.9
7
+ Stable tag: 2.0.0
8
License: GPLv2 or later
9
License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
11
+ Clean database by deleting orphaned data such as 'revisions', 'transients', optimize database and more...
12
13
== Description ==
14
+ Clean up database by deleting orphaned items such as 'old revisions', 'old drafts', optimize database and more...
15
16
+ If you have been using WordPress for a while, then you should think absolutely about a database cleanup. Indeed, your database may be full of garbage that make your site sluggish and bloated such as old revisions, old drafts, spammed comments, etc. You should clean-up this unnecessary data to reduce your database size and improve website speed. In addition, you will have quicker database backup since the file of your backup will be smaller.
17
18
+ 'Advanced Database Cleaner' is a must-have plugin that allows you to clean database, optimize database and more.
19
20
= Main Features =
21
+ * Cleanup database includes:
22
+ * Delete old revisions of posts and pages
23
+ * Delete old drafts of posts and pages
24
+ * Delete old auto drafts
25
+ * Delete pending comments
26
+ * Delete spam comments
27
+ * Delete trash comments
28
+ * Delete orphan postmeta
29
+ * Delete orphan commentmeta
30
+ * Delete orphan relationships
31
+ * Delete orphan dashboard transient feeds
32
+ * You can choose what items to clean-up
33
+ * You can schedule your database clean up to run automatically
34
+ * Optimize database and improve website speed
35
+ * You can schedule your database optimization to run automatically
36
+ * View and clean cron tasks (scheduled tasks)
37
+ * View and clean tables
38
+ * View and clean options
39
* Supports multisite installation
40
41
+ = Pro Features (<a href="https://sigmaplugin.com/downloads/wordpress-advanced-database-cleaner">Official website</a>) =
42
+ Do you know that even after deleting a plugin/theme from your WordPress website, some of its leftovers may remain in your database? Such as orphan options, orphan tables and orphan cron tasks. As you may know, not all plugins/themes care about the housekeeping of your WordPress database. As long as you are removing plugins/themes, leftovers will be accumulated in your database and will influence your website performance. The Pro version of Advanced Database Cleaner will help you remove all those leftovers and perform a deep database clean up. In the pro version you can:
43
+
44
+ * Display and view unused items before making a database clean up
45
+ * Classify database options according to their "creator". They can be either: plugins options, themes options or WP core options
46
+ * Detect and delete orphan options
47
+ * Classify database tables according to their "creator". They can be either: plugins tables, themes tables or WP core tables
48
+ * Detect and delete orphan tables
49
+ * Classify all cron tasks (cron jobs) according to their "creator". They can be either: plugins cron tasks, themes cron tasks or WP core tasks
50
+ * Detect and delete orphan cron tasks
51
+
52
= Multisite Support =
53
+ * Only the main site can view, clean and optimize the whole network. Other sites in the network cannot perform these tasks. We have opted for this philosophy because we are sure that your DB is precious and only the super administrator can perform such actions.
54
55
== Installation ==
56
59
= Single site installation =
60
* After extraction, upload the Plugin to your `/wp-content/plugins/` directory
61
* Go to "Dashboard" &raquo; "Plugins" and choose 'Activate'
62
+ * The plugin page can be accessed via "Dashboard" &raquo; "Tools" &raquo; "WP DB Cleaner" or via the left menu "WP DB Cleaner"
63
64
= Multisite installation =
65
* Login to your primary site and go to "My Sites" &raquo; "Network Admin" &raquo; "Plugins"
66
* Install the plugin as usual for multisite
67
+ * Network activate the plugin
68
+ * Only the main site can have access to the plugin
69
70
== Screenshots ==
71
72
+ 1. Example of database with items to clean
73
+ 2. View items before cleaning them (case of auto-draft)
74
+ 3. Example of clean database
75
+ 4. Example of tables that should be optimized
76
+ 5. Example of optimize database
77
+ 6. View and clean tables. You can also detect orphan tables, plugins tables, themes tables and WP tables (Pro version)
78
+ 7. View and clean options. You can also detect orphan options, plugins options, themes options and WP options (Pro version)
79
+ 8. View and clean scheduled tasks. You can also detect orphan tasks, plugins tasks, themes tasks and WP tasks (Pro version)
80
+ 9. Overview and settings page
81
82
== Changelog ==
83
84
+ = 2.0.0 =
85
+ * Some changes to readme.txt file
86
+ * Changing the way the plugin can be translated
87
+ * Correcting __() to some texts
88
+ * Correcting some displaying texts
89
+ * Big change in styles
90
+ * Restructuring the whole code for better performance
91
+ * Creation of the plugin main page: https://sigmaplugin.com/downloads/wordpress-advanced-database-cleaner
92
+ * Adding language translation support
93
+ * Correct the time zone offset for the scheduled tasks
94
+ * Skipping InnoDB tables while optimizing
95
+ * Change size of lost tables data from 'o' to 'KB'
96
+ * Main menu is now under 'Tools' not 'settings'
97
+ * Adding separate left menu (can be disabled)
98
+ * Adding overview page with some useful information
99
+ * Adding settings page
100
+ * "Reset database" is now in a separate plugin (please view our plugins page)
101
+ * Multisite: now only the main site can clean the network
102
+ * New feature: Display/view items before cleaning them (Pro)
103
+ * New feature: view and clean options
104
+ * New feature: Detect orphan options, plugins options, themes options and WP options (Pro)
105
+ * New feature: view and clean cron (scheduled tasks)
106
+ * New feature: Detect orphan tasks, plugins tasks, themes tasks and WP tasks (Pro)
107
+ * New feature: view and clean database tables
108
+ * New feature: Detect orphan tables, plugins tables, themes tables and WP tables (Pro)
109
+
110
= 1.3.7 =
111
* Adding "clean trash-posts"
112
* Updating FAQ
158
= 1.0.0 =
159
* First release: Hello world!
160
161
+ == Upgrade Notice ==
162
+
163
+ = 2.0.0 =
164
+ New release.
165
+
166
== Frequently Asked Questions ==
167
168
= What does mean "clean my database"? =
189
Wordpress automatically saves your post/page while you are editing it. This is called an auto-draft. If you don't hit the publish/update button, then the post/page will be saved as auto-draft and any modification to your post/page will not be visible in your public site. Over time, you could have multiple auto-drafts that you will never publish and hence you can clean them. The sql query used by the plugin to clean all auto-drafts is:
190
`DELETE FROM posts WHERE post_status = 'auto-draft'`
191
192
+ = What does mean "Pending comment"? What sql code is used to clean it? =
193
+ Pending comments are comments published by users and which are awaiting for your approval before appearing in your site. In some cases, you will have to clean all these comments. The sql query used by the plugin to clean all pending comments is:
194
`DELETE FROM comments WHERE comment_approved = '0'`
195
196
= What does mean "Spam comment"? What sql code is used to clean it? =
218
`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_%'`
219
220
= Is this plugin compatible with multisite? =
221
+ Yes, it is compatible with multisite. It should be noted that only the main site in the network can clean the database and orphan items of all the network. We prevent other sites to clean your DB since we believe that only the super administrator have the right to perform such operation. Your database is precious!
222
223
= Is this plugin compatible with SharDB, HyperDB or Multi-DB? =
224
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.
225
226
= Does this plugin cleans itself after the uninstall? =
227
+ We do clean-up of your WordPress site, it will be a shame if the plugin does not clean itself after an uninstall! Of course yes, the plugin cleans itself and removes any data used to store its settings once uninstalled.
advanced-db-cleaner.php CHANGED
@@ -1,127 +1,205 @@
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 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>';
25
- array_unshift($links, $adc_settings_link);
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
}
46
47
/******************************************************************************************
48
* The scheduler
49
* Get more info here: http://codex.wordpress.org/Plugin_API/Filter_Reference/cron_schedules
50
******************************************************************************************/
51
add_filter('cron_schedules', 'aDBc_additional_schedules');
52
function aDBc_additional_schedules($schedules){
53
// Add weekly schedule
54
$schedules['weekly'] = array(
55
'interval' => 604800,
56
- 'display' => __('Once Weekly')
57
);
58
// Add monthly schedule
59
$schedules['monthly'] = array(
60
'interval' => 2635200,
61
- 'display' => __('Once a month')
62
);
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');
70
- function aDBc_activate_plugin($network_wide){
71
- global $wpdb;
72
- if(function_exists('is_multisite') && is_multisite() && $network_wide){
73
$blogs_ids = $wpdb->get_col("SELECT blog_id FROM $wpdb->blogs");
74
foreach($blogs_ids as $blog_id){
75
switch_to_blog($blog_id);
76
- $aDBc_optimize_schedule = get_option('aDBc_optimize_schedule');
77
- if($aDBc_optimize_schedule && $aDBc_optimize_schedule != 'no_schedule'){
78
- if(!wp_next_scheduled('aDBc_optimize_scheduler'))
79
- wp_schedule_event(time()+60, $aDBc_optimize_schedule, 'aDBc_optimize_scheduler');
80
- }
81
- $aDBc_clean_schedule = get_option('aDBc_clean_schedule');
82
- if($aDBc_clean_schedule && $aDBc_clean_schedule != 'no_schedule'){
83
- if(!wp_next_scheduled('aDBc_clean_scheduler'))
84
- wp_schedule_event(time()+60, $aDBc_clean_schedule, 'aDBc_clean_scheduler');
85
}
86
restore_current_blog();
87
}
88
- }else{
89
- $aDBc_optimize_schedule = get_option('aDBc_optimize_schedule');
90
- if($aDBc_optimize_schedule && $aDBc_optimize_schedule != 'no_schedule'){
91
- if(!wp_next_scheduled('aDBc_optimize_scheduler'))
92
- wp_schedule_event(time()+60, $aDBc_optimize_schedule, 'aDBc_optimize_scheduler');
93
- }
94
- $aDBc_clean_schedule = get_option('aDBc_clean_schedule');
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;
106
- if(function_exists('is_multisite') && is_multisite() && $network_wide){
107
- $blogs_ids = $wpdb->get_col("SELECT blog_id FROM $wpdb->blogs");
108
- foreach($blogs_ids as $blog_id){
109
- switch_to_blog($blog_id);
110
- wp_clear_scheduled_hook('aDBc_optimize_scheduler');
111
- wp_clear_scheduled_hook('aDBc_clean_scheduler');
112
- restore_current_blog();
113
- }
114
- }else{
115
- wp_clear_scheduled_hook('aDBc_optimize_scheduler');
116
- wp_clear_scheduled_hook('aDBc_clean_scheduler');
117
- }
118
}
119
120
- /** Clear scheduled tasks + options if UNINSTALL */
121
register_uninstall_hook(__FILE__, 'aDBc_uninstall');
122
function aDBc_uninstall(){
123
- global $wpdb;
124
if(function_exists('is_multisite') && is_multisite()){
125
$blogs_ids = $wpdb->get_col("SELECT blog_id FROM $wpdb->blogs");
126
foreach($blogs_ids as $blog_id){
127
switch_to_blog($blog_id);
@@ -131,130 +209,92 @@ function aDBc_uninstall(){
131
wp_clear_scheduled_hook('aDBc_clean_scheduler');
132
restore_current_blog();
133
}
134
- }else{
135
- delete_option('aDBc_optimize_schedule');
136
- delete_option('aDBc_clean_schedule');
137
- wp_clear_scheduled_hook('aDBc_optimize_scheduler');
138
- wp_clear_scheduled_hook('aDBc_clean_scheduler');
139
}
140
}
141
142
- /** The admin page content */
143
- function adv_db_cleaner_page(){
144
- ?>
145
<div class="wrap">
146
- <h2>Advanced DB Cleaner</h2>
147
<?php
148
- // If one of the forms is sent, then process data and print results
149
- $adv_db_cleaner_message = '';
150
- $adv_db_cleaner_message_class = 'updated settings-error notice is-dismissible';
151
- if(isset($_POST['adbc_post_type'])){
152
- foreach($_POST['adbc_post_type'] as $adbc_type) {
153
- adv_db_cleaner($adbc_type);
154
- }
155
- $adv_db_cleaner_message = __('Database cleaned successfully!', 'advanced-db-cleaner');
156
- }elseif(isset($_POST['aDBc_optimize_form'])){
157
- adv_db_cleaner_optimize();
158
- $adv_db_cleaner_message = __('Database optimized successfully!', 'advanced-db-cleaner');
159
- }elseif(isset($_POST['aDBc_reset_form'])){
160
- if($_POST['aDBc_reset_comfirmation'] == 'reset'){
161
- adv_db_cleaner_reset();
162
- }else{
163
- $adv_db_cleaner_message = __('Please type the word "reset" correctly in the text box below.', 'advanced-db-cleaner');
164
- $adv_db_cleaner_message_class = 'error';
165
- }
166
- }elseif(isset($_POST['aDBc_optimize_schedule_form'])){
167
- wp_clear_scheduled_hook('aDBc_optimize_scheduler');
168
- if($_POST['aDBc_optimize_schedule'] == 'no_schedule'){
169
- delete_option('aDBc_optimize_schedule');
170
- }else{
171
- update_option('aDBc_optimize_schedule', $_POST['aDBc_optimize_schedule']);
172
- wp_schedule_event(time()+60, $_POST['aDBc_optimize_schedule'], 'aDBc_optimize_scheduler');
173
- }
174
- $adv_db_cleaner_message = __('The optimization schedule is saved successfully!', 'advanced-db-cleaner');
175
- }elseif(isset($_POST['aDBc_clean_schedule_form'])){
176
- wp_clear_scheduled_hook('aDBc_clean_scheduler');
177
- if($_POST['aDBc_clean_schedule'] == 'no_schedule'){
178
- delete_option('aDBc_clean_schedule');
179
- }else{
180
- update_option('aDBc_clean_schedule', $_POST['aDBc_clean_schedule']);
181
- wp_schedule_event(time()+60, $_POST['aDBc_clean_schedule'], 'aDBc_clean_scheduler');
182
- }
183
- $adv_db_cleaner_message = __('The clean-up schedule is saved successfully!', 'advanced-db-cleaner');
184
- }elseif(isset($_POST['adbc_cron_hooks'])){
185
- //Clean cron (scheduled tasks)
186
- if(function_exists('is_multisite') && is_multisite() && is_main_site()){
187
- foreach($_POST['adbc_cron_hooks'] as $adbc_cron_hook) {
188
- // Get the id of the blog and the hook name
189
- $adbc_blog_id_and_hook = explode("|", $adbc_cron_hook);
190
- switch_to_blog($adbc_blog_id_and_hook[0]);
191
- wp_clear_scheduled_hook($adbc_blog_id_and_hook[1]);
192
- restore_current_blog();
193
- }
194
- }else{
195
- foreach($_POST['adbc_cron_hooks'] as $adbc_cron_hook) {
196
- wp_clear_scheduled_hook($adbc_cron_hook);
197
- }
198
- }
199
- $adv_db_cleaner_message = __('Cron(s) cleaned successfully!', 'advanced-db-cleaner');
200
- }
201
- // Print message
202
- if($adv_db_cleaner_message != ''){
203
- echo '<div id="adbc_message" class="'. $adv_db_cleaner_message_class .'"><p><strong>' . $adv_db_cleaner_message . '</strong></p></div>';
204
- }
205
- ?>
206
- <div class="marginRight300">
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 = "";
217
- if($value["id"] == "aDBc-clean"
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";
226
- echo '<label for="'.$value["id"].'">'.$value["title"].'</label>'."\n";
227
}
228
?>
229
- <div class="tab1">
230
- <?php include_once 'includes/clean-db.php'; ?>
231
- </div>
232
- <div class="tab2">
233
- <?php include_once 'includes/optimize-db.php'; ?>
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()){
241
- include_once 'includes/reset-db.php';
242
- }else{
243
- echo "<div style='text-align:center; padding-top:100px; color:#777'>";
244
- _e('Sorry! The reset can be executed from the main site in your Network only!', 'advanced-db-cleaner');
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
?>
1
<?php
2
+ if (!defined('ABSPATH')) return;
3
+ if (!is_main_site()) return;
4
/*
5
Plugin Name: Advanced Database Cleaner
6
+ Plugin URI: https://sigmaplugin.com/downloads/wordpress-advanced-database-cleaner
7
+ Description: Clean database by deleting unused data such as 'old revisions', 'old drafts', 'orphan options', etc. Optimize database and more.
8
+ Version: 2.0.0
9
Author: Younes JFR.
10
+ Author URI: https://www.sigmaplugin.com
11
Contributors: symptote
12
+ Text Domain: advanced-database-cleaner
13
+ Domain Path: /languages/
14
License: GPLv2 or later
15
License URI: http://www.gnu.org/licenses/gpl-2.0.html
16
*/
17
18
+ /********************************************************************
19
+ * Require WordPress List Table Administration API
20
+ * xxx: Test validity of WP_List_Table class after each release of WP.
21
+ * Notice from Wordpress.org:
22
+ * Since this class is marked as private, developers should use this only at their own risk as this class is
23
+ * subject to change in future WordPress releases. Any developers using this class are strongly encouraged to
24
+ * test their plugins with all WordPress beta/RC releases to maintain compatibility.
25
+ ********************************************************************/
26
+ if(!class_exists('WP_List_Table')) {
27
+ if(file_exists(ABSPATH . 'wp-admin/includes/class-wp-list-table.php')){
28
+ require_once(ABSPATH . 'wp-admin/includes/class-wp-list-table.php');
29
+ }else{
30
+ return;
31
+ }
32
+ }
33
34
+ /********************************************************************
35
+ *
36
+ * Define common constants
37
+ *
38
+ ********************************************************************/
39
+ if (!defined("ADBC_PLUGIN_VERSION")) define("ADBC_PLUGIN_VERSION", "2.0.0");
40
+ if (!defined("ADBC_PLUGIN_DIR_PATH")) define("ADBC_PLUGIN_DIR_PATH", plugins_url('' , __FILE__));
41
+
42
+ /********************************************************************
43
+ *
44
+ * load language
45
+ *
46
+ ********************************************************************/
47
+ add_action('plugins_loaded', 'aDBc_load_textdomain');
48
+ function aDBc_load_textdomain() {
49
+ // load_plugin_textdomain('advanced-database-cleaner', false, plugin_basename(dirname(__FILE__)) . '/languages');
50
+ load_plugin_textdomain( 'advanced-database-cleaner' );
51
}
52
53
+ /********************************************************************
54
+ *
55
+ * Get settings
56
+ *
57
+ ********************************************************************/
58
+ global $aDBc_settings;
59
+ $aDBc_settings = get_option('aDBc_settings');
60
+ // Test if settings are updated
61
+ if(isset($_POST['save_settings'])){
62
+ $aDBc_settings['left_menu'] = isset($_POST['aDBc_left_menu']) ? "1" : "0";
63
+ $aDBc_settings['top_main_msg'] = isset($_POST['aDBc_top_main_msg']) ? "1" : "0";
64
+ // Update settings in DB
65
+ update_option( 'aDBc_settings', $aDBc_settings );
66
}
67
68
+ /********************************************************************
69
+ *
70
+ * Add 'Database Cleaner' to Wordpress menu
71
+ *
72
+ ********************************************************************/
73
+ add_action('admin_menu', 'aDBc_add_admin_menu');
74
+ function aDBc_add_admin_menu() {
75
+ global $aDBc_settings, $aDBc_left_menu, $aDBc_tool_submenu;
76
+ if($aDBc_settings['left_menu'] == "1"){
77
+ $aDBc_left_menu = add_menu_page('Advanced DB Cleaner', 'WP DB Cleaner', 'manage_options', 'advanced_db_cleaner', 'aDBc_main_page_callback', ADBC_PLUGIN_DIR_PATH.'/images/menu-icon.png', '80.01123');
78
+ }
79
+ $aDBc_tool_submenu = add_submenu_page('tools.php', 'Advanced DB Cleaner', 'WP DB Cleaner', 'manage_options', 'advanced_db_cleaner', 'aDBc_main_page_callback');
80
}
81
82
+ /********************************************************************
83
+ *
84
+ * Load CSS and JS
85
+ *
86
+ ********************************************************************/
87
+ add_action('admin_enqueue_scripts', 'aDBc_load_styles_and_scripts');
88
+ function aDBc_load_styles_and_scripts($hook) {
89
+ // Enqueue our js and css in the plugin pages only
90
+ global $aDBc_left_menu, $aDBc_tool_submenu;
91
+ if($hook != $aDBc_left_menu && $hook != $aDBc_tool_submenu){
92
+ return;
93
+ }
94
+ wp_enqueue_style('aDBc_css', ADBC_PLUGIN_DIR_PATH . '/css/admin.css');
95
+ wp_enqueue_script('aDBc_js', ADBC_PLUGIN_DIR_PATH . '/js/admin.js');
96
+ //wp_enqueue_script('jquery');
97
+ wp_enqueue_script('jquery-ui-dialog');
98
+ wp_enqueue_style('wp-jquery-ui-dialog');
99
}
100
101
/******************************************************************************************
102
+ *
103
* The scheduler
104
* Get more info here: http://codex.wordpress.org/Plugin_API/Filter_Reference/cron_schedules
105
+ *
106
******************************************************************************************/
107
add_filter('cron_schedules', 'aDBc_additional_schedules');
108
function aDBc_additional_schedules($schedules){
109
// Add weekly schedule
110
$schedules['weekly'] = array(
111
'interval' => 604800,
112
+ 'display' => __('Once weekly', 'advanced-database-cleaner')
113
);
114
// Add monthly schedule
115
$schedules['monthly'] = array(
116
'interval' => 2635200,
117
+ 'display' => __('Once monthly', 'advanced-database-cleaner')
118
);
119
return $schedules;
120
}
121
122
+ /********************************************************************
123
+ *
124
+ * (RE)-schedule tasks after (RE)-activation or update of the plugin
125
+ *
126
+ ********************************************************************/
127
register_activation_hook(__FILE__, 'aDBc_activate_plugin');
128
+ add_action('aDBc_optimize_scheduler', 'aDBc_optimize_tables');
129
+ add_action('aDBc_clean_scheduler', 'aDBc_clean_all_elements');
130
+ function aDBc_activate_plugin(){
131
+
132
+ // Add scheduled task for optimization if option exists
133
+ $aDBc_optimize_schedule = get_option('aDBc_optimize_schedule');
134
+ if($aDBc_optimize_schedule && $aDBc_optimize_schedule != 'no_schedule'){
135
+ if(!wp_next_scheduled('aDBc_optimize_scheduler'))
136
+ wp_schedule_event(time()+60, $aDBc_optimize_schedule, 'aDBc_optimize_scheduler');
137
+ }
138
+
139
+ // Add scheduled task for clean-up if option exists
140
+ $aDBc_clean_schedule = get_option('aDBc_clean_schedule');
141
+ if($aDBc_clean_schedule && $aDBc_clean_schedule != 'no_schedule'){
142
+ if(!wp_next_scheduled('aDBc_clean_scheduler'))
143
+ wp_schedule_event(time()+60, $aDBc_clean_schedule, 'aDBc_clean_scheduler');
144
+ }
145
+
146
+ // Add default settings if not exists
147
+ $aDBc_settings = get_option('aDBc_settings');
148
+ if(empty($aDBc_settings)){
149
+ $aDBc_settings['left_menu'] = "1";
150
+ $aDBc_settings['top_main_msg'] = "1";
151
+ $aDBc_settings['tables_cleanup_warning'] = "1";
152
+ update_option('aDBc_settings', $aDBc_settings);
153
+ }
154
+
155
+ // When activating version >= 2.0.0, delete all options and tasks created by older versions in MU sites since only the main site can clean the network now
156
+ if(function_exists('is_multisite') && is_multisite()){
157
+ global $wpdb;
158
$blogs_ids = $wpdb->get_col("SELECT blog_id FROM $wpdb->blogs");
159
foreach($blogs_ids as $blog_id){
160
switch_to_blog($blog_id);
161
+ if(!is_main_site()){
162
+ delete_option('aDBc_optimize_schedule');
163
+ delete_option('aDBc_clean_schedule');
164
+ wp_clear_scheduled_hook('aDBc_optimize_scheduler');
165
+ wp_clear_scheduled_hook('aDBc_clean_scheduler');
166
}
167
restore_current_blog();
168
}
169
+ }
170
}
171
172
+ /********************************************************************
173
+ *
174
+ * Clear current scheduled tasks (if any) when deactivated
175
+ *
176
+ ********************************************************************/
177
+ register_deactivation_hook(__FILE__, 'aDBc_deactivate_plugin');
178
function aDBc_deactivate_plugin($network_wide){
179
+ wp_clear_scheduled_hook('aDBc_optimize_scheduler');
180
+ wp_clear_scheduled_hook('aDBc_clean_scheduler');
181
}
182
183
+ /********************************************************************
184
+ *
185
+ * Clear scheduled tasks + options if UNINSTALL
186
+ *
187
+ ********************************************************************/
188
register_uninstall_hook(__FILE__, 'aDBc_uninstall');
189
function aDBc_uninstall(){
190
+
191
+ // Delete options
192
+ delete_option('aDBc_optimize_schedule');
193
+ delete_option('aDBc_clean_schedule');
194
+ delete_option('aDBc_settings');
195
+
196
+ // Clear scheduled tasks
197
+ wp_clear_scheduled_hook('aDBc_optimize_scheduler');
198
+ wp_clear_scheduled_hook('aDBc_clean_scheduler');
199
+
200
+ // Testing for MU is useful to delete options and tasks created by older versions of the plugin ( < 2.0.0 ) in network sites
201
if(function_exists('is_multisite') && is_multisite()){
202
+ global $wpdb;
203
$blogs_ids = $wpdb->get_col("SELECT blog_id FROM $wpdb->blogs");
204
foreach($blogs_ids as $blog_id){
205
switch_to_blog($blog_id);
209
wp_clear_scheduled_hook('aDBc_clean_scheduler');
210
restore_current_blog();
211
}
212
}
213
}
214
215
+ /********************************************************************
216
+ *
217
+ * The admin page of the plugin
218
+ *
219
+ ********************************************************************/
220
+ function aDBc_main_page_callback(){ ?>
221
<div class="wrap">
222
+ <h2>Advanced Database Cleaner</h2>
223
<?php
224
+ global $aDBc_settings;
225
+ if($aDBc_settings['top_main_msg'] == "1"){ ?>
226
+ <div id="aDBc_main_msg" class="updated aDBc-top-main-msg">
227
+ <span><?php _e('Welcome!', 'advanced-database-cleaner'); ?></span>
228
+ <p style="font-size:15px">
229
+ <?php _e('Before doing any clean-up, please make sure to always backup your database first.', 'advanced-database-cleaner'); ?>
230
+ <br/>
231
+ <span style="font-size:12px;color:#999"><?php _e('Once you read and understand this message, you can disable it from settings Tab.', 'advanced-database-cleaner'); ?></span>
232
+ </p>
233
+ </div>
234
+ <?php } ?>
235
+ <div class="aDBc-margin-r-300">
236
+ <div class="aDBc-tab-box">
237
<?php
238
+ $aDBc_tabs = array('general' => __('General clean-up', 'advanced-database-cleaner'),
239
+ 'optimize' => __('Optimize', 'advanced-database-cleaner'),
240
+ 'tables' => __('Tables', 'advanced-database-cleaner'),
241
+ 'options' => __('Options', 'advanced-database-cleaner'),
242
+ 'cron' => __('Scheduled tasks', 'advanced-database-cleaner'),
243
+ 'overview' => __('Overview & Settings', 'advanced-database-cleaner'),
244
+ 'premium' => __('Premium', 'advanced-database-cleaner')
245
);
246
+
247
+ $current_tab = isset($_GET['aDBc_tab']) ? $_GET['aDBc_tab'] : 'general';
248
+
249
+ echo '<h2 class="nav-tab-wrapper">';
250
+ foreach($aDBc_tabs as $tab => $name){
251
+ $class = ($tab == $current_tab) ? ' nav-tab-active' : '';
252
+ $link = "?page=advanced_db_cleaner&aDBc_tab=$tab";
253
+ if($tab == "tables" || $tab == "options" || $tab == "cron"){
254
+ $link .= '&aDBc_cat=all';
255
}
256
+ echo "<a class='nav-tab$class' href='$link'>$name</a>";
257
+ }
258
+ echo '</h2>';
259
+
260
+ echo '<div class="aDBc-tab-box-div">';
261
+ switch ($current_tab){
262
+ case 'general' :
263
+ include_once 'includes/clean_db.php';
264
+ break;
265
+ case 'optimize' :
266
+ include_once 'includes/class_optimize_tables.php';
267
+ break;
268
+ case 'tables' :
269
+ include_once 'includes/class_clean_tables.php';
270
+ break;
271
+ case 'options' :
272
+ include_once 'includes/class_clean_options.php';
273
+ break;
274
+ case 'cron' :
275
+ include_once 'includes/class_clean_cron.php';
276
+ break;
277
+ case 'overview' :
278
+ include_once 'includes/overview_settings.php';
279
+ break;
280
+ case 'premium' :
281
+ include_once 'includes/premium_page.php';
282
+ break;
283
+ }
284
+ echo '</div>';
285
?>
286
</div>
287
+ <div class="aDBc-sidebar"><?php include_once 'includes/sidebar.php'; ?></div>
288
</div>
289
</div>
290
+ <?php
291
}
292
293
+ /***************************************************************
294
+ *
295
+ * Get functions
296
+ *
297
+ ***************************************************************/
298
include_once 'includes/functions.php';
299
+
300
?>
css/admin.css ADDED
@@ -0,0 +1,568 @@
1
+ /*---------------------------------------------------------------------------------------------
2
+ *
3
+ * Global styles
4
+ *
5
+ *---------------------------------------------------------------------------------------------*/
6
+ html {
7
+ overflow-y: scroll;
8
+ }
9
+ .aDBc-top-main-msg {
10
+ border-left: 5px solid pink !important;
11
+ background: #fff !important;
12
+ padding: 20px !important;
13
+ }
14
+ .aDBc-top-main-msg > span {
15
+ font-size: 16px;
16
+ color: #2E6E9E;
17
+ font-weight: bold;
18
+ }
19
+ .aDBc-content-max-width {
20
+ max-width: 840px;
21
+ }
22
+ .aDBc-margin-r-300 {
23
+ margin-top: 10px;
24
+ margin-right: 260px;
25
+ }
26
+ .aDBc-margin-t-20 {
27
+ margin-top: 20px;
28
+ }
29
+ .aDBc-margin-b-20 {
30
+ margin-bottom: 20px;
31
+ }
32
+ .aDBc-margin-l-3 {
33
+ margin-left: 3px !important;
34
+ }
35
+ .aDBc-clear-both{
36
+ clear: both;
37
+ }
38
+ .aDBc-float-left{
39
+ float: left;
40
+ }
41
+ .aDBc-float-right{
42
+ float: right;
43
+ }
44
+ #aDBc-please-wait{
45
+ display: none;
46
+ height: 34px !important;
47
+ margin-bottom: 40px;
48
+ color: #999;
49
+ font-family: verdana;
50
+ font-size: 11px;
51
+ text-align: center;
52
+ }
53
+ .aDBc-loading-gif{
54
+ height: 45px;
55
+ background: url("../images/loading_img.gif") no-repeat;
56
+ background-position: 50% 0% !important;
57
+ text-align: center;
58
+ margin: -20px 0px 0px 0px;
59
+ }
60
+ .aDBc-category-counts{
61
+ background: #fefefe;
62
+ padding: 10px 0px 20px 0px;
63
+ text-align: center;
64
+ }
65
+ .aDBc-category-counts a:hover{
66
+ padding-bottom: 6px;
67
+ border-bottom: 1px solid #ccc;
68
+ }
69
+ .aDBc-category-counts-links {
70
+ text-decoration: none !important;
71
+ }
72
+ .aDBc-selected-category{
73
+ padding-bottom: 6px;
74
+ font-weight: bold;
75
+ }
76
+ .aDBc-category-separator{
77
+ color: #999;
78
+ padding-left: 10px;
79
+ padding-right: 10px
80
+ }
81
+ .aDBc-run-new-search{
82
+ height: 34px !important;
83
+ min-width: 175px !important;
84
+ background-image: url("../images/search-icon.png") !important;
85
+ background-repeat: no-repeat !important;
86
+ background-position: 8px 50% !important;
87
+ padding-left: 30px !important;
88
+ }
89
+ .aDBc-category-color{
90
+ padding: 0px 5px;
91
+ margin-right: 5px;
92
+ border-radius: 2px;
93
+ -moz-border-radius: 2px;
94
+ -webkit-border-radius: 2px;
95
+ display: inline-block;
96
+ height: 10px
97
+ }
98
+ .aDBc-left-content{
99
+ float: left;
100
+ width: 500px;
101
+ margin-right: 25px
102
+ }
103
+ .aDBc-text-status-db{
104
+ font-family: verdana;
105
+ font-size: 11px;
106
+ }
107
+ .aDBc-schedule-text{
108
+ font-weight: bold;
109
+ padding: 20px 0px 10px 0px;
110
+ font-size: 13px;
111
+ }
112
+ .aDBc-schedule-select{
113
+ width: 200px;
114
+ font-size:13px;
115
+ }
116
+ .aDBc-schedule-box{
117
+ border-top: 1px dashed #e1e1e1;
118
+ margin-top: 30px;
119
+ }
120
+ .aDBc-custom-clean-text{
121
+ font-size: 15px;
122
+ margin-top: 15px;
123
+ margin-bottom: 20px;
124
+ color: #0992CC;
125
+ }
126
+ /*---------------------------------------------------------------------------------------------
127
+ *
128
+ * These styles override those of WordPress
129
+ *
130
+ *---------------------------------------------------------------------------------------------*/
131
+ .widefat {
132
+ border-spacing: 1px;
133
+ }
134
+ .widefat > thead {
135
+ background: #f1f1f1;
136
+ }
137
+ .widefat thead tr th{
138
+ color: #666;
139
+ }
140
+ .widefat td, .widefat th {
141
+ border-bottom: 1px solid #f1f1f1;
142
+ border-right: 1px solid #f1f1f1;
143
+ overflow: visible !important;
144
+ }
145
+ .widefat th {
146
+ font-weight: bold !important;
147
+ font-size: 13px !important;
148
+ }
149
+ .widefat > tbody > tr:hover {
150
+ background-color: #f9f9f9;
151
+ }
152
+ .widefat td, .widefat td ol, .widefat td p, .widefat td ul {
153
+ line-height: 1.5em !important;
154
+ }
155
+ .widefat tbody th.check-column, .widefat tfoot td.check-column, .widefat thead td.check-column {
156
+ padding: 9px 0 5px 3px !important;
157
+ }
158
+ .widefat th input, .widefat thead td input{
159
+ margin: 1px 0 0 8px !important;
160
+ }
161
+ /* This style is used by WP tables (WP_List_Table class) for columns, it is not used directly in the code */
162
+ .column-site_id{
163
+ width: 40px;
164
+ }
165
+ .column-o_table_prefix{
166
+ width: 12%;
167
+ }
168
+ .column-o_table_name{
169
+ /*width: 27%;*/
170
+ }
171
+ .column-o_table_name{
172
+ /*width: 27%;*/
173
+ }
174
+ .column-lost_space{
175
+ border-right: 0 none !important;
176
+ width: 15%;
177
+ }
178
+ .column-option_value{
179
+ width: 27%;
180
+ }
181
+ .column-option_autoload{
182
+ width: 8%;
183
+ }
184
+ .column-option_belongs_to{
185
+ width: 25%;
186
+ }
187
+ .column-hook_name{
188
+ width: 30%;
189
+ }
190
+ .column-next_run{
191
+ width: 30%;
192
+ font-size: 12px !important;
193
+ }
194
+ .column-hook_belongs_to{
195
+ /*width: 32%;*/
196
+ }
197
+ .column-table_prefix{
198
+ width: 7%;
199
+ }
200
+ .column-table_name{
201
+ /*width: 100%;*/
202
+ }
203
+ .column-table_rows{
204
+ width: 7%;
205
+ }
206
+ .column-table_size{
207
+ width: 10%;
208
+ }
209
+ .column-table_belongs_to{
210
+ width: 24%;
211
+ font-size: 13px !important;
212
+ border-right: 0 none !important;
213
+ }
214
+ .column-view{
215
+ border-right: 0 none !important;
216
+ width: 20%;
217
+ text-align: center;
218
+ }
219
+ #view,
220
+ #count{
221
+ text-align: center;
222
+ }
223
+ .column-count{
224
+ width: 20%;
225
+ text-align: center;
226
+ }
227
+ .column-draft_id,
228
+ .column-revision_id{
229
+ width: 8%;
230
+ }
231
+ .column-draft_date,
232
+ .column-revision_date{
233
+ width: 20%;
234
+ }
235
+ .column-comment_id{
236
+ width: 6%;
237
+ }
238
+ .column-comment_author{
239
+ width: 14%;
240
+ }
241
+ .column-comment_date{
242
+ width: 18%;
243
+ }
244
+ .column-commentmeta_id,
245
+ .column-postmeta_id{
246
+ width: 6%;
247
+ }
248
+ .column-commentmeta_meta_key,
249
+ .column-postmeta_meta_key{
250
+ width: 22%;
251
+ }
252
+ .column-commentmeta_meta_value{
253
+ font-size: 12px !important;
254
+ }
255
+ .column-dash_feed_option_id{
256
+ width: 10%;
257
+ }
258
+ .column-dash_feed_autoload{
259
+ width: 12%;
260
+ }
261
+ /* To hide tfoot from tables used in the plugin */
262
+ .widefat tfoot {
263
+ display: none;
264
+ }
265
+ /* To add a space between pagination and the head of tables */
266
+ .tablenav {
267
+ margin: 8px 0 12px !important;
268
+ }
269
+ /* To color rows of tables in white */
270
+ .alternate, .striped > tbody > *:nth-child(2n), ul.striped > *:nth-child(2n) {
271
+ background-color: #fff;
272
+ }
273
+ .alternate, .striped > tbody > *:nth-child(2n+1), ul.striped > *:nth-child(2n+1) {
274
+ background-color: #fefefe;
275
+ }
276
+ /* For paginations of tables */
277
+ .tablenav-pages-navspan {
278
+ border-radius: 5px;
279
+ -moz-border-radius: 5px;
280
+ -webkit-border-radius: 5px;
281
+ }
282
+ .tablenav .tablenav-pages a, .tablenav-pages-navspan {
283
+ border-radius: 5px;
284
+ -moz-border-radius: 5px;
285
+ -webkit-border-radius: 5px;
286
+ }
287
+ .tablenav-pages .current-page {
288
+ border-radius: 5px;
289
+ -moz-border-radius: 5px;
290
+ -webkit-border-radius: 5px;
291
+ }
292
+ .displaying-num{
293
+ display: none !important;
294
+ }
295
+ /* For tabs */
296
+ h2.nav-tab-wrapper {
297
+ border-bottom: 0px !important;
298
+ padding-bottom: 0 !important;
299
+ padding-left: 0px !important;
300
+ }
301
+ h2 .nav-tab {
302
+ font-size: 13px;
303
+ line-height: 24px;
304
+ font-weight: normal;
305
+ padding: 4px 10px !important;
306
+ border-radius: 5px 5px 0 0;
307
+ -moz-border-radius: 5px 5px 0 0;
308
+ -webkit-border-radius: 5px 5px 0 0;
309
+ }
310
+ .nav-tab-active, .nav-tab-active:hover {
311
+ background: #fff;
312
+ font-weight: bold !important;
313
+ border-bottom: 0px;
314
+ color: #000;
315
+ border-top: 2px solid #1a9ac9;
316
+ color: #0073aa;
317
+ }
318
+ /*---------------------------------------------------------------------------------------------
319
+ *
320
+ * Tabs
321
+ *
322
+ *---------------------------------------------------------------------------------------------*/
323
+ .aDBc-tab-box {
324
+ float: left;
325
+ width: 100%;
326
+ }
327
+ .aDBc-tab-box-div {
328
+ min-height: 400px;
329
+ background: #fff;
330
+ border: 1px solid #ccc;
331
+ padding: 30px 20px 20px 20px;
332
+ border-radius: 0 5px 5px 5px;
333
+ -moz-border-radius: 0 5px 5px 5px;
334
+ -webkit-border-radius: 0 5px 5px 5px;
335
+ }
336
+
337
+ /*---------------------------------------------------------------------------------------------
338
+ *
339
+ * Sidebar
340
+ *
341
+ *---------------------------------------------------------------------------------------------*/
342
+ .aDBc-sidebar {
343
+ float: right;
344
+ border: 1px solid #ccc;
345
+ background: #fff;
346
+ margin-right: -260px;
347
+ margin-top: 42px;
348
+ width: 240px;
349
+ border-radius: 5px 5px 0 0;
350
+ -moz-border-radius: 5px 5px 0 0;
351
+ -webkit-border-radius: 5px 5px 0 0;
352
+ }
353
+ .aDBc-sidebar > div{
354
+ padding: 15px;
355
+ }
356
+ .aDBc-sidebar h2{
357
+ font-size: 16px;
358
+ text-align: center;
359
+ color: #888;
360
+ line-height: 24px;
361
+ }
362
+ .aDBc-donation-text{
363
+ text-align:center;
364
+ color: #555
365
+ }
366
+ .aDBc-donation-gif{
367
+ background: url("../images/donate.gif") no-repeat;
368
+ width: 92px;
369
+ height: 26px;
370
+ margin: auto;
371
+ }
372
+ .aDBc-grey-row{
373
+ height: 20px;
374
+ background-color: #f9f9f9;
375
+ }
376
+ .aDBc-white-row{
377
+ height: 20px;
378
+ }
379
+ .aDBc-row-text{
380
+ font-size: 13px;
381
+ color: #555;
382
+ }
383
+ .aDBc-sidebar-link{
384
+ text-decoration: none;
385
+ }
386
+ .aDBc-support-us{
387
+ background: url("../images/rate.png") no-repeat center right;
388
+ width: 88px;
389
+ height: 18px;
390
+ margin-top: 0px;
391
+ }
392
+
393
+ /*---------------------------------------------------------------------------------------------
394
+ *
395
+ * Box messages
396
+ *
397
+ *---------------------------------------------------------------------------------------------*/
398
+ .aDBc-box-warning {
399
+ background: #fff5cc url("../images/warning.png") no-repeat scroll 8px 50%;
400
+ /*border-bottom: 1px dashed orange;*/
401
+ color: #404040;
402
+ padding: 10px 10px 10px 40px;
403
+ margin-bottom: 20px;
404
+ }
405
+ .aDBc-box-info {
406
+ background: #f0f5fa url("../images/info.png") no-repeat scroll 8px 50%;
407
+ border-bottom: 1px dashed #ccc;
408
+ color: #404040;
409
+ padding: 10px 10px 10px 40px;
410
+ margin-bottom: 20px;
411
+ }
412
+ .aDBc-right-box{
413
+ float:left;
414
+ padding: 20px 20px 20px 20px;
415
+ margin-bottom: 5px;
416
+ margin-top: 49px;
417
+ border: 1px solid #eee;
418
+ background: #f9f9f9;
419
+ border-radius: 4px;
420
+ -moz-border-radius: 4px;
421
+ -webkit-border-radius: 4px;
422
+ font-size: 12px;
423
+ color: #888;
424
+ }
425
+ .aDBc-jquery-dialog{
426
+ padding:20px;
427
+ display:none;
428
+ }
429
+
430
+ /*---------------------------------------------------------------------------------------------
431
+ *
432
+ * Tool tip
433
+ *
434
+ *---------------------------------------------------------------------------------------------*/
435
+ a.aDBc-tooltips {
436
+ position: relative;
437
+ display: inline;
438
+ cursor: pointer;
439
+ }
440
+ a.aDBc-tooltips span {
441
+ position: absolute;
442
+ color: #fff;
443
+ background: #333;
444
+ font-size: 12px;
445
+ font-weight: normal;
446
+ padding: 8px;
447
+ visibility: hidden;
448
+ width: 200px;
449
+ text-shadow: 0 0px 0 rgba(255, 255, 255, 0.8);
450
+ }
451
+ a.aDBc-tooltips span:after {
452
+ content: '';
453
+ position: absolute;
454
+ top: 18px;
455
+ right: 100%;
456
+ margin-top: -8px;
457
+ width: 0; height: 0;
458
+ border-right: 8px solid #333;
459
+ border-top: 8px solid transparent;
460
+ border-bottom: 8px solid transparent;
461
+ }
462
+ a:hover.aDBc-tooltips span {
463
+ visibility: visible;
464
+ opacity: 0.9;
465
+ left: 100%;
466
+ top: 50%;
467
+ margin-top: -20.5px;
468
+ margin-left: 15px;
469
+ z-index: 999;
470
+ }
471
+
472
+ /*---------------------------------------------------------------------------------------------
473
+ *
474
+ * Premium page style
475
+ *
476
+ *---------------------------------------------------------------------------------------------*/
477
+ .aDBc-upgrade-msg{
478
+ border-left: 6px solid #D091BE !important;
479
+ background: #FFFFD4;
480
+ padding: 1px 8px;
481
+ margin-bottom: 20px;
482
+ }
483
+ .aDBc-check-list{
484
+ background: url("../images/check_ok.png") no-repeat;
485
+ padding-left: 20px;
486
+ margin-left: 20px;
487
+ }
488
+ .aDBc-vertical-box{
489
+ float: left;
490
+ background: #f9f9f9;
491
+ width: 28%;
492
+ margin:5px 15px;
493
+ min-height: 350px;
494
+ }
495
+ .aDBc-vertical-box > a{
496
+ text-decoration: none;
497
+ }
498
+ .aDBc-vertical-box-head{
499
+ color: #fff;
500
+ font-size: 15px;
501
+ font-weight: bold;
502
+ text-align: center;
503
+ padding: 12px;
504
+ background: #69ADE2;
505
+ border-radius: 8px;
506
+ }
507
+ .aDBc-vertical-box-line1{
508
+ text-align: center;
509
+ margin-top: 20px;
510
+ }
511
+ .aDBc-vertical-box-line2{
512
+ text-align: center;
513
+ margin-top: 50px;
514
+ }
515
+
516
+ /*---------------------------------------------------------------------------------------------
517
+ *
518
+ * Overview & settings page
519
+ *
520
+ *---------------------------------------------------------------------------------------------*/
521
+ .aDBc-overview-box{
522
+ float: left;
523
+ margin: 15px 20px 20px 10px;
524
+ width: 45%;
525
+ background: #fff;
526
+ }
527
+ .aDBc-overview-box-head{
528
+ text-align: center;
529
+ color: #fff;
530
+ font-size: 14px;
531
+ font-weight: bold;
532
+ padding: 7px 0px;
533
+ background: #69ADE2;
534
+ border: 1px solid #e1e1e1;
535
+ margin-bottom: 20px;
536
+ }
537
+ .aDBc-overview-box-line{
538
+ margin-left: 15px;
539
+ }
540
+ .aDBc-overview-box-line > li{
541
+ line-height: 32px;
542
+ }
543
+ .aDBc-overview-text-left{
544
+ float: left;
545
+ background: url("../images/check_ok.png") no-repeat left center;
546
+ padding-left: 30px;
547
+ width: 180px;
548
+ }
549
+ .aDBc-overview-text-left-warning{
550
+ float: left;
551
+ background: url("../images/small_warning.png") no-repeat left center;
552
+ padding-left: 30px;
553
+ width: 180px;
554
+ }
555
+ .aDBc-overview-text-right{
556
+ float: left;
557
+ }
558
+ .aDBc-overview-setting-desc{
559
+ padding-left: 24px;
560
+ color: #999;
561
+ line-height: 20px;
562
+ }
563
+ .aDBc-save-settings-button{
564
+ margin-left: 18px !important;
565
+ height: 30px !important;
566
+ padding: 1px 20px !important;
567
+ margin-top: 10px !important;
568
+ }
css/style.css DELETED
@@ -1,227 +0,0 @@
1
- /* ---------------------*/
2
- /* --- Global styles ---*/
3
- /* ---------------------*/
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
- /* ---------------------*/
23
- .tabBox {
24
- border-radius: 4px;
25
- margin: 10px 0 40px 0;
26
- float: left;
27
- width: 100%;
28
- }
29
- .tabBox > input[type="radio"] {
30
- position: absolute;
31
- left:-100px;
32
- top:-100px;
33
- }
34
- .tabBox > input[type="radio"] + label {
35
- display: inline-block;
36
- border: 1px solid #DEDBD1;
37
- border-radius: 5px 5px 0 0;
38
- -moz-border-radius: 5px 5px 0 0;
39
- -webkit-border-radius: 5px 5px 0 0;
40
- border-bottom: 0;
41
- padding: 6px 10px;
42
- background-color:#ddd;
43
- color: #111;
44
- font-size: 13px;
45
- }
46
- .tabBox > input[type="radio"]:checked + label {
47
- background-color:white;
48
- font-weight: bold;
49
- margin-bottom: -1px;
50
- color: #0073aa;
51
- border-top: 1px solid #1A9AC9;
52
- }
53
- .tabBox > div {
54
- display: none;
55
- border: 1px solid #DEDBD1;
56
- background-color: white;
57
- padding: 10px 20px 10px 20px;
58
- height: auto;
59
- overflow: auto;
60
- margin-top: -1px;
61
- border-radius: 0 5px 5px 5px;
62
- -moz-border-radius: 0 5px 5px 5px;
63
- -webkit-border-radius: 0 5px 5px 5px;
64
- }
65
- #aDBc-clean:checked ~ .tab1, #aDBc-optimize:checked ~ .tab2, #aDBc-cron:checked ~ .tab3, #aDBc-reset:checked ~ .tab4{
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;
85
- }
86
- .squaredFour label {
87
- cursor: pointer;
88
- position: absolute;
89
- width: 16px;
90
- height: 16px;
91
- top: 0;
92
- border-radius: 4px;
93
- border: 1px solid #999;
94
- background: #fcfff4;
95
- }
96
- .squaredFour label:after {
97
- -ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=0)";
98
- filter: alpha(opacity=0);
99
- opacity: 0;
100
- content: '';
101
- position: absolute;
102
- width: 7px;
103
- height: 4px;
104
- background: transparent;
105
- top: 4px;
106
- left: 4px;
107
- border: 2px solid #71ADE1;
108
- border-top: none;
109
- border-right: none;
110
- -webkit-transform: rotate(-45deg);
111
- -moz-transform: rotate(-45deg);
112
- -o-transform: rotate(-45deg);
113
- -ms-transform: rotate(-45deg);
114
- transform: rotate(-45deg);
115
- }
116
- .squaredFour label:hover::after {
117
- -ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=30)";
118
- filter: alpha(opacity=30);
119
- opacity: 0.3;
120
- }
121
- .squaredFour input[type=checkbox]:checked + label:after {
122
- -ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=100)";
123
- filter: alpha(opacity=100);
124
- opacity: 1;
125
- }
126
- /* ---------------------------------*/
127
- /* ------------ Sidebar ------------*/
128
- /* ---------------------------------*/
129
- .aDBcSidebar {
130
- float:right;
131
- border: 1px solid #ccc;
132
- background: #fff;
133
- margin-right: -300px;
134
- margin-top:44px;
135
- width: 280px;
136
- border-radius: 5px 5px 0 0;
137
- -moz-border-radius: 5px 5px 0 0;
138
- -webkit-border-radius: 5px 5px 0 0;
139
- }
140
- .aDBcSidebar > div{
141
- padding: 15px;
142
- }
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;
155
- -webkit-border-radius: 5px;
156
- background: #fff5cc url("../images/warning.png") no-repeat scroll 8px 50%;
157
- border-color: #f2dd8c;
158
- color: #404040;
159
- padding: 10px 10px 10px 50px;
160
- margin-top: 20px;
161
- }
162
- .box-info {
163
- border-radius: 5px;
164
- -moz-border-radius: 5px;
165
- -webkit-border-radius: 5px;
166
- background: #e1f1ff url("../images/info.png") no-repeat scroll 8px 50%;
167
- border-color: #a3d4ff;
168
- color: #404040;
169
- padding: 10px 10px 10px 60px;
170
- margin-top: 20px;
171
- }
172
- .aDBC-topBoxInfo {
173
- clear:both;
174
- border-radius: 5px;
175
- -moz-border-radius: 5px;
176
- -webkit-border-radius: 5px;
177
- background: #F0F5FA url("../images/info.png") no-repeat scroll 8px 50%;
178
- color: #888;
179
- margin-bottom: 25px;
180
- padding: 10px 10px 10px 40px;
181
- max-width: 730px;
182
- }
183
- .aDBCRightBox{
184
- padding:20px 0px 20px 0px;
185
- margin-bottom:5px;
186
- background:#fff;
187
- width:300px;
188
- font-size: 12px;
189
- text-align:justify;
190
- color: #888;
191
- }
192
- /* ---------------------------------*/
193
- /* ------------ Tooltip ------------*/
194
- /* ---------------------------------*/
195
- a.tooltips {
196
- position: relative;
197
- display: inline;
198
- }
199
- a.tooltips span {
200
- position: absolute;
201
- width:400px;
202
- color: #f2f2f2;
203
- background: #000000;
204
- padding:10px;
205
- visibility: hidden;
206
- border-radius: 5px;
207
- }
208
- a.tooltips span:after {
209
- content: '';
210
- position: absolute;
211
- top: 18px;
212
- right: 100%;
213
- margin-top: -8px;
214
- width: 0; height: 0;
215
- border-right: 8px solid #000000;
216
- border-top: 8px solid transparent;
217
- border-bottom: 8px solid transparent;
218
- }
219
- a:hover.tooltips span {
220
- visibility: visible;
221
- opacity: 0.9;
222
- left: 100%;
223
- top: 50%;
224
- margin-top: -20.5px;
225
- margin-left: 15px;
226
- z-index: 999;
227
- }
images/about.png DELETED
Binary file
images/check_ok.png ADDED
Binary file
images/db_clean.png CHANGED
Binary file
images/db_not_clean.png CHANGED
Binary file
images/features.png ADDED
Binary file
images/go_back.png ADDED
Binary file
images/help.png ADDED
Binary file
images/loading_img.gif ADDED
Binary file
images/menu-icon.png ADDED
Binary file
images/nothing_to_see.png ADDED
Binary file
images/notice.png ADDED
Binary file
images/order_now.png ADDED
Binary file
images/premium_ok.png ADDED
Binary file
images/search-icon.png ADDED
Binary file
images/see.png ADDED
Binary file
images/small_warning.png ADDED
Binary file
includes/class_clean_cron.php ADDED
@@ -0,0 +1,256 @@
1
+ <?php
2
+
3
+ class ADBC_Tasks_List extends WP_List_Table {
4
+
5
+ /** Holds the message to be displayed if any */
6
+ private $aDBc_message = "";
7
+
8
+ /** Holds the class for the message : updated or error. Default is updated */
9
+ private $aDBc_class_message = "updated";
10
+
11
+ /** Holds tasks that will be displayed */
12
+ private $aDBc_tasks_to_display = array();
13
+
14
+ /** Holds counts + info of tasks categories */
15
+ private $aDBc_tasks_categories_info = array();
16
+
17
+ function __construct(){
18
+ parent::__construct(array(
19
+ 'singular' => __('Task', 'advanced-database-cleaner'), //singular name of the listed records
20
+ 'plural' => __('Tasks', 'advanced-database-cleaner'), //plural name of the listed records
21
+ 'ajax' => false //does this table support ajax?
22
+ ));
23
+ if(isset($_POST['aDBc_new_search_button']) && $_GET['aDBc_cat'] == "all"){
24
+ $this->aDBc_message = __('This feature is available in Pro version only.', 'advanced-database-cleaner');
25
+ $this->aDBc_message .= " <a href='?page=advanced_db_cleaner&aDBc_tab=premium'>" . __('Please upgrade to pro version', 'advanced-database-cleaner') . "</a>";
26
+ $this->aDBc_class_message = "aDBc-upgrade-msg";
27
+ }
28
+ $this->aDBc_prepare_and_count_tasks();
29
+ $this->aDBc_print_page_content();
30
+ }
31
+
32
+ /** Prepare tasks to display and count tasks for each category */
33
+ function aDBc_prepare_and_count_tasks(){
34
+
35
+ // Process bulk action if any before preparing tasks to display
36
+ if(!isset($_POST['aDBc_new_search_button'])){
37
+ $this->process_bulk_action();
38
+ }
39
+
40
+ // Prepare data
41
+ aDBc_prepare_items_to_display($this->aDBc_tasks_to_display, $this->aDBc_tasks_categories_info, "tasks");
42
+
43
+ // Call WP prepare_items function
44
+ $this->prepare_items();
45
+ }
46
+
47
+ /** WP: Get columns */
48
+ function get_columns(){
49
+ $aDBc_belongs_to_toolip = "<a class='aDBc-tooltips'>
50
+ <img class='aDBc-margin-l-3' src='". ADBC_PLUGIN_DIR_PATH . '/images/notice.png' . "'/>
51
+ <span>" . __('Indicates the creator of the cron task. It can be a plugin name, a theme name or WordPress itself.','advanced-database-cleaner') ." </span>
52
+ </a>";
53
+ $columns = array(
54
+ 'cb' => '<input type="checkbox" />',
55
+ 'hook_name' => __('Hook name','advanced-database-cleaner'),
56
+ 'next_run' => __('Next run - Frequency','advanced-database-cleaner'),
57
+ 'site_id' => __('Site id','advanced-database-cleaner'),
58
+ 'hook_belongs_to' => __('Belongs to','advanced-database-cleaner') . $aDBc_belongs_to_toolip
59
+ );
60
+ return $columns;
61
+ }
62
+
63
+ /** WP: Prepare items to display */
64
+ function prepare_items() {
65
+ $columns = $this->get_columns();
66
+ $hidden = $this->get_hidden_columns();
67
+ $sortable = array();
68
+ $this->_column_headers = array($columns, $hidden, $sortable);
69
+ $per_page = 50;
70
+ $current_page = $this->get_pagenum();
71
+ // Prepare sequence of options to display
72
+ $display_data = array_slice($this->aDBc_tasks_to_display,(($current_page-1) * $per_page), $per_page);
73
+ $this->set_pagination_args( array(
74
+ 'total_items' => count($this->aDBc_tasks_to_display),
75
+ 'per_page' => $per_page
76
+ ));
77
+ $this->items = $display_data;
78
+ }
79
+
80
+ /** WP: Get columns that should be hidden */
81
+ function get_hidden_columns(){
82
+ // If MU, nothing to hide, else hide Side ID column
83
+ if(function_exists('is_multisite') && is_multisite()){
84
+ return array();
85
+ }else{
86
+ return array('site_id');
87
+ }
88
+ }
89
+
90
+ /** WP: Column default */
91
+ function column_default($item, $column_name){
92
+ switch($column_name){
93
+ case 'hook_name':
94
+ case 'next_run':
95
+ case 'site_id':
96
+ case 'hook_belongs_to':
97
+ return $item[$column_name];
98
+ default:
99
+ return print_r($item, true) ; //Show the whole array for troubleshooting purposes
100
+ }
101
+ }
102
+
103
+ /** WP: Column cb for check box */
104
+ function column_cb($item) {
105
+ return sprintf('<input type="checkbox" name="aDBc_tasks_to_delete[]" value="%s" />', $item['site_id']."|".$item['hook_name']);
106
+ }
107
+
108
+ /** WP: Get bulk actions */
109
+ function get_bulk_actions() {
110
+ $actions = array(
111
+ 'delete' => __('Delete','advanced-database-cleaner')
112
+ );
113
+ return $actions;
114
+ }
115
+
116
+ /** WP: Message to display when no items found */
117
+ function no_items() {
118
+ if($_GET['aDBc_cat'] == "all"){
119
+ _e('No tasks found!','advanced-database-cleaner');
120
+ }else{
121
+ _e('Available in Pro version!', 'advanced-database-cleaner');
122
+ }
123
+ }
124
+
125
+ /** WP: Process bulk actions */
126
+ public function process_bulk_action() {
127
+ // security check!
128
+ if (isset($_POST['_wpnonce']) && !empty($_POST['_wpnonce'])){
129
+ $nonce = filter_input(INPUT_POST, '_wpnonce', FILTER_SANITIZE_STRING);
130
+ $action = 'bulk-' . $this->_args['plural'];
131
+ if (!wp_verify_nonce( $nonce, $action))
132
+ wp_die('Security check failed!');
133
+ }
134
+ $action = $this->current_action();
135
+
136
+ if($action == 'delete'){
137
+ // If the user wants to clean the tasks he/she selected
138
+ if(isset($_POST['aDBc_tasks_to_delete'])){
139
+ if(function_exists('is_multisite') && is_multisite()){
140
+ // Prepare tasks to delete in organized array to minimize switching from blogs
141
+ $tasks_to_delete = array();
142
+ foreach($_POST['aDBc_tasks_to_delete'] as $task){
143
+ $task_info = explode("|", $task);
144
+ if(empty($tasks_to_delete[$task_info[0]])){
145
+ $tasks_to_delete[$task_info[0]] = array();
146
+ }
147
+ array_push($tasks_to_delete[$task_info[0]], $task_info[1]);
148
+ }
149
+ // Delete tasks
150
+ foreach($tasks_to_delete as $site_id => $tasks){
151
+ switch_to_blog($site_id);
152
+ foreach($tasks as $task) {
153
+ wp_clear_scheduled_hook($task);
154
+ }
155
+ restore_current_blog();
156
+ }
157
+ }else{
158
+ foreach($_POST['aDBc_tasks_to_delete'] as $task) {
159
+ $aDBc_cron_info = explode("|", $task);
160
+ wp_clear_scheduled_hook($aDBc_cron_info[1]);
161
+ }
162
+ }
163
+ // Update the message to show to the user
164
+ $this->aDBc_message = __('Selected scheduled tasks cleaned successfully!', 'advanced-database-cleaner');
165
+ }
166
+ }
167
+ }
168
+
169
+ /** Print the page content */
170
+ function aDBc_print_page_content(){
171
+ // Print a message if any
172
+ if($this->aDBc_message != ""){
173
+ echo '<div id="aDBc_message" class="' . $this->aDBc_class_message . ' notice is-dismissible"><p>' . $this->aDBc_message . '</p></div>';
174
+ }
175
+ ?>
176
+ <div class="aDBc-content-max-width">
177
+ <form id="aDBc_form" action="" method="post">
178
+ <?php
179
+ $aDBc_new_URI = $_SERVER['REQUEST_URI'];
180
+ // Remove the paged parameter to start always from the first page when selecting a new category of tasks
181
+ $aDBc_new_URI = remove_query_arg('paged', $aDBc_new_URI);
182
+ ?>
183
+ <!-- Print numbers of tasks found in each category -->
184
+ <div class="aDBc-category-counts">
185
+ <?php
186
+ $iterations = 0;
187
+ foreach($this->aDBc_tasks_categories_info as $abreviation => $category_info){
188
+ $iterations++;
189
+ $aDBc_new_URI = add_query_arg('aDBc_cat', $abreviation, $aDBc_new_URI);?>
190
+ <span class="<?php echo $abreviation == $_GET['aDBc_cat'] ? 'aDBc-selected-category' : ''?>" style="<?php echo $abreviation == $_GET['aDBc_cat'] ? 'border-bottom: 1px solid ' . $category_info['color'] : '' ?> ">
191
+ <a href="<?php echo $aDBc_new_URI; ?>" class="aDBc-category-counts-links" style="color:<?php echo $category_info['color']; ?>">
192
+ <span class="aDBc-category-color" style="background: <?php echo $category_info['color']; ?>"></span>
193
+ <span><?php echo $category_info['name']; ?> : </span>
194
+ <span><?php echo $category_info['count'];?></span>
195
+ </a>
196
+ </span>
197
+ <?php
198
+ if($iterations < 5){
199
+ echo '<span class="aDBc-category-separator"></span>';
200
+ }
201
+ }?>
202
+ </div>
203
+
204
+ <div class="aDBc-clear-both"></div>
205
+
206
+ <!-- Code for "run new search" button + Show loading image -->
207
+ <div class="aDBc-margin-t-20">
208
+ <input id="aDBc_new_search_button" type="submit" class="button-primary aDBc-run-new-search" value="<?php _e('Detect orphan tasks','advanced-database-cleaner'); ?>" name="aDBc_new_search_button"/>
209
+
210
+ <div id="aDBc-please-wait">
211
+ <div class="aDBc-loading-gif"></div>
212
+ <?php
213
+ //_e('Searching...Please wait! If your browser stops loading without refreshing, please refresh this page.','advanced-database-cleaner');
214
+ _e('Please wait!','advanced-database-cleaner');
215
+ ?>
216
+ </div>
217
+ </div>
218
+
219
+ <div class="aDBc-clear-both aDBc-margin-b-20"></div>
220
+
221
+ <!-- Print a notice/warning according to each type of tasks -->
222
+ <?php
223
+ if($_GET['aDBc_cat'] == 'all' && $this->aDBc_tasks_categories_info['all']['count'] > 0){
224
+ echo '<div class="aDBc-box-warning">' . __('Below the list of all your scheduled tasks. Please do not delete any task unless you really know what you are doing!','advanced-database-cleaner') . '</div>';
225
+ }
226
+
227
+ if($_GET['aDBc_cat'] != 'all'){
228
+ echo '<div class="aDBc-upgrade-msg notice is-dismissible"><p>' . __('This feature is available in Pro version only.', 'advanced-database-cleaner') . ' <a href="?page=advanced_db_cleaner&aDBc_tab=premium">' . __('Please upgrade to pro version', 'advanced-database-cleaner') . "</a>" . '</p></div>';
229
+ }
230
+
231
+ // Print the tasks
232
+ $this->display();
233
+
234
+ ?>
235
+ </form>
236
+ </div>
237
+ <div id="aDBc_dialog1" title="<?php _e('Cleaning...','advanced-database-cleaner'); ?>" class="aDBc-jquery-dialog">
238
+ <p class="aDBc-box-warning">
239
+ <?php _e('You are about to clean some of your scheduled tasks. This operation is irreversible. Don\'t forget to make a backup first.','advanced-database-cleaner'); ?>
240
+ </p>
241
+ <p>
242
+ <?php _e('Are you sure to continue?','advanced-database-cleaner'); ?>
243
+ </p>
244
+ </div>
245
+ <div id="aDBc_dialog2" title="<?php _e('Action required','advanced-database-cleaner'); ?>" class="aDBc-jquery-dialog">
246
+ <p class="aDBc-box-info">
247
+ <?php _e('Please select an action!','advanced-database-cleaner'); ?>
248
+ </p>
249
+ </div>
250
+ <?php
251
+ }
252
+ }
253
+
254
+ new ADBC_Tasks_List();
255
+
256
+ ?>
includes/class_clean_options.php ADDED
@@ -0,0 +1,258 @@
1
+ <?php
2
+
3
+ class ADBC_Options_List extends WP_List_Table {
4
+
5
+ /** Holds the message to be displayed if any */
6
+ private $aDBc_message = "";
7
+
8
+ /** Holds the class for the message : updated or error. Default is updated */
9
+ private $aDBc_class_message = "updated";
10
+
11
+ /** Holds options that will be displayed */
12
+ private $aDBc_options_to_display = array();
13
+
14
+ /** Holds counts + info of options categories */
15
+ private $aDBc_options_categories_info = array();
16
+
17
+ function __construct(){
18
+ parent::__construct(array(
19
+ 'singular' => __('Option', 'advanced-database-cleaner'), //singular name of the listed records
20
+ 'plural' => __('Options', 'advanced-database-cleaner'), //plural name of the listed records
21
+ 'ajax' => false //does this table support ajax?
22
+ ));
23
+ if(isset($_POST['aDBc_new_search_button']) && $_GET['aDBc_cat'] == "all"){
24
+ $this->aDBc_message = __('This feature is available in Pro version only.', 'advanced-database-cleaner');
25
+ $this->aDBc_message .= " <a href='?page=advanced_db_cleaner&aDBc_tab=premium'>" . __('Please upgrade to pro version', 'advanced-database-cleaner') . "</a>";
26
+ $this->aDBc_class_message = "aDBc-upgrade-msg";
27
+ }
28
+ $this->aDBc_prepare_and_count_options();
29
+ $this->aDBc_print_page_content();
30
+ }
31
+
32
+ /** Prepare options to display and count options for each category */
33
+ function aDBc_prepare_and_count_options(){
34
+
35
+ // Process bulk action if any before preparing options to display
36
+ if(!isset($_POST['aDBc_new_search_button'])){
37
+ $this->process_bulk_action();
38
+ }
39
+
40
+ // Prepare data
41
+ aDBc_prepare_items_to_display($this->aDBc_options_to_display, $this->aDBc_options_categories_info, "options");
42
+
43
+ // Call WP prepare_items function
44
+ $this->prepare_items();
45
+ }
46
+
47
+ /** WP: Get columns */
48
+ function get_columns(){
49
+ $aDBc_belongs_to_toolip = "<a class='aDBc-tooltips'>
50
+ <img class='aDBc-margin-l-3' src='". ADBC_PLUGIN_DIR_PATH . '/images/notice.png' . "'/>
51
+ <span>" . __('Indicates the creator of the option. It can be a plugin name, a theme name or WordPress itself.','advanced-database-cleaner') ." </span>
52
+ </a>";
53
+ $columns = array(
54
+ 'cb' => '<input type="checkbox" />',
55
+ 'option_name' => __('Option name','advanced-database-cleaner'),
56
+ 'option_value' => __('Value','advanced-database-cleaner'),
57
+ 'option_autoload' => __('Autoload','advanced-database-cleaner'),
58
+ 'site_id' => __('Site id','advanced-database-cleaner'),
59
+ 'option_belongs_to' => __('Belongs to','advanced-database-cleaner') . $aDBc_belongs_to_toolip
60
+ );
61
+ return $columns;
62
+ }
63
+
64
+ /** WP: Prepare items to display */
65
+ function prepare_items() {
66
+ $columns = $this->get_columns();
67
+ $hidden = $this->get_hidden_columns();
68
+ $sortable = array();
69
+ $this->_column_headers = array($columns, $hidden, $sortable);
70
+ $per_page = 50;
71
+ $current_page = $this->get_pagenum();
72
+ // Prepare sequence of options to display
73
+ $display_data = array_slice($this->aDBc_options_to_display,(($current_page-1) * $per_page), $per_page);
74
+ $this->set_pagination_args( array(
75
+ 'total_items' => count($this->aDBc_options_to_display),
76
+ 'per_page' => $per_page
77
+ ));
78
+ $this->items = $display_data;
79
+ }
80
+
81
+ /** WP: Get columns that should be hidden */
82
+ function get_hidden_columns(){
83
+ // If MU, nothing to hide, else hide Side ID column
84
+ if(function_exists('is_multisite') && is_multisite()){
85
+ return array();
86
+ }else{
87
+ return array('site_id');
88
+ }
89
+ }
90
+
91
+ /** WP: Column default */
92
+ function column_default($item, $column_name){
93
+ switch($column_name){
94
+ case 'option_name':
95
+ case 'option_value':
96
+ case 'option_autoload':
97
+ case 'site_id':
98
+ case 'option_belongs_to':
99
+ return $item[$column_name];
100
+ default:
101
+ return print_r($item, true) ; //Show the whole array for troubleshooting purposes
102
+ }
103
+ }
104
+
105
+ /** WP: Column cb for check box */
106
+ function column_cb($item) {
107
+ return sprintf('<input type="checkbox" name="aDBc_options_to_delete[]" value="%s" />', $item['site_id']."|".$item['option_name']);
108
+ }
109
+
110
+ /** WP: Get bulk actions */
111
+ function get_bulk_actions() {
112
+ $actions = array(
113
+ 'delete' => __('Delete','advanced-database-cleaner')
114
+ );
115
+ return $actions;
116
+ }
117
+
118
+ /** WP: Message to display when no items found */
119
+ function no_items() {
120
+ if($_GET['aDBc_cat'] == "all"){
121
+ _e('No tasks found!','advanced-database-cleaner');
122
+ }else{
123
+ _e('Available in Pro version!', 'advanced-database-cleaner');
124
+ }
125
+ }
126
+
127
+ /** WP: Process bulk actions */
128
+ public function process_bulk_action() {
129
+ // security check!
130
+ if (isset($_POST['_wpnonce']) && !empty($_POST['_wpnonce'])){
131
+ $nonce = filter_input(INPUT_POST, '_wpnonce', FILTER_SANITIZE_STRING);
132
+ $action = 'bulk-' . $this->_args['plural'];
133
+ if (!wp_verify_nonce( $nonce, $action))
134
+ wp_die('Security check failed!');
135
+ }
136
+ $action = $this->current_action();
137
+
138
+ if($action == 'delete'){
139
+ // If the user wants to clean the options he/she selected
140
+ if(isset($_POST['aDBc_options_to_delete'])){
141
+ if(function_exists('is_multisite') && is_multisite()){
142
+ // Prepare options to delete in organized array to minimize switching from blogs
143
+ $options_to_delete = array();
144
+ foreach($_POST['aDBc_options_to_delete'] as $option){
145
+ $option_info = explode("|", $option);
146
+ if(empty($options_to_delete[$option_info[0]])){
147
+ $options_to_delete[$option_info[0]] = array();
148
+ }
149
+ array_push($options_to_delete[$option_info[0]], $option_info[1]);
150
+ }
151
+ // Delete options
152
+ foreach($options_to_delete as $site_id => $options){
153
+ switch_to_blog($site_id);
154
+ foreach($options as $option) {
155
+ delete_option($option);
156
+ }
157
+ restore_current_blog();
158
+ }
159
+ }else{
160
+ foreach($_POST['aDBc_options_to_delete'] as $option) {
161
+ $aDBc_option_info = explode("|", $option);
162
+ delete_option($aDBc_option_info[1]);
163
+ }
164
+ }
165
+ // Update the message to show to the user
166
+ $this->aDBc_message = __('Selected options cleaned successfully!', 'advanced-database-cleaner');
167
+ }
168
+ }
169
+ }