Skip to content

Commit

Permalink
refactor for readability
Browse files Browse the repository at this point in the history
  • Loading branch information
scruffian committed Sep 9, 2022
1 parent 0e333f0 commit d270ecc
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions lib/compat/wordpress-6.1/get-global-styles-and-settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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 );
}
}
}
Expand Down

0 comments on commit d270ecc

Please sign in to comment.