enabled() ) { return; } add_filter( 'pre_site_transient_update_core', array( $this, 'no_updates_stub' ) ); add_filter( 'pre_site_transient_update_plugins', array( $this, 'no_updates_stub' ) ); add_filter( 'pre_site_transient_update_themes', array( $this, 'no_updates_stub' ) ); // Core's own `wp_schedule_update_checks()` (hooked on `init`) would // otherwise re-add these crons on the very next request. remove_action( 'init', 'wp_schedule_update_checks' ); wp_clear_scheduled_hook( 'wp_version_check' ); wp_clear_scheduled_hook( 'wp_update_plugins' ); wp_clear_scheduled_hook( 'wp_update_themes' ); wp_clear_scheduled_hook( 'wp_maybe_auto_update' ); remove_action( 'admin_notices', 'update_nag', 3 ); remove_action( 'network_admin_notices', 'update_nag', 3 ); remove_action( 'admin_notices', 'maintenance_nag' ); remove_action( 'network_admin_notices', 'maintenance_nag' ); add_filter( 'automatic_updater_disabled', '__return_true' ); add_filter( 'auto_update_core', '__return_false' ); add_filter( 'allow_minor_auto_core_updates', '__return_false' ); add_filter( 'allow_major_auto_core_updates', '__return_false' ); add_filter( 'allow_dev_auto_core_updates', '__return_false' ); add_filter( 'auto_update_plugin', '__return_false' ); add_filter( 'auto_update_theme', '__return_false' ); } /** * A "nothing to update" stub, the same shape core itself uses for * these transients (confirmed against this install's own * `wp-includes/update.php`). * * @return object */ public function no_updates_stub(): object { $stub = new \stdClass(); $stub->updates = array(); $stub->response = array(); $stub->no_update = array(); $stub->last_checked = time(); $stub->version_checked = function_exists( 'wp_get_wp_version' ) ? wp_get_wp_version() : get_bloginfo( 'version' ); // wp_get_wp_version() is WordPress 6.7+. return $stub; } /** * Whether the feature is enabled. * * @return bool */ private function enabled(): bool { return (bool) aiou()->settings()->get_value( 'performance', 'updates', 'disable_update_checks', 0 ); } }