mirror of
git://develop.git.wordpress.org/
synced 2025-03-23 13:29:56 +01:00
Script Loader: Enqueue block stylesheet only when the corresponding block is used.
Before this change, block stylesheets were enqueued although the corresponding blocks were not used in the current post, even if the `should_load_separate_core_block_assets` filter was set to `true`. Props shimotomoki, devutpol, audrasjb. Fixes #54457. git-svn-id: https://develop.svn.wordpress.org/trunk@52262 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
5fb4b61339
commit
9f56ce822e
@ -2459,10 +2459,14 @@ function enqueue_block_styles_assets() {
|
||||
if ( wp_should_load_separate_core_block_assets() ) {
|
||||
add_filter(
|
||||
'render_block',
|
||||
function( $html ) use ( $style_properties ) {
|
||||
wp_enqueue_style( $style_properties['style_handle'] );
|
||||
function( $html, $block ) use ( $block_name, $style_properties ) {
|
||||
if ( $block['blockName'] === $block_name ) {
|
||||
wp_enqueue_style( $style_properties['style_handle'] );
|
||||
}
|
||||
return $html;
|
||||
}
|
||||
},
|
||||
10,
|
||||
2
|
||||
);
|
||||
} else {
|
||||
wp_enqueue_style( $style_properties['style_handle'] );
|
||||
|
Loading…
x
Reference in New Issue
Block a user