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

Commit

Permalink
Merge branch 'add/compatibility-single-product-block' of https://gith…
Browse files Browse the repository at this point in the history
…ub.com/woocommerce/woocommerce-blocks into 8505-the-woocommerce-product-grid-block-block-is-not-visible-on-the-front-end-when-the-products-block-is-on-the-same-page
  • Loading branch information
gigitux committed Feb 24, 2023
2 parents 386616f + 34c4aca commit 1d71030
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 65 deletions.
11 changes: 8 additions & 3 deletions bin/hook-docs/data/actions.json
Original file line number Diff line number Diff line change
Expand Up @@ -1056,12 +1056,17 @@
"file": "Templates/AbstractTemplateCompatibility.php",
"type": "action",
"doc": {
"description": "",
"description": "Action to render the content of a hook.",
"long_description": "",
"tags": [],
"tags": [
{
"name": "since",
"content": "9.5.0"
}
],
"long_description_html": ""
},
"args": 0
}
]
}
}
33 changes: 0 additions & 33 deletions bin/hook-docs/data/filters.json
Original file line number Diff line number Diff line change
Expand Up @@ -566,27 +566,6 @@
},
"args": 1
},
{
"name": "woocommerce_blocks_hook_compatibility_additional_data",
"file": "Templates/AbstractTemplateCompatibility.php",
"type": "filter",
"doc": {
"description": "When extensions implement their equivalent blocks of the template hook functions, they can use this filter to register their old hooked data here, so in the blockified template, the old hooked functions can be removed in favor of the new blocks while keeping the old hooked functions working in classic templates.",
"long_description": "Accepts an array of hooked data. The array should be in the following format: [ [ hook => <hook-name>, function => <function-name>, priority => <priority>, ], ... ] Where: - hook-name is the name of the hook that have the functions hooked to. - function-name is the hooked function name. - priority is the priority of the hooked function.",
"tags": [
{
"name": "param",
"content": "Additional hooked data. Default to empty",
"types": [
"array"
],
"variable": "$data"
}
],
"long_description_html": "<p>Accepts an array of hooked data. The array should be in the following format: [ [ hook =&gt; <hook-name>, function =&gt; <function-name>, priority =&gt; <priority>, ], ... ] Where:</p> <ul> <li>hook-name is the name of the hook that have the functions hooked to.</li> <li>function-name is the hooked function name.</li> <li>priority is the priority of the hooked function.</li> </ul>"
},
"args": 1
},
{
"name": "woocommerce_blocks_product_grid_is_cacheable",
"file": "BlockTypes/AbstractProductGrid.php",
Expand Down Expand Up @@ -772,18 +751,6 @@
},
"args": 1
},
{
"name": "woocommerce_disable_compatibility_layer",
"file": "Templates/AbstractTemplateCompatibility.php",
"type": "filter",
"doc": {
"description": "",
"long_description": "",
"tags": [],
"long_description_html": ""
},
"args": 1
},
{
"name": "woocommerce_ga_disable_tracking",
"file": "Domain/Services/GoogleAnalytics.php",
Expand Down
2 changes: 1 addition & 1 deletion docs/third-party-developers/extensibility/hooks/actions.md
Original file line number Diff line number Diff line change
Expand Up @@ -874,7 +874,7 @@ do_action( 'woocommerce_{$product->get_type()}_add_to_cart' )
## {$hook}



Action to render the content of a hook.

```php
do_action( '{$hook}' )
Expand Down
35 changes: 17 additions & 18 deletions docs/third-party-developers/extensibility/hooks/filters.md
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ apply_filters( 'woocommerce_add_cart_item_data', array $cart_item_data, integer
### Returns


`array`
`array`

### Source

Expand Down Expand Up @@ -276,7 +276,7 @@ apply_filters( 'woocommerce_add_to_cart_sold_individually_quantity', integer $so
### Returns


`integer`
`integer`

### Source

Expand Down Expand Up @@ -314,7 +314,7 @@ apply_filters( 'woocommerce_add_to_cart_validation', boolean $passed_validation,
### Returns


`boolean`
`boolean`

### Source

Expand Down Expand Up @@ -348,7 +348,7 @@ apply_filters( 'woocommerce_adjust_non_base_location_prices', boolean $adjust_no
### Returns


`boolean`
`boolean`

### Source

Expand Down Expand Up @@ -396,7 +396,7 @@ apply_filters( 'woocommerce_apply_individual_use_coupon', array $coupons, \WC_Co
### Returns


`array`
`array`

### Source

Expand Down Expand Up @@ -429,7 +429,7 @@ apply_filters( 'woocommerce_apply_with_individual_use_coupon', boolean $apply_wi
### Returns


`boolean`
`boolean`

### Source

Expand Down Expand Up @@ -540,7 +540,7 @@ apply_filters( 'woocommerce_blocks_register_script_dependencies', array $depende
### Returns


`array`
`array`

### Source

Expand Down Expand Up @@ -602,7 +602,6 @@ apply_filters( 'woocommerce_disable_compatibility_layer', \Automattic\WooCommerc


- [Templates/AbstractTemplateCompatibility.php](../../../../src/Templates/AbstractTemplateCompatibility.php)
- [Templates/AbstractTemplateCompatibility.php](../../../../src/Templates/AbstractTemplateCompatibility.php)

---

Expand Down Expand Up @@ -657,7 +656,7 @@ apply_filters( 'woocommerce_get_item_data', array $item_data, array $cart_item )
### Returns


`array`
`array`

### Source

Expand Down Expand Up @@ -726,7 +725,7 @@ apply_filters( 'woocommerce_new_customer_data', array $customer_data )
### Returns


`array`
`array`

### Source

Expand Down Expand Up @@ -762,7 +761,7 @@ apply_filters( 'woocommerce_registration_errors', \WP_Error $errors, string $use
### Returns


`\WP_Error`
`\WP_Error`

### Source

Expand Down Expand Up @@ -796,7 +795,7 @@ apply_filters( 'woocommerce_shared_settings', array $data )
### Returns


`array`
`array`

### Source

Expand Down Expand Up @@ -895,7 +894,7 @@ apply_filters( 'woocommerce_store_api_add_to_cart_data', array $customer_data )
### Returns


`array`
`array`

### Source

Expand Down Expand Up @@ -926,7 +925,7 @@ apply_filters( 'woocommerce_store_api_disable_nonce_check', boolean $disable_non
### Returns


`boolean`
`boolean`

### Source

Expand Down Expand Up @@ -958,7 +957,7 @@ apply_filters( 'woocommerce_store_api_product_quantity_limit', integer $quantity
### Returns


`integer`
`integer`

### Source

Expand Down Expand Up @@ -991,7 +990,7 @@ apply_filters( 'woocommerce_store_api_product_quantity_{$value_type}', mixed $va
### Returns


`mixed`
`mixed`

### Source

Expand All @@ -1018,7 +1017,7 @@ apply_filters( 'woocommerce_store_api_rate_limit_options', array $rate_limit_opt
### Returns


`array`
`array`

### Source

Expand Down Expand Up @@ -1055,7 +1054,7 @@ apply_filters( 'woocommerce_variation_option_name', string $value, null $unused,
### Returns


`string`
`string`

### Source

Expand Down
24 changes: 14 additions & 10 deletions src/Templates/AbstractTemplateCompatibility.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,7 @@ abstract class AbstractTemplateCompatibility {
* Initialization method.
*/
public function init() {
/**
* Filters to disable the compatibility layer for the blockified templates.
*
* This hooks allows to disable the compatibility layer for the blockified.
*
* @param boolean.
*/
$is_disabled_compatility_layer = apply_filters( 'woocommerce_disable_compatibility_layer', false );

if ( ! wc_current_theme_is_fse_theme() || $is_disabled_compatility_layer ) {
if ( ! wc_current_theme_is_fse_theme() ) {
return;
}

Expand All @@ -40,6 +31,14 @@ public function init() {
add_filter(
'render_block',
function ( $block_content, $block ) {
/**
* Filters to disable the compatibility layer for the blockified templates.
*
* This hooks allows to disable the compatibility layer for the blockified.
*
* @since 9.7.0
* @param boolean.
*/
$is_disabled_compatility_layer = apply_filters( 'woocommerce_disable_compatibility_layer', false );

if ( $is_disabled_compatility_layer ) {
Expand Down Expand Up @@ -166,6 +165,11 @@ protected function get_hooks_buffer( $hooks, $position ) {
ob_start();
foreach ( $hooks as $hook => $data ) {
if ( $data['position'] === $position ) {
/**
* Action to render the content of a hook.
*
* @since 9.5.0
*/
do_action( $hook );
}
}
Expand Down

0 comments on commit 1d71030

Please sign in to comment.