Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
use global var
  • Loading branch information
swissspidy committed Jan 31, 2024
commit 777bdc989b1cf56ba6911972199d3a6f62d6fa2d
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