isset( $dependencies['static'] ) || isset( $dependencies['dynamic'] ) ? $dependencies['static'] ?? array() : $dependencies, 'dynamic' => isset( $dependencies['dynamic'] ) ? $dependencies['dynamic'] : array(), ); self::$registered[ $module_identifier ] = array( 'src' => $src, 'version' => $version, 'dependencies' => $deps, ); } } /** * Enqueues a module in the page. * * @param string $module_identifier The identifier of the module. */ public static function enqueue( $module_identifier ) { // Add the module to the queue if it's not already there. if ( ! in_array( $module_identifier, self::$enqueued, true ) ) { self::$enqueued[] = $module_identifier; } } /** * Returns the import map array. * * @return array Associative array with 'imports' key mapping to an array of module identifiers and their respective source strings. */ public static function get_import_map() { $imports = array(); foreach ( self::get_dependencies( self::$enqueued, array( 'static', 'dynamic' ) ) as $module_identifier => $module ) { $imports[ $module_identifier ] = $module['src'] . self::get_version_query_string( $module['version'] ); } return array( 'imports' => $imports ); } /** * Prints the import map. */ public static function print_import_map() { $import_map = self::get_import_map(); if ( ! empty( $import_map['imports'] ) ) { echo ''; } } /** * Prints all the enqueued modules using