Automattic\WooCommerce\Blocks\BlockTypes
CustomerAccount::should_unhook_block
Callback for the Block Hooks API to determine if the block should be auto-inserted.
Method of the class: CustomerAccount{}
No Hooks.
Returns
Array.
Usage
// protected - for code of main (parent) or child class $result = $this->should_unhook_block( $hooked_blocks, $position, $anchor_block, $context );
- $hooked_blocks(array) (required)
- An array of block slugs hooked into a given context.
- $position(string) (required)
- Position of the block insertion point.
- $anchor_block(string) (required)
- The block acting as the anchor for the inserted block.
- $context(array|\WP_Post|\WP_Block_Template) (required)
- Where the block is embedded.
CustomerAccount::should_unhook_block() CustomerAccount::should unhook block code WC 10.8.1
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;
}