mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-06-30 23:30:05 +00:00
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. git-svn-id: https://develop.svn.wordpress.org/trunk@51267 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -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' ) )
|
||||
|
||||
Reference in New Issue
Block a user