Plugins can be a great boon to WordPress sites, but there are times they outlive their usefulness.

If a plugin fulfills a function you don’t need anymore, stops being updated, or appears to slow your site down, it may be time to remove it.

Normally to delete a plugin you would go to the Plugins section of the admin, deactivate it first, and then select the delete option. Then you’re done… right?

Unfortunately, not always.

Uninstalling a plugin should be a simple task, but it is not always the case. Plugins can store data in a number of places, and unfortunately, not all developers include an uninstall script which fully removes that data.

In this post, we’ll cover:

What plugins typically store data?

Plugins which ask for user input are the most likely to store data.

They include:

  • Form plugins
  • Caching plugins
  • SEO plugins
  • Security plugins

Where do plugins store data?

The wp_options database table stores information on which plugins are active, and what settings they have active.

Custom database tables are created by some plugins to store data.

Plugins may modify WordPress’ wp-config.php file. If your site runs on Apache, the .htaccess file may have rules added to it. These could include security or caching settings, for example.

Files and folders within the wp-content folder may be created by plugins too.

To identify what’s added by plugins, it helps to know what’s in a standard WordPress install.

What’s in a new install of WordPress?

Database tables

A new install of WordPress will have the following tables:

  1. wp_commentmeta
  2. wp_comments
  3. wp_links
  4. wp_options
  5. wp_postmeta
  6. wp_posts
  7. wp_termmeta
  8. wp_terms
  9. wp_term_relationships
  10. wp_term_taxonomy
  11. wp_usermeta
  12. wp_users
Tables in a single vanilla WordPress install
Tables in a single vanilla WordPress install

If you set up a multisite you’ll have those 12 tables plus a few more:

  1. wp_blogs
  2. wp_blog_versions
  3. wp_registration_log
  4. wp_signups
  5. wp_site
  6. wp_sitemeta

Your WordPress install might have a prefix other than wp_ if you chose another one on install, or have altered it through the use of a plugin. (For simplicity I’ll continue to mention wp_ as a shorthand for your database table prefix.)

For each new site you add to a multisite, there will be another ten tables starting with wp_2_ etc.

wp-content folder

The basic WordPress folder has an index.php file and two subfolders:

  • plugins
  • themes

A mature install will likely have other subfolders which may include the following:

  • languages
  • mu-plugins
  • upgrade
  • uploads

Any other folders present may have been created by a plugin.

How easy is it to fully delete plugins?

I tested this out on a single WordPress install with some existing plugins. I tried installing and deleting a number of popular plugins to see how easy it was to uninstall them completely.

All the plugins I tested stored information in wp_options.

Plugins that have uninstallers in wp-admin

Gravity Forms

What’s stored?

Gravity Forms creates 9 new database tables:

  1. wp_rg_form
  2. wp_rg_form_meta
  3. wp_rg_form_view
  4. wp_rg_incomplete_submissions
  5. wp_rg_lead
  6. wp_rg_lead_detail
  7. wp_rg_lead_detail_long
  8. wp_rg_lead_meta
  9. wp_rg_lead_notes

How should you uninstall Gravity Forms?

  1. Go to Forms > Settings > Uninstall.
  2. Click the button.
  3. Choose OK.
  4. Go to the plugin screen to fully delete the plugin.
Gravity Forms Uninstall dialog
Gravity Forms Uninstall dialog

Is everything deleted?

All 9 custom tables are deleted, but some data remains in the wp_options table.

Wordfence

What’s stored?

A whopping 23 database tables are created by this popular security plugin.

  1. wp_wfBadLeechers
  2. wp_wfBlockedCommentLog
  3. wp_wfBlockedIPLog
  4. wp_wfBlocks7
  5. wp_wfConfig
  6. wp_wfCrawlers
  7. wp_wfFileChanges
  8. wp_wfFileMods
  9. wp_wfHits
  10. wp_wfHoover
  11. wp_wfIssues
  12. wp_wfKnownFileList
  13. wp_wfLeechers
  14. wp_wfLocs
  15. wp_wfLogins
  16. wp_wfNet404s
  17. wp_wfNotifications
  18. wp_wfPendingIssues
  19. wp_wfReverseCache
  20. wp_wfScanners
  21. wp_wfSNIPCache
  22. wp_wfStatus
  23. wp_wfVulnScanners

You’ll also see a wflogs folder in wp-content.

How should you uninstall Wordfence?

An alternative to Wordfence’s manual uninstall is adding the Wordfence Assistant plugin to do the job.

