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
This commit is contained in:
Ilyas Foo 2024-04-24 17:44:35 +08:00 committed by GitHub
parent 70f49bb389
commit 27e4b07074
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
7 changed files with 25 additions and 6 deletions

View File

@ -0,0 +1,4 @@
Significance: minor
Type: update
Add feature flag check for patterns and wrap coming soon template and patterns under feature flag

View File

@ -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
*/

View File

@ -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
*/

View File

@ -3,6 +3,7 @@
* Title: Coming Soon
* Slug: woocommerce/coming-soon
* Categories: WooCommerce
* Feature Flag: launch-your-store
*
* @package WooCommerce\Blocks
*/

View File

@ -1,6 +1,7 @@
<?php
namespace Automattic\WooCommerce\Blocks;
use Automattic\WooCommerce\Admin\Features\Features;
use Automattic\WooCommerce\Blocks\AI\Connection;
use Automattic\WooCommerce\Blocks\Images\Pexels;
use Automattic\WooCommerce\Blocks\Domain\Package;
@ -119,6 +120,7 @@ class BlockPatterns {
'keywords' => '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(

View File

@ -1,6 +1,7 @@
<?php
namespace Automattic\WooCommerce\Blocks;
use Automattic\WooCommerce\Admin\Features\Features;
use Automattic\WooCommerce\Blocks\Utils\BlockTemplateUtils;
use Automattic\WooCommerce\Blocks\Templates\AbstractTemplate;
use Automattic\WooCommerce\Blocks\Templates\AbstractTemplatePart;
@ -46,14 +47,14 @@ class BlockTemplatesRegistry {
ProductSearchResultsTemplate::SLUG => 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(

View File

@ -1,6 +1,7 @@
<?php
namespace Automattic\WooCommerce\Blocks\Utils;
use Automattic\WooCommerce\Admin\Features\Features;
use Automattic\WooCommerce\Blocks\Options;
use Automattic\WooCommerce\Blocks\Package;
use Automattic\WooCommerce\Blocks\BlockTemplatesRegistry;
@ -296,9 +297,8 @@ class BlockTemplateUtils {
* @return array $path_list A list of paths to all template part files.
*/
public static function get_template_paths( $template_type ) {
$wp_template_filenames = array(
$wp_template_filenames = array(
'archive-product.html',
'coming-soon.html',
'order-confirmation.html',
'page-cart.html',
'page-checkout.html',
@ -308,6 +308,11 @@ class BlockTemplateUtils {
'taxonomy-product_cat.html',
'taxonomy-product_tag.html',
);
if ( Features::is_enabled( 'launch-your-store' ) ) {
$wp_template_filenames[] = 'coming-soon.html';
}
$wp_template_part_filenames = array(
'checkout-header.html',
'mini-cart.html',