Changeset 53091 for trunk/src/wp-includes/blocks.php
- Timestamp:
- 04/07/2022 11:57:16 AM (3 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/blocks.php
r52939 r53091 109 109 // Path needs to be normalized to work in Windows env. 110 110 $wpinc_path_norm = wp_normalize_path( realpath( ABSPATH . WPINC ) ); 111 $theme_path_norm = wp_normalize_path( get_theme_file_path() ); 111 112 $script_path_norm = wp_normalize_path( realpath( dirname( $metadata['file'] ) . '/' . $script_path ) ); 112 113 $is_core_block = isset( $metadata['file'] ) && 0 === strpos( $metadata['file'], $wpinc_path_norm ); 113 114 $script_uri = $is_core_block ? 115 includes_url( str_replace( $wpinc_path_norm, '', $script_path_norm ) ) : 116 plugins_url( $script_path, $metadata['file'] ); 114 $is_theme_block = 0 === strpos( $script_path_norm, $theme_path_norm ); 115 116 $script_uri; 117 if ( $is_core_block ) { 118 $script_uri = includes_url( str_replace( $wpinc_path_norm, '', $script_path_norm ) ); 119 } elseif ( $is_theme_block ) { 120 $script_uri = get_theme_file_uri( str_replace( $theme_path_norm, '', $script_path_norm ) ); 121 } else { 122 $script_uri = plugins_url( $script_path, $metadata['file'] ); 123 } 124 117 125 $script_asset = require $script_asset_path; 118 126 $script_dependencies = isset( $script_asset['dependencies'] ) ? $script_asset['dependencies'] : array(); … … 151 159 } 152 160 $wpinc_path_norm = wp_normalize_path( realpath( ABSPATH . WPINC ) ); 161 $theme_path_norm = wp_normalize_path( get_theme_file_path() ); 153 162 $is_core_block = isset( $metadata['file'] ) && 0 === strpos( $metadata['file'], $wpinc_path_norm ); 154 163 if ( $is_core_block && ! wp_should_load_separate_core_block_assets() ) { … … 170 179 $style_path = "style$suffix.css"; 171 180 $style_uri = includes_url( 'blocks/' . str_replace( 'core/', '', $metadata['name'] ) . "/style$suffix.css" ); 181 } 182 183 $style_path_norm = wp_normalize_path( realpath( dirname( $metadata['file'] ) . '/' . $style_path ) ); 184 $is_theme_block = 0 === strpos( $style_path_norm, $theme_path_norm ); 185 186 if ( $is_theme_block ) { 187 $style_uri = get_theme_file_uri( str_replace( $theme_path_norm, '', $style_path_norm ) ); 172 188 } 173 189 … … 1316 1332 $args = array( 'handle' => $handle ); 1317 1333 if ( 0 === strpos( $handle, 'file:' ) && isset( $metadata['file'] ) ) { 1318 $style_path = remove_block_asset_path_prefix( $handle ); 1334 $style_path = remove_block_asset_path_prefix( $handle ); 1335 $theme_path_norm = wp_normalize_path( get_theme_file_path() ); 1336 $style_path_norm = wp_normalize_path( realpath( dirname( $metadata['file'] ) . '/' . $style_path ) ); 1337 $is_theme_block = isset( $metadata['file'] ) && 0 === strpos( $metadata['file'], $theme_path_norm ); 1338 1339 $style_uri = plugins_url( $style_path, $metadata['file'] ); 1340 1341 if ( $is_theme_block ) { 1342 $style_uri = get_theme_file_uri( str_replace( $theme_path_norm, '', $style_path_norm ) ); 1343 } 1344 1319 1345 $args = array( 1320 1346 'handle' => sanitize_key( "{$metadata['name']}-{$style_path}" ), 1321 'src' => plugins_url( $style_path, $metadata['file'] ),1347 'src' => $style_uri, 1322 1348 ); 1323 1349 }
Note: See TracChangeset
for help on using the changeset viewer.