Gocodebox_Banner_Notifier::notification_check_option_helper( mixed $option_value, string $check_type, mixed $check_value )
Helper function to check if a value is greater than, less than, greater than or equal to, or less than or equal to another value.
Parameters Parameters
- $option_value
-
(mixed) (Required) The option value to compare.
- $check_type
-
(string) (Required) The comparison operator.
- $check_value
-
(mixed) (Required) The value to compare against.
Return Return
(bool) True if the comparison is true, false otherwise.
Source Source
File: libraries/banner-notifications/src/notifications.php
function notification_check_option_helper( $option_value, $check_type, $check_value ) {
// If the option value is an array, check each element individually and return true if any of them match.
if ( is_array( $option_value ) || is_object( $option_value ) ) {
foreach ( $option_value as $value ) {
if ( $this->notification_check_option_helper( $value, $check_type, $check_value ) ) {
return true;
}
}
return false;
}
// We have a single value to compare. Let's do it.
switch ( $check_type ) {
case '=':
case '==':
return $option_value == $check_value;
case '!=':
return $option_value != $check_value;
case '>':
case '<':
case '>=':
case '<=':
return pmpro_int_compare( $option_value, $check_value, $check_type );
case 'contains':
// Only proceed if $option_value is a string
return is_string( $option_value ) && strpos( $option_value, $check_value ) !== false;
case 'notcontains':
// If $option_value is not a string and it doesn't contain $check_value, return true.
return ! ( is_string( $option_value ) && strpos( $option_value, $check_value ) !== false );
case 'empty':
return empty( $option_value );
case 'notempty':
return ! empty( $option_value );
default:
return false;
}
}
Expand full source code Collapse full source code View on GitHub
Changelog Changelog
| Version | Description |
|---|---|
| 1.0.1 | Introduced. |