To use Wordfence Assistant, deactivate and delete Wordfence as normal. Then in Wordfence Assistant’s options, choose the Delete All Wordfence Data and Tables option.

Remove all Wordfence data in the database and elsewhere
Remove all Wordfence data in the database and elsewhere

Is everything deleted?

Using Wordfence Assistant, the database and files were purged of Wordfence content.

Plugins that have uninstall scripts

Well developed plugins have an uninstall.php file to take care of the uninstall process.

For example:

Broken Link Checker’s uninstall script removes its 4 database tables.

Relevanssi’s uninstall script removes 3 tables created by the plugin.

WP Rocket has an uninstall script which is supposed to remove all data and files including the advanced-cache.php file.  When I tried it, I noticed that this file stayed put after the plugin was gone.

Other plugin uninstall methods

If there is no uninstall script, some plugins have provided other suggestions for a complete uninstall.

NextGEN Gallery

This plugin creates 3 database tables:

  • wp_ngg_album
  • wp_ngg_gallery
  • wp_ngg_pictures

It also creates an ngg folder within wp-content.

You will need to manually remove the 3 tables and the folder, as they aren’t removed on uninstall. Try this advice for a full NextGen Gallery uninstall.

WooCommerce

WooCommerce creates 16 tables:

  1. wp_wc_download_log
  2. wp_wc_webhooks
  3. wp_woocommerce_api_keys
  4. wp_woocommerce_attribute_taxonomies
  5. wp_woocommerce_downloadable_product_permissions
  6. wp_woocommerce_log
  7. wp_woocommerce_order_itemmeta
  8. wp_woocommerce_order_items
  9. wp_woocommerce_payment_tokenmeta
  10. wp_woocommerce_payment_tokens
  11. wp_woocommerce_sessions
  12. wp_woocommerce_shipping_zones
  13. wp_woocommerce_shipping_zone_locations
  14. wp_woocommerce_shipping_zone_methods
  15. wp_woocommerce_tax_rates
  16. wp_woocommerce_tax_rate_locations

WooCommerce recommend adding a line to wp-config.php for a completed uninstall:

I tried this twice and didn’t get a perfect uninstall either time. Remember to double-check that the data has gone.

Plugins that leave data behind

These are some plugins I found which don’t remove all data when uninstalled.

Akismet

Akismet stores a lot of data in the wp_commentmeta table, which remains on deletion.

Mine had nearly 6,000 rows!

EWWW Image Optimizer

This plugin stores data about the path to your images, their original size, size after compression and % reduction in the table wp_ewwwio_images. This table stayed when I removed the plugin, as did an ewww folder.

WP All Export

4 tables are created by this plugin:

  • wp_pmxe_exports
  • wp_pmxe_google_cats
  • wp_pmxe_posts
  • wp_pmxe_templates

These are not removed when the plugin is deleted.

Yoast SEO

Yoast SEO creates 2 tables:

  • wp_yoast_seo_links
  • wp_yoast_seo_meta

It also stores some data in:

wp_usermeta – contains some meta_key values like wpseo_title.
wp_postmeta – contains some meta_key values for various post ids, including:

  1. _yoast_wpseo_linkdex
  2. _yoast_wpseo_title
  3. _yoast_wpseo_metadesc
  4. _yoast_wpseo_focuskw
  5. _yoast_wpseo_focuskw_text_input
  6. _yoast_wpseo_primary_category
  7. _yoast_wpseo_content_score

A deactivate/delete uninstall leaves all this data behind.

How do you clean up after messy plugins?

Firstly, back up your site (files and database) in case you make a mistake. Super important!

WPMU Dev members can use Snapshot Pro for backups.

You’ll be using FTP and SQL queries for the clean up. If you’re not comfortable with these, have an expert on hand.

Delete pages

For any plugin that created pages, delete them if they weren’t removed on uninstall and you don’t need them any more. Remember to 301 redirect the page permalinks.

Remove unwanted database tables

Any tables which are not part of the usual WordPress install are likely to be tables added by plugins.
You can use phpMyAdmin, a database manipulation tool available on most hosting control panels.

Use the Drop option to delete individual tables from unwanted plugins.

phpMyAdmin showing tables with options including Drop
phpMyAdmin showing tables with options including Drop

phpMyAdmin’s warning confirmation dialog for dropping a table
phpMyAdmin’s warning confirmation dialog for dropping a table

Or select multiple tables and select Drop from the With selected dropdown, then confirm.

Dropping multiple tables with phpMyAdmin
Dropping multiple tables with phpMyAdmin

