From 6d0a691b84d411813378f1983a0a87bf78a1ccad Mon Sep 17 00:00:00 2001 From: Jb Audras Date: Wed, 1 Mar 2023 15:56:50 +0000 Subject: [PATCH] Script Loader: Pass the asset path to the `_doing_it_wrong()` notice in `register_block_script_handle()`. This changeset ensures the file path is correctly passed in the output from `_doing_it_wrong()` notice in `register_block_script_handle()`. Props desrosj, neychok, mahbubshovan, ironprogrammer, robinwpdeveloper, hellofromTonya, simongomes02, mukesh27, costdev. Fixes #53566. git-svn-id: https://develop.svn.wordpress.org/trunk@55446 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-includes/blocks.php | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/wp-includes/blocks.php b/src/wp-includes/blocks.php index 8962680c53..5b8871d3f7 100644 --- a/src/wp-includes/blocks.php +++ b/src/wp-includes/blocks.php @@ -107,19 +107,19 @@ function register_block_script_handle( $metadata, $field_name, $index = 0 ) { return $script_handle; } - $script_handle = generate_block_asset_handle( $metadata['name'], $field_name, $index ); - $script_asset_path = wp_normalize_path( - realpath( - dirname( $metadata['file'] ) . '/' . - substr_replace( $script_path, '.asset.php', - strlen( '.js' ) ) - ) + $script_asset_raw_path = dirname( $metadata['file'] ) . '/' . substr_replace( $script_path, '.asset.php', - strlen( '.js' ) ); + $script_handle = generate_block_asset_handle( $metadata['name'], $field_name, $index ); + $script_asset_path = wp_normalize_path( + realpath( $script_asset_raw_path ) ); - if ( ! file_exists( $script_asset_path ) ) { + + if ( empty( $script_asset_path ) ) { _doing_it_wrong( __FUNCTION__, sprintf( - /* translators: 1: Field name, 2: Block name. */ - __( 'The asset file for the "%1$s" defined in "%2$s" block definition is missing.' ), + /* 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.' ), + $script_asset_raw_path, $field_name, $metadata['name'] ),