Changeset 51501 for trunk/src/wp-includes/blocks.php
- Timestamp:
- 07/28/2021 10:05:01 AM (3 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/blocks.php
r51477 r51501 43 43 $asset_handle .= '-editor'; 44 44 } 45 if ( 0 === strpos( $field_name, 'view' ) ) { 46 $asset_handle .= '-view'; 47 } 45 48 return $asset_handle; 46 49 } … … 49 52 'editorScript' => 'editor-script', 50 53 'script' => 'script', 54 'viewScript' => 'view-script', 51 55 'editorStyle' => 'editor-style', 52 56 'style' => 'style', … … 97 101 return false; 98 102 } 99 $script_asset = require $script_asset_path; 100 $result = wp_register_script( 103 $is_core_block = isset( $metadata['file'] ) && 0 === strpos( $metadata['file'], ABSPATH . WPINC ); 104 $script_uri = $is_core_block ? 105 includes_url( str_replace( ABSPATH . WPINC, '', realpath( dirname( $metadata['file'] ) . '/' . $script_path ) ) ) : 106 plugins_url( $script_path, $metadata['file'] ); 107 $script_asset = require $script_asset_path; 108 $script_dependencies = isset( $script_asset['dependencies'] ) ? $script_asset['dependencies'] : array(); 109 $result = wp_register_script( 101 110 $script_handle, 102 plugins_url( $script_path, $metadata['file'] ),103 $script_ asset['dependencies'],104 $script_asset['version']111 $script_uri, 112 $script_dependencies, 113 isset( $script_asset['version'] ) ? $script_asset['version'] : false 105 114 ); 106 115 if ( ! $result ) { … … 108 117 } 109 118 110 if ( ! empty( $metadata['textdomain'] ) ) {119 if ( ! empty( $metadata['textdomain'] ) && in_array( 'wp-i18n', $script_dependencies ) ) { 111 120 wp_set_script_translations( $script_handle, $metadata['textdomain'] ); 112 121 } … … 183 192 * 184 193 * @since 5.5.0 194 * @since 5.9.0 Added support for the `viewScript` field. 185 195 * 186 196 * @param string $file_or_folder Path to the JSON file with metadata definition for … … 305 315 } 306 316 317 if ( ! empty( $metadata['viewScript'] ) ) { 318 $settings['view_script'] = register_block_script_handle( 319 $metadata, 320 'viewScript' 321 ); 322 } 323 307 324 if ( ! empty( $metadata['editorStyle'] ) ) { 308 325 $settings['editor_style'] = register_block_style_handle(
Note: See TracChangeset
for help on using the changeset viewer.