mirror of
https://github.com/WordPress/WordPress.git
synced 2025-02-01 21:21:24 +01:00
Editor: Ensure global styles are rendered for third-party blocks.
This change ensures custom styles for all third-party blocks are rendered on the front end if assets are set to be loaded on a per-block basis. Additionally, this change includes new unit tests to help prevent a similar bug in the future. Props scruffian, aristath, poena, wildworks, ajlende, andraganescu, ndiego, gigitux, cbravobernal, ramonopoly, andrewserong, oandregal, hellofromTonya, bernhard-reiter. Fixes #56915. Built from https://develop.svn.wordpress.org/trunk@54703 git-svn-id: http://core.svn.wordpress.org/trunk@54255 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
d60cae82a1
commit
94ba2c6bf1
@ -218,14 +218,18 @@ function wp_add_global_styles_for_blocks() {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$stylesheet_handle = 'global-styles';
|
||||||
if ( isset( $metadata['name'] ) ) {
|
if ( isset( $metadata['name'] ) ) {
|
||||||
$block_name = str_replace( 'core/', '', $metadata['name'] );
|
|
||||||
/*
|
/*
|
||||||
* These block styles are added on block_render.
|
* These block styles are added on block_render.
|
||||||
* This hooks inline CSS to them so that they are loaded conditionally
|
* This hooks inline CSS to them so that they are loaded conditionally
|
||||||
* based on whether or not the block is used on the page.
|
* based on whether or not the block is used on the page.
|
||||||
*/
|
*/
|
||||||
wp_add_inline_style( 'wp-block-' . $block_name, $block_css );
|
if ( str_starts_with( $metadata['name'], 'core/' ) ) {
|
||||||
|
$block_name = str_replace( 'core/', '', $metadata['name'] );
|
||||||
|
$stylesheet_handle = 'wp-block-' . $block_name;
|
||||||
|
}
|
||||||
|
wp_add_inline_style( $stylesheet_handle, $block_css );
|
||||||
}
|
}
|
||||||
|
|
||||||
// The likes of block element styles from theme.json do not have $metadata['name'] set.
|
// The likes of block element styles from theme.json do not have $metadata['name'] set.
|
||||||
@ -242,8 +246,11 @@ function wp_add_global_styles_for_blocks() {
|
|||||||
)
|
)
|
||||||
);
|
);
|
||||||
if ( isset( $result[0] ) ) {
|
if ( isset( $result[0] ) ) {
|
||||||
$block_name = str_replace( 'core/', '', $result[0] );
|
if ( str_starts_with( $result[0], 'core/' ) ) {
|
||||||
wp_add_inline_style( 'wp-block-' . $block_name, $block_css );
|
$block_name = str_replace( 'core/', '', $result[0] );
|
||||||
|
$stylesheet_handle = 'wp-block-' . $block_name;
|
||||||
|
}
|
||||||
|
wp_add_inline_style( $stylesheet_handle, $block_css );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -16,7 +16,7 @@
|
|||||||
*
|
*
|
||||||
* @global string $wp_version
|
* @global string $wp_version
|
||||||
*/
|
*/
|
||||||
$wp_version = '6.2-alpha-54702';
|
$wp_version = '6.2-alpha-54703';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
||||||
|
Loading…
Reference in New Issue
Block a user