WP-Sweep
Add to ListThis plugin cleans up:
- Revisions
- Auto drafts
- Deleted comments
- Unapproved comments
- Spammed comments
- Deleted comments
- Orphaned post meta
- Orphaned comment meta
- Orphaned user meta
- Orphaned term meta
- Orphan term relationships
- Unused terms
- Duplicated post meta
- Duplicated comment meta
- Duplicated user meta
- Duplicated term meta
- Transient options
- Optimizes database tables
- oEmbed caches in post meta
This plugin uses proper WordPress delete functions as much as possible instead of running direct delete MySQL queries.
Following delete functions are used:
- wp_delete_post_revision()
- wp_delete_post()
- wp_delete_comment()
- delete_post_meta()
- delete_comment_meta()
- delete_user_meta()
- delete_term_meta()
- wp_remove_object_terms()
- wp_delete_term()
- delete_transient()
- delete_site_transient()
WP-Sweep WP REST API Endpoints
* GET /wp-json/sweep/v1/count/<Name>. Get the number of items that we will be sweeping.
* GET /wp-json/sweep/v1/details/<Name>. Get the details of the items that we will be sweeping.
* DELETE /wp-json/sweep/v1/sweep/<Name>. Runs sweep for that particular item.
WP-Sweep WP-CLI Commands
* wp sweep --all. Runs sweep for all items.
* wp sweep <Name>. Runs sweep for that particular item.
* wp sweep <Name1> <Name2>. Run sweep for the selected items.
WP-Sweep Available Items:
* revisions
* auto_drafts
* deleted_posts
* unapproved_comments
* spam_comments
* deleted_comments
* transient_options
* orphan_postmeta
* orphan_commentmeta
* orphan_usermeta
* orphan_termmeta
* orphan_term_relationships
* unused_terms
* duplicated_postmeta
* duplicated_commentmeta
* duplicated_usermeta
* duplicated_termmeta
* optimize_database
* oembed_postmeta
WP-Sweep Available Filters:
WP-Sweep exposes a number of filters so you can customise what gets swept and protect data you do not want deleted.
wp_sweep_postmeta_whitelist(array) — Meta keys to exclude when sweeping orphaned and duplicated post meta. Return an array ofmeta_keyvalues to keep them from being deleted. Default: empty array.wp_sweep_commentmeta_whitelist(array) — Meta keys to exclude when sweeping orphaned and duplicated comment meta. Default: empty array.wp_sweep_usermeta_whitelist(array) — Meta keys to exclude when sweeping orphaned and duplicated user meta. Default: empty array.wp_sweep_termmeta_whitelist(array) — Meta keys to exclude when sweeping orphaned and duplicated term meta. Default: empty array.wp_sweep_excluded_taxonomies(array) — Taxonomies to exclude from the orphaned term relationships sweep. Default:array( 'link_category' ).wp_sweep_excluded_termids(array) — Term IDs to exclude from the unused terms sweep. Default: the default taxonomy terms plus any term that is a parent of another term.wp_sweep_total_count(int$count, string$name) — Filter the total number of rows reported for a given sweep type (used for the “% of” column).wp_sweep_count(int$count, string$name) — Filter the number of items that will be swept for a given sweep name.wp_sweep_details(array$details, string$name) — Filter the sample list of items shown in the details view for a given sweep name.wp_sweep_sweep(string$message, string$name) — Filter the result message returned after a sweep has run.
Example — protect specific post meta keys from being swept:
add_filter( 'wp_sweep_postmeta_whitelist', function ( $meta_keys ) {
$meta_keys[] = '_my_plugin_setting';
$meta_keys[] = '_keep_this_meta';
return $meta_keys;
} );
Example — exclude an additional taxonomy from the orphaned term relationships sweep:
add_filter( 'wp_sweep_excluded_taxonomies', function ( $taxonomies ) {
$taxonomies[] = 'product_type';
return $taxonomies;
} );
WP-Sweep is not compatible with the following plugins:
* Custom Fonts
* Elementor Popup Builder
* MailPress
* Meta Slider
* Polylang
* Slider Revolution
* Viba Portfolio
* WPML
Development
Credits
Donations
I spent most of my free time creating, updating, maintaining and supporting these plugins, if you really love my plugins and could spare me a couple of bucks, I will really appreciate it. If not feel free to use it without any obligations.