Automattic\WooCommerce\Blocks\BlockTypes
CustomerAccount::should_unhook_block
Callback for the Block Hooks API to determine if the block should be auto-inserted.
Метод класса: CustomerAccount{}
Хуков нет.
Возвращает
Массив
.
Использование
// protected - в коде основоного (родительского) или дочернего класса $result = $this->should_unhook_block( $hooked_blocks, $position, $anchor_block, $context );
- $hooked_blocks(массив) (обязательный)
- An array of block slugs hooked into a given context.
- $position(строка) (обязательный)
- Position of the block insertion point.
- $anchor_block(строка) (обязательный)
- The block acting as the anchor for the inserted block.
- $context(массив|\WP_Post|\WP_Block_Template) (обязательный)
- Where the block is embedded.
Код CustomerAccount::should_unhook_block() CustomerAccount::should unhook block WC 9.9.4
protected function should_unhook_block( $hooked_blocks, $position, $anchor_block, $context ) { $block_name = $this->namespace . '/' . $this->block_name; $block_is_hooked = in_array( $block_name, $hooked_blocks, true ); if ( $block_is_hooked ) { $active_theme = wp_get_theme()->get( 'Name' ); $exclude_themes = array( 'Twenty Twenty-Two', 'Twenty Twenty-Three' ); if ( in_array( $active_theme, $exclude_themes, true ) ) { $key = array_search( $block_name, $hooked_blocks, true ); unset( $hooked_blocks[ $key ] ); } } return $hooked_blocks; }