Make WordPress Core


Ignore:
Timestamp:
03/01/2023 03:56:50 PM (12 months ago)
Author:
audrasjb
Message:

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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/blocks.php

    r55126 r55446  
    108108    }
    109109
    110     $script_handle     = generate_block_asset_handle( $metadata['name'], $field_name, $index );
    111     $script_asset_path = wp_normalize_path(
    112         realpath(
    113             dirname( $metadata['file'] ) . '/' .
    114             substr_replace( $script_path, '.asset.php', - strlen( '.js' ) )
    115         )
    116     );
    117     if ( ! file_exists( $script_asset_path ) ) {
     110    $script_asset_raw_path = dirname( $metadata['file'] ) . '/' . substr_replace( $script_path, '.asset.php', - strlen( '.js' ) );
     111    $script_handle         = generate_block_asset_handle( $metadata['name'], $field_name, $index );
     112    $script_asset_path     = wp_normalize_path(
     113        realpath( $script_asset_raw_path )
     114    );
     115
     116    if ( empty( $script_asset_path ) ) {
    118117        _doing_it_wrong(
    119118            __FUNCTION__,
    120119            sprintf(
    121                 /* translators: 1: Field name, 2: Block name. */
    122                 __( 'The asset file for the "%1$s" defined in "%2$s" block definition is missing.' ),
     120                /* translators: 1: Asset file location, 2: Field name, 3: Block name.  */
     121                __( 'The asset file (%1$s) for the "%2$s" defined in "%3$s" block definition is missing.' ),
     122                $script_asset_raw_path,
    123123                $field_name,
    124124                $metadata['name']
Note: See TracChangeset for help on using the changeset viewer.