Changeset 54327
- Timestamp:
- 09/27/2022 03:09:14 PM (2 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/blocks.php
r54323 r54327 128 128 return false; 129 129 } 130 130 131 // Path needs to be normalized to work in Windows env. 131 132 $wpinc_path_norm = wp_normalize_path( realpath( ABSPATH . WPINC ) ); 132 133 $theme_path_norm = wp_normalize_path( get_theme_file_path() ); 133 134 $script_path_norm = wp_normalize_path( realpath( dirname( $metadata['file'] ) . '/' . $script_path ) ); 134 $is_core_block = isset( $metadata['file'] ) && 0 === strpos( $metadata['file'], $wpinc_path_norm ); 135 $is_theme_block = 0 === strpos( $script_path_norm, $theme_path_norm ); 135 136 $is_core_block = isset( $metadata['file'] ) && 0 === strpos( $metadata['file'], $wpinc_path_norm ); 137 $is_theme_block = 0 === strpos( $script_path_norm, $theme_path_norm ); 136 138 137 139 $script_uri = plugins_url( $script_path, $metadata['file'] ); … … 182 184 183 185 $wpinc_path_norm = wp_normalize_path( realpath( ABSPATH . WPINC ) ); 184 $theme_path_norm = wp_normalize_path( get_theme_file_path() ); 185 $is_core_block 186 187 $is_core_block = isset( $metadata['file'] ) && 0 === strpos( $metadata['file'], $wpinc_path_norm ); 186 188 // Skip registering individual styles for each core block when a bundled version provided. 187 189 if ( $is_core_block && ! wp_should_load_separate_core_block_assets() ) { … … 213 215 $style_path = "style$suffix.css"; 214 216 } 217 215 218 $style_path_norm = wp_normalize_path( realpath( dirname( $metadata['file'] ) . '/' . $style_path ) ); 216 219 $has_style_file = '' !== $style_path_norm; 220 217 221 if ( $has_style_file ) { 218 $style_uri = plugins_url( $style_path, $metadata['file'] ); 222 $style_uri = plugins_url( $style_path, $metadata['file'] ); 223 224 // Cache $theme_path_norm to avoid calling get_theme_file_path() multiple times. 225 static $theme_path_norm = ''; 226 if ( ! $theme_path_norm ) { 227 $theme_path_norm = wp_normalize_path( get_theme_file_path() ); 228 } 229 219 230 $is_theme_block = str_starts_with( $style_path_norm, $theme_path_norm ); 231 220 232 if ( $is_theme_block ) { 221 233 $style_uri = get_theme_file_uri( str_replace( $theme_path_norm, '', $style_path_norm ) ); 222 234 } elseif ( $is_core_block ) { 223 $style_uri 235 $style_uri = includes_url( 'blocks/' . str_replace( 'core/', '', $metadata['name'] ) . "/style$suffix.css" ); 224 236 } 225 237 } else {
Note: See TracChangeset
for help on using the changeset viewer.