WC_Brands::hook_product_brand_block()
Hooks the product brand terms block into single product templates.
Метод класса: WC_Brands{}
Хуков нет.
Возвращает
Массив
. The array of hooked block types.
Использование
$WC_Brands = new WC_Brands(); $WC_Brands->hook_product_brand_block( $hooked_block_types, $relative_position, $anchor_block_type, $context );
- $hooked_block_types(массив) (обязательный)
- The array of hooked block types.
- $relative_position(int) (обязательный)
- The relative position of the hooked block.
- $anchor_block_type(строка) (обязательный)
- The type of anchor block.
- $context(WP_Block_Template) (обязательный)
- The context of the block.
Код WC_Brands::hook_product_brand_block() WC Brands::hook product brand block WC 9.8.2
public function hook_product_brand_block( $hooked_block_types, $relative_position, $anchor_block_type, $context ) { // Only add the block as the last child of the product meta block if ( 'woocommerce/product-meta' === $anchor_block_type && 'last_child' === $relative_position && $context instanceof WP_Block_Template && 'single-product' === $context->slug ) { remove_action( 'woocommerce_product_meta_end', array( $this, 'show_brand' ) ); // Check if the template already has a product brand block if ( ! $this->template_already_has_brand_block( $context ) ) { // Simply add the core/post-terms block type $hooked_block_types[] = 'core/post-terms'; } } return $hooked_block_types; }