From 12b190eb17ae4d51c29147f27d82ac762b0315a7 Mon Sep 17 00:00:00 2001 From: Sergey Biryukov Date: Tue, 27 Sep 2022 15:43:09 +0000 Subject: [PATCH] Editor: Correctly load RTL stylesheets in `register_block_style_handle()`. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When setting an RTL language under Settings → General, some RTL stylesheets were not loaded, with LTR stylesheets being loaded instead, meaning that some blocks were not displayed correctly. This commit ensures that all appropriate RTL stylesheets are loaded when selecting an RTL language. Additionally, this commit improves performance by only running a `file_exists()` check for an RTL stylesheet if `is_rtl()` returns true, i.e. an RTL locale is selected. Follow-up to [49982], [50836]. Props zoonini, sabernhardt, maahrokh, ankit-k-gupta, aristath, poena, SergeyBiryukov. See #56325. Built from https://develop.svn.wordpress.org/trunk@54330 git-svn-id: http://core.svn.wordpress.org/trunk@53889 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/blocks.php | 7 +++---- wp-includes/version.php | 2 +- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/wp-includes/blocks.php b/wp-includes/blocks.php index 261394bb65..d6db591bc6 100644 --- a/wp-includes/blocks.php +++ b/wp-includes/blocks.php @@ -251,14 +251,13 @@ function register_block_style_handle( $metadata, $field_name, $index = 0 ) { } if ( $has_style_file ) { - if ( file_exists( str_replace( '.css', '-rtl.css', $style_path_norm ) ) ) { - wp_style_add_data( $style_handle, 'rtl', 'replace' ); - } - wp_style_add_data( $style_handle, 'path', $style_path_norm ); $rtl_file = str_replace( "{$suffix}.css", "-rtl{$suffix}.css", $style_path_norm ); + if ( is_rtl() && file_exists( $rtl_file ) ) { + wp_style_add_data( $style_handle, 'rtl', 'replace' ); + wp_style_add_data( $style_handle, 'suffix', $suffix ); wp_style_add_data( $style_handle, 'path', $rtl_file ); } } diff --git a/wp-includes/version.php b/wp-includes/version.php index 1777bd7014..2eb8be7994 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -16,7 +16,7 @@ * * @global string $wp_version */ -$wp_version = '6.1-beta1-54329'; +$wp_version = '6.1-beta1-54330'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.