Skip to content

Commit

Permalink
Editor: Add fallback for block version when registering block script …
Browse files Browse the repository at this point in the history
…module

It aligns implementation with how regular scripts are handled.

Follow-up [57437].
See #60233.




git-svn-id: https://develop.svn.wordpress.org/trunk@57677 602fd350-edb4-49c9-b593-d223f7449a82
  • Loading branch information
gziolo committed Feb 21, 2024
1 parent 299e2ad commit a578de5
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/wp-includes/blocks.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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 );
Expand Down

0 comments on commit a578de5

Please sign in to comment.