Skip to content

Commit be6233e

Browse files
committed
Block: Load viewStyle in the head tag when wp_should_load_block_assets_on_demand is false
1 parent 35ca22a commit be6233e

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

src/wp-includes/class-wp-block.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -617,7 +617,8 @@ public function render( $options = array() ) {
617617
}
618618
}
619619

620-
if ( ( ! empty( $this->block_type->view_style_handles ) ) ) {
620+
// Only enqueue if not already enqueued by wp_enqueue_registered_block_scripts_and_styles.
621+
if ( ( ! empty( $this->block_type->view_style_handles ) ) && wp_should_load_block_assets_on_demand() ) {
621622
foreach ( $this->block_type->view_style_handles as $view_style_handle ) {
622623
wp_enqueue_style( $view_style_handle );
623624
}

src/wp-includes/script-loader.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2696,6 +2696,11 @@ function wp_enqueue_registered_block_scripts_and_styles() {
26962696
wp_enqueue_style( $style_handle );
26972697
}
26982698

2699+
// Front-end styles.
2700+
foreach ( $block_type->view_style_handles as $view_style_handle ) {
2701+
wp_enqueue_style( $view_style_handle );
2702+
}
2703+
26992704
// Front-end and editor scripts.
27002705
foreach ( $block_type->script_handles as $script_handle ) {
27012706
wp_enqueue_script( $script_handle );

0 commit comments

Comments
 (0)