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. Built from https://develop.svn.wordpress.org/trunk@52262 git-svn-id: http://core.svn.wordpress.org/trunk@51854 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
74d251884f
commit
dc853cb0e9
|
@ -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'] );
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
*
|
||||
* @global string $wp_version
|
||||
*/
|
||||
$wp_version = '5.9-alpha-52261';
|
||||
$wp_version = '5.9-alpha-52262';
|
||||
|
||||
/**
|
||||
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
||||
|
|
Loading…
Reference in New Issue