Clean Up WordPress with the New WP-Sweep Plugin

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.