Automatically Update Your WordPress Plugins and Themes Using Code

WordPress allows you to automatically update your WordPress plugins and themes by adding some PHP constants and filters to your WordPress installation.


 Plugin Name: UpdateWordPress
 Plugin URI:
 Description: This updates stuff
 Author:WP Beaches
 Author URI:
 License: GPL2

add_filter( 'auto_update_plugin', '__return_true' ); // Updates Plugins
add_filter( 'auto_update_theme', '__return_true' ); // Updates Themes
add_filter( 'auto_update_translation', '__return_true' ); // Updates Translations

So the above will update all plugins, themes and translations, to reverse the behaviour and not update you can either change the return value to __return_false or simply not add the filter.

See also  How to Create a New Product Type

When does it actually update? it won’t do it straight away,  give it a bit of time and soon the automagic updates will kick in.

Updates to WordPress Itself

By default any minor updates or what is known as point releases are by default enabled – here are some constants you can add in wp-config.php to change that behaviour.


Disable all the things, WordPress, themes, plugins and translations

define( 'WP_AUTO_UPDATE_CORE', true );

Enable major WordPress core releases, like going from a 4.7 to a 4.8

define( 'WP_AUTO_UPDATE_CORE', false );

Disable all WordPress releases major and minor

define( 'WP_AUTO_UPDATE_CORE', minor );

Enable WordPress minor updates, disable WordPress major updates – this is the default.

See also  How to Change WooCommerce SKU text to another label

Don’t Update Specific WordPress Plugins

You can manipulate the filter auto_update_plugins ,  lets say you where happy updating all plugins bar a few suspect ones you could do this…View the code on Gist.

So here I am in the above code snippet updating all plugins apart from Akismet and Duplicator – these are just examples, reality is I would have no issues auto-updating these ones, we all know which ones give us grief, and for the ones that do cause grief on the update just add them to the comma-separated array using their lowercase slug name as named in the plugin repo.

Leave a Reply

Your email address will not be published. Required fields are marked *