Editor: Add fallback for block version when registering block script module

It aligns implementation with how regular scripts are handled.

Follow-up [57437].
See #60233.



Built from https://develop.svn.wordpress.org/trunk@57677


git-svn-id: http://core.svn.wordpress.org/trunk@57178 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
gziolo 2024-02-21 11:20:10 +00:00
parent 3b828d85af
commit 7889a84379
2 changed files with 5 additions and 3 deletions

View File

@ -172,12 +172,14 @@ function register_block_script_module_id( $metadata, $field_name, $index = 0 ) {
$module_asset = ! empty( $module_asset_path ) ? require $module_asset_path : array();
$module_dependencies = isset( $module_asset['dependencies'] ) ? $module_asset['dependencies'] : array();
$block_version = isset( $metadata['version'] ) ? $metadata['version'] : false;
$module_version = isset( $module_asset['version'] ) ? $module_asset['version'] : $block_version;
wp_register_script_module(
$module_id,
$module_uri,
$module_dependencies,
isset( $module_asset['version'] ) ? $module_asset['version'] : false
$module_version
);
return $module_id;
@ -225,7 +227,7 @@ function register_block_script_handle( $metadata, $field_name, $index = 0 ) {
);
// Asset file for blocks is optional. See https://core.trac.wordpress.org/ticket/60460.
$script_asset = ! empty( $script_asset_path ) ? require $script_asset_path : array();
$script_asset = ! empty( $script_asset_path ) ? require $script_asset_path : array();
$script_handle = isset( $script_asset['handle'] ) ?
$script_asset['handle'] :
generate_block_asset_handle( $metadata['name'], $field_name, $index );

View File

@ -16,7 +16,7 @@
*
* @global string $wp_version
*/
$wp_version = '6.5-beta2-57676';
$wp_version = '6.5-beta2-57677';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.