diff --git a/src/wp-includes/script-modules.php b/src/wp-includes/script-modules.php index 205494f699386..2aff768bb3d1a 100644 --- a/src/wp-includes/script-modules.php +++ b/src/wp-includes/script-modules.php @@ -14,17 +14,20 @@ * This function provides access to the WP_Script_Modules instance, creating one * if it doesn't exist yet. * + * @global WP_Script_Modules $wp_script_modules + * * @since 6.5.0 * * @return WP_Script_Modules The main WP_Script_Modules instance. */ function wp_script_modules(): WP_Script_Modules { - static $instance = null; - if ( is_null( $instance ) ) { - $instance = new WP_Script_Modules(); - $instance->add_hooks(); + global $wp_script_modules; + + if ( ! ( $wp_script_modules instanceof WP_Script_Modules ) ) { + $wp_script_modules = new WP_Script_Modules(); } - return $instance; + + return $wp_script_modules; } /** diff --git a/src/wp-settings.php b/src/wp-settings.php index 624b1d804acf0..87769333c59e5 100644 --- a/src/wp-settings.php +++ b/src/wp-settings.php @@ -378,6 +378,8 @@ require ABSPATH . WPINC . '/script-modules.php'; require ABSPATH . WPINC . '/interactivity-api.php'; +wp_script_modules()->add_hooks(); + $GLOBALS['wp_embed'] = new WP_Embed(); /**