Changeset 57559 for trunk/src/wp-includes/blocks.php
- Timestamp:
- 02/08/2024 08:16:59 AM (15 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/blocks.php
r57550 r57559 125 125 /** 126 126 * Finds a script handle for the selected block metadata field. It detects 127 * when a path to file was provided and finds a corresponding asset file128 * with details necessary to register the script under automatically127 * when a path to file was provided and optionally finds a corresponding asset 128 * file with details necessary to register the script under automatically 129 129 * generated handle name. It returns unprocessed script handle otherwise. 130 130 * 131 131 * @since 5.5.0 132 132 * @since 6.1.0 Added `$index` parameter. 133 * @since 6.5.0 The asset file is optional. 133 134 * 134 135 * @param array $metadata Block metadata. … … 164 165 ); 165 166 166 if ( empty( $script_asset_path ) ) {167 _doing_it_wrong(168 __FUNCTION__,169 sprintf(170 /* translators: 1: Asset file location, 2: Field name, 3: Block name. */171 __( 'The asset file (%1$s) for the "%2$s" defined in "%3$s" block definition is missing.' ),172 $script_asset_raw_path,173 $field_name,174 $metadata['name']175 ),176 '5.5.0'177 );178 return false;179 }180 181 167 $script_path_norm = wp_normalize_path( realpath( $path . '/' . $script_path ) ); 182 168 $script_uri = get_block_asset_url( $script_path_norm ); … … 187 173 } 188 174 189 $script_asset = require $script_asset_path; 175 // Asset file for blocks is optional. See https://core.trac.wordpress.org/ticket/60460. 176 $script_asset = ! empty( $script_asset_path ) ? require $script_asset_path : array(); 190 177 $script_dependencies = isset( $script_asset['dependencies'] ) ? $script_asset['dependencies'] : array(); 191 178 $result = wp_register_script(
Note: See TracChangeset
for help on using the changeset viewer.