From 18ba63b646f57ac2e9e8e3156e9c6cfaccd66f81 Mon Sep 17 00:00:00 2001 From: Luigi Date: Tue, 28 Feb 2023 11:49:38 +0100 Subject: [PATCH] fix code after merge --- bin/hook-docs/data/filters.json | 6 +++--- .../extensibility/hooks/filters.md | 4 ++-- src/BlockTemplatesController.php | 18 +++--------------- .../AbstractTemplateCompatibility.php | 4 ++-- 4 files changed, 10 insertions(+), 22 deletions(-) diff --git a/bin/hook-docs/data/filters.json b/bin/hook-docs/data/filters.json index 0dc3ce18145..b9edf39f0a8 100644 --- a/bin/hook-docs/data/filters.json +++ b/bin/hook-docs/data/filters.json @@ -739,8 +739,8 @@ "file": "Templates/AbstractTemplateCompatibility.php", "type": "filter", "doc": { - "description": "Filters to disable the compatibility layer for the blockified templates.", - "long_description": "This hooks allows to disable the compatibility layer for the blockified.", + "description": "Filter to disable the compatibility layer for the blockified templates.", + "long_description": "This hook allows to disable the compatibility layer for the blockified.", "tags": [ { "name": "since", @@ -756,7 +756,7 @@ "variable": "" } ], - "long_description_html": "

This hooks allows to disable the compatibility layer for the blockified.

" + "long_description_html": "

This hook allows to disable the compatibility layer for the blockified.

" }, "args": 1 }, diff --git a/docs/third-party-developers/extensibility/hooks/filters.md b/docs/third-party-developers/extensibility/hooks/filters.md index 4774a34a9f9..43d93904d9e 100644 --- a/docs/third-party-developers/extensibility/hooks/filters.md +++ b/docs/third-party-developers/extensibility/hooks/filters.md @@ -582,7 +582,7 @@ apply_filters( 'woocommerce_cart_contents_changed', array $cart_contents ) ## woocommerce_disable_compatibility_layer -Filters to disable the compatibility layer for the blockified templates. +Filter to disable the compatibility layer for the blockified templates. ```php apply_filters( 'woocommerce_disable_compatibility_layer', \Automattic\WooCommerce\Blocks\Templates\boolean. $argument0 ) @@ -590,7 +590,7 @@ apply_filters( 'woocommerce_disable_compatibility_layer', \Automattic\WooCommerc ### Description -

This hooks allows to disable the compatibility layer for the blockified.

+

This hook allows to disable the compatibility layer for the blockified.

### Parameters diff --git a/src/BlockTemplatesController.php b/src/BlockTemplatesController.php index 55c0fae2dbb..0c780f5dbe4 100644 --- a/src/BlockTemplatesController.php +++ b/src/BlockTemplatesController.php @@ -3,7 +3,6 @@ use Automattic\WooCommerce\Blocks\Domain\Package; use Automattic\WooCommerce\Blocks\Templates\ProductAttributeTemplate; -use Automattic\WooCommerce\Blocks\Templates\ProductSearchResultsTemplate; use Automattic\WooCommerce\Blocks\Templates\SingleProductTemplateCompatibility; use Automattic\WooCommerce\Blocks\Utils\BlockTemplateUtils; @@ -326,22 +325,11 @@ function( $template ) { $template->description = BlockTemplateUtils::get_block_template_description( $template->slug ); } - if ( in_array( $template->slug, array( 'archive-product', ProductSearchResultsTemplate::SLUG, ProductAttributeTemplate::SLUG, 'taxonomy-product_cat', 'taxonomy-product_tag' ) ) ) { - - if ( ! is_admin() && BlockTemplateUtils::template_has_legacy_template_block( $template ) ) { - add_filter( 'woocommerce_disable_compatibility_layer', '__return_true' ); - return $template; - } - return $template; - } - if ( 'single-product' === $template->slug ) { - if ( ! is_admin() && BlockTemplateUtils::template_has_legacy_template_block( $template ) ) { - add_filter( 'woocommerce_disable_compatibility_layer', '__return_true' ); - return $template; + if ( ! is_admin() ) { + $new_content = SingleProductTemplateCompatibility::add_compatibility_layer( $template->content ); + $template->content = $new_content; } - $new_content = SingleProductTemplateCompatibility::add_compatibility_layer( $template->content ); - $template->content = $new_content; return $template; } diff --git a/src/Templates/AbstractTemplateCompatibility.php b/src/Templates/AbstractTemplateCompatibility.php index 7e776047945..b0f88a607d7 100644 --- a/src/Templates/AbstractTemplateCompatibility.php +++ b/src/Templates/AbstractTemplateCompatibility.php @@ -55,9 +55,9 @@ function( $parsed_block, $source_block, $parent_block ) { 'render_block', function ( $block_content, $block ) { /** - * Filters to disable the compatibility layer for the blockified templates. + * Filter to disable the compatibility layer for the blockified templates. * - * This hooks allows to disable the compatibility layer for the blockified. + * This hook allows to disable the compatibility layer for the blockified. * * @since TBD * @param boolean.