Make WordPress Core

Changeset 54330


Ignore:
Timestamp:
09/27/2022 03:41:15 PM (2 years ago)
Author:
SergeyBiryukov
Message:

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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/blocks.php

    r54327 r54330  
    252252
    253253    if ( $has_style_file ) {
    254         if ( file_exists( str_replace( '.css', '-rtl.css', $style_path_norm ) ) ) {
     254        wp_style_add_data( $style_handle, 'path', $style_path_norm );
     255
     256        $rtl_file = str_replace( "{$suffix}.css", "-rtl{$suffix}.css", $style_path_norm );
     257
     258        if ( is_rtl() && file_exists( $rtl_file ) ) {
    255259            wp_style_add_data( $style_handle, 'rtl', 'replace' );
    256         }
    257 
    258         wp_style_add_data( $style_handle, 'path', $style_path_norm );
    259 
    260         $rtl_file = str_replace( "{$suffix}.css", "-rtl{$suffix}.css", $style_path_norm );
    261         if ( is_rtl() && file_exists( $rtl_file ) ) {
     260            wp_style_add_data( $style_handle, 'suffix', $suffix );
    262261            wp_style_add_data( $style_handle, 'path', $rtl_file );
    263262        }
Note: See TracChangeset for help on using the changeset viewer.