| 1 |
<?php |
| 2 |
|
| 3 |
namespace Sellkit\Contact_Segmentation\Operators; |
| 4 |
|
| 5 |
use Sellkit\Contact_Segmentation\Operator_Base; |
| 6 |
|
| 7 |
defined( 'ABSPATH' ) || die(); |
| 8 |
|
| 9 |
/** |
| 10 |
* Class Sellkit_Is_Operator |
| 11 |
* |
| 12 |
* @package Sellkit\Contact_Segmentation\Conditions |
| 13 |
* @since 1.1.0 |
| 14 |
*/ |
| 15 |
class Is extends Operator_Base { |
| 16 |
|
| 17 |
/** |
| 18 |
* Condition name. |
| 19 |
* |
| 20 |
* @since 1.1.0 |
| 21 |
*/ |
| 22 |
public function get_name() { |
| 23 |
return 'is'; |
| 24 |
} |
| 25 |
|
| 26 |
/** |
| 27 |
* Condition title. |
| 28 |
* |
| 29 |
* @since 1.1.0 |
| 30 |
*/ |
| 31 |
public function get_title() { |
| 32 |
return __( 'is', 'sellkit' ); |
| 33 |
} |
| 34 |
|
| 35 |
/** |
| 36 |
* Conditions. |
| 37 |
* |
| 38 |
* @since 1.1.0 |
| 39 |
*/ |
| 40 |
public function get_conditions() { |
| 41 |
return [ |
| 42 |
'browser-language', |
| 43 |
'user-type', |
| 44 |
'utm-source', |
| 45 |
'utm-medium', |
| 46 |
'utm-campaign', |
| 47 |
'utm-content', |
| 48 |
'utm-term', |
| 49 |
'referral-source-url', |
| 50 |
'time-deadline', |
| 51 |
'billing-city', |
| 52 |
'billing-city-checkout', |
| 53 |
'shipping-city', |
| 54 |
'shipping-city-checkout', |
| 55 |
'visitor-city', |
| 56 |
'days-of-week', |
| 57 |
'whitin-date-range', |
| 58 |
'whitin-time-period', |
| 59 |
'url-query-string', |
| 60 |
'login-status', |
| 61 |
'cart-item-quantity', |
| 62 |
'purchased-product-quantity', |
| 63 |
]; |
| 64 |
} |
| 65 |
|
| 66 |
/** |
| 67 |
* Condition title. |
| 68 |
* |
| 69 |
* @since 1.1.0 |
| 70 |
* @param mixed $value mixed The value of current value. |
| 71 |
* @param mixed $condition_value The value of condition input. |
| 72 |
*/ |
| 73 |
public function is_valid( $value, $condition_value ) { |
| 74 |
$value = strtolower( $value ); |
| 75 |
$condition_value = strtolower( $condition_value ); |
| 76 |
if ( $value === $condition_value ) { |
| 77 |
return true; |
| 78 |
} |
| 79 |
|
| 80 |
return false; |
| 81 |
} |
| 82 |
} |
| 83 |
|