From b368bba72ed14ac2877ead1825b8a6d275e346a3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9CJoshua?= Date: Wed, 18 Sep 2024 13:40:46 -0400 Subject: [PATCH] Only register block assets on the frontend during block render --- plugins/woocommerce/src/Blocks/BlockTypes/AbstractBlock.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/woocommerce/src/Blocks/BlockTypes/AbstractBlock.php b/plugins/woocommerce/src/Blocks/BlockTypes/AbstractBlock.php index dbe9007d6a8..152715c951a 100644 --- a/plugins/woocommerce/src/Blocks/BlockTypes/AbstractBlock.php +++ b/plugins/woocommerce/src/Blocks/BlockTypes/AbstractBlock.php @@ -90,9 +90,9 @@ abstract class AbstractBlock { * @return string Rendered block type output. */ public function render_callback( $attributes = [], $content = '', $block = null ) { - $render_callback_attributes = $this->parse_render_callback_attributes( $attributes ); if ( ! is_admin() && ! WC()->is_rest_api_request() ) { + $this->register_block_type_assets(); $this->enqueue_assets( $render_callback_attributes, $content, $block ); } return $this->render( $render_callback_attributes, $content, $block ); @@ -107,6 +107,7 @@ abstract class AbstractBlock { if ( $this->enqueued_assets ) { return; } + $this->register_block_type_assets(); $this->enqueue_data(); } @@ -122,7 +123,6 @@ abstract class AbstractBlock { return false; } $this->integration_registry->initialize( $this->block_name . '_block' ); - $this->register_block_type_assets(); $this->register_block_type(); add_action( 'enqueue_block_editor_assets', [ $this, 'enqueue_editor_assets' ] ); }