After years of creating new content, changing themes, and adding and removing plugins, a WordPress installation can become littered with unused, orphaned, and duplicated data. Not every plugin properly extricates itself and its data from your site when you uninstall.
Lester Chan‘s new WP Sweep plugin was designed to perform housekeeping on WordPress installations. Chan is a prolific plugin developer, who created his first plugin in 2003 shortly after WordPress was forked from b2. He now has 24+ plugins listed in directory.
WP-Sweep’s distinguishing characteristic is that it uses proper WordPress delete functions as much as possible instead of running direct delete MySQL queries. This method is in direct contrast to similarly purposed plugins such as WP-Optimize, which has been downloaded more than 1.5 million times.
Looking through WP-Optimize and they are using SQL query to delete post revisions which means there will be orphaned data left behind.
— Lester Chan (@gamerz) February 23, 2015
What can WP-Sweep clean?
WP-Sweep uses WordPress delete functions, such as wp_delete_post_revision()
, delete_post_meta()
, wp_delete_comment()
, etc. to clean up the database. It can perform sweeps of all of the following:
- Revisions
- Auto drafts
- Deleted comments
- Unapproved comments
- Spammed comments
- Deleted comments
- Orphaned post meta
- Orphaned comment meta
- Orphaned user meta
- Orphan term relationships
- Unused terms
- Duplicated post meta
- Duplicated comment meta
- Duplicated user meta
- Transient options
WP-Sweep can be found under the tools menu after you install it. It will give you a full overview of items that can be cleaned up.
Scroll further down and you’ll see reports for comments, users, terms, and options. Certain sweeps have extra instructions to consider before using, i.e unused terms: “Note that some unused terms might belong to draft posts that have not been published yet. Only sweep this when you do not have any draft posts.”
One user tested the plugin and reported a savings of 23.5% on database size. He also reported a bug, which Chan promptly fixed.
@gamerz plugin saved me 23,5% of a database size. But not everything works as expected: https://t.co/UeiDedH7Yd
— Slava Abakumov (@slaFFik) February 25, 2015
Chan plans to continue to develop the plugin and is considering adding unused options to the sweeps in a future version. If you want to use the plugin to clean up your website, you are strongly advised to make a backup of your database first, as the actions it performs are irreversible. Check out WP-Sweep on WordPress.org and favorite it for the next time you need to do some database housekeeping.
Sara, I’m glad you posted this.
I’ve been using the WP-Optimize plugin daily in 3 different WordPress installations. What I never really understood was why the existence of database remnants of previously uninstalled plugins always seemed to be maintained. I posted this question on the plugin’s support forums here over 4 months ago: https://wordpress.org/support/topic/deleted-plugins-remnants-recreation?replies=5 and even though the developer was both polite and helpful, I never got a good idea on HOW to get rid of previous plugins’ leftovers.
Months ago, I temporarily installed BuddyPress on all 3 of those websites and bits-and-pieces of the software still remain. Because of your previous post back on February 20th here: https://wptavern.com/new-plugin-detects-shared-terms-in-wordpress-ahead-of-taxonomy-term-splitting-in-4-2 , I started re-evaluating my usage of older plugins. Approximately 1 hour ago I disabled and uninstalled the WP-Optimize plugin, deleted my cache, installed this WP-Sweep plugin, and then ran the sweep. So far…So good. I’ll let you know how things progress (one thing I noticed is that all 3 installations updated much more quickly).
(For me, the correct selection and usage of plugins can be confusing, frustrating, and quite a learning curve over time.)