Exclude a Plugin
I’ve occasionally run into the situation where I’ve implemented a custom plugin for a client and given it a unique name. Then, someone else releases a plugin by the same name and now there is an ‘update’ for my plugin. The client goes in and updates the plugin only to find that they have lost the custom functionality I implemented for them.
If you create a custom plugin for a client, be sure to disable plugin updates!
Just place the code above in the main file of your plugin and WordPress will never show that it has an update.
Exclude a Theme
Another situation I’ve run into is where a new client comes to me and has a WordPress theme that was directly modified. Since they aren’t using a child theme, updating the theme would cause them to lose all the original customizations.
If you modify a publicly released theme, be sure to disable theme updates!
Note: This only works if the theme is active! If you want to prevent updates even if the theme is inactive, then you will need to add the code to a plugin and use hardcoded values instead of
get_option( 'template' ) and
get_option( 'stylesheet' ).