Filter
uncanny-automator
automator_option_less_or_greater_than
Filters the comparison operator for automator options, allowing you to change less than or greater than.
add_filter( 'automator_option_less_or_greater_than', $callback, 10, 1 );
Description
Filters the available operator options for "less than" or "greater than" comparisons in Uncanny Automator recipes. Developers can add, remove, or modify these options to customize comparison logic for specific recipe triggers or actions. This hook runs when generating the dropdown for numerical or date comparisons.
Usage
add_filter( 'automator_option_less_or_greater_than', 'your_function_name', 10, 1 );
Return Value
The filtered value.
Examples
/**
* Example custom function to modify the operators available for "less than" or "greater than" comparisons.
* This function adds a "not equal to" operator to the available options.
*
* @param array $operators The original array of comparison operators.
*
* @return array The modified array of comparison operators.
*/
add_filter(
'automator_option_less_or_greater_than',
function ( $operators ) {
// Add a 'not equal to' operator to the list.
$operators['!='] = esc_attr__( 'not equal to', 'uncanny-automator' );
return $operators;
},
10, // Priority
1 // Accepted arguments
);
Placement
This code should be placed in the functions.php file of your active theme, a custom plugin, or using a code snippets plugin.
Source Code
src/core/lib/helpers/class-automator-recipe-helpers.php:761
public function less_or_greater_than() {
$option = array(
'option_code' => 'NUMBERCOND',
/* translators: Noun */
'label' => esc_attr__( 'Condition', 'uncanny-automator' ),
'input_type' => 'select',
'required' => true,
'options' => array(
'=' => esc_attr__( 'equal to', 'uncanny-automator' ),
'!=' => esc_attr__( 'not equal to', 'uncanny-automator' ),
'<' => esc_attr__( 'less than', 'uncanny-automator' ),
'>' => esc_attr__( 'greater than', 'uncanny-automator' ),
'>=' => esc_attr__( 'greater or equal to', 'uncanny-automator' ),
'<=' => esc_attr__( 'less or equal to', 'uncanny-automator' ),
),
);
$option = apply_filters_deprecated( 'uap_option_less_or_greater_than', array( $option ), '3.0', 'automator_option_less_or_greater_than' );
return apply_filters( 'automator_option_less_or_greater_than', $option );
}