Automattic\WooCommerce\Internal\Admin\BlockTemplates
AbstractBlock::add_hide_condition
Add a hide condition to the block.
The hide condition is a JavaScript-like expression that will be evaluated on the client to determine if the block should be hidden. See @woocommerce/expression-evaluation for more details.
Method of the class: AbstractBlock{}
No Hooks.
Returns
null. Nothing (null).
Usage
$AbstractBlock = new AbstractBlock(); $AbstractBlock->add_hide_condition( $expression ): string;
- $expression(string) (required)
- An expression, which if true, will hide the block.
AbstractBlock::add_hide_condition() AbstractBlock::add hide condition code WC 10.9.4
public function add_hide_condition( string $expression ): string {
$key = 'k' . $this->hide_conditions_counter;
$this->hide_conditions_counter++;
// Storing the expression in an array to allow for future expansion
// (such as adding the plugin that added the condition).
$this->hide_conditions[ $key ] = array(
'expression' => $expression,
);
/**
* Action called after a hide condition is added to a block.
*
* @param BlockInterface $block The block.
*
* @since 8.4.0
* @deprecated 10.9.0 This hook will be removed in WooCommerce 11.0.
*/
wc_do_deprecated_action(
'woocommerce_block_template_after_add_hide_condition',
array( $this ),
'10.9.0',
null,
'This block template hook will be removed in WooCommerce 11.0.'
);
return $key;
}