Skip to content

Commit

Permalink
Change the way RTL styles get enqueued (#28274)
Browse files Browse the repository at this point in the history
  • Loading branch information
aristath authored Jan 19, 2021
1 parent 8fe2ec8 commit 9928dc0
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions lib/blocks.php
Original file line number Diff line number Diff line change
Expand Up @@ -164,29 +164,27 @@ function gutenberg_register_core_block_styles( $block_name ) {

$block_name = str_replace( 'core/', '', $block_name );

$style_path = is_rtl()
? "build/block-library/blocks/$block_name/style-rtl.css"
: "build/block-library/blocks/$block_name/style.css";
$editor_style_path = is_rtl()
? "build/block-library/blocks/$block_name/style-editor-rtl.css"
: "build/block-library/blocks/$block_name/style-editor.css";
$style_path = "build/block-library/blocks/$block_name/style.css";
$editor_style_path = "build/block-library/blocks/$block_name/style-editor.css";

if ( file_exists( gutenberg_dir_path() . $style_path ) ) {
wp_register_style(
'wp-block-' . $block_name,
"wp-block-{$block_name}",
gutenberg_url( $style_path ),
array(),
filemtime( gutenberg_dir_path() . $style_path )
);
wp_style_add_data( "wp-block-{$block_name}", 'rtl', 'replace' );
}

if ( file_exists( gutenberg_dir_path() . $editor_style_path ) ) {
wp_register_style(
'wp-block-' . $block_name . '-editor',
"wp-block-{$block_name}-editor",
gutenberg_url( $editor_style_path ),
array(),
filemtime( gutenberg_dir_path() . $editor_style_path )
);
wp_style_add_data( "wp-block-{$block_name}-editor", 'rtl', 'replace' );
}
}

Expand Down

0 comments on commit 9928dc0

Please sign in to comment.