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.
Built from https://develop.svn.wordpress.org/trunk@51267


git-svn-id: http://core.svn.wordpress.org/trunk@50876 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
desrosj 2021-06-30 01:46:57 +00:00
parent 1b7cd950ca
commit e7387a9ace
2 changed files with 7 additions and 2 deletions

View File

@ -82,7 +82,12 @@ function register_block_script_handle( $metadata, $field_name ) {
return $script_handle;
}
$script_handle = generate_block_asset_handle( $metadata['name'], $field_name );
$script_handle = generate_block_asset_handle( $metadata['name'], $field_name );
if ( 'viewScript' === $field_name ) {
$script_path = str_replace( '.min.js', '.js', $script_path );
}
$script_asset_path = realpath(
dirname( $metadata['file'] ) . '/' .
substr_replace( $script_path, '.asset.php', - strlen( '.js' ) )

View File

@ -13,7 +13,7 @@
*
* @global string $wp_version
*/
$wp_version = '5.8-beta4-51266';
$wp_version = '5.8-beta4-51267';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.