mirror of
https://github.com/WordPress/WordPress.git
synced 2024-12-22 09:07:59 +01:00
Script Loader: Use a global variable in wp_script_modules()
.
This brings the function more in line with its related `wp_scripts()` and `wp_styles()` functions and makes it easier to reset the class instance in tests. Props westonruter, luisherranz. See #56313. Built from https://develop.svn.wordpress.org/trunk@57503 git-svn-id: http://core.svn.wordpress.org/trunk@57004 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
1550a2bf77
commit
d8996a3c77
@ -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;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -16,7 +16,7 @@
|
||||
*
|
||||
* @global string $wp_version
|
||||
*/
|
||||
$wp_version = '6.5-alpha-57502';
|
||||
$wp_version = '6.5-alpha-57503';
|
||||
|
||||
/**
|
||||
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
||||
|
@ -378,6 +378,8 @@ require ABSPATH . WPINC . '/class-wp-script-modules.php';
|
||||
require ABSPATH . WPINC . '/script-modules.php';
|
||||
require ABSPATH . WPINC . '/interactivity-api.php';
|
||||
|
||||
wp_script_modules()->add_hooks();
|
||||
|
||||
$GLOBALS['wp_embed'] = new WP_Embed();
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user