From 27e4b07074277e94a858bc5292ab1f1952fdba8a Mon Sep 17 00:00:00 2001 From: Ilyas Foo Date: Wed, 24 Apr 2024 17:44:35 +0800 Subject: [PATCH] Wrap LYS templates and patterns under feature flag (#46856) * Add feature flag for site editor templates and patterns for coming soon * Changelog * Lint * Fix classic themes --- ...date-wrap-coming-soon-templates-patterns-feature-flag | 4 ++++ plugins/woocommerce/patterns/coming-soon-entire-site.php | 1 + plugins/woocommerce/patterns/coming-soon-store-only.php | 1 + plugins/woocommerce/patterns/coming-soon.php | 1 + plugins/woocommerce/src/Blocks/BlockPatterns.php | 6 ++++++ .../woocommerce/src/Blocks/BlockTemplatesRegistry.php | 9 +++++---- .../woocommerce/src/Blocks/Utils/BlockTemplateUtils.php | 9 +++++++-- 7 files changed, 25 insertions(+), 6 deletions(-) create mode 100644 plugins/woocommerce/changelog/update-wrap-coming-soon-templates-patterns-feature-flag diff --git a/plugins/woocommerce/changelog/update-wrap-coming-soon-templates-patterns-feature-flag b/plugins/woocommerce/changelog/update-wrap-coming-soon-templates-patterns-feature-flag new file mode 100644 index 00000000000..d6dbfa6b9e0 --- /dev/null +++ b/plugins/woocommerce/changelog/update-wrap-coming-soon-templates-patterns-feature-flag @@ -0,0 +1,4 @@ +Significance: minor +Type: update + +Add feature flag check for patterns and wrap coming soon template and patterns under feature flag diff --git a/plugins/woocommerce/patterns/coming-soon-entire-site.php b/plugins/woocommerce/patterns/coming-soon-entire-site.php index cd654ec367c..c00accf1367 100644 --- a/plugins/woocommerce/patterns/coming-soon-entire-site.php +++ b/plugins/woocommerce/patterns/coming-soon-entire-site.php @@ -3,6 +3,7 @@ * Title: Coming Soon Entire Site * Slug: woocommerce/coming-soon-entire-site * Categories: WooCommerce + * Feature Flag: launch-your-store * * @package WooCommerce\Blocks */ diff --git a/plugins/woocommerce/patterns/coming-soon-store-only.php b/plugins/woocommerce/patterns/coming-soon-store-only.php index d09ececf676..ad551d50f06 100644 --- a/plugins/woocommerce/patterns/coming-soon-store-only.php +++ b/plugins/woocommerce/patterns/coming-soon-store-only.php @@ -3,6 +3,7 @@ * Title: Coming Soon Store Only * Slug: woocommerce/coming-soon-store-only * Categories: WooCommerce + * Feature Flag: launch-your-store * * @package WooCommerce\Blocks */ diff --git a/plugins/woocommerce/patterns/coming-soon.php b/plugins/woocommerce/patterns/coming-soon.php index 0693146df9a..e3a15aceb67 100644 --- a/plugins/woocommerce/patterns/coming-soon.php +++ b/plugins/woocommerce/patterns/coming-soon.php @@ -3,6 +3,7 @@ * Title: Coming Soon * Slug: woocommerce/coming-soon * Categories: WooCommerce + * Feature Flag: launch-your-store * * @package WooCommerce\Blocks */ diff --git a/plugins/woocommerce/src/Blocks/BlockPatterns.php b/plugins/woocommerce/src/Blocks/BlockPatterns.php index 6da7870d27e..bc4d225cf73 100644 --- a/plugins/woocommerce/src/Blocks/BlockPatterns.php +++ b/plugins/woocommerce/src/Blocks/BlockPatterns.php @@ -1,6 +1,7 @@ 'Keywords', 'blockTypes' => 'Block Types', 'inserter' => 'Inserter', + 'featureFlag' => 'Feature Flag', ); if ( ! file_exists( $this->patterns_path ) ) { @@ -170,6 +172,10 @@ class BlockPatterns { continue; } + if ( $pattern_data['featureFlag'] && ! Features::is_enabled( $pattern_data['featureFlag'] ) ) { + continue; + } + // Title is a required property. if ( ! $pattern_data['title'] ) { _doing_it_wrong( diff --git a/plugins/woocommerce/src/Blocks/BlockTemplatesRegistry.php b/plugins/woocommerce/src/Blocks/BlockTemplatesRegistry.php index 594de3bc5b5..0985cd5e536 100644 --- a/plugins/woocommerce/src/Blocks/BlockTemplatesRegistry.php +++ b/plugins/woocommerce/src/Blocks/BlockTemplatesRegistry.php @@ -1,6 +1,7 @@ new ProductSearchResultsTemplate(), CartTemplate::SLUG => new CartTemplate(), CheckoutTemplate::SLUG => new CheckoutTemplate(), - ComingSoonTemplate::SLUG => new ComingSoonTemplate(), OrderConfirmationTemplate::SLUG => new OrderConfirmationTemplate(), SingleProductTemplate::SLUG => new SingleProductTemplate(), ); } else { - $templates = array( - ComingSoonTemplate::SLUG => new ComingSoonTemplate(), - ); + $templates = array(); + } + if ( Features::is_enabled( 'launch-your-store' ) ) { + $templates[ ComingSoonTemplate::SLUG ] = new ComingSoonTemplate(); } if ( BlockTemplateUtils::supports_block_templates( 'wp_template_part' ) ) { $template_parts = array( diff --git a/plugins/woocommerce/src/Blocks/Utils/BlockTemplateUtils.php b/plugins/woocommerce/src/Blocks/Utils/BlockTemplateUtils.php index 264fafcdf4f..4bc4474ccbc 100644 --- a/plugins/woocommerce/src/Blocks/Utils/BlockTemplateUtils.php +++ b/plugins/woocommerce/src/Blocks/Utils/BlockTemplateUtils.php @@ -1,6 +1,7 @@