Exclude a Plugin or Theme from WordPress Updates

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' ).

Both of the code snippets above are an updated version of the code originally posted by Mark Jaquith.

Comments

  1. The first line “<?php" crushed my website. I had to access the functions.php file through cPanel and delete it.

    However, the website is up and running but still asks for updates. The trick I got to do and I saw it working is to edit the style.css file. Where it sais Version 1.9.1 (in my case) I wrote Version 100.9.1 so it will not ask for updates unless the theme will pass the 100.9.1 version. Kind Regards,

    Benjamin,

    1. Yes, placing another opening PHP tag in your functions.php file would definitely do that. Copying everything except the opening PHP tag to the end of the functions.php file should work. Bumping the version also works, if you don’t mind doing that. I prefer to use semantic versioning, so inflating the version is something I was trying to avoid when I wrote this code. I probably should have mentioned the option of bumping the version, so thanks for chiming in!

  2. So what values do we put in for get_option( ‘template’ ) and get_option( ‘stylesheet’ ) ? I’m not a developer, so I’m not familiar.

    1. The template and stylesheet options in the database store the name of the theme folder for the active parent and child themes respectively. If you don’t have a parent theme, those values would be the same. For example, if you were running the Twenty Seventeen theme, the values for both options would be twentyseventeen.

      1. Thank you! I realized shortly after posting that, that it was the child theme I needed to prevent from updating anyway, so I could just include it right in the child theme.

Leave a Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.