From a6b0e7d56bd1b5e06e279276fdabe350ad624b77 Mon Sep 17 00:00:00 2001 From: Grzegorz Ziolkowski Date: Mon, 12 Sep 2022 15:54:45 +0200 Subject: [PATCH] Fix the special handling for the first style in core blocks --- src/wp-includes/blocks.php | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/wp-includes/blocks.php b/src/wp-includes/blocks.php index 907bbf2313a24..82aa0a800a910 100644 --- a/src/wp-includes/blocks.php +++ b/src/wp-includes/blocks.php @@ -180,10 +180,10 @@ function register_block_style_handle( $metadata, $field_name, $index = 0 ) { return false; } - $wpinc_path_norm = wp_normalize_path( realpath( ABSPATH . WPINC ) ); - $theme_path_norm = wp_normalize_path( get_theme_file_path() ); - $is_core_block = isset( $metadata['file'] ) && 0 === strpos( $metadata['file'], $wpinc_path_norm ); - if ( $is_core_block && ! wp_should_load_separate_core_block_assets() ) { + $wpinc_path_norm = wp_normalize_path( realpath( ABSPATH . WPINC ) ); + $theme_path_norm = wp_normalize_path( get_theme_file_path() ); + $is_core_block_first_style = isset( $metadata['file'] ) && 0 === strpos( $metadata['file'], $wpinc_path_norm ) && $index === 0; + if ( $is_core_block_first_style && ! wp_should_load_separate_core_block_assets() ) { return false; } @@ -196,14 +196,14 @@ function register_block_style_handle( $metadata, $field_name, $index = 0 ) { } $style_path = remove_block_asset_path_prefix( $style_handle ); - if ( $style_handle === $style_path && ! $is_core_block ) { + if ( $style_handle === $style_path && ! $is_core_block_first_style ) { return $style_handle; } // Check whether styles should have a ".min" suffix or not. $suffix = SCRIPT_DEBUG ? '' : '.min'; $style_uri = plugins_url( $style_path, $metadata['file'] ); - if ( $is_core_block ) { + if ( $is_core_block_first_style ) { $style_path = "style$suffix.css"; $style_uri = includes_url( 'blocks/' . str_replace( 'core/', '', $metadata['name'] ) . "/style$suffix.css" ); } @@ -219,7 +219,7 @@ function register_block_style_handle( $metadata, $field_name, $index = 0 ) { $block_dir = dirname( $metadata['file'] ); $style_file = realpath( "$block_dir/$style_path" ); $has_style_file = false !== $style_file; - $version = ! $is_core_block && isset( $metadata['version'] ) ? $metadata['version'] : false; + $version = ! $is_core_block_first_style && isset( $metadata['version'] ) ? $metadata['version'] : false; $style_uri = $has_style_file ? $style_uri : false; $result = wp_register_style( $style_handle,