wppaste
WordPress

WP_Script_Modules

Since
6.5.0
Source
wp-includes/class-wp-script-modules.php:26
Core class used to register script modules.

Compatibility

WordPress
since 6.5.0
  • 6.7.7
  • 6.8.8
  • 6.9.7
  • 7.0.4
  • 7.1.0

Present in every tracked release (6.7.7 to 7.1.0).

Hooks and filters fired · 2

Every hook that fires from inside WP_Script_Modules, in the order it appears in the class, grouped by the method that fires it.

Properties · 7

$registeredarray<string,private
Holds the registered script modules, keyed by script module identifier.
$queuestring[]private
An array of IDs for queued script modules.
$donestring[]private
Holds the script module identifiers that have been printed.
$a11y_availableboolprivate
Tracks whether the @wordpress/a11y script module is available.
$dependents_maparray<string,private
Holds a mapping of dependents (as IDs) for a given script ID.
$prioritiesstring[]private
Holds the valid values for fetchpriority.
$modules_with_missing_dependenciesstring[]private
List of IDs for script modules encountered which have missing dependencies.

Methods · 28

Source code

class WP_Script_Modules {	/**	 * Holds the registered script modules, keyed by script module identifier.	 *	 * @since 6.5.0	 * @var array<string, array<string, mixed>>	 * @phpstan-var array<string, ScriptModule>	 */	private $registered = array(); 	/**	 * An array of IDs for queued script modules.	 *	 * @since 6.9.0	 * @var string[]	 */	private $queue = array(); 	/**	 * Holds the script module identifiers that have been printed.	 *	 * @since 6.9.0	 * @var string[]	 */	private $done = array(); 	/**	 * Tracks whether the @wordpress/a11y script module is available.	 *	 * Some additional HTML is required on the page for the module to work. Track	 * whether it's available to print at the appropriate time.	 *	 * @since 6.7.0	 * @var bool	 */	private $a11y_available = false; 	/**	 * Holds a mapping of dependents (as IDs) for a given script ID.	 * Used to optimize recursive dependency tree checks.	 *	 * @since 6.9.0	 * @var array<string, string[]>	 */	private $dependents_map = array(); 	/**	 * Holds the valid values for fetchpriority.	 *	 * @since 6.9.0	 * @var string[]	 */	private $priorities = array(		'low',		'auto',		'high',	); 	/**	 * List of IDs for script modules encountered which have missing dependencies.	 *	 * An ID is added to this list when it is discovered to have missing dependencies. At this time, a warning is	 * emitted with {@see _doing_it_wrong()}. The ID is then added to this list, so that duplicate warnings don't occur.	 *	 * @since 6.9.1	 * @var string[]	 */	private $modules_with_missing_dependencies = array(); 	/**	 * Registers the script module if no script module with that script module	 * identifier has already been registered.	 *	 * @since 6.5.0	 * @since 6.9.0 Added the $args parameter.	 *	 * @param string                              $id      The identifier of the script module. Should be unique. It will be used in the	 *                                                     final import map.	 * @param string                              $src     Optional. Full URL of the script module, or path of the script module relative	 *                                                     to the WordPress root directory. If it is provided and the script module has

Changelog

Introduced in 6.5.0. 14 changes between 6.7.7 and 7.1.0.

  1. 6.7.7
  2. 6.8.8
  3. 6.9.7
  4. 7.0.4
  5. 7.1.0

Signature, return type and hooks compared across 5 parsed releases.

7.0.4
Method set_translations() added.verified against source
7.0.4
Method print_script_module_translations() added.verified against source
7.0.4
Method get_registered() added.verified against source
6.9.7
Method get_queue() added.verified against source
6.9.7
Method is_valid_fetchpriority() added.verified against source
6.9.7
Method set_fetchpriority() added.verified against source
6.9.7
Method set_in_footer() added.verified against source
6.9.7
Method get_highest_fetchpriority() added.verified against source
6.9.7
Method print_head_enqueued_script_modules() added.verified against source
6.9.7
Method print_script_module() added.verified against source
6.9.7
Method get_dependents() added.verified against source
6.9.7
Method get_recursive_dependents() added.verified against source
6.9.7
Method get_sorted_dependencies() added.verified against source
6.9.7
Method sort_item_dependencies() added.verified against source
6.5.0
Introduced.from the docblock

About this page

Parsed data
Generated from the wordpress-develop 7.1.0 tag, from src/wp-includes/class-wp-script-modules.php, and regenerated for each WordPress release so it tracks the code rather than a snapshot of it.
Corrections
Something wrong on this page? Report it and it gets fixed in the next regeneration.