Version Description
Known issues have been fixed in both free and pro versions (timeout error, activation, scheduled tasks...) New features have been added (new items to cleanup, filter & sort items...) Readme.txt file updated.
Download this release
Release Info
Developer | symptote |
Plugin | ![]() |
Version | 3.0.0 |
Comparing to | |
See all releases |
Code changes from version 2.0.0 to 3.0.0
- LICENSE.txt +85 -0
- README.txt +171 -62
- advanced-db-cleaner.php +687 -252
- css/admin.css +510 -152
- images/add_schedule.svg +6 -0
- images/alarm-clock.svg +11 -0
- images/alert.svg +1 -0
- images/alert_delete.svg +1 -0
- images/check_ok.png +0 -0
- images/check_ok.svg +4 -0
- images/db_clean.png +0 -0
- images/db_clean.svg +2 -0
- images/db_not_clean.png +0 -0
- images/donate.gif +0 -0
- images/edit_schedule.svg +4 -0
- images/go_back.png +0 -0
- images/go_back.svg +2 -0
- images/green_clock.svg +7 -0
- images/grey_clock.svg +7 -0
- images/help.svg +70 -0
- images/icon-128x128.png +0 -0
- images/info.png +0 -0
- images/info.svg +4 -0
- images/information.svg +54 -0
- images/information2.svg +48 -0
- images/loading20px.svg +1 -0
- images/loading_img.gif +0 -0
- images/nothing_to_see.png +0 -0
- images/nothing_to_see.svg +4 -0
- images/notice.png +0 -0
- images/premium.svg +1 -0
- images/rate.png +0 -0
- images/search-icon.png +0 -0
- images/search-icon.svg +6 -0
- images/see.png +0 -0
- images/see.svg +12 -0
- images/small_warning.png +0 -0
- images/switch-off.svg +8 -0
- images/switch-on.svg +5 -0
- images/warning.png +0 -0
- images/warning.svg +2 -0
- includes/class_clean_cron.php +237 -83
- includes/class_clean_options.php +260 -77
- includes/class_clean_tables.php +479 -75
- includes/class_general_cleanup.php +243 -68
- includes/class_optimize_tables.php +0 -294
- includes/clean_db.php +44 -15
- includes/custom-clean-view/class_clean_comment.php +195 -39
- includes/custom-clean-view/class_clean_commentmeta.php +0 -136
- includes/custom-clean-view/class_clean_dashboard_transient_feed.php +0 -136
- includes/custom-clean-view/class_clean_draft_trash.php +0 -150
- includes/custom-clean-view/class_clean_meta_comment_post_user_term.php +291 -0
- includes/custom-clean-view/class_clean_postmeta.php +0 -136
- includes/custom-clean-view/class_clean_relationships.php +145 -42
- includes/custom-clean-view/class_clean_revision.php +0 -136
- includes/custom-clean-view/class_clean_revision_draft_trash.php +285 -0
- includes/custom-clean-view/class_clean_transient.php +318 -0
- includes/custom-clean-view/header_page_custom_clean.php +90 -0
- includes/custom-clean-view/page_custom_clean.php +35 -0
- includes/custom-schedule-view/class_add_cleanup_schedule.php +328 -0
- includes/custom-schedule-view/class_add_optimize_schedule.php +211 -0
- includes/custom-schedule-view/class_edit_cleanup_schedule.php +371 -0
- includes/custom-schedule-view/class_edit_optimize_schedule.php +257 -0
- includes/functions.php +1010 -119
- includes/header_page_filter.php +173 -0
- includes/license/ADBC_EDD_SL_Plugin_Updater.php +572 -0
- includes/license/adbc-edd-sample-plugin.php +379 -0
- includes/optimize_db.php +22 -0
- includes/overview_settings.php +79 -25
- includes/premium_page.php +7 -7
- includes/sidebar.php +34 -39
- index.php +1 -1
- js/admin.js +173 -5
- languages/advanced-database-cleaner.pot +1565 -0
- languages/advanced-db-cleaner.pot +0 -881
LICENSE.txt
ADDED
@@ -0,0 +1,85 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
GNU GENERAL PUBLIC LICENSE
|
2 |
+
Version 2, June 1991
|
3 |
+
|
4 |
+
Copyright (C) 1989, 1991 Free Software Foundation, Inc.
|
5 |
+
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
6 |
+
|
7 |
+
Everyone is permitted to copy and distribute verbatim copies
|
8 |
+
of this license document, but changing it is not allowed.
|
9 |
+
|
10 |
+
Preamble
|
11 |
+
|
12 |
+
The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This General Public License applies to most of the Free Software Foundation's software and to any other program whose authors commit to using it. (Some other Free Software Foundation software is covered by the GNU Lesser General Public License instead.) You can apply it to your programs, too.
|
13 |
+
|
14 |
+
When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs; and that you know you can do these things.
|
15 |
+
|
16 |
+
To protect your rights, we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute copies of the software, or if you modify it.
|
17 |
+
|
18 |
+
For example, if you distribute copies of such a program, whether gratis or for a fee, you must give the recipients all the rights that you have. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights.
|
19 |
+
|
20 |
+
We protect your rights with two steps: (1) copyright the software, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the software.
|
21 |
+
|
22 |
+
Also, for each author's protection and ours, we want to make certain that everyone understands that there is no warranty for this free software. If the software is modified by someone else and passed on, we want its recipients to know that what they have is not the original, so that any problems introduced by others will not reflect on the original authors' reputations.
|
23 |
+
|
24 |
+
Finally, any free program is threatened constantly by software patents. We wish to avoid the danger that redistributors of a free program will individually obtain patent licenses, in effect making the program proprietary. To prevent this, we have made it clear that any patent must be licensed for everyone's free use or not licensed at all.
|
25 |
+
|
26 |
+
The precise terms and conditions for copying, distribution and modification follow.
|
27 |
+
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
|
28 |
+
|
29 |
+
0. This License applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License. The "Program", below, refers to any such program or work, and a "work based on the Program" means either the Program or any derivative work under copyright law: that is to say, a work containing the Program or a portion of it, either verbatim or with modifications and/or translated into another language. (Hereinafter, translation is included without limitation in the term "modification".) Each licensee is addressed as "you".
|
30 |
+
|
31 |
+
Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running the Program is not restricted, and the output from the Program is covered only if its contents constitute a work based on the Program (independent of having been made by running the Program). Whether that is true depends on what the Program does.
|
32 |
+
|
33 |
+
1. You may copy and distribute verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and give any other recipients of the Program a copy of this License along with the Program.
|
34 |
+
|
35 |
+
You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee.
|
36 |
+
|
37 |
+
2. You may modify your copy or copies of the Program or any portion of it, thus forming a work based on the Program, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions:
|
38 |
+
|
39 |
+
a) You must cause the modified files to carry prominent notices stating that you changed the files and the date of any change.
|
40 |
+
b) You must cause any work that you distribute or publish, that in whole or in part contains or is derived from the Program or any part thereof, to be licensed as a whole at no charge to all third parties under the terms of this License.
|
41 |
+
c) If the modified program normally reads commands interactively when run, you must cause it, when started running for such interactive use in the most ordinary way, to print or display an announcement including an appropriate copyright notice and a notice that there is no warranty (or else, saying that you provide a warranty) and that users may redistribute the program under these conditions, and telling the user how to view a copy of this License. (Exception: if the Program itself is interactive but does not normally print such an announcement, your work based on the Program is not required to print an announcement.)
|
42 |
+
|
43 |
+
These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Program, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Program, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it.
|
44 |
+
|
45 |
+
Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Program.
|
46 |
+
|
47 |
+
In addition, mere aggregation of another work not based on the Program with the Program (or with a work based on the Program) on a volume of a storage or distribution medium does not bring the other work under the scope of this License.
|
48 |
+
|
49 |
+
3. You may copy and distribute the Program (or a work based on it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you also do one of the following:
|
50 |
+
|
51 |
+
a) Accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or,
|
52 |
+
b) Accompany it with a written offer, valid for at least three years, to give any third party, for a charge no more than your cost of physically performing source distribution, a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or,
|
53 |
+
c) Accompany it with the information you received as to the offer to distribute corresponding source code. (This alternative is allowed only for noncommercial distribution and only if you received the program in object code or executable form with such an offer, in accord with Subsection b above.)
|
54 |
+
|
55 |
+
The source code for a work means the preferred form of the work for making modifications to it. For an executable work, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the executable. However, as a special exception, the source code distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable.
|
56 |
+
|
57 |
+
If distribution of executable or object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place counts as distribution of the source code, even though third parties are not compelled to copy the source along with the object code.
|
58 |
+
|
59 |
+
4. You may not copy, modify, sublicense, or distribute the Program except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense or distribute the Program is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance.
|
60 |
+
|
61 |
+
5. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Program or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Program (or any work based on the Program), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Program or works based on it.
|
62 |
+
|
63 |
+
6. Each time you redistribute the Program (or any work based on the Program), the recipient automatically receives a license from the original licensor to copy, distribute or modify the Program subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties to this License.
|
64 |
+
|
65 |
+
7. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Program at all. For example, if a patent license would not permit royalty-free redistribution of the Program by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Program.
|
66 |
+
|
67 |
+
If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply and the section as a whole is intended to apply in other circumstances.
|
68 |
+
|
69 |
+
It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system, which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice.
|
70 |
+
|
71 |
+
This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License.
|
72 |
+
|
73 |
+
8. If the distribution and/or use of the Program is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Program under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License.
|
74 |
+
|
75 |
+
9. The Free Software Foundation may publish revised and/or new versions of the General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns.
|
76 |
+
|
77 |
+
Each version is given a distinguishing version number. If the Program specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of this License, you may choose any version ever published by the Free Software Foundation.
|
78 |
+
|
79 |
+
10. If you wish to incorporate parts of the Program into other free programs whose distribution conditions are different, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally.
|
80 |
+
|
81 |
+
NO WARRANTY
|
82 |
+
|
83 |
+
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
84 |
+
|
85 |
+
12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
|
README.txt
CHANGED
@@ -1,86 +1,181 @@
|
|
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 |
-
|
7 |
-
|
|
|
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 |
-
|
|
|
|
|
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 |
-
|
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
|
29 |
-
* Delete
|
|
|
|
|
|
|
|
|
30 |
* Delete orphan relationships
|
31 |
-
* Delete
|
32 |
-
*
|
33 |
-
*
|
34 |
-
*
|
35 |
-
*
|
36 |
-
*
|
37 |
-
*
|
38 |
-
*
|
39 |
-
*
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 |
-
*
|
45 |
-
*
|
46 |
-
*
|
47 |
-
*
|
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 |
-
=
|
53 |
-
|
|
|
54 |
|
55 |
== Installation ==
|
56 |
|
57 |
-
This section describes how to install the plugin
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
58 |
|
59 |
-
=
|
60 |
-
* After extraction, upload the Plugin to your `/wp-content/plugins/` directory
|
61 |
-
* Go to "Dashboard" » "Plugins" and choose 'Activate'
|
62 |
-
* The plugin page can be accessed via "Dashboard" » "Tools" » "WP DB Cleaner" or via the left menu "WP DB Cleaner"
|
63 |
|
64 |
-
|
65 |
-
*
|
66 |
-
*
|
67 |
-
*
|
68 |
-
*
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
69 |
|
70 |
== Screenshots ==
|
71 |
|
72 |
-
1.
|
73 |
-
2. View items before cleaning them (case of
|
74 |
-
3.
|
75 |
-
4.
|
76 |
-
5.
|
77 |
-
6.
|
78 |
-
7.
|
79 |
-
8.
|
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
|
@@ -88,7 +183,7 @@ This section describes how to install the plugin and get it working.
|
|
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
|
@@ -160,6 +255,9 @@ This section describes how to install the plugin and get it working.
|
|
160 |
|
161 |
== Upgrade Notice ==
|
162 |
|
|
|
|
|
|
|
163 |
= 2.0.0 =
|
164 |
New release.
|
165 |
|
@@ -169,59 +267,70 @@ New release.
|
|
169 |
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.
|
170 |
|
171 |
= Is it safe to clean my database? =
|
172 |
-
Yes, it is. We do not run any code that can break down your site or delete your posts, pages, comments, etc. However,
|
173 |
|
174 |
= What does mean "Optimize my database"? =
|
175 |
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.
|
176 |
|
177 |
= Is it safe to clean the cron (scheduled tasks)? =
|
178 |
-
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
|
179 |
|
180 |
= What does mean "Revision"? What sql code is used to clean it? =
|
181 |
WordPress stores a record (called "revision") of each saved draft or published update. This system allows you to see what changes were made in each post and page over time. However, this can lead to a lot of unnecessary overhead in your WordPress database, which consumes a lot of space. The sql query used by the plugin to clean all revisions is:
|
182 |
`DELETE FROM posts WHERE post_type = 'revision'`
|
183 |
|
184 |
-
= What does mean "Draft"? What sql code is used to clean it? =
|
185 |
-
WordPress allows you to save a post or a page without having to publish it immediately. This way you can work on it as much as you want and publish it only when it is ready. This is called a Draft. Over time, you could have multiple drafts that you will never publish and hence you can clean them. The sql query used by the plugin to clean all drafts is:
|
186 |
-
`DELETE FROM posts WHERE post_status = 'draft'`
|
187 |
-
|
188 |
= What does mean "Auto-draft"? What sql code is used to clean it? =
|
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
|
194 |
`DELETE FROM comments WHERE comment_approved = '0'`
|
195 |
|
196 |
= What does mean "Spam comment"? What sql code is used to clean it? =
|
197 |
-
It is a comment that you (or a plugin) have marked as
|
198 |
`DELETE FROM comments WHERE comment_approved = 'spam'`
|
199 |
|
200 |
= What does mean "Trash comment"? What sql code is used to clean it? =
|
201 |
A trash comment is a comment that you have deleted from your Wordpress and have been moved to the trash. A trash comment is not visible in your site and should be deleted forever. The sql query used by the plugin to clean all trash comments is:
|
202 |
`DELETE FROM comments WHERE comment_approved = 'trash'`
|
203 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
204 |
= What does mean "Orphan post meta"? What sql code is used to clean it? =
|
205 |
-
The post meta data is the information you provide to viewers about each post. This information usually includes the author of the post, when it was written (or posted), and how the author categorized that particular post. In some cases, some post meta data information
|
206 |
`DELETE pm FROM postmeta pm LEFT JOIN posts wp ON wp.ID = pm.post_id WHERE wp.ID IS NULL`
|
207 |
|
208 |
= What does mean "Orphan comment meta"? What sql code is used to clean it? =
|
209 |
The same as "Orphan post meta" with the exception that "orphan comment meta" concern comments and not posts. The sql query used by the plugin to clean all orphan comment meta is:
|
210 |
`DELETE FROM commentmeta WHERE comment_id NOT IN (SELECT comment_id FROM comments)`
|
211 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
212 |
= What does mean "Orphan relationships"? What sql code is used to clean it? =
|
213 |
Sometimes the wp_term_relationships table becomes bloated with many orphaned relationships. This happens particularly often if you’re using your site not as a blog but as some other type of content site where posts are deleted periodically. Over time, you could get thousands of term relationships for posts that no longer exist which consumes a lot of database space. The sql query used by the plugin to clean all orphan relationships is:
|
214 |
`DELETE FROM term_relationships WHERE term_taxonomy_id=1 AND object_id NOT IN (SELECT id FROM posts)`
|
215 |
|
216 |
-
= What does mean "
|
217 |
-
|
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
|
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.
|
1 |
=== Advanced Database Cleaner ===
|
2 |
Contributors: symptote
|
3 |
Donate Link: https://www.sigmaplugin.com/donation
|
4 |
+
Tags: clean, clean up, cleanup, database, optimize, performance, speed, optimizing, clean-up, orphan, orphaned, tables, options
|
5 |
Requires at least: 3.1.0
|
6 |
+
Requires PHP: 5.0
|
7 |
+
Tested up to: 5.4
|
8 |
+
Stable tag: 3.0.0
|
9 |
License: GPLv2 or later
|
10 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
11 |
|
12 |
+
Clean database by deleting orphaned data such as 'revisions', 'expired transients', optimize database and more...
|
13 |
|
14 |
== Description ==
|
|
|
15 |
|
16 |
+
Clean up database by deleting orphaned items such as 'old revisions', 'spam comments', optimize database and more...
|
17 |
+
|
18 |
+
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 makes your site sluggish and bloated such as old revisions, orphaned post meta, spam comments, etc. You should clean-up this unnecessary data to reduce your database size and improve website speed and performance. In addition, you will have quicker database backup since the file of your backup will be smaller.
|
19 |
|
20 |
'Advanced Database Cleaner' is a must-have plugin that allows you to clean database, optimize database and more.
|
21 |
|
22 |
= Main Features =
|
23 |
+
|
24 |
* Delete old revisions of posts and pages
|
|
|
25 |
* Delete old auto drafts
|
26 |
+
* Delete trash posts
|
27 |
* Delete pending comments
|
28 |
* Delete spam comments
|
29 |
* Delete trash comments
|
30 |
+
* Delete pingbacks
|
31 |
+
* Delete trackbacks
|
32 |
+
* Delete orphan post metadata
|
33 |
+
* Delete orphan comment metadata
|
34 |
+
* Delete orphan user metadata
|
35 |
+
* Delete orphan term metadata
|
36 |
* Delete orphan relationships
|
37 |
+
* Delete expired transients
|
38 |
+
* Display and view orphaned information before making a database clean-up so you can be sure about what you are going to clean-up
|
39 |
+
* Search & filter all items based on their names or values
|
40 |
+
* Keep last x days' data from being cleaned: clean only data older than the number of days you have specified
|
41 |
+
* Schedule database clean up to run automatically
|
42 |
+
* Create as many scheduled cleanup tasks as you need and specify what items should be cleaned by the scheduled task
|
43 |
+
* Scheduled tasks can be executed based on several frequencies: Once, hourly, twice a day, daily, weekly or monthly
|
44 |
+
* Display database tables information such as the number of rows, table size, etc.
|
45 |
+
* Optimize database tables (The plugin will notify you if any tables require optimization)
|
46 |
+
* Repair corrupted database tables or damaged ones (The plugin will notify you if any tables are corrupted or damaged)
|
47 |
+
* Schedule database optimization and/or reparation to run automatically and specify what tables should be optimized and/or repaired
|
48 |
+
* Empty database tables rows
|
49 |
+
* Clean and delete database tables
|
50 |
+
* Display options list
|
51 |
+
* Display options information such as option name, option value, option size, option autoload
|
52 |
+
* Clean and delete options
|
53 |
+
* Set options autoload to no / yes
|
54 |
+
* Display active cron tasks list (scheduled tasks) with their information such as arguments, next run, etc.
|
55 |
+
* Clean and delete scheduled tasks
|
56 |
+
* User-friendly and simple to use
|
57 |
+
|
58 |
+
= Multisite Support =
|
59 |
+
|
60 |
+
* The plugin is compatible with Multisite installations
|
61 |
+
* 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
|
62 |
+
* You can clean up all sites from one place (the main site). You can also specify specific sites you want to cleanup
|
63 |
+
|
64 |
+
= By using the ADC plugin, you will =
|
65 |
+
|
66 |
+
* <strong>Get and overview:</strong> The plugin will help you get an overview of what is happening in your database. It will report all unused/orphaned items that should be cleaned, it will give you the number of tables/options/tasks you have, etc. This way, you can control your database if anything goes wrong
|
67 |
+
|
68 |
+
* <strong>Save time:</strong> You can specify what items should be cleaned/optimized/repaired, what is the number of days' data to keep and the cleanup/optimization/reparation frequency. The plugin will then automate the process to run automatically based on your settings
|
69 |
+
|
70 |
+
* <strong>Save space:</strong> By deleting unused/orphaned items, you will save space in your database and make quicker backups since the file of your backup will be smaller
|
71 |
|
72 |
= Pro Features (<a href="https://sigmaplugin.com/downloads/wordpress-advanced-database-cleaner">Official website</a>) =
|
73 |
+
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:
|
74 |
|
75 |
+
* Classify options according to their "creator". They can be either: plugins options, themes options or WP core options
|
76 |
+
* Detect and delete orphan options. Your 'wp_options' table may be full of orphaned options and therefore can impact the performance of loading data from it, which may lead to a slow website. Clean up orphaned options is then important
|
77 |
+
* Classify tables according to their "creator". They can be either: plugins tables, themes tables or WP core tables
|
78 |
+
* Detect and delete orphan tables. As for options, you may also have some orphaned tables that were created by plugins/themes you are not using anymore. Clean up orphaned tables will decrease the size of your database
|
|
|
79 |
* Classify all cron tasks (cron jobs) according to their "creator". They can be either: plugins cron tasks, themes cron tasks or WP core tasks
|
80 |
+
* Detect and delete orphan cron jobs. After you uninstall a plugin/theme, some of its cron tasks may still be active making WordPress calling unknown functions. using the pro version, you can detect and clean orphaned tasks
|
81 |
+
* Search & filter options, filter tables and filter cron tasks based on several criteria such as the "name", "creator", "value", etc.
|
82 |
+
* Get premium support: we will provide quick support as well as any technical answers to help you clean up your database efficiently
|
83 |
|
84 |
+
= Translations =
|
85 |
+
|
86 |
+
You are welcome to contribute to the plugin translation via the [WordPress translation website](https://translate.wordpress.org/projects/wp-plugins/advanced-database-cleaner).
|
87 |
|
88 |
== Installation ==
|
89 |
|
90 |
+
This section describes how to install the plugin. In general, there are 3 ways to install this plugin like any other WordPress plugin.
|
91 |
+
|
92 |
+
= 1. Via WordPress dashboard =
|
93 |
+
|
94 |
+
* Click on 'Add New' in the plugins dashboard
|
95 |
+
* Search for 'advanced-database-cleaner'
|
96 |
+
* Click 'Install Now' button
|
97 |
+
* Activate the plugin from the same page or from the Plugins dashboard
|
98 |
|
99 |
+
= 2. Via uploading the plugin to WordPress dashboard =
|
|
|
|
|
|
|
100 |
|
101 |
+
* Download the plugin to your computer from (https://wordpress.org/plugins/advanced-database-cleaner/)
|
102 |
+
* Click on 'Add New' in the plugins dashboard
|
103 |
+
* Click on 'Upload Plugin' button
|
104 |
+
* Select the zip file of the plugin that you have downloaded to your computer before
|
105 |
+
* Click 'Install Now'
|
106 |
+
* Activate the plugin from the Plugins dashboard
|
107 |
+
|
108 |
+
= 3. Via FTP =
|
109 |
+
|
110 |
+
* Download the plugin to your computer from (https://wordpress.org/plugins/advanced-database-cleaner/)
|
111 |
+
* Unzip the zip file, which will extract the 'advanced-database-cleaner-3.0.0' directory
|
112 |
+
* Upload the 'advanced-database-cleaner' directory (included inside the extracted folder) to the /wp-content/plugins/ directory in your web space
|
113 |
+
* Activate the plugin from the Plugins dashboard
|
114 |
+
|
115 |
+
= For Multisite installation =
|
116 |
+
|
117 |
+
* Log in to your primary site and go to "My Sites" » "Network Admin" » "Plugins"
|
118 |
+
* Install the plugin following one of the above ways
|
119 |
+
* Network activate the plugin (Note that only the main site can have access to the plugin)
|
120 |
+
|
121 |
+
= Where the plugin menu will be displayed? =
|
122 |
+
|
123 |
+
* The plugin page can be accessed via "Dashboard" » "Tools" » "WP DB Cleaner" or via the left menu "WP DB Cleaner" (You can change this via the plugin settings)
|
124 |
|
125 |
== Screenshots ==
|
126 |
|
127 |
+
1. Database with items to clean
|
128 |
+
2. View items before cleaning them (case of revisions)
|
129 |
+
3. Cleanup scheduled task
|
130 |
+
4. Tables overview (scan of tables is available in PRO)
|
131 |
+
5. Tables optimization/repair scheduled task
|
132 |
+
6. Options overview (scan of options is available in PRO)
|
133 |
+
7. Scheduled tasks overview (scan of tasks is available in PRO)
|
134 |
+
8. Overview and settings page
|
|
|
135 |
|
136 |
== Changelog ==
|
137 |
|
138 |
+
= 3.0.0 - 05/12/2019 =
|
139 |
+
* IMPORTANT NOTICE FOR PRO USERS: After you upgrade to 3.0.0 from an old version, you will notice that WordPress has deactivated the plugin due to an error: 'Plugin file does not exist'. This is because we have renamed the pro plugin folder name from "advanced-db-cleaner" to "advanced-database-cleaner-pro", causing the WordPress to not being able to find the old one and therefore deactivating the plugin. Just activate it again. It doesn’t break anything. Once you activate the plugin again it will continue working normally without any issues. You will also probably lose the pro version after this upgrade (This is due to a conflict between the free and pro versions which is now solved). If it is the case, please follow these steps to restore your pro version with all new features: (https://sigmaplugin.com/blog/restore-pro-version-after-upgrade-to-3-0-0)
|
140 |
+
|
141 |
+
* COMPATIBILITY: The plugin is tested with WordPress 5.3
|
142 |
+
* CHANGE: Some changes to readme.txt file
|
143 |
+
* REMOVE: Drafts are not cleaned anymore in 3.0.0 since many users have reported that drafts are useful for them
|
144 |
+
* New: You can now clean up new items: pingbacks, trackbacks, orphaned user meta, orphaned term meta, expired transients
|
145 |
+
* New: The plugin icon in the left side menu has been changed to white color
|
146 |
+
* New: Change text-domain to 'advanced-database-cleaner'
|
147 |
+
* New: Enhancements to the look and feel of the plugin
|
148 |
+
* New: The sidebar has been changed for the free version and deleted in the pro version
|
149 |
+
* New: For options, we have added the option size column and two new actions: Set autoload to no / yes
|
150 |
+
* New: For tables, we have added two actions: Empty tables and repair tables
|
151 |
+
* New: You can now order and sort all items
|
152 |
+
* New: You can change the number of items per page
|
153 |
+
* New: You can keep last x days' data from being cleaned and clean only data older than the number of days you have specified
|
154 |
+
* New: You can specify elements to cleanup in a scheduled task. You can also create as many scheduled tasks as you need
|
155 |
+
* New: Add information to each line of unused data in 'General clean-up' tab to let users know more about each item they will clean
|
156 |
+
* New: Display/view items before cleaning them (in 'General cleanup' tab) is now in the free version
|
157 |
+
* New: Add a new setting to hide the "premium" tab in the free version
|
158 |
+
* Fix: Repair some strings with correct text domain
|
159 |
+
* Fix: Some tasks with arguments can't be cleaned. This is fixed now
|
160 |
+
* Fix: Some tasks with the same hook name and different arguments were not displayed. This is fixed now
|
161 |
+
* Fix: In some previous versions, tables were not shown for some users. This has been fixed
|
162 |
+
* PERFORMANCE: All images used by the plugin are now in SVG format
|
163 |
+
* PERFORMANCE: Restructuring the whole code for better performance
|
164 |
+
* SECURITY: add some _wpnonce to forms
|
165 |
+
* New (PRO): Add "Pro" to the title of the pro version to distinguish between the free and the pro versions
|
166 |
+
* New (PRO): You can now search and filter all elements: options, tables, tasks, etc. based on several criteria
|
167 |
+
* New (PRO): Add progress bar when searching for orphan items to show remaining items to process
|
168 |
+
* New (PRO): Add a category called "uncategorized" to let users see items that have not been categorized yet
|
169 |
+
* Fix (PRO): The activation issue is now fixed
|
170 |
+
* Fix (PRO): The scan of orphaned items generated timeout errors for big databases, we use now ajax to solve this
|
171 |
+
* Fix (PRO): A conflict between the free and the pro versions is now solved
|
172 |
+
* PERFORMANCE (PRO): We are now using an enhanced new update class provided by EDD plugin
|
173 |
+
* PERFORMANCE (PRO): Set autoload to no in all options used by the plugin
|
174 |
+
* PERFORMANCE (PRO): The plugin does not store scan results in DB anymore. We use files instead
|
175 |
+
* SECURITY (PRO): The license is now hidden after activation for security reasons
|
176 |
+
* WEBSITE (PRO): You can now view your purchase history, downloads, generate an invoice, upgrade your license, etc. [Read more](https://sigmaplugin.com/blog/how-to-get-access-to-my-account-and-downloads)
|
177 |
+
* WEBSITE (PRO): Enhancements of the [plugin premium page](https://sigmaplugin.com/downloads/wordpress-advanced-database-cleaner)
|
178 |
+
|
179 |
= 2.0.0 =
|
180 |
* Some changes to readme.txt file
|
181 |
* Changing the way the plugin can be translated
|
183 |
* Correcting some displaying texts
|
184 |
* Big change in styles
|
185 |
* Restructuring the whole code for better performance
|
186 |
+
* Creation of the plugin main page: (https://sigmaplugin.com/downloads/wordpress-advanced-database-cleaner)
|
187 |
* Adding language translation support
|
188 |
* Correct the time zone offset for the scheduled tasks
|
189 |
* Skipping InnoDB tables while optimizing
|
255 |
|
256 |
== Upgrade Notice ==
|
257 |
|
258 |
+
= 3.0.0 =
|
259 |
+
Known issues have been fixed in both free and pro versions (timeout error, activation, scheduled tasks...) New features have been added (new items to cleanup, filter & sort items...) Readme.txt file updated.
|
260 |
+
|
261 |
= 2.0.0 =
|
262 |
New release.
|
263 |
|
267 |
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.
|
268 |
|
269 |
= Is it safe to clean my database? =
|
270 |
+
Yes, it is. We do not run any code that can break down your site or delete your posts, pages, comments, etc. However, make sure to always back up your database before any cleanup. This is not optional; it is required! It is always better to be safe than sorry!
|
271 |
|
272 |
= What does mean "Optimize my database"? =
|
273 |
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.
|
274 |
|
275 |
= Is it safe to clean the cron (scheduled tasks)? =
|
276 |
+
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 you are not sure, it is better to not clean any task.
|
277 |
|
278 |
= What does mean "Revision"? What sql code is used to clean it? =
|
279 |
WordPress stores a record (called "revision") of each saved draft or published update. This system allows you to see what changes were made in each post and page over time. However, this can lead to a lot of unnecessary overhead in your WordPress database, which consumes a lot of space. The sql query used by the plugin to clean all revisions is:
|
280 |
`DELETE FROM posts WHERE post_type = 'revision'`
|
281 |
|
|
|
|
|
|
|
|
|
282 |
= What does mean "Auto-draft"? What sql code is used to clean it? =
|
283 |
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:
|
284 |
`DELETE FROM posts WHERE post_status = 'auto-draft'`
|
285 |
|
286 |
= What does mean "Pending comment"? What sql code is used to clean it? =
|
287 |
+
Pending comments are comments published by users and which are waiting 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:
|
288 |
`DELETE FROM comments WHERE comment_approved = '0'`
|
289 |
|
290 |
= What does mean "Spam comment"? What sql code is used to clean it? =
|
291 |
+
It is a comment that you (or a plugin) have marked as spam. The sql query used by the plugin to clean all spam comments is:
|
292 |
`DELETE FROM comments WHERE comment_approved = 'spam'`
|
293 |
|
294 |
= What does mean "Trash comment"? What sql code is used to clean it? =
|
295 |
A trash comment is a comment that you have deleted from your Wordpress and have been moved to the trash. A trash comment is not visible in your site and should be deleted forever. The sql query used by the plugin to clean all trash comments is:
|
296 |
`DELETE FROM comments WHERE comment_approved = 'trash'`
|
297 |
|
298 |
+
= What does mean "trackback"? What sql code is used to clean it? =
|
299 |
+
Trackbacks allows you to notify other websites owners that you have linked to their article on your website. These trackbacks can be used to send huge amounts of spam. Spammers use them to get their links posted on as many sites as possible. That is why they should be deactivated/cleaned if you do not use them. The sql query used by the plugin to clean trackbacks is:
|
300 |
+
`DELETE FROM comments WHERE comment_type = 'trackback'`
|
301 |
+
|
302 |
+
= What does mean "pingback"? What sql code is used to clean it? =
|
303 |
+
Pingbacks allow you to notify other websites owners that you have linked to their article on your website. Pingbacks were designed to solve some of the problems that people saw with trackbacks. Although there are some minor technical differences, a trackback is basically the same things as a pingback. These pingbacks can be used to send huge amounts of spam. Spammers use them to get their links posted on as many sites as possible. That is why they should be deactivated/cleaned if you do not use them. The sql query used by the plugin to clean pingbacks is:
|
304 |
+
`DELETE FROM comments WHERE comment_type = 'pingback'`
|
305 |
+
|
306 |
= What does mean "Orphan post meta"? What sql code is used to clean it? =
|
307 |
+
The post meta data is the information you provide to viewers about each post. This information usually includes the author of the post, when it was written (or posted), and how the author categorized that particular post. In some cases, some post meta data information becomes orphan and does not belong to any post. They are then called "orphan postmeta" and should be cleaned since they are not useful. The sql query used by the plugin to clean all orphan postmeta is:
|
308 |
`DELETE pm FROM postmeta pm LEFT JOIN posts wp ON wp.ID = pm.post_id WHERE wp.ID IS NULL`
|
309 |
|
310 |
= What does mean "Orphan comment meta"? What sql code is used to clean it? =
|
311 |
The same as "Orphan post meta" with the exception that "orphan comment meta" concern comments and not posts. The sql query used by the plugin to clean all orphan comment meta is:
|
312 |
`DELETE FROM commentmeta WHERE comment_id NOT IN (SELECT comment_id FROM comments)`
|
313 |
|
314 |
+
= What does mean "Orphan user meta"? What sql code is used to clean it? =
|
315 |
+
The user meta data is the information you provide to viewers about each user. This information usually includes additional data that is not stored in the users table of WordPress. In some cases, some user meta data information becomes orphaned and does not belong to any user. They are then called "orphaned usermeta" and should be cleaned since they are not useful. The sql query used by the plugin to clean all orphan comment meta is:
|
316 |
+
`DELETE FROM usermeta WHERE user_id NOT IN (SELECT ID FROM users)`
|
317 |
+
|
318 |
+
= What does mean "Orphan term meta"? What sql code is used to clean it? =
|
319 |
+
The term meta data is the information that is provided for each taxonomy term. This information usually includes additional data that is not stored in the terms table of WordPress. In some cases, some term meta data information becomes orphaned and does not belong to any taxonomy term. They are then called "orphaned termmeta" and should be cleaned since they are not useful. The sql query used by the plugin to clean all orphan comment meta is:
|
320 |
+
`DELETE FROM termmeta WHERE term_id NOT IN (SELECT term_id FROM terms)`
|
321 |
+
|
322 |
= What does mean "Orphan relationships"? What sql code is used to clean it? =
|
323 |
Sometimes the wp_term_relationships table becomes bloated with many orphaned relationships. This happens particularly often if you’re using your site not as a blog but as some other type of content site where posts are deleted periodically. Over time, you could get thousands of term relationships for posts that no longer exist which consumes a lot of database space. The sql query used by the plugin to clean all orphan relationships is:
|
324 |
`DELETE FROM term_relationships WHERE term_taxonomy_id=1 AND object_id NOT IN (SELECT id FROM posts)`
|
325 |
|
326 |
+
= What does mean "expired transient"? =
|
327 |
+
Transients are a way of storing cached data in the WordPress DB temporarily by giving it a name and a time frame after which it will expire and be deleted. This helps improve WordPress performance and speed up your website while reducing the overall server load. Expired transients are transients that are expired and still exist in the database. These ones can be safely cleaned. Transients housekeeping is now part of WordPress core, as of version 4.9, so no need to clean up them manually unless you have specific needs.
|
|
|
328 |
|
329 |
= Is this plugin compatible with multisite? =
|
330 |
+
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 has the right to perform such operation. Your database is precious!
|
331 |
|
332 |
= Is this plugin compatible with SharDB, HyperDB or Multi-DB? =
|
333 |
+
Actually the plugin is not supposed to be compatible with SharDB, HyperDB or Multi-DB. We will try to make it compatible in the coming releases.
|
334 |
|
335 |
= Does this plugin cleans itself after the uninstall? =
|
336 |
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
@@ -5,7 +5,7 @@ if (!is_main_site()) return;
|
|
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:
|
9 |
Author: Younes JFR.
|
10 |
Author URI: https://www.sigmaplugin.com
|
11 |
Contributors: symptote
|
@@ -15,286 +15,721 @@ 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 |
-
*
|
21 |
-
*
|
22 |
-
|
23 |
-
|
24 |
-
|
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 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
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 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
'display' => __('Once monthly', 'advanced-database-cleaner')
|
118 |
-
);
|
119 |
-
return $schedules;
|
120 |
-
}
|
121 |
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
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 |
-
//
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
144 |
}
|
145 |
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
153 |
}
|
154 |
|
155 |
-
//
|
156 |
-
|
157 |
-
|
158 |
-
$
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
wp_clear_scheduled_hook('aDBc_clean_scheduler');
|
166 |
-
}
|
167 |
-
restore_current_blog();
|
168 |
}
|
169 |
-
}
|
170 |
-
}
|
171 |
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
182 |
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
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);
|
206 |
delete_option('aDBc_optimize_schedule');
|
207 |
delete_option('aDBc_clean_schedule');
|
208 |
-
|
209 |
-
wp_clear_scheduled_hook('aDBc_clean_scheduler');
|
210 |
-
restore_current_blog();
|
211 |
}
|
212 |
}
|
213 |
-
}
|
214 |
|
215 |
-
|
216 |
-
|
217 |
-
|
218 |
-
|
219 |
-
|
220 |
-
|
221 |
-
|
222 |
-
|
223 |
-
|
224 |
-
|
225 |
-
|
226 |
-
|
227 |
-
|
228 |
-
|
229 |
-
|
230 |
-
|
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 |
-
|
259 |
-
|
260 |
-
|
261 |
-
|
262 |
-
|
263 |
-
|
264 |
-
|
265 |
-
|
266 |
-
|
267 |
-
|
268 |
-
|
269 |
-
|
270 |
-
|
271 |
-
|
272 |
-
|
273 |
-
|
274 |
-
|
275 |
-
|
276 |
-
|
277 |
-
|
278 |
-
|
279 |
-
|
280 |
-
|
281 |
-
|
282 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
283 |
}
|
284 |
-
|
285 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
286 |
</div>
|
287 |
-
<div class="aDBc-sidebar"><?php include_once 'includes/sidebar.php'; ?></div>
|
288 |
</div>
|
289 |
-
|
290 |
-
|
291 |
}
|
292 |
|
293 |
-
/***************************************************************
|
294 |
-
*
|
295 |
-
* Get functions
|
296 |
-
*
|
297 |
-
***************************************************************/
|
298 |
-
include_once 'includes/functions.php';
|
299 |
|
300 |
-
|
|
|
|
|
|
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: 3.0.0
|
9 |
Author: Younes JFR.
|
10 |
Author URI: https://www.sigmaplugin.com
|
11 |
Contributors: symptote
|
15 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
16 |
*/
|
17 |
|
18 |
+
/***************************************************************************************************************
|
19 |
* Require WordPress List Table Administration API
|
20 |
+
* yyy: Test validity of WP_List_Table class after each release of WP Since this class is marked as private by WP
|
21 |
+
* http://codex.wordpress.org/Class_Reference/WP_List_Table
|
22 |
+
***************************************************************************************************************/
|
23 |
+
if(!class_exists('WP_List_Table')){
|
24 |
+
require_once(ABSPATH . 'wp-admin/includes/class-wp-list-table.php');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
25 |
}
|
26 |
|
27 |
+
class ADBC_Advanced_DB_Cleaner {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
28 |
|
29 |
+
public function __construct(){
|
30 |
+
|
31 |
+
// Define common constants that should be modified in each version
|
32 |
+
if(!defined("ADBC_PLUGIN_F_TYPE")) define("ADBC_PLUGIN_F_TYPE", "free");
|
33 |
+
if(!defined("ADBC_PLUGIN_VERSION")) define("ADBC_PLUGIN_VERSION", "3.0.0");
|
34 |
+
|
35 |
+
// Prevent conflicts between free and pro, load text-domain and check if should update settings after upgrade
|
36 |
+
add_action('plugins_loaded', array($this, 'plugins_loaded'));
|
37 |
+
|
38 |
+
// Load CSS and JS
|
39 |
+
add_action('admin_enqueue_scripts', array($this, 'aDBc_load_styles_and_scripts'));
|
40 |
+
|
41 |
+
// Add some schedules
|
42 |
+
add_filter('cron_schedules', array($this, 'aDBc_additional_schedules'));
|
43 |
+
|
44 |
+
// Add actions for scheduled events
|
45 |
+
add_action('aDBc_optimize_scheduler', 'aDBc_optimize_scheduled_tables');
|
46 |
+
add_action('aDBc_clean_scheduler', 'aDBc_clean_scheduled_elements');
|
47 |
+
|
48 |
+
// Register activation, deactivation and uninstall hooks of the plugin
|
49 |
+
register_activation_hook (__FILE__, array($this, 'aDBc_activate_plugin'));
|
50 |
+
register_deactivation_hook (__FILE__, array($this, 'aDBc_deactivate_plugin'));
|
51 |
+
register_uninstall_hook (__FILE__, array('ADBC_Advanced_DB_Cleaner', 'aDBc_uninstall'));
|
52 |
+
|
53 |
+
// Add admin notice to rate plugin
|
54 |
+
add_action('admin_notices', array($this, 'aDBc_rate_notice'));
|
55 |
+
add_action('admin_init', array($this, 'aDBc_ignore_notice'));
|
56 |
|
57 |
+
// Update settings if changed by users
|
58 |
+
$this->aDBc_update_settings();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
59 |
}
|
|
|
|
|
60 |
|
61 |
+
// Do this on plugins loded : prevent conflict between free and pro, load text-domain and check if we should update settings in DB
|
62 |
+
public function plugins_loaded(){
|
63 |
+
|
64 |
+
// Prevent conflicts between free and pro versions and between old pro and new pro
|
65 |
+
if(!function_exists('deactivate_plugins')) include_once(ABSPATH.'wp-admin/includes/plugin.php');
|
66 |
+
// Test if the user want to activate the pro version and he has the free version activated
|
67 |
+
if(is_plugin_active('advanced-database-cleaner-pro/advanced-db-cleaner.php') && is_plugin_active(
|
68 |
+
'advanced-database-cleaner/advanced-db-cleaner.php')){
|
69 |
+
// Deactivate the free version in silent mode without calling its deactivation function in order to keep scheduled tasks for pro
|
70 |
+
deactivate_plugins('advanced-database-cleaner/advanced-db-cleaner.php', true);
|
71 |
+
add_action('admin_notices', array($this, 'aDBc_conflict_notice_free'));
|
72 |
+
return;
|
73 |
+
}
|
74 |
+
// Test if the user want to activate the pro version and he has the old pro version activated
|
75 |
+
if(is_plugin_active('advanced-database-cleaner-pro/advanced-db-cleaner.php') && is_plugin_active(
|
76 |
+
'advanced-db-cleaner/advanced-db-cleaner.php')){
|
77 |
+
// Deactivate the old pro version in silent mode without calling its deactivation function in order to keep scheduled tasks for pro
|
78 |
+
deactivate_plugins('advanced-db-cleaner/advanced-db-cleaner.php', true);
|
79 |
+
add_action('admin_notices', array($this, 'aDBc_conflict_notice_old_pro'));
|
80 |
+
return;
|
81 |
+
}
|
82 |
+
|
83 |
+
/********************************************************************
|
84 |
+
* Include functions and specific elements for pro version
|
85 |
+
********************************************************************/
|
86 |
+
include_once 'includes/functions.php';
|
87 |
+
if(ADBC_PLUGIN_F_TYPE == "pro"){
|
88 |
+
|
89 |
+
// Include pro functions
|
90 |
+
include_once 'includes/functions_pro.php';
|
91 |
+
|
92 |
+
// In pro, register as well function for timeout
|
93 |
+
register_shutdown_function('aDBc_shutdown_due_to_timeout');
|
94 |
+
|
95 |
+
// Load license (Load only in pro version)
|
96 |
+
include_once 'includes/license/adbc-edd-sample-plugin.php';
|
97 |
+
|
98 |
+
// Add actions for searching and progress bar in pro
|
99 |
+
add_action('wp_ajax_aDBc_new_run_search_for_items', 'aDBc_new_run_search_for_items');
|
100 |
+
add_action('wp_ajax_aDBc_get_progress_bar_width', 'aDBc_get_progress_bar_width');
|
101 |
+
|
102 |
+
}
|
103 |
+
|
104 |
+
/**************************************************************************************************************
|
105 |
+
*
|
106 |
+
* Define other variables (we switch all "\" to "/" in paths)
|
107 |
+
*
|
108 |
+
**************************************************************************************************************/
|
109 |
+
|
110 |
+
if(!defined("ADBC_PLUGIN_DIR_PATH")) define("ADBC_PLUGIN_DIR_PATH", plugins_url('' , __FILE__));
|
111 |
+
|
112 |
+
// Main Plugin file
|
113 |
+
if(!defined("ADBC_MAIN_PLUGIN_FILE_PATH")) define("ADBC_MAIN_PLUGIN_FILE_PATH", str_replace('\\' ,'/', __FILE__ ));
|
114 |
+
|
115 |
+
// ABSPATH without trailing slash
|
116 |
+
if(!defined("ADBC_ABSPATH")) define("ADBC_ABSPATH", rtrim(str_replace('\\' ,'/', ABSPATH), "/"));
|
117 |
+
|
118 |
+
// WP Content directory
|
119 |
+
if(!defined("WP_CONTENT_DIR")) define("WP_CONTENT_DIR", ABSPATH . 'wp-content');
|
120 |
+
if(!defined("ADBC_WP_CONTENT_DIR_PATH")) define("ADBC_WP_CONTENT_DIR_PATH", str_replace('\\' ,'/', WP_CONTENT_DIR));
|
121 |
+
|
122 |
+
// WP Plugin directory path & name
|
123 |
+
if(!defined("WP_PLUGIN_DIR")) define("WP_PLUGIN_DIR", WP_CONTENT_DIR . '/plugins');
|
124 |
+
if(!defined("ADBC_WP_PLUGINS_DIR_PATH")) define("ADBC_WP_PLUGINS_DIR_PATH", str_replace('\\' ,'/', WP_PLUGIN_DIR));
|
125 |
+
|
126 |
+
// MU Must have plugin path & name (MU plugins are no longer used only by Mulsite but all wordpress installations)
|
127 |
+
if(!defined("WPMU_PLUGIN_DIR")) define("WPMU_PLUGIN_DIR", WP_CONTENT_DIR . '/mu-plugins');
|
128 |
+
if(!defined("ADBC_WPMU_PLUGIN_DIR_PATH")) define("ADBC_WPMU_PLUGIN_DIR_PATH", str_replace('\\' ,'/', WPMU_PLUGIN_DIR));
|
129 |
+
|
130 |
+
// WP Uploads directory & name
|
131 |
+
$aDBc_upload_dir = wp_upload_dir();
|
132 |
+
if(!defined("ADBC_UPLOAD_DIR_PATH")) define("ADBC_UPLOAD_DIR_PATH", str_replace('\\' ,'/', $aDBc_upload_dir['basedir']));
|
133 |
+
|
134 |
+
/**************************************************************************************************************
|
135 |
+
*
|
136 |
+
* Define & create adbc upload folder or rename existing one by adding security code for versions < 3.1.0
|
137 |
+
* In version >= 3.0.0 of ADBC, we will use files to store data instead of database
|
138 |
+
* In version >= 3.1.0, we've added a unique security code to the end of the folder to prevent third parties accesssing files directly via URL
|
139 |
+
*
|
140 |
+
**************************************************************************************************************/
|
141 |
+
|
142 |
+
if(ADBC_PLUGIN_F_TYPE == "pro"){
|
143 |
+
|
144 |
+
$aDBc_security_folder_code = get_option('aDBc_security_folder_code');
|
145 |
+
|
146 |
+
// If the security code does not exist, generate a new one and add it to the DB
|
147 |
+
if(empty($aDBc_security_folder_code)){
|
148 |
+
|
149 |
+
$permitted_chars = '00112233445566778899abcdefghijklmnopqrstuvwxyz';
|
150 |
+
$aDBc_security_folder_code = substr(str_shuffle($permitted_chars), 0, 12);
|
151 |
+
update_option('aDBc_security_folder_code', $aDBc_security_folder_code, "no");
|
152 |
+
}
|
153 |
+
|
154 |
+
// Define ADBC upload folder name with the security code
|
155 |
+
if(!defined("ADBC_UPLOAD_DIR_PATH_TO_ADBC")) define("ADBC_UPLOAD_DIR_PATH_TO_ADBC", ADBC_UPLOAD_DIR_PATH . '/adbc_uploads_' . $aDBc_security_folder_code);
|
156 |
+
|
157 |
+
// First, test of the old folder "/adbc_uploads" exists. If so, rename it by adding new security code
|
158 |
+
if(file_exists(ADBC_UPLOAD_DIR_PATH . '/adbc_uploads')){
|
159 |
+
|
160 |
+
rename(ADBC_UPLOAD_DIR_PATH . '/adbc_uploads', ADBC_UPLOAD_DIR_PATH . '/adbc_uploads_' . $aDBc_security_folder_code);
|
161 |
+
|
162 |
+
}else {
|
163 |
+
// If the old folder does not exist, then add the folder with security code
|
164 |
+
if(!file_exists(ADBC_UPLOAD_DIR_PATH_TO_ADBC)){
|
165 |
+
aDBc_create_folder_plus_index_file(ADBC_UPLOAD_DIR_PATH_TO_ADBC);
|
166 |
+
}
|
167 |
+
}
|
168 |
+
|
169 |
+
}
|
170 |
+
|
171 |
+
/**************************************************************************************************************
|
172 |
+
*
|
173 |
+
* Try to increase the timeout of the server to 300 to prevent timeout errors and multiple loads while searching
|
174 |
+
*
|
175 |
+
**************************************************************************************************************/
|
176 |
+
|
177 |
+
if(!defined("ADBC_ORIGINAL_TIMEOUT")) define("ADBC_ORIGINAL_TIMEOUT", ini_get('max_execution_time'));
|
178 |
+
if(ADBC_PLUGIN_F_TYPE == "pro"){
|
179 |
+
if(function_exists('set_time_limit') && ADBC_ORIGINAL_TIMEOUT < 300){
|
180 |
+
@set_time_limit(300);
|
181 |
+
}
|
182 |
+
}
|
183 |
+
|
184 |
+
// Add 'Database Cleaner' to Wordpress menu
|
185 |
+
add_action('admin_menu', array($this, 'aDBc_add_admin_menu'));
|
186 |
+
|
187 |
+
// Load text-domain
|
188 |
+
load_plugin_textdomain('advanced-database-cleaner', false, dirname(plugin_basename(__FILE__)) . '/languages');
|
189 |
+
|
190 |
+
// If plugin get updated, make changes to old version
|
191 |
+
$this->aDBc_update_plugin_check();
|
192 |
+
|
193 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
194 |
|
195 |
+
// Show notice if conflict detected between free and pro version when installed together
|
196 |
+
function aDBc_conflict_notice_free(){
|
197 |
+
echo '<div class="error"><p>';
|
198 |
+
_e('The free version of Advanced DB Cleaner has been de-activated since the pro version is active.', 'advanced-database-cleaner');
|
199 |
+
echo "</p></div>";
|
200 |
+
}
|
201 |
+
function aDBc_conflict_notice_old_pro(){
|
202 |
+
echo '<div class="error"><p>';
|
203 |
+
_e('The old pro of Advanced DB Cleaner has been de-activated since the new pro version is active.', 'advanced-database-cleaner');
|
204 |
+
echo "</p></div>";
|
205 |
+
}
|
206 |
+
|
207 |
+
// Add 'Database Cleaner' to Wordpress menu
|
208 |
+
function aDBc_add_admin_menu(){
|
209 |
+
|
210 |
+
global $aDBc_settings, $aDBc_left_menu, $aDBc_tool_submenu;
|
|
|
|
|
|
|
|
|
211 |
|
212 |
+
$icon_svg = 'data:image/svg+xml;base64,' . base64_encode('<svg width="20" height="20" viewBox="0 0 1792 1792" xmlns="http://www.w3.org/2000/svg"><path fill="#a0a5aa" d="M896 768q237 0 443-43t325-127v170q0 69-103 128t-280 93.5-385 34.5-385-34.5-280-93.5-103-128v-170q119 84 325 127t443 43zm0 768q237 0 443-43t325-127v170q0 69-103 128t-280 93.5-385 34.5-385-34.5-280-93.5-103-128v-170q119 84 325 127t443 43zm0-384q237 0 443-43t325-127v170q0 69-103 128t-280 93.5-385 34.5-385-34.5-280-93.5-103-128v-170q119 84 325 127t443 43zm0-1152q208 0 385 34.5t280 93.5 103 128v128q0 69-103 128t-280 93.5-385 34.5-385-34.5-280-93.5-103-128v-128q0-69 103-128t280-93.5 385-34.5z"/></svg>');
|
213 |
+
|
214 |
+
if(!empty($aDBc_settings['left_menu']) && $aDBc_settings['left_menu'] == "1"){
|
215 |
+
$aDBc_left_menu = add_menu_page('Advanced DB Cleaner', 'WP DB Cleaner', 'manage_options', 'advanced_db_cleaner', array($this, 'aDBc_main_page_callback'), $icon_svg, '80.01123');
|
216 |
+
}
|
217 |
+
if(!empty($aDBc_settings['menu_under_tools']) && $aDBc_settings['menu_under_tools'] == "1"){
|
218 |
+
$aDBc_tool_submenu = add_submenu_page('tools.php', 'Advanced DB Cleaner', 'WP DB Cleaner', 'manage_options', 'advanced_db_cleaner', array($this, 'aDBc_main_page_callback'));
|
219 |
+
}
|
220 |
+
// In case the settings has been deleted by accident, create left menu
|
221 |
+
if(empty($aDBc_settings['left_menu']) && empty($aDBc_settings['menu_under_tools'])){
|
222 |
+
$aDBc_left_menu = add_menu_page('Advanced DB Cleaner', 'WP DB Cleaner', 'manage_options', 'advanced_db_cleaner', array($this, 'aDBc_main_page_callback'), $icon_svg, '80.01123');
|
223 |
+
}
|
|
|
|
|
|
|
224 |
}
|
225 |
|
226 |
+
// Load CSS and JS
|
227 |
+
function aDBc_load_styles_and_scripts($hook){
|
228 |
+
|
229 |
+
// Enqueue our js and css in the plugin pages only
|
230 |
+
global $aDBc_left_menu, $aDBc_tool_submenu;
|
231 |
+
if($hook != $aDBc_left_menu && $hook != $aDBc_tool_submenu){
|
232 |
+
return;
|
233 |
+
}
|
234 |
+
|
235 |
+
wp_enqueue_style('aDBc_css', ADBC_PLUGIN_DIR_PATH . '/css/admin.css');
|
236 |
+
wp_enqueue_script('aDBc_js', ADBC_PLUGIN_DIR_PATH . '/js/admin.js');
|
237 |
+
|
238 |
+
// The wp_localize_script allows us to output the ajax_url path for our script to use.
|
239 |
+
wp_localize_script('aDBc_js', 'aDBc_ajax_obj', array(
|
240 |
+
'ajaxurl' => admin_url('admin-ajax.php'),
|
241 |
+
'images_path' => ADBC_PLUGIN_DIR_PATH . "/images/",
|
242 |
+
'sentence_scanning' => __('Scanning ...', 'advanced-database-cleaner')
|
243 |
+
));
|
244 |
+
//wp_enqueue_script('jquery');
|
245 |
+
wp_enqueue_script('jquery-ui-dialog');
|
246 |
+
wp_enqueue_style('wp-jquery-ui-dialog');
|
247 |
}
|
248 |
|
249 |
+
/******************************************************************************************
|
250 |
+
* Add some schedules
|
251 |
+
* Get more info here: http://codex.wordpress.org/Plugin_API/Filter_Reference/cron_schedules
|
252 |
+
******************************************************************************************/
|
253 |
+
function aDBc_additional_schedules($schedules){
|
254 |
+
// hourly, daily and twicedaily are default schedules in WP, we will add weekly and monthly
|
255 |
+
// Add weekly schedule
|
256 |
+
$schedules['weekly'] = array(
|
257 |
+
'interval' => 604800,
|
258 |
+
'display' => __('Once weekly', 'advanced-database-cleaner')
|
259 |
+
);
|
260 |
+
// Add monthly schedule
|
261 |
+
$schedules['monthly'] = array(
|
262 |
+
'interval' => 2635200,
|
263 |
+
'display' => __('Once monthly', 'advanced-database-cleaner')
|
264 |
+
);
|
265 |
+
return $schedules;
|
266 |
}
|
267 |
|
268 |
+
// Register activation of the plugin
|
269 |
+
function aDBc_activate_plugin(){
|
270 |
+
// Add default settings if not exists for normal installation
|
271 |
+
$settings = get_option('aDBc_settings');
|
272 |
+
if(empty($settings)){
|
273 |
+
$settings['left_menu'] = "1";
|
274 |
+
$settings['menu_under_tools'] = "1";
|
275 |
+
$settings['plugin_version'] = ADBC_PLUGIN_VERSION;
|
276 |
+
$settings['installed_on'] = date("Y/m/d");
|
277 |
+
update_option('aDBc_settings', $settings, "no");
|
|
|
|
|
|
|
278 |
}
|
279 |
+
}
|
|
|
280 |
|
281 |
+
// Register deactivation hook
|
282 |
+
function aDBc_deactivate_plugin($network_wide){
|
283 |
+
|
284 |
+
// Clean these in case there are any remining tasks from older versions < 3.0.0. Those tasks were without arguments
|
285 |
+
wp_clear_scheduled_hook('aDBc_optimize_scheduler');
|
286 |
+
wp_clear_scheduled_hook('aDBc_clean_scheduler');
|
287 |
+
|
288 |
+
// Clear all schedules and update options in DB
|
289 |
+
// Clear clean tasks
|
290 |
+
$aDBc_clean_schedules = get_option('aDBc_clean_schedule');
|
291 |
+
$aDBc_clean_schedules = is_array($aDBc_clean_schedules) ? $aDBc_clean_schedules : array();
|
292 |
+
foreach($aDBc_clean_schedules as $task_name => $task_info){
|
293 |
+
wp_clear_scheduled_hook('aDBc_clean_scheduler', array($task_name));
|
294 |
+
// Set active to no in DB
|
295 |
+
$task_info['active'] = 0;
|
296 |
+
$aDBc_clean_schedules[$task_name] = $task_info;
|
297 |
+
update_option('aDBc_clean_schedule', $aDBc_clean_schedules, "no");
|
298 |
+
}
|
299 |
+
// Clear optimize tasks
|
300 |
+
$aDBc_optimize_schedules = get_option('aDBc_optimize_schedule');
|
301 |
+
$aDBc_optimize_schedules = is_array($aDBc_optimize_schedules) ? $aDBc_optimize_schedules : array();
|
302 |
+
foreach($aDBc_optimize_schedules as $task_name => $task_info){
|
303 |
+
wp_clear_scheduled_hook('aDBc_optimize_scheduler', array($task_name));
|
304 |
+
// Set active to no in DB
|
305 |
+
$task_info['active'] = 0;
|
306 |
+
$aDBc_optimize_schedules[$task_name] = $task_info;
|
307 |
+
update_option('aDBc_optimize_schedule', $aDBc_optimize_schedules, "no");
|
308 |
+
}
|
309 |
+
}
|
310 |
+
|
311 |
+
// Register UNINSTALL hook
|
312 |
+
public static function aDBc_uninstall(){
|
313 |
+
|
314 |
+
// Keep these ones in case they still in DB from older version < 3.0.0
|
315 |
+
delete_option('aDBc_options_status');
|
316 |
+
delete_option('aDBc_tables_status');
|
317 |
+
delete_option('aDBc_tasks_status');
|
318 |
+
|
319 |
+
// These options are temp and should not exist after finishing the search of oprhans. We make sure to clean them just in case
|
320 |
+
$array_items = array('options','tables','tasks');
|
321 |
+
foreach($array_items as $item){
|
322 |
+
delete_option('aDBc_temp_last_iteration_' . $item);
|
323 |
+
delete_option('aDBc_temp_still_searching_' . $item);
|
324 |
+
delete_option('aDBc_temp_last_item_line_' . $item);
|
325 |
+
delete_option('aDBc_temp_last_file_line_' . $item);
|
326 |
+
delete_option('aDBc_last_search_ok_') . $item;
|
327 |
+
}
|
328 |
+
|
329 |
+
// if we are in pro version, clean these ones
|
330 |
+
if(ADBC_PLUGIN_F_TYPE == "pro"){
|
331 |
+
|
332 |
+
// Get security code
|
333 |
+
$aDBc_security_folder_code = get_option('aDBc_security_folder_code');
|
334 |
+
|
335 |
+
// Delete folder containing search results having the security code
|
336 |
+
$aDBc_upload_dir = wp_upload_dir();
|
337 |
+
$aDBc_upload_dir = str_replace('\\' ,'/', $aDBc_upload_dir['basedir']) . '/adbc_uploads_' . $aDBc_security_folder_code;
|
338 |
+
if(file_exists($aDBc_upload_dir)){
|
339 |
+
$dir = opendir($aDBc_upload_dir);
|
340 |
+
while(($file = readdir($dir)) !== false){
|
341 |
+
if ($file != '.' && $file != '..'){
|
342 |
+
unlink($aDBc_upload_dir . "/" . $file);
|
343 |
+
}
|
344 |
+
}
|
345 |
+
closedir($dir);
|
346 |
+
rmdir($aDBc_upload_dir);
|
347 |
+
}
|
348 |
+
|
349 |
+
// Just in case the old folder (in versions < 3.1.0) have not been cleaned for any reason, try to clean it
|
350 |
+
$aDBc_upload_dir = wp_upload_dir();
|
351 |
+
$aDBc_upload_dir = str_replace('\\' ,'/', $aDBc_upload_dir['basedir']) . '/adbc_uploads';
|
352 |
+
if(file_exists($aDBc_upload_dir)){
|
353 |
+
$dir = opendir($aDBc_upload_dir);
|
354 |
+
while(($file = readdir($dir)) !== false){
|
355 |
+
if ($file != '.' && $file != '..'){
|
356 |
+
unlink($aDBc_upload_dir . "/" . $file);
|
357 |
+
}
|
358 |
+
}
|
359 |
+
closedir($dir);
|
360 |
+
rmdir($aDBc_upload_dir);
|
361 |
+
}
|
362 |
+
|
363 |
+
// Delete security code option
|
364 |
+
delete_option('aDBc_security_folder_code');
|
365 |
+
// Delete license options
|
366 |
+
delete_option('aDBc_edd_license_key');
|
367 |
+
delete_option('aDBc_edd_license_status');
|
368 |
+
// Uninstall the license key? Maybe no need for deactivating the license!
|
369 |
+
// if(!function_exists('aDBc_edd_deactivate_license_after_uninstall')){
|
370 |
+
// include_once 'includes/license/adbc-edd-sample-plugin.php';
|
371 |
+
// }
|
372 |
+
// aDBc_edd_deactivate_license_after_uninstall();
|
373 |
+
}
|
374 |
|
375 |
+
// Options below are used by both free and pro version
|
376 |
+
// Test if both version are installed to prevent deleting options
|
377 |
+
if((file_exists(WP_PLUGIN_DIR . "/advanced-database-cleaner-pro") && file_exists(WP_PLUGIN_DIR . "/advanced-database-cleaner")) ||
|
378 |
+
(file_exists(WPMU_PLUGIN_DIR . "/advanced-database-cleaner-pro") && file_exists(WPMU_PLUGIN_DIR . "/advanced-database-cleaner"))){
|
379 |
+
// Do nothing in this case because we want to keep settings for the remaining version of the plugin
|
380 |
+
}else{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
381 |
delete_option('aDBc_optimize_schedule');
|
382 |
delete_option('aDBc_clean_schedule');
|
383 |
+
delete_option('aDBc_settings');
|
|
|
|
|
384 |
}
|
385 |
}
|
|
|
386 |
|
387 |
+
// If plugin get updated, make changes to old version
|
388 |
+
function aDBc_update_plugin_check(){
|
389 |
+
$settings = get_option('aDBc_settings');
|
390 |
+
if(!empty($settings)){
|
391 |
+
if(empty($settings['plugin_version'])){
|
392 |
+
|
393 |
+
// If settings is not empty, this means that the users had already installed ADBC plugin
|
394 |
+
// if empty($settings['plugin_version']) => the user will update to or will install the version >= 3.0.0 for the first time
|
395 |
+
|
396 |
+
// Before starting the update, make all previous plugin options to autoload "no"
|
397 |
+
$options_array = array('aDBc_optimize_schedule', 'aDBc_clean_schedule', 'aDBc_settings', 'aDBc_edd_license_key', 'aDBc_edd_license_status');
|
398 |
+
foreach($options_array as $option_name){
|
399 |
+
$options_value = get_option($option_name);
|
400 |
+
if(!empty($options_value)){
|
401 |
+
update_option($option_name, "xyz");
|
402 |
+
update_option($option_name, $options_value, "no");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
403 |
}
|
|
|
404 |
}
|
405 |
+
|
406 |
+
// Proceed to update routine. First, add some options
|
407 |
+
$settings['ignore_premium'] = "no";
|
408 |
+
$settings['plugin_version'] = ADBC_PLUGIN_VERSION;
|
409 |
+
$settings['installed_on'] = date("Y/m/d");
|
410 |
+
// Delete some unused options
|
411 |
+
unset($settings['top_main_msg']);
|
412 |
+
unset($settings['tables_cleanup_warning']);
|
413 |
+
update_option('aDBc_settings', $settings, "no");
|
414 |
+
|
415 |
+
// If there are any scheduled cleanup tasks, change corresponding structure in DB to meet the new version
|
416 |
+
if($timestamp = wp_next_scheduled('aDBc_clean_scheduler')){
|
417 |
+
// Prepare new structure
|
418 |
+
// Since in version <= 3.0.0 the schedule cleans all elements, we will add only those elements not new introduced ones
|
419 |
+
$new_schedule_params['elements_to_clean'] = array('revision','auto-draft','trash-posts','moderated-comments','spam-comments','trash-comments','orphan-postmeta','orphan-commentmeta','orphan-relationships');
|
420 |
+
$repeat = get_option('aDBc_clean_schedule');
|
421 |
+
$repeat = empty($repeat) ? 'weekly' : $repeat;
|
422 |
+
$new_schedule_params['repeat'] = $repeat;
|
423 |
+
$date = date('Y-m-d', $timestamp) . "";
|
424 |
+
$time = date('H:i', $timestamp) . "";
|
425 |
+
$new_schedule_params['start_date'] = $date;
|
426 |
+
$new_schedule_params['start_time'] = $time;
|
427 |
+
$new_schedule_params['active'] = "1";
|
428 |
+
$clean_schedule_setting['cleanup_schedule'] = $new_schedule_params;
|
429 |
+
update_option('aDBc_clean_schedule', $clean_schedule_setting, "no");
|
430 |
+
// Reschedule the event with arg name
|
431 |
+
wp_clear_scheduled_hook('aDBc_clean_scheduler');
|
432 |
+
wp_schedule_event($timestamp, $repeat, "aDBc_clean_scheduler", array('cleanup_schedule'));
|
433 |
+
}else{
|
434 |
+
// If no scheduled task, delete any remining option in DB
|
435 |
+
delete_option('aDBc_clean_schedule');
|
436 |
}
|
437 |
+
|
438 |
+
// If there are any optimize cleanup tasks, change corresponding structure in DB to meet the new version
|
439 |
+
if($timestamp = wp_next_scheduled('aDBc_optimize_scheduler')){
|
440 |
+
// Prepare new structure
|
441 |
+
$repeat = get_option('aDBc_optimize_schedule');
|
442 |
+
$repeat = empty($repeat) ? 'weekly' : $repeat;
|
443 |
+
$new_schedule_params['repeat'] = $repeat;
|
444 |
+
$date = date('Y-m-d', $timestamp) . "";
|
445 |
+
$time = date('H:i', $timestamp) . "";
|
446 |
+
$new_schedule_params['start_date'] = $date;
|
447 |
+
$new_schedule_params['start_time'] = $time;
|
448 |
+
// Prepare operations to perform. Since in versions < 3.0.0 there were no repair, add only optimize to keep users settings
|
449 |
+
$operations = array('optimize');
|
450 |
+
$new_schedule_params['operations'] = $operations;
|
451 |
+
$new_schedule_params['active'] = "1";
|
452 |
+
$optimize_schedule_setting['optimize_schedule'] = $new_schedule_params;
|
453 |
+
update_option('aDBc_optimize_schedule', $optimize_schedule_setting, "no");
|
454 |
+
// Reschedule the event with arg name
|
455 |
+
wp_clear_scheduled_hook('aDBc_optimize_scheduler');
|
456 |
+
wp_schedule_event($timestamp, $repeat, "aDBc_optimize_scheduler", array('optimize_schedule'));
|
457 |
+
}else{
|
458 |
+
// If no scheduled task, delete any remining option in DB
|
459 |
+
delete_option('aDBc_optimize_schedule');
|
460 |
+
}
|
461 |
+
|
462 |
+
// Change categorization of tables, options, tasks from database to files
|
463 |
+
$types_array = array('tables', 'options', 'tasks');
|
464 |
+
foreach($types_array as $type){
|
465 |
+
$aDBc_items = get_option("aDBc_" . $type . "_status");
|
466 |
+
$aDBc_items_status = empty($aDBc_items['items_status']) ? "" : $aDBc_items['items_status'];
|
467 |
+
if(!empty($aDBc_items_status)){
|
468 |
+
$item_info = explode(",", $aDBc_items_status);
|
469 |
+
$myfile = fopen(ADBC_UPLOAD_DIR_PATH_TO_ADBC . "/" . $type . ".txt", "a");
|
470 |
+
foreach($item_info as $item){
|
471 |
+
$columns = explode(":", $item);
|
472 |
+
// A customer reported that the colon is not supported as separator in searching and all options with colon are not categorized!
|
473 |
+
// == 5 means that the option does not contain a colon. Process only these cases since intems with >=5 are by default uncategorized
|
474 |
+
if(count($columns) == 5){
|
475 |
+
fwrite($myfile, $item."\n");
|
476 |
+
}
|
477 |
+
}
|
478 |
+
fclose($myfile);
|
479 |
+
}
|
480 |
+
// Delete options in DB that store searching status since they are not used anymore in version >= 3.0.0
|
481 |
+
delete_option("aDBc_" . $type . "_status");
|
482 |
+
}
|
483 |
+
|
484 |
+
// 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
|
485 |
+
if(function_exists('is_multisite') && is_multisite()){
|
486 |
+
global $wpdb;
|
487 |
+
$blogs_ids = $wpdb->get_col("SELECT blog_id FROM $wpdb->blogs");
|
488 |
+
foreach($blogs_ids as $blog_id){
|
489 |
+
switch_to_blog($blog_id);
|
490 |
+
if(!is_main_site()){
|
491 |
+
delete_option('aDBc_optimize_schedule');
|
492 |
+
delete_option('aDBc_clean_schedule');
|
493 |
+
wp_clear_scheduled_hook('aDBc_optimize_scheduler');
|
494 |
+
wp_clear_scheduled_hook('aDBc_clean_scheduler');
|
495 |
+
}
|
496 |
+
restore_current_blog();
|
497 |
+
}
|
498 |
+
}
|
499 |
+
}else{
|
500 |
+
// If plugin_version is not empty, should we update the plugin version in DB?
|
501 |
+
if($settings['plugin_version'] != ADBC_PLUGIN_VERSION){
|
502 |
+
$settings['plugin_version'] = ADBC_PLUGIN_VERSION;
|
503 |
+
update_option('aDBc_settings', $settings, "no");
|
504 |
+
}
|
505 |
+
}
|
506 |
+
}
|
507 |
+
}
|
508 |
+
|
509 |
+
// Add admin notice to rate plugin
|
510 |
+
function aDBc_rate_notice(){
|
511 |
+
$settings = get_option('aDBc_settings');
|
512 |
+
if(!empty($settings['installed_on'])){
|
513 |
+
$ignore_rating = empty($settings['ignore_rating']) ? "" : $settings['ignore_rating'];
|
514 |
+
if($ignore_rating != "yes"){
|
515 |
+
$date1 = $settings['installed_on'];
|
516 |
+
$date2 = date("Y/m/d");
|
517 |
+
$diff = abs(strtotime($date2) - strtotime($date1));
|
518 |
+
$days = floor($diff / (60*60*24));
|
519 |
+
if($days >= 7){
|
520 |
+
$aDBc_new_URI = $_SERVER['REQUEST_URI'];
|
521 |
+
$aDBc_new_URI = add_query_arg('adbc-ignore-notice', '0', $aDBc_new_URI);
|
522 |
+
echo '<div class="updated"><p>';
|
523 |
+
printf(__('Awesome! You have been using <a href="admin.php?page=advanced_db_cleaner">Advanced DB Cleaner</a> for more than 1 week. Would you mind taking a few seconds to give it a 5-star rating on WordPress? Thank you in advance :) <a href="%2$s" target="_blank">Ok, you deserved it</a> | <a href="%1$s">I already did</a> | <a href="%1$s">No, not good enough</a>', 'advanced-database-cleaner'), $aDBc_new_URI,
|
524 |
+
'https://wordpress.org/support/plugin/advanced-database-cleaner/reviews/?filter=5');
|
525 |
+
echo "</p></div>";
|
526 |
+
}
|
527 |
+
}
|
528 |
+
}
|
529 |
+
}
|
530 |
+
function aDBc_ignore_notice(){
|
531 |
+
if(isset($_GET['adbc-ignore-notice']) && $_GET['adbc-ignore-notice'] == "0"){
|
532 |
+
$settings = get_option('aDBc_settings');
|
533 |
+
$settings['ignore_rating'] = "yes";
|
534 |
+
update_option('aDBc_settings', $settings, "no");
|
535 |
+
}
|
536 |
+
}
|
537 |
+
|
538 |
+
// Update settings when saved in "overview & settings" tab. Test also to disable premium notice if closed by users
|
539 |
+
function aDBc_update_settings(){
|
540 |
+
|
541 |
+
global $aDBc_settings;
|
542 |
+
$aDBc_settings = get_option('aDBc_settings');
|
543 |
+
if(isset($_POST['save_settings'])){
|
544 |
+
$aDBc_settings['left_menu'] = isset($_POST['aDBc_left_menu']) ? "1" : "0";
|
545 |
+
$aDBc_settings['menu_under_tools'] = isset($_POST['aDBc_menu_under_tools']) ? "1" : "0";
|
546 |
+
// In case the user does not select any of menu positions, we force the menu under tools to be shown
|
547 |
+
if(!isset($_POST['aDBc_left_menu']) && !isset($_POST['aDBc_menu_under_tools'])){
|
548 |
+
$aDBc_settings['left_menu'] = "1";
|
549 |
+
}
|
550 |
+
if(ADBC_PLUGIN_F_TYPE == "free"){
|
551 |
+
$aDBc_settings['hide_premium_tab'] = isset($_POST['aDBc_hide_premium_tab']) ? "1" : "0";
|
552 |
+
}
|
553 |
+
// Update settings in DB
|
554 |
+
update_option('aDBc_settings', $aDBc_settings, "no");
|
555 |
+
}
|
556 |
+
/********************************************************************
|
557 |
+
* Update premium notice for lost licenses
|
558 |
+
********************************************************************/
|
559 |
+
if(isset($_GET['ignore-premium-notice']) && $_GET['ignore-premium-notice'] == "yes"){
|
560 |
+
$aDBc_settings['ignore_premium'] = "yes";
|
561 |
+
update_option('aDBc_settings', $aDBc_settings, "no");
|
562 |
+
}
|
563 |
+
|
564 |
+
}
|
565 |
+
|
566 |
+
// The admin page of the plugin
|
567 |
+
function aDBc_main_page_callback(){ ?>
|
568 |
+
<div class="wrap">
|
569 |
+
|
570 |
+
<div>
|
571 |
+
<table width="100%" cellspacing="0">
|
572 |
+
<tr style="background:#fff;border:0px solid #eee;">
|
573 |
+
|
574 |
+
<td style="padding:10px 10px 10px 20px">
|
575 |
+
<img style="width:50px" src="<?php echo ADBC_PLUGIN_DIR_PATH; ?>/images/icon-128x128.png"/>
|
576 |
+
</td>
|
577 |
+
|
578 |
+
<td width="100%">
|
579 |
+
<div style="background:#fff;padding:10px;margin-bottom:10px;">
|
580 |
+
<?php
|
581 |
+
if(ADBC_PLUGIN_F_TYPE == 'free'){
|
582 |
+
$aDBc_plugin_title = "Advanced DB Cleaner '" . ADBC_PLUGIN_VERSION . "'";
|
583 |
+
}else{
|
584 |
+
$aDBc_plugin_title = "Advanced DB Cleaner <b>PRO</b> '" . ADBC_PLUGIN_VERSION . "'";
|
585 |
+
}
|
586 |
+
?>
|
587 |
+
<div style="font-size: 20px;font-weight: 400;margin-bottom:10px"><?php echo $aDBc_plugin_title; ?></div>
|
588 |
+
<div style="border-top:1px dashed #eee;padding-top:4px">
|
589 |
+
<span class="aDBc-row-text"><?php _e('By', 'advanced-database-cleaner'); ?></span>
|
590 |
+
<a class="aDBc-sidebar-link" href="https://profiles.wordpress.org/symptote/" target="_blank">Younes JFR.</a>
|
591 |
+
|
|
592 |
+
<span class="aDBc-row-text"><?php _e('Need help?', 'advanced-database-cleaner'); ?></span>
|
593 |
+
<a class="aDBc-sidebar-link" href="http://sigmaplugin.com/contact" target="_blank"><?php _e('Contact me', 'advanced-database-cleaner'); ?></a>
|
594 |
+
</div>
|
595 |
+
</div>
|
596 |
+
</td>
|
597 |
+
|
598 |
+
<td style="text-align:center">
|
599 |
+
<div style="background:#fff;padding:10px;margin-bottom:10px;">
|
600 |
+
<a class="aDBc-sidebar-link" href="http://sigmaplugin.com/contact" target="_blank">
|
601 |
+
<img style="width:50px" src="<?php echo ADBC_PLUGIN_DIR_PATH; ?>/images/help.svg"/>
|
602 |
+
<br/>
|
603 |
+
<span><?php _e('Support', 'advanced-database-cleaner'); ?></span>
|
604 |
+
</a>
|
605 |
+
</div>
|
606 |
+
</td>
|
607 |
+
</tr>
|
608 |
+
</table>
|
609 |
+
</div>
|
610 |
+
|
611 |
+
<h1 style="font-size:10px"></h1>
|
612 |
+
|
613 |
+
<?php
|
614 |
+
if(ADBC_PLUGIN_F_TYPE == 'pro' && !aDBc_edd_is_license_activated()){
|
615 |
+
echo '<div class="aDBc-please-activate-msg notice is-dismissible"><p>' . __('Please activate your license key to get lifetime automatic updates and support.', 'advanced-database-cleaner') . " <a href='?page=advanced_db_cleaner&aDBc_tab=license'>" . __('Activate now', 'advanced-database-cleaner') . "</a>" . '</p></div>';
|
616 |
+
}
|
617 |
+
global $aDBc_settings;
|
618 |
+
|
619 |
+
// This is a notice for premium users who will lose pro version when upgrading to 3.0.0 from an old version
|
620 |
+
if(ADBC_PLUGIN_F_TYPE == 'free' && !empty($aDBc_settings['ignore_premium']) && $aDBc_settings['ignore_premium'] == "no"){
|
621 |
+
|
622 |
+
$aDBc_new_URI = $_SERVER['REQUEST_URI'];
|
623 |
+
$aDBc_new_URI = add_query_arg('ignore-premium-notice', 'yes', $aDBc_new_URI);
|
624 |
+
|
625 |
+
?>
|
626 |
+
<div id="aDBc_main_msg" class="aDBc-premium-lost-msg">
|
627 |
+
<span style="float:left;margin-bottom:20px"><?php _e('Important notice to premium users!', 'advanced-database-cleaner'); ?></span>
|
628 |
+
<a style="text-decoration:none;float:right" href="<?php echo $aDBc_new_URI ?>">
|
629 |
+
<span class="dashicons-dismiss dashicons"></span>
|
630 |
+
</a>
|
631 |
+
<p style="font-size:13px;clear:both">
|
632 |
+
<?php _e('You will probably lose the pro version after this upgrade (This is due to a conflict between the free and pro versions which is now solved). If it is the case, please follow these <a target ="_blank" href="https://sigmaplugin.com/blog/restore-pro-version-after-upgrade-to-3-0-0">steps to restore your pro version</a> with all new features. Thank you :)', 'advanced-database-cleaner'); ?>
|
633 |
+
<br/>
|
634 |
+
<span style="font-size:12px;color:#999"><?php _e('If you are not a premium user, please kindly just close this message since you are not concerned by this issue!', 'advanced-database-cleaner'); ?></span>
|
635 |
+
</p>
|
636 |
+
</div>
|
637 |
+
<?php
|
638 |
+
}
|
639 |
+
|
640 |
+
if(ADBC_PLUGIN_F_TYPE == 'free'){
|
641 |
+
$aDBc_margin_class = "aDBc-margin-r-300";
|
642 |
+
}else{
|
643 |
+
$aDBc_margin_class = "";
|
644 |
+
}
|
645 |
+
|
646 |
+
?>
|
647 |
+
<div class="<?php echo $aDBc_margin_class; ?>">
|
648 |
+
<div class="aDBc-tab-box">
|
649 |
+
<?php
|
650 |
+
$aDBc_tabs = array('general' => __('General clean-up', 'advanced-database-cleaner'),
|
651 |
+
'tables' => __('Tables', 'advanced-database-cleaner'),
|
652 |
+
'options' => __('Options', 'advanced-database-cleaner'),
|
653 |
+
'cron' => __('Cron jobs', 'advanced-database-cleaner'),
|
654 |
+
'overview' => __('Overview & settings', 'advanced-database-cleaner'),
|
655 |
+
'premium' => __('Premium', 'advanced-database-cleaner'),
|
656 |
+
'license' => __('License', 'advanced-database-cleaner')
|
657 |
+
);
|
658 |
+
|
659 |
+
// If we are in free version or if the user choosed to hide the premium tab, then hide it
|
660 |
+
// Also hide license tab
|
661 |
+
if(ADBC_PLUGIN_F_TYPE == "pro" || (!empty($aDBc_settings['hide_premium_tab']) && $aDBc_settings['hide_premium_tab'] == "1")){
|
662 |
+
unset($aDBc_tabs['premium']);
|
663 |
+
}
|
664 |
+
|
665 |
+
// If we are in free version, hide license tab
|
666 |
+
if(ADBC_PLUGIN_F_TYPE == "free"){
|
667 |
+
unset($aDBc_tabs['license']);
|
668 |
+
}
|
669 |
+
|
670 |
+
$aDBc_dashicons_css = array('general' => 'dashicons-format-aside dashicons',
|
671 |
+
'tables' => 'dashicons-grid-view dashicons',
|
672 |
+
'options' => 'dashicons-forms dashicons',
|
673 |
+
'cron' => 'dashicons-backup dashicons',
|
674 |
+
'overview' => 'dashicons-admin-settings dashicons',
|
675 |
+
'premium' => 'dashicons-awards dashicons',
|
676 |
+
'license' => 'dashicons-admin-network dashicons',
|
677 |
+
);
|
678 |
+
|
679 |
+
$current_tab = isset($_GET['aDBc_tab']) ? $_GET['aDBc_tab'] : 'general';
|
680 |
+
|
681 |
+
echo '<h2 class="nav-tab-wrapper">';
|
682 |
+
foreach($aDBc_tabs as $tab => $name){
|
683 |
+
$class = ($tab == $current_tab) ? ' nav-tab-active' : '';
|
684 |
+
$link = "?page=advanced_db_cleaner&aDBc_tab=$tab";
|
685 |
+
if($tab == "tables" || $tab == "options" || $tab == "cron"){
|
686 |
+
$link .= '&aDBc_cat=all';
|
687 |
+
}
|
688 |
+
echo "<a class='nav-tab$class' href='$link'><span class='$aDBc_dashicons_css[$tab]'></span> $name</a>";
|
689 |
+
}
|
690 |
+
echo '</h2>';
|
691 |
+
|
692 |
+
echo '<div class="aDBc-tab-box-div">';
|
693 |
+
switch ($current_tab){
|
694 |
+
case 'general' :
|
695 |
+
include_once 'includes/clean_db.php';
|
696 |
+
break;
|
697 |
+
case 'tables' :
|
698 |
+
include_once 'includes/optimize_db.php';
|
699 |
+
break;
|
700 |
+
case 'options' :
|
701 |
+
include_once 'includes/class_clean_options.php';
|
702 |
+
break;
|
703 |
+
case 'cron' :
|
704 |
+
include_once 'includes/class_clean_cron.php';
|
705 |
+
break;
|
706 |
+
case 'overview' :
|
707 |
+
include_once 'includes/overview_settings.php';
|
708 |
+
break;
|
709 |
+
case 'premium' :
|
710 |
+
include_once 'includes/premium_page.php';
|
711 |
+
break;
|
712 |
+
case 'license' :
|
713 |
+
aDBc_edd_license_page();
|
714 |
+
break;
|
715 |
+
}
|
716 |
+
echo '</div>';
|
717 |
+
?>
|
718 |
+
</div>
|
719 |
+
|
720 |
+
<!-- In pro version, don't show sidebar -->
|
721 |
+
<?php if(ADBC_PLUGIN_F_TYPE == "free"){ ?>
|
722 |
+
<div class="aDBc-sidebar"><?php include_once 'includes/sidebar.php'; ?></div>
|
723 |
+
<?php } ?>
|
724 |
+
|
725 |
</div>
|
|
|
726 |
</div>
|
727 |
+
<?php
|
728 |
+
}
|
729 |
}
|
730 |
|
|
|
|
|
|
|
|
|
|
|
|
|
731 |
|
732 |
+
|
733 |
+
|
734 |
+
// Get instance
|
735 |
+
new ADBC_Advanced_DB_Cleaner();
|
css/admin.css
CHANGED
@@ -6,23 +6,28 @@
|
|
6 |
html {
|
7 |
overflow-y: scroll;
|
8 |
}
|
9 |
-
.aDBc-
|
10 |
-
border-left: 5px solid
|
11 |
background: #fff !important;
|
12 |
padding: 20px !important;
|
13 |
}
|
14 |
-
.aDBc-
|
15 |
-
font-size:
|
16 |
-
|
|
|
17 |
font-weight: bold;
|
18 |
}
|
19 |
-
|
|
|
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 |
}
|
@@ -41,51 +46,100 @@ html {
|
|
41 |
.aDBc-float-right{
|
42 |
float: right;
|
43 |
}
|
44 |
-
|
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 |
-
|
|
|
56 |
background-position: 50% 0% !important;
|
57 |
text-align: center;
|
58 |
-
margin: -20px 0px 0px 0px;
|
59 |
-
}
|
60 |
.aDBc-category-counts{
|
61 |
-
|
62 |
-
|
63 |
-
|
|
|
|
|
|
|
|
|
64 |
}
|
65 |
.aDBc-category-counts a:hover{
|
66 |
-
padding-bottom:
|
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 |
-
|
79 |
-
|
80 |
}
|
81 |
-
.aDBc-run-new-search{
|
82 |
height: 34px !important;
|
83 |
-
min-width:
|
84 |
-
background-image: url("../images/search-icon.
|
85 |
background-repeat: no-repeat !important;
|
86 |
background-position: 8px 50% !important;
|
87 |
-
padding-left:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
88 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
89 |
.aDBc-category-color{
|
90 |
padding: 0px 5px;
|
91 |
margin-right: 5px;
|
@@ -97,39 +151,89 @@ html {
|
|
97 |
}
|
98 |
.aDBc-left-content{
|
99 |
float: left;
|
100 |
-
width:
|
101 |
margin-right: 25px
|
102 |
}
|
103 |
.aDBc-text-status-db{
|
104 |
font-family: verdana;
|
105 |
-
font-size:
|
106 |
}
|
107 |
.aDBc-schedule-text{
|
108 |
-
font-weight: bold
|
109 |
-
padding:
|
110 |
-
font-
|
|
|
|
|
111 |
}
|
112 |
-
.aDBc-schedule-
|
113 |