The plugins_auto_update_enabled WordPress PHP filter allows you to control whether plugins auto-update is enabled or not.
Usage
add_filter('plugins_auto_update_enabled', 'your_custom_function'); function your_custom_function($enabled) { // your custom code here return $enabled; }
Parameters
- $enabled (bool) – True if plugins auto-update is enabled, false otherwise.
More information
See WordPress Developer Resources: plugins_auto_update_enabled
Examples
Disable auto-updates for all plugins
This code snippet disables auto-updates for all plugins.
add_filter('plugins_auto_update_enabled', '__return_false');
Enable auto-updates for all plugins
This code snippet enables auto-updates for all plugins.
add_filter('plugins_auto_update_enabled', '__return_true');
Enable auto-updates only for specific plugins
This code snippet enables auto-updates only for plugins with the specified slugs.
add_filter('plugins_auto_update_enabled', 'enable_specific_plugins_auto_update', 10, 2); function enable_specific_plugins_auto_update($enabled, $plugin) { $plugins_to_update = array('plugin-slug-1', 'plugin-slug-2'); if (in_array($plugin, $plugins_to_update)) { return true; } return $enabled; }
Disable auto-updates for specific plugins
This code snippet disables auto-updates for plugins with the specified slugs.
add_filter('plugins_auto_update_enabled', 'disable_specific_plugins_auto_update', 10, 2); function disable_specific_plugins_auto_update($enabled, $plugin) { $plugins_to_exclude = array('plugin-slug-1', 'plugin-slug-2'); if (in_array($plugin, $plugins_to_exclude)) { return false; } return $enabled; }
Enable auto-updates for all plugins except specific ones
This code snippet enables auto-updates for all plugins except the ones with specified slugs.
add_filter('plugins_auto_update_enabled', 'enable_all_except_specific_plugins_auto_update', 10, 2); function enable_all_except_specific_plugins_auto_update($enabled, $plugin) { $plugins_to_exclude = array('plugin-slug-1', 'plugin-slug-2'); if (in_array($plugin, $plugins_to_exclude)) { return false; } return true; }