From cdfcd943589c06d21b706e5c7975ddc8cdc1c7ce Mon Sep 17 00:00:00 2001 From: Joshua T Flowers Date: Wed, 16 Oct 2024 06:57:06 -0400 Subject: [PATCH] Limit loading product block editor to admin pages and rest requests (#51954) * Limit loading product block editor to admin pages and rest requests * Add changelog entry --- plugins/woocommerce/changelog/update-51953 | 4 ++++ .../src/Admin/Features/ProductBlockEditor/Init.php | 6 ++++++ 2 files changed, 10 insertions(+) create mode 100644 plugins/woocommerce/changelog/update-51953 diff --git a/plugins/woocommerce/changelog/update-51953 b/plugins/woocommerce/changelog/update-51953 new file mode 100644 index 00000000000..6f4cb75eb4f --- /dev/null +++ b/plugins/woocommerce/changelog/update-51953 @@ -0,0 +1,4 @@ +Significance: patch +Type: performance + +Limit loading product block editor to admin pages and rest requests diff --git a/plugins/woocommerce/src/Admin/Features/ProductBlockEditor/Init.php b/plugins/woocommerce/src/Admin/Features/ProductBlockEditor/Init.php index 7e274815e91..ab7c0ee3741 100644 --- a/plugins/woocommerce/src/Admin/Features/ProductBlockEditor/Init.php +++ b/plugins/woocommerce/src/Admin/Features/ProductBlockEditor/Init.php @@ -3,6 +3,8 @@ * WooCommerce Product Block Editor */ +declare(strict_types = 1); + namespace Automattic\WooCommerce\Admin\Features\ProductBlockEditor; use Automattic\WooCommerce\Admin\Features\Features; @@ -49,6 +51,10 @@ class Init { * Constructor */ public function __construct() { + if ( ! is_admin() && ! WC()->is_rest_api_request() ) { + return; + } + array_push( $this->supported_product_types, 'variable' ); array_push( $this->supported_product_types, 'external' ); array_push( $this->supported_product_types, 'grouped' );