wp-includes/class-wp-script-modules.php:16Core class used to register script modules.
Every hook that fires from inside WP_Script_Modules, in the order it appears in the class, grouped by the method that fires it.
$registeredarray[]private$enqueued_before_registeredarray<string,private$a11y_availableboolprivateclass WP_Script_Modules { /** * Holds the registered script modules, keyed by script module identifier. * * @since 6.5.0 * @var array[] */ private $registered = array(); /** * Holds the script module identifiers that were enqueued before registered. * * @since 6.5.0 * @var array<string, true> */ private $enqueued_before_registered = 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; /** * Registers the script module if no script module with that script module * identifier has already been registered. * * @since 6.5.0 * * @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 * not been registered yet, it will be registered. * @param array $deps { * Optional. List of dependencies. * * @type string|array ...$0 { * An array of script module identifiers of the dependencies of this script * module. The dependencies can be strings or arrays. If they are arrays, * they need an `id` key with the script module identifier, and can contain * an `import` key with either `static` or `dynamic`. By default, * dependencies that don't contain an `import` key are considered static. * * @type string $id The script module identifier. * @type string $import Optional. Import type. May be either `static` or * `dynamic`. Defaults to `static`. * } * } * @param string|false|null $version Optional. String specifying the script module version number. Defaults to false. * It is added to the URL as a query string for cache busting purposes. If $version * is set to false, the version number is the currently installed WordPress version. * If $version is set to null, no version is added. */ public function register( string $id, string $src, array $deps = array(), $version = false ) { if ( ! isset( $this->registered[ $id ] ) ) { $dependencies = array(); foreach ( $deps as $dependency ) { if ( is_array( $dependency ) ) { if ( ! isset( $dependency['id'] ) ) { _doing_it_wrong( __METHOD__, __( 'Missing required id key in entry among dependencies array.' ), '6.5.0' ); continue; } $dependencies[] = array( 'id' => $dependency['id'], 'import' => isset( $dependency['import'] ) && 'dynamic' === $dependency['import'] ? 'dynamic' : 'static', ); } elseif ( is_string( $dependency ) ) { $dependencies[] = array( 'id' => $dependency, 'import' => 'static', ); } else { _doing_it_wrong( __METHOD__, __( 'Entries in dependencies array must be either strings or arrays with an id key.' ), '6.5.0' ); }Introduced in 6.5.0. 14 changes between 6.7.7 and 7.1.0.
Signature, return type and hooks compared across 5 parsed releases.
set_translations() added.verified against sourceprint_script_module_translations() added.verified against sourceget_registered() added.verified against sourceget_queue() added.verified against sourceis_valid_fetchpriority() added.verified against sourceset_fetchpriority() added.verified against sourceset_in_footer() added.verified against sourceget_highest_fetchpriority() added.verified against sourceprint_head_enqueued_script_modules() added.verified against sourceprint_script_module() added.verified against sourceget_dependents() added.verified against sourceget_recursive_dependents() added.verified against sourceget_sorted_dependencies() added.verified against sourcesort_item_dependencies() added.verified against sourcesrc/wp-includes/class-wp-script-modules.php, and regenerated for each WordPress release so it tracks the code rather than a snapshot of it.