Clean Up WordPress with the New WP-Sweep Plugin

clean-up

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.

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.

wp-sweep

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.

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.

20 Comments


  1. 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.)

    Report


  2. Hey Sarah
    Looks comprehensive, it’s receiving great reviews. The “Backup your database first” tip at the top of the plugin page is essential, take note people!

    There’s nothing like a bloated database to slow down a website, so it’s well worth the time invested to clean it up.

    A preventative measure is to limit the number of post revisions stored by WordPress in the database, I use a plugin called Revision Control to limit the number of stored revisions to three.

    Cheers
    Chris

    Report


    1. Alternatively, use this snippet and put in the wp-config.php Too much plugin bloat your wp, doesn’t it? :)

      Report


    2. /**
      * Limit wordpress post revisions
      *
      */
      define( ‘WP_POST_REVISIONS’, 5 ); // limited to 5 revisions

      Report


    1. I was thinking the exact same thing. I assume it’s missing because he wants you to look over every option closely before sweeping, but after doing it a few times, most of us are going to want that sweep all option.

      Report


      1. Sweep All (with “be careful” text), plus a Details button so you can see what will be cleaned for each area, were both added to the Beta version Lester created yesterday (see link added below by shapeshifter3). Nice improvements!

        Report


  3. This looks like a great plugin to add to most sites. I will definitely look into this. Thanks to Lester for creating this.

    Report


  4. Thanks for the plug guys =D I intend to add a Sweep All and Cron feature in the future =D

    Report


  5. Hi Sarah. After reading was quite excited to try WP Sweep. Just wanted to understand how different it is from WP Clean Up which I currently use..

    Report


  6. Maybe other developers can inspire by you Lester. I checked all your plugins are updated, all have necessary details, screenshots. Also how you active support them all in support forum, it shows your passion for this.
    I read your “bio” :) it explain that.

    Report


  7. Very nice. I would really like to see the ability to view what will be deleted before I use the Sweep button. For example, my site shows a few Orphaned Term Relationships. I’d like to be able to view what they are (perhaps by clicking on the number in the Count column) so I can feel more confident about pressing Sweep.

    Report


      1. Good idea! I thought about the same too, I will probably add that in in the future.

        Report


  8. That’s great news! Lester makes some really good stuff, and I expect that this will be just as awesome.

    I’ve been using a couple tools for this, and it looks like this might actually cover both of them, and if it uses legit WP functions, what’s not to like?

    Thanks!!!
    Dave

    Report


  9. I’m a big fan of WP-Optimize, so I’m eager to try this plugin and compare results. And backing that thang up before making any changes to the database is always a pretty good idea.

    Report


  10. This is my new installed plugin and Never regretted I did! Awesome!

    Report

Comments are closed.