Skip to content
This repository has been archived by the owner on Feb 23, 2024. It is now read-only.

Commit

Permalink
fix code after merge
Browse files Browse the repository at this point in the history
  • Loading branch information
gigitux committed Feb 28, 2023
1 parent e77431c commit 18ba63b
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 22 deletions.
6 changes: 3 additions & 3 deletions bin/hook-docs/data/filters.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -756,7 +756,7 @@
"variable": ""
}
],
"long_description_html": "<p>This hooks allows to disable the compatibility layer for the blockified.</p>"
"long_description_html": "<p>This hook allows to disable the compatibility layer for the blockified.</p>"
},
"args": 1
},
Expand Down
4 changes: 2 additions & 2 deletions docs/third-party-developers/extensibility/hooks/filters.md
Original file line number Diff line number Diff line change
Expand Up @@ -582,15 +582,15 @@ 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 )
```

### Description

<p>This hooks allows to disable the compatibility layer for the blockified.</p>
<p>This hook allows to disable the compatibility layer for the blockified.</p>

### Parameters

Expand Down
18 changes: 3 additions & 15 deletions src/BlockTemplatesController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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;
}

Expand Down
4 changes: 2 additions & 2 deletions src/Templates/AbstractTemplateCompatibility.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit 18ba63b

Please sign in to comment.