Automattic\WooCommerce\Blocks\Templates
SingleProductTemplateCompatibility::has_single_product_template_blocks()
Check if the Single Product template has a single product template block: woocommerce/product-gallery-image, woocommerce/product-details, woocommerce/add-to-cart-form]
Метод класса: SingleProductTemplateCompatibility{}
Хуков нет.
Возвращает
true|false
. True if the template has a single product template block, false otherwise.
Использование
$result = SingleProductTemplateCompatibility::has_single_product_template_blocks( $parsed_blocks, $single_product_template_blocks );
- $parsed_blocks(массив) (обязательный)
- Array of parsed block objects.
- $single_product_template_blocks(массив) (обязательный)
- Array of single product template blocks.
Код SingleProductTemplateCompatibility::has_single_product_template_blocks() SingleProductTemplateCompatibility::has single product template blocks WC 7.7.2
private static function has_single_product_template_blocks( $parsed_blocks, $single_product_template_blocks ) { $found = false; foreach ( $parsed_blocks as $block ) { if ( isset( $block['blockName'] ) && in_array( $block['blockName'], $single_product_template_blocks, true ) ) { $found = true; break; } $found = self::has_single_product_template_blocks( $block['innerBlocks'], $single_product_template_blocks ); if ( $found ) { break; } } return $found; }