Skip to content

Commit

Permalink
use global var
Browse files Browse the repository at this point in the history
  • Loading branch information
swissspidy committed Jan 31, 2024
1 parent da3ac22 commit 777bdc9
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 26 deletions.
25 changes: 0 additions & 25 deletions src/wp-includes/class-wp-script-modules.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,31 +30,6 @@ class WP_Script_Modules {
*/
private $enqueued_before_registered = array();

/**
* Container for the main instance of the class.
*
* @since 6.5.0
* @var WP_Script_Modules|null
*/
private static $instance = null;

/**
* Utility method to retrieve the main instance of the class.
*
* The instance will be created if it does not exist yet.
*
* @since 6.5.0
*
* @return WP_Script_Modules The main instance.
*/
public static function get_instance(): WP_Script_Modules {
if ( null === self::$instance ) {
self::$instance = new self();
}

return self::$instance;
}

/**
* Registers the script module if no script module with that script module
* identifier has already been registered.
Expand Down
10 changes: 9 additions & 1 deletion src/wp-includes/script-modules.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +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 {
return WP_Script_Modules::get_instance();
global $wp_script_modules;

if ( ! ( $wp_script_modules instanceof WP_Script_Modules ) ) {
$wp_script_modules = new WP_Script_Modules();
}

return $wp_script_modules;
}

/**
Expand Down

0 comments on commit 777bdc9

Please sign in to comment.