Another option is to use the Advanced Database Cleaner plugin to inspect your tables within WordPress.

There’s a button to detect orphaned tables, though you need to upgrade to the Pro version to use it.

Any plugin-related tables that you’re sure you don’t need you can delete. Check them and choose Delete from the Bulk Actions dropdown.

Advanced Database Cleaner shows all your WordPress data tables
Advanced Database Cleaner shows all your WordPress data tables

Delete redundant folders from wp-content

FTP into your site and check the contents of files and folders you don’t recognise. If you’re sure you won’t need them, delete them.

For example:

  • EWWW Image optimizer adds an ewww folder.
  • NextGEN Gallery adds two folders – gallery and ngg.
  • WP Rocket adds advanced-cache.php and a cache folder.
The EWWW folder within wp-content
The EWWW folder within wp-content

Check wp-config.php and .htaccess files

These are critical files, so copy them first before editing them!

If you spot any lines in wp-config.php added by plugins you’ve deleted, remove them.

In .htaccess look for a # followed by the plugin name and remove any lines in between.

Part of the code created by iThemes Security in .htaccess
Part of the code created by iThemes Security in .htaccess

Remember to upload the updated file(s) when you are done.

Cleaning up transients and cron jobs

Transients are data stored temporarily by WordPress. Checks for WordPress updates and notices on the admin dashboard are stored in transients. Transients are (mostly) set to expire after a set time period, and are recreated over time.

Some plugins create transients. The Transients Manager plugin will help you identify which plugins have done so, and you can delete any you no longer wish to keep.

Transients Manager shows transients and expiry date
Transients Manager shows transients and expiry date

Deleting all transients won’t remove them all – the WordPress ones remain.

Cron jobs are scheduled tasks that can be run on a web server. WordPress runs its own cron jobs through WP-Cron.

WP Crontrol plugin will show you what cron jobs are running and when.

Some cron jobs revealed by WP Crontrol
Some cron jobs revealed by WP Crontrol

You can modify or delete the cron jobs, but some core cron jobs can’t be deleted.

Unfortunately you’re at the mercy of the plugin developer when it comes to naming cron jobs. If the name of a job is unclear, don’t delete it, as it may affect the performance of a plugin you depend on.

Cleaning up your database tables

Now it’s time to run some database queries for a final clean up.

Akismet

Did you use Akismet? This is a tidying up task you can run even if you continue to use the plugin, since Akismet generates a lot of table rows.

On the wp_commentmeta table, run the SQL query:

Querying wp_commentmeta to find Akismet data
Querying wp_commentmeta to find Akismet data

(Remember to change wp_ in this query if you have a different table prefix.)

Then assuming the query found some rows, run the query

Deleting Akismet data from wp_commentmeta
Deleting Akismet data from wp_commentmeta

You should now have a much lighter wp_commentmeta table.

Yoast SEO

Yoast data seems to lurk everywhere!

Try this SQL query on the wp_postmeta table:

Yoast data in wp_postmeta
Yoast data in wp_postmeta

558 rows of Yoast data were removed from wp_postmeta
558 rows of Yoast data were removed from wp_postmeta

For wp_usermeta try:

wp_options table

Most plugins leave some entries in the wp_options table. If you want to go the whole hog in cleaning you can remove the rows related to your deleted plugins.

Use similar queries to the previous ones to find relevant rows, and if any are found, delete them:

Replace the pluginname with the name or abbreviation of the plugin you’re looking for (keep the % signs). Most are straightforward but a few may need some educated guesswork. Examples are:

  • EWWW Image Optimizer: ewwwio
  • NextGEN Gallery: ngg
  • WooCommerce: wc

While you’re at it, you can do some more housekeeping by following these 10 database optimization tips and these WordPress clean up tips.

Summing up

Deleting plugins is not always as straightforward as it appears. A lot of information can be stored by plugins both in the filesystem and the database, and plugin developers vary on the thoroughness of their uninstall routines.

Most of us assume an uninstall means deleting all data, and that’s not regularly the case.

If you’re a plugin developer, you might not be able to bear the thought that someone may never use your plugin again! But most users will thank you for including an uninstall script. Please follow the Uninstall Methods section in the plugin development handbook.

As a user, select your plugins carefully. Find out from developers how you uninstall them. Test out new plugins on a staging site rather than your live site to keep your site clutter-free. And remember as a general rule, the bigger the plugin, the more data it stores.

What steps do you take to clear unused plugins from your site?

Tags: