wp-sweep
Last commit date
inc
1 month ago
js
9 years ago
CLAUDE.md
3 months ago
admin.php
7 years ago
composer.json
6 years ago
composer.lock
6 years ago
index.php
7 years ago
readme.txt
1 month ago
uninstall.php
7 years ago
wp-sweep.php
1 month ago
readme.txt
242 lines
| 1 | # WP-Sweep |
| 2 | Contributors: GamerZ |
| 3 | Donate link: https://lesterchan.net/site/donation/ |
| 4 | Tags: sweep, clean, cleanup, clean up, optimize, orphan, unused, duplicated, posts, post meta, comments, comment meta, users, user meta, terms, term meta, term relationships, revisions, auto drafts, transient, database, tables, oembed |
| 5 | Requires at least: 4.6 |
| 6 | Tested up to: 7.0 |
| 7 | Stable tag: 1.2.0 |
| 8 | License: GPLv2 or later |
| 9 | License URI: http://www.gnu.org/licenses/gpl-2.0.html |
| 10 | |
| 11 | WP-Sweep allows you to clean up unused, orphaned and duplicated data in your WordPress. It also optimizes your database tables. |
| 12 | |
| 13 | ## Description |
| 14 | This plugin cleans up: |
| 15 | |
| 16 | * Revisions |
| 17 | * Auto drafts |
| 18 | * Deleted comments |
| 19 | * Unapproved comments |
| 20 | * Spammed comments |
| 21 | * Deleted comments |
| 22 | * Orphaned post meta |
| 23 | * Orphaned comment meta |
| 24 | * Orphaned user meta |
| 25 | * Orphaned term meta |
| 26 | * Orphan term relationships |
| 27 | * Unused terms |
| 28 | * Duplicated post meta |
| 29 | * Duplicated comment meta |
| 30 | * Duplicated user meta |
| 31 | * Duplicated term meta |
| 32 | * Transient options |
| 33 | * Optimizes database tables |
| 34 | * oEmbed caches in post meta |
| 35 | |
| 36 | This plugin uses proper WordPress delete functions as much as possible instead of running direct delete MySQL queries. |
| 37 | |
| 38 | Following delete functions are used: |
| 39 | |
| 40 | * wp_delete_post_revision() |
| 41 | * wp_delete_post() |
| 42 | * wp_delete_comment() |
| 43 | * delete_post_meta() |
| 44 | * delete_comment_meta() |
| 45 | * delete_user_meta() |
| 46 | * delete_term_meta() |
| 47 | * wp_remove_object_terms() |
| 48 | * wp_delete_term() |
| 49 | * delete_transient() |
| 50 | * delete_site_transient() |
| 51 | |
| 52 | WP-Sweep WP REST API Endpoints |
| 53 | * `GET /wp-json/sweep/v1/count/<Name>`. Get the number of items that we will be sweeping. |
| 54 | * `GET /wp-json/sweep/v1/details/<Name>`. Get the details of the items that we will be sweeping. |
| 55 | * `DELETE /wp-json/sweep/v1/sweep/<Name>`. Runs sweep for that particular item. |
| 56 | |
| 57 | WP-Sweep WP-CLI Commands |
| 58 | * `wp sweep --all`. Runs sweep for all items. |
| 59 | * `wp sweep <Name>`. Runs sweep for that particular item. |
| 60 | * `wp sweep <Name1> <Name2>`. Run sweep for the selected items. |
| 61 | |
| 62 | WP-Sweep Available Items: |
| 63 | * revisions |
| 64 | * auto_drafts |
| 65 | * deleted_posts |
| 66 | * unapproved_comments |
| 67 | * spam_comments |
| 68 | * deleted_comments |
| 69 | * transient_options |
| 70 | * orphan_postmeta |
| 71 | * orphan_commentmeta |
| 72 | * orphan_usermeta |
| 73 | * orphan_termmeta |
| 74 | * orphan_term_relationships |
| 75 | * unused_terms |
| 76 | * duplicated_postmeta |
| 77 | * duplicated_commentmeta |
| 78 | * duplicated_usermeta |
| 79 | * duplicated_termmeta |
| 80 | * optimize_database |
| 81 | * oembed_postmeta |
| 82 | |
| 83 | WP-Sweep Available Filters: |
| 84 | |
| 85 | WP-Sweep exposes a number of filters so you can customise what gets swept and protect data you do not want deleted. |
| 86 | |
| 87 | * `wp_sweep_postmeta_whitelist` (array) — Meta keys to exclude when sweeping orphaned and duplicated **post** meta. Return an array of `meta_key` values to keep them from being deleted. Default: empty array. |
| 88 | * `wp_sweep_commentmeta_whitelist` (array) — Meta keys to exclude when sweeping orphaned and duplicated **comment** meta. Default: empty array. |
| 89 | * `wp_sweep_usermeta_whitelist` (array) — Meta keys to exclude when sweeping orphaned and duplicated **user** meta. Default: empty array. |
| 90 | * `wp_sweep_termmeta_whitelist` (array) — Meta keys to exclude when sweeping orphaned and duplicated **term** meta. Default: empty array. |
| 91 | * `wp_sweep_excluded_taxonomies` (array) — Taxonomies to exclude from the orphaned term relationships sweep. Default: `array( 'link_category' )`. |
| 92 | * `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. |
| 93 | * `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). |
| 94 | * `wp_sweep_count` (int `$count`, string `$name`) — Filter the number of items that will be swept for a given sweep name. |
| 95 | * `wp_sweep_details` (array `$details`, string `$name`) — Filter the sample list of items shown in the details view for a given sweep name. |
| 96 | * `wp_sweep_sweep` (string `$message`, string `$name`) — Filter the result message returned after a sweep has run. |
| 97 | |
| 98 | Example — protect specific post meta keys from being swept: |
| 99 | |
| 100 | ~~~ |
| 101 | add_filter( 'wp_sweep_postmeta_whitelist', function ( $meta_keys ) { |
| 102 | $meta_keys[] = '_my_plugin_setting'; |
| 103 | $meta_keys[] = '_keep_this_meta'; |
| 104 | return $meta_keys; |
| 105 | } ); |
| 106 | ~~~ |
| 107 | |
| 108 | Example — exclude an additional taxonomy from the orphaned term relationships sweep: |
| 109 | |
| 110 | ~~~ |
| 111 | add_filter( 'wp_sweep_excluded_taxonomies', function ( $taxonomies ) { |
| 112 | $taxonomies[] = 'product_type'; |
| 113 | return $taxonomies; |
| 114 | } ); |
| 115 | ~~~ |
| 116 | |
| 117 | WP-Sweep is not compatible with the following plugins: |
| 118 | * [Custom Fonts](https://wordpress.org/plugins/custom-fonts/) |
| 119 | * [Elementor Popup Builder](https://elementor.com/features/popup-builder/) |
| 120 | * [MailPress](https://wordpress.org/plugins/mailpress/) |
| 121 | * [Meta Slider](https://wordpress.org/support/plugin/ml-slider/) |
| 122 | * [Polylang](https://wordpress.org/plugins/polylang/) |
| 123 | * [Slider Revolution](https://revolution.themepunch.com/) |
| 124 | * [Viba Portfolio](https://codecanyon.net/item/viba-portfolio-wordpress-plugin/9561599) |
| 125 | * [WPML](https://wpml.org/) |
| 126 | |
| 127 | ### Development |
| 128 | * [https://github.com/lesterchan/wp-sweep](https://github.com/lesterchan/wp-sweep "https://github.com/lesterchan/wp-sweep") |
| 129 | |
| 130 | ### Credits |
| 131 | * Plugin icon by [Freepik](http://www.freepik.com) from [Flaticon](http://www.flaticon.com) |
| 132 | |
| 133 | ### Donations |
| 134 | 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. |
| 135 | |
| 136 | ## Changelog |
| 137 | ### 1.2.0 |
| 138 | * NEW: Per-type meta key filters (`wp_sweep_postmeta_whitelist`, `wp_sweep_commentmeta_whitelist`, `wp_sweep_usermeta_whitelist`, `wp_sweep_termmeta_whitelist`) to protect metadata from accidental deletion |
| 139 | * NEW: Documented all available filters in README |
| 140 | |
| 141 | ### 1.1.9 |
| 142 | * NEW: Bump WordPress 7.0 |
| 143 | * NEW: Add CLAUDE.md |
| 144 | |
| 145 | ### 1.1.8 |
| 146 | * FIXED: Added current_user_can() Check For AJAX Calls |
| 147 | |
| 148 | ### 1.1.7 |
| 149 | * FIXED: Pass in default blank string to fix fatal error |
| 150 | |
| 151 | ### 1.1.6 |
| 152 | * NEW: Re-org wp-sweep.php to inc/class-wpsweep.php |
| 153 | * NEW: Bump to WordPress 6.2 |
| 154 | |
| 155 | ### 1.1.5 |
| 156 | * NEW: Bump to WordPress 5.8 |
| 157 | |
| 158 | ### 1.1.4 |
| 159 | * FIXED: Replaced %\_transient\_% with %\\\_transient\\\_%. Escape _ in MySQL if not it is being used as a wildcard character. Props @janrenn. |
| 160 | |
| 161 | ### 1.1.3 |
| 162 | * FIXED: Changed permissions check to `activate_plugins` because `update_plugins` will return false when DISALLOW_FILE_MODS=true. |
| 163 | |
| 164 | ### 1.1.2 |
| 165 | * NEW: Changed permission check to `update_plugins` for better MultiSite compatibility. |
| 166 | * NEW: Bump min PHP version to 5.6. |
| 167 | |
| 168 | ### 1.1.1 |
| 169 | * NEW: `wp_sweep_excluded_termids` filter. |
| 170 | |
| 171 | ### 1.1.0 |
| 172 | * NEW: Added WP Rest API Endpoint support, `sweep/v1/count/<Name>`, `sweep/v1/details/<Name>`, and `sweep/v1/sweep/<Name>` |
| 173 | * FIXED: Follow as close as possible to WordPress Coding Standards |
| 174 | |
| 175 | ### 1.0.12 |
| 176 | * NEW: Bump to WordPress 4.9 |
| 177 | * NEW: Update README to incompatible plugins |
| 178 | |
| 179 | ### 1.0.10 |
| 180 | * FIXED: Invalid plugin head 'This plugin has an invalid header.' |
| 181 | |
| 182 | ### 1.0.9 |
| 183 | * NEW: Support for Codeclimate |
| 184 | * FIXES: Uses `get_sites()` on WordPress 4.6. This should fix deprecated notices. |
| 185 | * FIXES: Fixes translation placeholder count. Props @pedro-mendonca. |
| 186 | * FIXES: Use `manage_options` capability as it conflicts with Admin Menu Editor on multisite installs. Props @EusebiuOprinoiu. |
| 187 | |
| 188 | ### 1.0.8 |
| 189 | * NEW: Added wp_sweep_excluded_taxonomies filter to allow more than just link_category taxonomy |
| 190 | * NEW: Support for WP-CLI `wp sweep` |
| 191 | |
| 192 | ### 1.0.7 |
| 193 | * FIXES: Use custom query to delete Orphaned Term Relationship if wp_remove_object_terms() fails |
| 194 | |
| 195 | ### 1.0.6 |
| 196 | * NEW: Delete 'languages' folder from the plugin |
| 197 | * NEW: Use translate.wordpress.org to translate the plugin |
| 198 | * FIXED: Works only with WordPress 4.4 because of new term meta |
| 199 | |
| 200 | ### 1.0.5 |
| 201 | * FIXED: apply_filters() wrong arguments |
| 202 | |
| 203 | ### 1.0.4 |
| 204 | * NEW: oEmbed caches in post meta Sweep |
| 205 | * NEW: Add POT file for translators |
| 206 | |
| 207 | ### 1.0.3 |
| 208 | * NEW: AJAX Sweep All |
| 209 | * NEW: AJAX Sweeping |
| 210 | * NEW: View details of sweep |
| 211 | * NEW: Optimize DB sweep |
| 212 | * NEW: User hint and confirmation. Props @SiamKreative |
| 213 | * FIXED: Division by zero. Pros @barisunver |
| 214 | |
| 215 | ### 1.0.2 |
| 216 | * FIXED: Use term_id for wp_remove_object_terms() |
| 217 | * FIXED: number_format_i18n() issues after sweeping |
| 218 | |
| 219 | ### 1.0.1 |
| 220 | * NEW: Moved plugin location to WP-Admin -> Tools -> Sweep |
| 221 | * NEW: Add Deleted Post Sweep |
| 222 | * FIXED: Use forced_delete for wp_delete_post() and wp_delete_comment(); |
| 223 | * FIXED: If orphaned meta has an object id of 0, use SQL query to delete |
| 224 | |
| 225 | ### 1.0.0 |
| 226 | * Initial release |
| 227 | |
| 228 | ## Installation |
| 229 | 1. Upload `wp-sweep` folder to the `/wp-content/plugins/` directory |
| 230 | 2. Activate the `WP-Sweep` plugin through the 'Plugins' menu in WordPress |
| 231 | 3. You can access `WP-Sweep` via `WP-Admin -> Tools -> Sweep` |
| 232 | |
| 233 | ## Screenshots |
| 234 | 1. WP-Sweep Administrator Page (Before Sweeping) |
| 235 | 2. WP-Sweep Administrator Page (Swept) |
| 236 | |
| 237 | ## Frequently Asked Questions |
| 238 | Coming soon ... |
| 239 | |
| 240 | ## Upgrade Notice |
| 241 | N/A |
| 242 |