wp-includes/blocks.php:169Finds a script module ID for the selected block metadata field.
$metadataarray$field_namestring$indexintoptional0string|falsefunction register_block_script_module_id( $metadata, $field_name, $index = 0 ) { if ( empty( $metadata[ $field_name ] ) ) { return false; } $module_id = $metadata[ $field_name ]; if ( is_array( $module_id ) ) { if ( empty( $module_id[ $index ] ) ) { return false; } $module_id = $module_id[ $index ]; } $module_path = remove_block_asset_path_prefix( $module_id ); if ( $module_id === $module_path ) { return $module_id; } $path = dirname( $metadata['file'] ); $module_asset_raw_path = $path . '/' . substr_replace( $module_path, '.asset.php', - strlen( '.js' ) ); $module_id = generate_block_asset_handle( $metadata['name'], $field_name, $index ); $module_asset_path = wp_normalize_path( realpath( $module_asset_raw_path ) ); $module_path_norm = wp_normalize_path( realpath( $path . '/' . $module_path ) ); $module_uri = get_block_asset_url( $module_path_norm ); /** @var array{ dependencies?: list<non-falsy-string|array{id: non-falsy-string, import?: 'static'|'dynamic'}>, version?: string|false|null, ... } $module_asset */ $module_asset = ! empty( $module_asset_path ) ? require $module_asset_path : array(); $module_dependencies = $module_asset['dependencies'] ?? array(); $block_version = $metadata['version'] ?? false; $module_version = $module_asset['version'] ?? $block_version; $supports_interactivity_true = isset( $metadata['supports']['interactivity'] ) && true === $metadata['supports']['interactivity']; $is_interactive = $supports_interactivity_true || ( isset( $metadata['supports']['interactivity']['interactive'] ) && true === $metadata['supports']['interactivity']['interactive'] ); $supports_client_navigation = $supports_interactivity_true || ( isset( $metadata['supports']['interactivity']['clientNavigation'] ) && true === $metadata['supports']['interactivity']['clientNavigation'] ); $args = array(); // Blocks using the Interactivity API are server-side rendered, so they are // by design not in the critical rendering path and should be deprioritized. if ( $is_interactive ) { $args['fetchpriority'] = 'low'; $args['in_footer'] = true; } // Blocks using the Interactivity API that support client-side navigation // must be marked as such in their script modules. if ( $is_interactive && $supports_client_navigation ) { wp_interactivity()->add_client_navigation_support_to_script_module( $module_id ); } wp_register_script_module( $module_id, $module_uri, $module_dependencies, $module_version, $args ); return $module_id;}Introduced in 6.5.0. Unchanged from 6.7.7 through 7.1.0.
Signature, return type and hooks compared across 5 parsed releases.
src/wp-includes/blocks.php, and regenerated for each WordPress release so it tracks the code rather than a snapshot of it.