Using WordPress ‘auto_update_{$type}’ PHP filter

The auto_update_{$type} WordPress PHP filter is used to decide if core, a plugin, a theme, or a language should be automatically updated. The dynamic portion of the hook name, $type, refers to the type of update being checked.

Usage

add_filter('auto_update_plugin', 'my_custom_auto_update_function', 10, 2);
function my_custom_auto_update_function($update, $item) {
  // your custom code here
  return $update;
}

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.

More information

See WordPress Developer Resources: auto_update_{$type}

Examples

Disable auto-updates for all plugins

add_filter('auto_update_plugin', '__return_false');

Enable auto-updates for a specific plugin

add_filter('auto_update_plugin', 'enable_specific_plugin_auto_update', 10, 2);
function enable_specific_plugin_auto_update($update, $item) {
  if ('my-plugin-slug' === $item->slug) {
    return true;
  }
  return $update;
}

Disable auto-updates for a specific theme

add_filter('auto_update_theme', 'disable_specific_theme_auto_update', 10, 2);
function disable_specific_theme_auto_update($update, $item) {
  if ('my-theme-slug' === $item->theme) {
    return false;
  }
  return $update;
}

Enable auto-updates for all themes

add_filter('auto_update_theme', '__return_true');

Disable auto-updates for major core updates

add_filter('allow_major_auto_core_updates', '__return_false');