Skip to Content


Compare values using passed parameters.

PHP June 23, 2017


nebula()->compare_operator($a, $b, $c)


(Required) (Integer) The first value
Default: None

(Required) (Integer) The second value
Default: None

(Optional) (String) The comparison operator
Default: ==

Parameter Notes

Possible comparison operators include:

  • Equal: “=”, “==”, “e”
  • Greater than or Equal to: “>=”, “=>”, “gte”, “ge”
  • Less than or Equal to: “<=”, “=<“, “lte”, “le”
  • Greater than: “>”, “gt”
  • Less than: “<“, “lt”

Request or provide clarification »

Source File

Located in /libs/Utilities/Utilities.php on line 1021.

1 Hook

Find these filters and actions in the source code below to hook into them. Use do_action() and add_filter() in your functions file or plugin.

Need a new filter hook? Request one here.

This function has no action hooks available. Request one?

        public function compare_operator($a=null, $b=null, $c='=='){
            $override = apply_filters('pre_nebula_compare_operator', null, $a, $b, $c);
            if ( isset($override) ){return $override;}

            if ( empty($a) || empty($b) ){
                trigger_error('nebula_compare_operator requires values to compare.');
                return false;

            switch ( $c ){
                case "=":
                case "==":
                case "===":
                case "e":
                    return $a === $b;
                case ">=":
                case "=>":
                case "gte":
                case "ge":
                    return $a >= $b;
                case "<=":
                case "=<":
                case "lte":
                case "le":
                    return $a <= $b;
                case ">":
                case "gt":
                    return $a > $b;
                case "<":
                case "lt":
                    return $a < $b;
                    trigger_error('nebula_compare_operator does not allow "' . $c . '".');
                    return false;


To override this PHP function, use this hook in your child theme or plugin ("my_custom" can be changed):

add_filter('pre_nebula_compare_operator', 'my_custom_compare_operator', 10, 4); //The last integer must be 1 more than the actual parameters
function my_custom_compare_operator($null, $a, $b, $c){ //$null is required, but can be ignored
    //Write your own code here

    return true; //Return true to prevent the original function from running afterwords

You can completely disable this PHP function with a single line actions:

 add_filter('pre_nebula_compare_operator', '__return_false');