Automattic\WooCommerce\Blocks\BlockTypes
FeaturedItem::extract_featured_item_inner_block_names
Extract the inner block names for the Featured Item block. This way it's possible to map all the inner blocks for a Featured Item block and manipulate the data as needed.
Метод класса: FeaturedItem{}
Хуков нет.
Возвращает
Массив. Array containing all the inner block names of a Featured Item block.
Использование
// protected - в коде основоного (родительского) или дочернего класса $result = $this->extract_featured_item_inner_block_names( $block, $result );
- $block(массив) (обязательный)
- The Featured Item block or its inner blocks.
- $result(массив) (передается по ссылке — &)
- Array of inner block names.
По умолчанию:[]
Код FeaturedItem::extract_featured_item_inner_block_names() FeaturedItem::extract featured item inner block names WC 11.0.1
protected function extract_featured_item_inner_block_names( $block, &$result = [] ) {
if ( isset( $block['blockName'] ) ) {
$result[] = $block['blockName'];
}
if ( 'woocommerce/product-template' === $block['blockName'] || 'core/post-template' === $block['blockName'] ) {
return $result;
}
if ( isset( $block['innerBlocks'] ) ) {
foreach ( $block['innerBlocks'] as $inner_block ) {
$this->extract_featured_item_inner_block_names( $inner_block, $result );
}
}
return $result;
}