diff --git a/src/wp-includes/blocks.php b/src/wp-includes/blocks.php index c9b3d51c32b60..4601a07086475 100644 --- a/src/wp-includes/blocks.php +++ b/src/wp-includes/blocks.php @@ -138,27 +138,27 @@ function get_block_asset_url( $path ) { * @return string|false Script handle provided directly or created through * script's registration, or false on failure. */ -function register_block_module_handle( $metadata, $field_name, $index = 0 ) { +function register_block_module_id( $metadata, $field_name, $index = 0 ) { if ( empty( $metadata[ $field_name ] ) ) { return false; } - $module_handle = $metadata[ $field_name ]; - if ( is_array( $module_handle ) ) { - if ( empty( $module_handle[ $index ] ) ) { + $module_id = $metadata[ $field_name ]; + if ( is_array( $module_id ) ) { + if ( empty( $module_id[ $index ] ) ) { return false; } - $module_handle = $module_handle[ $index ]; + $module_id = $module_id[ $index ]; } - $module_path = remove_block_asset_path_prefix( $module_handle ); - if ( $module_handle === $module_path ) { - return $module_handle; + $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_handle = generate_block_asset_handle( $metadata['name'], $field_name, $index ); + $module_id = generate_block_asset_handle( $metadata['name'], $field_name, $index ); $module_asset_path = wp_normalize_path( realpath( $module_asset_raw_path ) ); @@ -184,7 +184,7 @@ function register_block_module_handle( $metadata, $field_name, $index = 0 ) { $module_asset = require $module_asset_path; $module_dependencies = isset( $module_asset['dependencies'] ) ? $module_asset['dependencies'] : array(); $result = wp_register_module( - $module_handle, + $module_id, $module_uri, $module_dependencies, isset( $module_asset['version'] ) ? $module_asset['version'] : false, @@ -192,10 +192,10 @@ function register_block_module_handle( $metadata, $field_name, $index = 0 ) { if ( ! empty( $metadata['textdomain'] ) && in_array( 'wp-i18n', $module_dependencies, true ) ) { // script translations? - wp_set_script_translations( $module_handle, $metadata['textdomain'] ); + wp_set_script_translations( $module_id, $metadata['textdomain'] ); } - return $module_handle; + return $module_id; } /** @@ -578,7 +578,7 @@ function register_block_type_from_metadata( $file_or_folder, $args = array() ) { } $module_fields = array( - 'viewModule' => 'view_module_handles', + 'viewModule' => 'view_module_ids', ); foreach ( $module_fields as $metadata_field_name => $settings_field_name ) { @@ -590,7 +590,7 @@ function register_block_type_from_metadata( $file_or_folder, $args = array() ) { $processed_modules = array(); if ( is_array( $modules ) ) { for ( $index = 0; $index < count( $modules ); $index++ ) { - $result = register_block_module_handle( + $result = register_block_module_id( $metadata, $metadata_field_name, $index @@ -600,7 +600,7 @@ function register_block_type_from_metadata( $file_or_folder, $args = array() ) { } } } else { - $result = register_block_module_handle( + $result = register_block_module_id( $metadata, $metadata_field_name ); diff --git a/src/wp-includes/class-wp-block-type.php b/src/wp-includes/class-wp-block-type.php index 3cf04501df1df..2e67382e6377d 100644 --- a/src/wp-includes/class-wp-block-type.php +++ b/src/wp-includes/class-wp-block-type.php @@ -210,12 +210,12 @@ class WP_Block_Type { public $view_script_handles = array(); /** - * Block type front end only module handles. + * Block type front end only module IDs. * * @since 6.5.0 * @var string[] */ - public $view_module_handles = array(); + public $view_module_ids = array(); /** * Block type editor only style handles. diff --git a/src/wp-includes/class-wp-block.php b/src/wp-includes/class-wp-block.php index 42c697cfd4713..2d6e97607130a 100644 --- a/src/wp-includes/class-wp-block.php +++ b/src/wp-includes/class-wp-block.php @@ -274,9 +274,9 @@ public function render( $options = array() ) { } } - if ( ! empty( $this->block_type->view_module_handles ) ) { - foreach ( $this->block_type->view_module_handles as $view_module_handle ) { - wp_enqueue_module( $view_module_handle ); + if ( ! empty( $this->block_type->view_module_ids ) ) { + foreach ( $this->block_type->view_module_ids as $view_module_id ) { + wp_enqueue_module( $view_module_id ); } }