Disable Auto Updates
Overview
Disable WordPress automatic updates for core, plugins, and themes.
The snippet disables the automatic updater subsystem, prevents forced item updates, and returns false for core, plugin, and theme auto-update filters. Manual updates through the dashboard or deployment workflow are still possible.
Variants
- Procedural
- OOP
<?php
/**
* Disable WordPress automatic updates.
*/
/**
* Disable automatic updater subsystem.
*/
if ( ! function_exists( 'mac_disable_automatic_updater' ) ) {
function mac_disable_automatic_updater(): bool {
return true;
}
}
add_filter( 'automatic_updater_disabled', 'mac_disable_automatic_updater' );
/**
* Prevent forced auto-updates.
*/
if ( ! function_exists( 'mac_disable_forced_auto_updates' ) ) {
function mac_disable_forced_auto_updates( mixed $forced, mixed $item ): bool {
return false;
}
}
add_filter( 'wp_is_auto_update_forced_for_item', 'mac_disable_forced_auto_updates', 10, 2 );
/**
* Disable core auto-updates.
*/
if ( ! function_exists( 'mac_disable_core_auto_updates' ) ) {
function mac_disable_core_auto_updates( mixed $update, mixed $item ): bool {
return false;
}
}
add_filter( 'auto_update_core', 'mac_disable_core_auto_updates', 10, 2 );
/**
* Disable plugin auto-updates.
*/
if ( ! function_exists( 'mac_disable_plugin_auto_updates' ) ) {
function mac_disable_plugin_auto_updates( mixed $update, mixed $item ): bool {
return false;
}
}
add_filter( 'auto_update_plugin', 'mac_disable_plugin_auto_updates', 10, 2 );
/**
* Disable theme auto-updates.
*/
if ( ! function_exists( 'mac_disable_theme_auto_updates' ) ) {
function mac_disable_theme_auto_updates( mixed $update, mixed $item ): bool {
return false;
}
}
add_filter( 'auto_update_theme', 'mac_disable_theme_auto_updates', 10, 2 );
<?php
/**
* Disable all WordPress automatic updates.
*
* @package mac-core
*/
declare(strict_types=1);
namespace MacCore\Services\Core;
use MacCore\Contracts\Service;
final class DisableAutoUpdates implements Service
{
/**
* Register WordPress hooks.
*
* @return void
*/
public function register(): void
{
// Disable the automatic updater subsystem entirely.
\add_filter( 'automatic_updater_disabled', '__return_true' );
// Never force auto-updates for any item.
\add_filter( 'wp_is_auto_update_forced_for_item', '__return_false', 10, 2 );
// Disable auto-updates for core, plugins, and themes.
\add_filter( 'auto_update_core', '__return_false', 10, 2 );
\add_filter( 'auto_update_plugin', '__return_false', 10, 2 );
\add_filter( 'auto_update_theme', '__return_false', 10, 2 );
}
}