From 2d3a37ffabc3b01e50416927ee5a019b3137e001 Mon Sep 17 00:00:00 2001 From: Jon Surrell Date: Wed, 7 Feb 2024 16:26:49 +0100 Subject: [PATCH] Make module asset file optional See #5799 / https://core.trac.wordpress.org/ticket/60460 --- src/wp-includes/blocks.php | 17 +---------------- 1 file changed, 1 insertion(+), 16 deletions(-) diff --git a/src/wp-includes/blocks.php b/src/wp-includes/blocks.php index b5658ac0b8827..9c32f8e166aa3 100644 --- a/src/wp-includes/blocks.php +++ b/src/wp-includes/blocks.php @@ -166,25 +166,10 @@ function register_block_script_module_id( $metadata, $field_name, $index = 0 ) { realpath( $module_asset_raw_path ) ); - if ( empty( $module_asset_path ) ) { - _doing_it_wrong( - __FUNCTION__, - sprintf( - /* 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.' ), - $module_asset_raw_path, - $field_name, - $metadata['name'] - ), - '6.5.0' - ); - return false; - } - $module_path_norm = wp_normalize_path( realpath( $path . '/' . $module_path ) ); $module_uri = get_block_asset_url( $module_path_norm ); - $module_asset = require $module_asset_path; + $module_asset = @include $module_asset_path; $module_dependencies = isset( $module_asset['dependencies'] ) ? $module_asset['dependencies'] : array(); wp_register_script_module(