Skip to content

Commit

Permalink
Make module asset file optional
Browse files Browse the repository at this point in the history
  • Loading branch information
sirreal committed Feb 7, 2024
1 parent 0ae983c commit 0f5f26d
Showing 1 changed file with 1 addition and 16 deletions.
17 changes: 1 addition & 16 deletions src/wp-includes/blocks.php
Original file line number Diff line number Diff line change
Expand Up @@ -166,25 +166,10 @@ function register_block_script_module_id( $metadata, $field_name, $index = 0 ) {
realpath( $module_asset_raw_path )
);

if ( empty( $module_asset_path ) ) {
_doing_it_wrong(
__FUNCTION__,
sprintf(
/* translators: 1: Asset file location, 2: Field name, 3: Block name. */
__( 'The asset file (%1$s) for the "%2$s" defined in "%3$s" block definition is missing.' ),
$module_asset_raw_path,
$field_name,
$metadata['name']
),
'6.5.0'
);
return false;
}

$module_path_norm = wp_normalize_path( realpath( $path . '/' . $module_path ) );
$module_uri = get_block_asset_url( $module_path_norm );

$module_asset = require $module_asset_path;
$module_asset = @include $module_asset_path;
$module_dependencies = isset( $module_asset['dependencies'] ) ? $module_asset['dependencies'] : array();

wp_register_script_module(
Expand Down

0 comments on commit 0f5f26d

Please sign in to comment.