Make WordPress Core

Changeset 51267


Ignore:
Timestamp:
06/30/2021 01:45:10 AM (3 years ago)
Author:
desrosj
Message:

Script Loader: Fix PHP notice caused by the viewScript for the core/file block.

This fixes a PHP notice caused by the viewScript for the core/file block having .min.js instead of just .js.

register_block_script_handle() was incorrectly looking for view.min.asset.php, which does not exist, and caused the _doing_it_wrong() notice.

This adds a check for .min.js in the viewScript field of block.json and corrects it to .js in order to match the expected pattern of view.asset.php until a more permanent fix can be created.

Follow up to [51259].

Props ipstenu, pbiron, peterwilsoncc.
See #53397.

File:
1 edited

Legend:

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

    r51262 r51267  
    8383    }
    8484
    85     $script_handle     = generate_block_asset_handle( $metadata['name'], $field_name );
     85    $script_handle = generate_block_asset_handle( $metadata['name'], $field_name );
     86
     87    if ( 'viewScript' === $field_name ) {
     88        $script_path = str_replace( '.min.js', '.js', $script_path );
     89    }
     90
    8691    $script_asset_path = realpath(
    8792        dirname( $metadata['file'] ) . '/' .
Note: See TracChangeset for help on using the changeset viewer.