How to fully uninstall a WordPress plugin
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.
What plugins typically store data?
Plugins which ask for user input are the most likely to store data.
- 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?
A new install of WordPress will have the following tables:
If you set up a multisite you’ll have those 12 tables plus a few more:
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.
The basic WordPress folder has an index.php file and two subfolders:
A mature install will likely have other subfolders which may include the following:
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 which have uninstallers in wp-admin
Gravity Forms creates 9 new database tables:
How should you uninstall Gravity Forms?
- Go to Forms > Settings > Uninstall.
- Click the button.
- Choose OK.
- Go to the plugin screen to fully delete the plugin.
Is everything deleted?
All 9 custom tables are deleted, but some data remains in the wp_options table.
A whopping 23 database tables are created by this popular security plugin.
You’ll also see a wflogs folder in wp-content.
How should you uninstall Wordfence?
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.
Is everything deleted?
Using Wordfence Assistant, the database and files were purged of Wordfence content.
Plugins which have uninstall scripts
Well developed plugins have an uninstall.php file to take care of the uninstall process.
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.
This plugin creates 3 database tables:
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 creates 16 tables:
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 which leave data behind
These are some plugins I found which don’t remove all data when uninstalled.
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:
These are not removed when the plugin is deleted.
Yoast SEO creates 2 tables:
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:
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.
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.
Or select multiple tables and select Drop from the With selected dropdown, then confirm.
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.
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.
- 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.
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.
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.
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.
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.
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:
(Remember to change wp_ in this query if you have a different table prefix.)
Then assuming the query found some rows, run the query
You should now have a much lighter wp_commentmeta table.
Yoast data seems to lurk everywhere!
Try this SQL query on the wp_postmeta table:
For wp_usermeta try:
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
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.
WIN a Share of $5K
Subscribe to our blog this #hostingmonth for a chance to win one of 5 prizes of $1,000 WPMU Dev credit! Learn More.