Commit 9ac486d56f9 for woocommerce
commit 9ac486d56f97c7f116fb77236e9e7b136ed5f2d7
Author: Luigi Teschio <gigitux@gmail.com>
Date: Wed Jul 29 09:39:03 2026 +0200
Fix early translation loading in Blocks bootstrap (#67072)
* Fix early unified assets feature check
* Add changelog entry for unified assets bootstrap fix
diff --git a/plugins/woocommerce/changelog/fix-blocks-bootstrap-translation-loading b/plugins/woocommerce/changelog/fix-blocks-bootstrap-translation-loading
new file mode 100644
index 00000000000..8b4ce1fe48b
--- /dev/null
+++ b/plugins/woocommerce/changelog/fix-blocks-bootstrap-translation-loading
@@ -0,0 +1,4 @@
+Significance: patch
+Type: fix
+
+Prevent early translation loading when checking unified block editor build assets.
diff --git a/plugins/woocommerce/src/Blocks/Domain/Bootstrap.php b/plugins/woocommerce/src/Blocks/Domain/Bootstrap.php
index b19c178e88b..51b8c2fc52f 100644
--- a/plugins/woocommerce/src/Blocks/Domain/Bootstrap.php
+++ b/plugins/woocommerce/src/Blocks/Domain/Bootstrap.php
@@ -171,13 +171,25 @@ class Bootstrap {
* @return bool
*/
protected function is_built() {
- $editor_asset = BlockEditorUnifiedAssets::is_enabled() ? 'wc-block-library.js' : 'featured-product.js';
+ $editor_asset = $this->is_block_editor_unified_assets_enabled_during_bootstrap() ? 'wc-block-library.js' : 'featured-product.js';
return file_exists(
$this->package->get_path( 'assets/client/blocks/' . $editor_asset )
);
}
+ /**
+ * Check whether unified block editor assets are enabled during plugin bootstrap.
+ *
+ * Feature definitions contain translated presentation strings and are not safe to use before init.
+ *
+ * @return bool
+ */
+ private function is_block_editor_unified_assets_enabled_during_bootstrap(): bool {
+ // Keep this fallback aligned with `enabled_by_default` for unified block editor assets in FeaturesController.
+ return 'yes' === get_option( BlockEditorUnifiedAssets::OPTION_NAME, 'no' );
+ }
+
/**
* Add a notice stating that the build has not been done yet.
*/