From 854f5a2ed5dad4f221ca175b215a9542c3d37eea Mon Sep 17 00:00:00 2001 From: HostForge Systems Date: Sat, 18 Apr 2026 12:01:20 +0800 Subject: [PATCH] fix(mu-plugins): strengthen core management behavior and correct MU plugin metadata --- .../mu-plugins/hostforge-systems.php | 1 + .../hostforge-systems/bootstrap.php | 10 +-- .../CoreUpdates/Disable_Core_Updates.php | 66 ++++++++++++++----- 3 files changed, 52 insertions(+), 25 deletions(-) diff --git a/code/wp-content/mu-plugins/hostforge-systems.php b/code/wp-content/mu-plugins/hostforge-systems.php index d5ba1343a3..23ea3a1609 100644 --- a/code/wp-content/mu-plugins/hostforge-systems.php +++ b/code/wp-content/mu-plugins/hostforge-systems.php @@ -6,6 +6,7 @@ * Version: 1.0.0 * Author: HostForge * Author URI: https://hostforge.cloud + * Network: true */ if (! defined('ABSPATH')) { diff --git a/code/wp-content/mu-plugins/hostforge-systems/bootstrap.php b/code/wp-content/mu-plugins/hostforge-systems/bootstrap.php index 5ec641b06b..8aacce8bd8 100644 --- a/code/wp-content/mu-plugins/hostforge-systems/bootstrap.php +++ b/code/wp-content/mu-plugins/hostforge-systems/bootstrap.php @@ -4,22 +4,16 @@ if (! defined('ABSPATH')) { exit; } -/** - * Define the HostForge Systems base path. - */ if (! defined('HOSTFORGE_SYSTEMS_PATH')) { define('HOSTFORGE_SYSTEMS_PATH', __DIR__); } -/** - * Define the HostForge Systems base URL. - */ if (! defined('HOSTFORGE_SYSTEMS_URL')) { define('HOSTFORGE_SYSTEMS_URL', content_url('mu-plugins/hostforge-systems')); } /** - * Load the required HostForge Systems core files. + * Load required HostForge core files. * * @return void */ @@ -42,7 +36,7 @@ function hostforge_systems_load_core_files() hostforge_systems_load_core_files(); /** - * Boot the HostForge Systems loader. + * Boot HostForge Systems. * * @return void */ diff --git a/code/wp-content/mu-plugins/hostforge-systems/src/Modules/CoreUpdates/Disable_Core_Updates.php b/code/wp-content/mu-plugins/hostforge-systems/src/Modules/CoreUpdates/Disable_Core_Updates.php index 6473edbbb7..9ceac78954 100644 --- a/code/wp-content/mu-plugins/hostforge-systems/src/Modules/CoreUpdates/Disable_Core_Updates.php +++ b/code/wp-content/mu-plugins/hostforge-systems/src/Modules/CoreUpdates/Disable_Core_Updates.php @@ -11,14 +11,13 @@ if (! defined('ABSPATH')) { } /** - * Disables WordPress core updates inside wp-admin. - * - * WordPress core updates must be managed through the HostForge Dashboard. + * Disable WordPress core updates in wp-admin and route update management + * through the HostForge platform. */ class Disable_Core_Updates implements Module_Interface { /** - * Register WordPress hooks for this module. + * Register WordPress hooks. * * @return void */ @@ -30,25 +29,28 @@ class Disable_Core_Updates implements Module_Interface add_filter('allow_minor_auto_core_updates', '__return_false'); add_filter('allow_major_auto_core_updates', '__return_false'); - add_filter('pre_site_transient_update_core', [$this, 'filter_core_update_transient']); - add_filter('site_transient_update_core', [$this, 'filter_core_update_transient']); - add_filter('pre_set_site_transient_update_core', [$this, 'filter_core_update_transient']); + add_filter('pre_option__site_transient_update_core', [$this, 'force_empty_core_updates']); + add_filter('pre_site_transient_update_core', [$this, 'force_empty_core_updates'], 999); + add_filter('site_transient_update_core', [$this, 'force_empty_core_updates'], 999); + add_filter('pre_set_site_transient_update_core', [$this, 'force_empty_core_updates'], 999); add_action('admin_init', [$this, 'clear_core_update_transient'], 1); add_action('admin_init', [$this, 'remove_core_update_nag'], 1); add_action('admin_init', [$this, 'maybe_redirect_updates_screen'], 1); + add_action('init', [$this, 'disable_core_version_check'], 1); + add_filter('schedule_event', [$this, 'block_core_version_check_schedule'], 1); + add_action('admin_menu', [$this, 'remove_updates_submenu'], 999); add_action('admin_notices', [$this, 'render_admin_notice']); } /** - * Force an empty WordPress core update response. + * Return a clean empty core update object. * - * @param mixed $transient Existing transient value. * @return \stdClass */ - public function filter_core_update_transient($transient): stdClass + public function force_empty_core_updates(): stdClass { $clean = new stdClass(); $clean->updates = []; @@ -60,10 +62,7 @@ class Disable_Core_Updates implements Module_Interface } /** - * Clear any cached WordPress core update transient. - * - * This runs on every admin request so stale update data - * does not continue to appear in wp-admin. + * Clear cached core update transient during admin requests. * * @return void */ @@ -74,6 +73,11 @@ class Disable_Core_Updates implements Module_Interface } delete_site_transient('update_core'); + + wp_cache_delete('update_core', 'site-transient'); + wp_cache_delete('update_core', 'site-options'); + wp_cache_delete('_site_transient_update_core', 'options'); + wp_cache_delete('update_core', 'options'); } /** @@ -87,7 +91,7 @@ class Disable_Core_Updates implements Module_Interface } /** - * Redirect users away from the WordPress Updates screen. + * Redirect users away from the native Updates screen. * * @return void */ @@ -108,7 +112,34 @@ class Disable_Core_Updates implements Module_Interface } /** - * Remove the Updates submenu from wp-admin. + * Disable WordPress core version checking hooks. + * + * @return void + */ + public function disable_core_version_check(): void + { + remove_action('init', 'wp_version_check'); + remove_action('admin_init', '_maybe_update_core'); + remove_action('wp_version_check', 'wp_version_check'); + } + + /** + * Block scheduling of core version checks. + * + * @param object|false $event Scheduled event object. + * @return object|false + */ + public function block_core_version_check_schedule($event) + { + if (is_object($event) && isset($event->hook) && $event->hook === 'wp_version_check') { + return false; + } + + return $event; + } + + /** + * Remove Updates submenu entries. * * @return void */ @@ -116,10 +147,11 @@ class Disable_Core_Updates implements Module_Interface { remove_submenu_page('index.php', 'update-core.php'); remove_submenu_page('options-general.php', 'update-core.php'); + remove_submenu_page('tools.php', 'update-core.php'); } /** - * Render a HostForge notice in wp-admin. + * Render HostForge notice on selected admin screens. * * @return void */