Automattic\WooCommerce\Blocks\BlockTypes
SingleProduct::extract_single_product_inner_block_names()
Extract the inner block names for the Single Product block. This way it's possible to map all the inner blocks for a Single Product block and manipulate the data as needed.
Method of the class: SingleProduct{}
No Hooks.
Return
Array
. Array containing all the inner block names of a Single Product block.
Usage
// protected - for code of main (parent) or child class $result = $this->extract_single_product_inner_block_names( $block, $result );
- $block(array) (required)
- The Single Product block or its inner blocks.
- $result(array) (passed by reference — &)
- Array of inner block names.
Default: []
SingleProduct::extract_single_product_inner_block_names() SingleProduct::extract single product inner block names code WC 9.4.2
protected function extract_single_product_inner_block_names( $block, &$result = [] ) { if ( isset( $block['blockName'] ) ) { $result[] = $block['blockName']; } if ( isset( $block['innerBlocks'] ) ) { foreach ( $block['innerBlocks'] as $inner_block ) { $this->extract_single_product_inner_block_names( $inner_block, $result ); } } return $result; }