apply_filters( "auto_update_{$type}", bool|null $update, object $item )

Filters whether to automatically update core, a plugin, a theme, or a language.


Description

The dynamic portion of the hook name, $type, refers to the type of update being checked.

Possible hook names include:

  • auto_update_core
  • auto_update_plugin
  • auto_update_theme
  • auto_update_translation

Since WordPress 3.7, minor and development versions of core, and translations have been auto-updated by default. New installs on WordPress 5.6 or higher will also auto-update major versions by default. Starting in 5.6, older sites can opt-in to major version auto-updates, and auto-updates for plugins and themes.

See the ‘allow_dev_auto_core_updates’, ‘allow_minor_auto_core_updates’, and ‘allow_major_auto_core_updates’ filters for a more straightforward way to adjust core updates.


Top ↑

Parameters

$update bool|null
Whether to update. The value of null is internally used to detect whether nothing has hooked into this filter.
$item object
The update offer.

Top ↑

Source

File: wp-admin/includes/class-wp-automatic-updater.php. View all references

$update = apply_filters( "auto_update_{$type}", $update, $item );


Top ↑

Changelog

Changelog
Version Description
5.5.0 The $update parameter accepts the value of null.
3.7.0 Introduced.

Top ↑

User Contributed Notes

  1. Skip to note 1 content
    Contributed by Jer Clarke

    Note that the filters mentioned above will not stop WP from visiting the update endpoints using the HTTP API. The following URLs will be checked on a regular bases even with the filters above set to disable updates:

    https://api.wordpress.org/core/version-check/...
    https://api.wordpress.org/plugins/update-check/...
    https://api.wordpress.org/themes/update-check/...

    If you want to completely stop update checking, e.g. for performance reasons while coding or during acceptance testing, removing the following filters will ensure that the update endpoints are not checked:

    /**
    * ! These actually stop the HTTP API requests!
    * Copied from WP_Customize_Manager->construct()
    */
    remove_action( 'admin_init', '_maybe_update_core' );
    remove_action( 'admin_init', '_maybe_update_plugins' );
    remove_action( 'admin_init', '_maybe_update_themes' );

  2. Skip to note 3 content
    Contributed by Dev Kabir

    To enable automatic updates for a plugin programmatically, you can use the WordPress functions and filters available. Here’s an example of how you can achieve this:

    /**
     * Enable automatic updates for a specific plugin.
     *
     * @param boolean $value Current auto-update status.
     * @param object  $item  Plugin update object.
     * @return boolean Updated auto-update status.
     */
    function wpdocs_enable_plugin_auto_updates( $value, $item ) {
        if ( 'your-plugin-slug' === $item->slug ) {
            return true; // Enable auto-updates for the specified plugin
        }
    
        return $value; // Preserve auto-update status for other plugins
    }
    add_filter( 'auto_update_plugin', 'wpdocs_enable_plugin_auto_updates', 10, 2 );

You must log in before being able to contribute a note or feedback.