Restricting Condition & Features

People managing WordPress sites have requested hiding certain conditions and functionality from Conditional Blocks UI. It’s now possible to exclude parts from the interface.

Excluding Conditions Types in the UI

You can find the specific condition types by turning on the Developer Mode within the Condition Builder. Then the specific conditions to your block, you’ll see the Condition “type” listed in the Developer Mode section.

The below snippet will exclude the Query Strings & Date Range condition. Place them with your own.


/**
 * Exclude condition types from rendering in the Conditional Builder.
 * 
 * Note: Blocks that that have an excluded condition applied will continue as normal
 *
 * @param array $excluded_condition_types
 * @return array
 */
function custom_excluded_condition_types( $excluded_condition_types ) {
	$excluded_condition_types[] = 'queryStrings';
	$excluded_condition_types[] = 'dateRange';
	return $excluded_condition_types;
}
add_filter( 'conditional_blocks_excluded_condition_types', 'custom_excluded_condition_types', 10, 1 );
Code language: PHP (php)

Exclude Entire Condition Categories

/**
 * Exclude whole categories from rendering in the Conditional Builder.
 * 
 * Note: Blocks that that have an excluded category applied will continue as normal
 *
 * @param array $excluded_categories
 * @return array
 */
function custom_excluded_categories( $excluded_categories ) {
	$excluded_categories[] = 'advanced';
	$excluded_categories[] = 'geolocation';
	return $excluded_categories;
}
add_filter( 'conditional_blocks_excluded_categories', 'custom_excluded_categories', 10, 1 );
Code language: PHP (php)
Was this page helpful?