|
10 | 10 | add_filter( 'render_block_core/post-title', __NAMESPACE__ . '\swap_h0_for_paragraph', 20 );
|
11 | 11 | add_filter( 'render_block_core/query-title', __NAMESPACE__ . '\swap_h0_for_paragraph', 20 );
|
12 | 12 | add_filter( 'wp_script_attributes', __NAMESPACE__ . '\inject_module_cachebuster' );
|
| 13 | +add_action( 'wp_enqueue_scripts', __NAMESPACE__ . '\fix_rtl_style_includes', 1 ); |
13 | 14 |
|
14 | 15 | // Remove duplicate elements generation, can be removed after GB18.3+ is active.
|
15 | 16 | // See https://github.com/WordPress/wporg-parent-2021/issues/135.
|
@@ -68,3 +69,24 @@ function inject_module_cachebuster( $attributes ) {
|
68 | 69 | $attributes['src'] = $source;
|
69 | 70 | return $attributes;
|
70 | 71 | }
|
| 72 | + |
| 73 | +/** |
| 74 | + * Remove the suffix from RTL files. |
| 75 | + * |
| 76 | + * CSS registered from block.json are incorrectly configured with a suffix for |
| 77 | + * RTL sites, but the files don't use a suffix. This prevents the files from |
| 78 | + * being replaced correctly, causing visual issues on RTL sites. |
| 79 | + * |
| 80 | + * See https://core.trac.wordpress.org/ticket/61625. |
| 81 | + */ |
| 82 | +function fix_rtl_style_includes() { |
| 83 | + $wp_styles = wp_styles(); |
| 84 | + |
| 85 | + foreach ( $wp_styles->registered as $handle => $data ) { |
| 86 | + // Filter out the wporg-* styles, and only adjust styles with rtl data. |
| 87 | + if ( \str_starts_with( $handle, 'wporg-' ) && isset( $data->extra['rtl'] ) ) { |
| 88 | + // Remove the suffix data. |
| 89 | + wp_style_add_data( $handle, 'suffix', '' ); |
| 90 | + } |
| 91 | + } |
| 92 | +} |
0 commit comments