From b717d4fba3c7efd5179ecaa61f96955b9d152d68 Mon Sep 17 00:00:00 2001 From: Ari Stathopoulos Date: Thu, 4 Nov 2021 16:06:52 +0200 Subject: [PATCH] backport https://github.com/WordPress/gutenberg/pull/31239 --- src/wp-includes/script-loader.php | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/wp-includes/script-loader.php b/src/wp-includes/script-loader.php index 66d4c4cdef6cf..9254c65bc35bb 100644 --- a/src/wp-includes/script-loader.php +++ b/src/wp-includes/script-loader.php @@ -2265,7 +2265,19 @@ function wp_common_block_scripts_and_styles() { wp_enqueue_style( 'wp-block-library' ); if ( current_theme_supports( 'wp-block-styles' ) ) { - wp_enqueue_style( 'wp-block-library-theme' ); + if ( wp_should_load_separate_core_block_assets() ) { + $suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? 'css' : 'min.css'; + $files = glob( __DIR__ . "/blocks/**/theme.$suffix" ); + foreach ( $files as $path ) { + $block_name = basename( dirname( $path ) ); + if ( is_rtl() && file_exists( __DIR__ . "/blocks/$block_name/theme-rtl.$suffix")) { + $path = __DIR__ . "/blocks/$block_name/theme-rtl.$suffix"; + } + wp_add_inline_style( "wp-block-{$block_name}", file_get_contents( $path ) ); + } + } else { + wp_enqueue_style( 'wp-block-library-theme' ); + } } /**