Keeps your WordPress database clean
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
README.md
WordpressCleaner.php
index.php
style.css

README.md

WordPress Cleaner

Removes most common junk from your WordPress database. Can significantly decrease size of your tables. Currently script recognizes following types of unneeded data:

  • post revisions (disabled by default)
  • auto drafts
  • spam comments
  • unapproved comments
  • orphan commentmeta
  • orphan postmeta
  • transient options
  • akismet commentmeta

Usage

Just drop these files in their own directory, name it cleaner or whatever. Visit the URL, fill in the form and run it. Oh, and really, don't ignore that big red warning and backup your database before you start.

Format of tasks

It is very easy to extend script functionallity. Look at the format of WordpressCleaner::$tasks entry:

'spam_comments' => [
    'name' => 'Spam comments',
    'desc' => 'Removes comments marked as spam',
    'query' => "DELETE FROM {prefix}comments WHERE comment_approved = 'spam'",
    'default' => true
]

Element's key is used as a internal task identifier. Keys in associative array are rather self explanatory. One thing worth noting is the fact that whenever you use {prefix} in the query, it will be substituted with WordPress table prefix.

More advanced tasks

You might need more complex logic than just execute query. If so, pass false as query value. Script will then look for WordpressCleaner::taskYourTaskId() method - it can't take any arguments and must return number of deleted items. Look at the example.

// Entry in WordpressCleaner::$task
'advanced_task' => [
    'name' => 'Advanced task',
    'desc' => 'More than just a query!',
    'query' => false,
    'default' => false
]

// Custom method in WordpressCleaner.php
private function taskAdvancedTask() {
    // Your awesome complex logic

    return 667; // Return number of removed rows/items
}

Contributions and/or feedback are most certainly welcome!

Screenshot