From d270ecc1fd90f562244c40c5d2de3b5d685f3278 Mon Sep 17 00:00:00 2001 From: Ben Dwyer Date: Fri, 9 Sep 2022 12:20:14 +0100 Subject: [PATCH] refactor for readability --- .../wordpress-6.1/get-global-styles-and-settings.php | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/lib/compat/wordpress-6.1/get-global-styles-and-settings.php b/lib/compat/wordpress-6.1/get-global-styles-and-settings.php index 8bf335d8d81fb3..313bbc67bba9b7 100644 --- a/lib/compat/wordpress-6.1/get-global-styles-and-settings.php +++ b/lib/compat/wordpress-6.1/get-global-styles-and-settings.php @@ -19,11 +19,11 @@ function wp_add_global_styles_for_blocks() { continue; } + $stylesheet_handle = 'global-styles'; if ( isset( $metadata['name'] ) ) { // These block styles are added on block_render. // This hooks inline CSS to them so that they are loaded conditionally // based on whether or not the block is used on the page. - $stylesheet_handle = 'global-styles'; if ( str_starts_with( $metadata['name'], 'core/' ) ) { $block_name = str_replace( 'core/', '', $metadata['name'] ); $stylesheet_handle = 'wp-block-' . $block_name; @@ -45,12 +45,11 @@ function ( $item ) { ) ); if ( isset( $result[0] ) ) { - if ( 0 === strpos( $metadata['name'], 'core/' ) ) { + if ( str_starts_with( $metadata['name'], 'core/' ) ) { $block_name = str_replace( 'core/', '', $result[0] ); - wp_add_inline_style( 'wp-block-' . $block_name, $block_css ); - } else { - wp_add_inline_style( 'global-styles', $block_css ); + $stylesheet_handle = 'wp-block-' . $block_name; } + wp_add_inline_style( $stylesheet_handle, $block_css ); } } }