Installing a plugin is easy. But sometimes they resist to being completely uninstalled without leaving some scrap codes in your WordPress website.
This is not a big problem unless you install and uninstall lots of plugins. If so you may have tons of scrap codes that may harm your WordPress speed or even worst, it could trigger an error.
Uninstalling a plugin is easy, you just click on “delete” button in your plugins dashboard page and that’s it.
But. ¿How do you know if plugin is completely uninstalled and it doesn’t leave any trace?
Here you will learn how to discover that, and how clean up any junk code left in your WordPress installation.
Were the plugins can leave traces
A plugin can write code in any file of WordPress, and not always they are deleted after uninstall.
They can leave some trash codes in:
- Wp-config.php file
- .htaccess file
- Database created tables
- Additional folders or files in root, wp-content, uploads or plugins folder
First step to identify junk code that plugins may left, is knowing which files and directories comes with a standard wordpress installation.
¿What’s in a standard WordPress installation?
Tables in database in a fresh WordPress installation are these:
And in multisites there are six more additional tables:
Known this, you can be sure that if there are any other table in database it’s there because some plugin or theme has created it.
WordPress files and directories in a fresh installation are:
But WordPress will add some files when your website grows:
All these folders have some sub folders in it, except uploads.
As you can see, if any plugin saves a file or folder in any subdirectories, things can get really complicated.
Fortunately, most of plugins that do this add their files only in wp-content and/or in uploads.
¿Where can you find the junk code leaved by an uninstalled plugin?
Having in mind what we’ve just said, suspicious places were you can find scrap code will be the following:
- Folders and files in wp-content and uploads
- Additional tables in the database
- Additional lines in the wp-options table of WordPress (almost all plugins do this)
¿How to completely uninstall a plugin?
There are many things to check, and if we think that each developer and plugin is completely different from each other, and that there is no standard specification or requirement of how a plugin must be uninstalled; we have no other option that check manually every time we uninstall a plugin.
Let’s see some examples of what happens when you uninstall some of the most popular plugins.
If you ever wanted to test WooCommerce just to know what it’s about, and then you uninstalled it, you must know that it leaves a lot of trash after uninstall.
In fact, in WC official webpage they warn about this and recommend to add a line of code to wp-config.php file to prevent it.
/* Completely uninstall WooCommerce */
define( 'WC_REMOVE_ALL_DATA', true);
This way, when you uninstall it, WC will delete these 16 additional tables in database:
After uninstalling it, you have to remove the code you added before.
If you didn’t know this and already have uninstalled WC, you will have to delete all the tables in DB manually using PHPMyAdmin.
This procedure is similar when you want to eliminate any trace that a plugin leaves in there.
Important: Before you delete any table, be sure to grab a backup, just in case…
Another popular plugin that leaves considerable amount of scrap after uninstalling it.
When installing Yoast SEO, it will create two additional tables in DB:
But it also stores data in:
- wp_usermeta – meta_key values like wpseo_title.
- wp_postmeta – meta_key values for several ID’s such as:
This plugin saves tons of data in wp_commentmeta table, that will remain there after uninstalling it.
And we are talking about thousands of lines.
Cache plugins uninstall deserves a full post. Absolutely all of them leaves some trash somewhere. And we are talking of lots of scrap in some of them.
Now that you know it, I’m sure you are going to think it twice before change your cache plugin.
And don’t forget shortcodes
Many plugins uses shortcodes that can be inserted into posts, widgets or pages. After uninstalling the plugin, shortcodes will remain there.
You will have to edit all of the posts or anywhere they are placed.
It can be a hazardous work to do if you have lots of posts. Fortunately, you can use search in posts page to find them. Just write the shortcode in search box and all posts containing the shortcode will be shown.
So, ¿what shall you do to clean up your website of scrap code?
First of all, think wisely if you really need that plugin you are about to install. Don’t install them just for seeing how it works.
If you don’t remember how many plugins you’ve uninstalled, it’s sure that your WP installation is full of scrappy code.
This is what you have to do in order to make a clean-up.
- Make backup of database, WP files and directories.
- After uninstalling a plugin, delete any additional folder and/or file created by plugin
- Delete any database table created by plugin through PHPMyAdmin
- If the plugin was using shortcodes, search for them and edit content
- Check the wp-options table and clean it if you find something
It’s not easy work to do, but it’s important to maintain your WP clean and healthy.
And cleaning all this garbage is one thing you can do for that.
¿Did you find many junk left by plugins? Please tell us your experience leaving a comment.