There is an opt-in filter that allows all plugins on my site to receive automatic updates:

add_filter( 'auto_update_plugin', '__return_true' );

I like this feature, but I don’t want all my plugins to be updated automatically. How can I allow some plugins to be updated automatically, while excluding those I want to do manually?

2

Instead of using the code from the question in functions.php, replace it with this:

/**
 * Prevent certain plugins from receiving automatic updates, and auto-update the rest.
 *
 * To auto-update certain plugins and exclude the rest, simply remove the "!" operator
 * from the function.
 *
 * Also, by using the 'auto_update_theme' or 'auto_update_core' filter instead, certain
 * themes or WordPress versions can be included or excluded from updates.
 *
 * auto_update_$type filter: applied on line 1772 of /wp-admin/includes/class-wp-upgrader.php
 *
 * @since 3.8.2
 *
 * @param bool   $update Whether to update (not used for plugins)
 * @param object $item   The plugin's info
 */
function exclude_plugins_from_auto_update( $update, $item ) {
    return ( ! in_array( $item->slug, array(
        'akismet',
        'buddypress',
    ) ) );
}
add_filter( 'auto_update_plugin', 'exclude_plugins_from_auto_update', 10, 2 );

This code can easily be tweaked to customize theme and core updates, too.

Plugin and theme update statistics were added in WordPress 3.8.2 (27905). The above function uses the slug to identify the plugins, but you can use any of the object’s info (in $item):

[id] => 15
[slug] => akismet
[plugin] => akismet/akismet.php
[new_version] => 3.0.0
[url] => https://wordpress.org/plugins/akismet/
[package] => https://downloads.wordpress.org/plugin/akismet.3.0.0.zip

For WordPress 3.8.1 and below, use this function instead:

function exclude_plugins_from_auto_update( $update, $item ) {
    return ( ! in_array( $item, array(
        'akismet/akismet.php',
        'buddypress/bp-loader.php',
    ) ) );
}
add_filter( 'auto_update_plugin', 'exclude_plugins_from_auto_update', 10, 2 );

Props go to @WiseOwl9000 for pointing out the change with WP 3.8.2

Leave a Reply

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