Skip to content

Commit d145c50

Browse files
Editor: Correctly load RTL stylesheets in register_block_style_handle().
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. git-svn-id: https://develop.svn.wordpress.org/trunk@54330 602fd350-edb4-49c9-b593-d223f7449a82
1 parent 717c00f commit d145c50

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

src/wp-includes/blocks.php

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -251,14 +251,13 @@ function register_block_style_handle( $metadata, $field_name, $index = 0 ) {
251251
}
252252

253253
if ( $has_style_file ) {
254-
if ( file_exists( str_replace( '.css', '-rtl.css', $style_path_norm ) ) ) {
255-
wp_style_add_data( $style_handle, 'rtl', 'replace' );
256-
}
257-
258254
wp_style_add_data( $style_handle, 'path', $style_path_norm );
259255

260256
$rtl_file = str_replace( "{$suffix}.css", "-rtl{$suffix}.css", $style_path_norm );
257+
261258
if ( is_rtl() && file_exists( $rtl_file ) ) {
259+
wp_style_add_data( $style_handle, 'rtl', 'replace' );
260+
wp_style_add_data( $style_handle, 'suffix', $suffix );
262261
wp_style_add_data( $style_handle, 'path', $rtl_file );
263262
}
264263
}

0 commit comments

Comments
 (0)