| 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_None_Of_Operator |
| 11 |
* |
| 12 |
* @package Sellkit\Contact_Segmentation\Conditions |
| 13 |
* @since 1.1.0 |
| 14 |
*/ |
| 15 |
class Is_None_Of extends Operator_Base { |
| 16 |
|
| 17 |
/** |
| 18 |
* Condition name. |
| 19 |
* |
| 20 |
* @since 1.1.0 |
| 21 |
*/ |
| 22 |
public function get_name() { |
| 23 |
return 'is-none-of'; |
| 24 |
} |
| 25 |
|
| 26 |
/** |
| 27 |
* Condition title. |
| 28 |
* |
| 29 |
* @since 1.1.0 |
| 30 |
*/ |
| 31 |
public function get_title() { |
| 32 |
return __( 'is none of', 'sellkit' ); |
| 33 |
} |
| 34 |
|
| 35 |
/** |
| 36 |
* Conditions. |
| 37 |
* |
| 38 |
* @since 1.1.0 |
| 39 |
*/ |
| 40 |
public function get_conditions() { |
| 41 |
return [ |
| 42 |
'user-device', |
| 43 |
'user-role', |
| 44 |
'purchased-product', |
| 45 |
'viewed-category', |
| 46 |
'viewed-product', |
| 47 |
'purchased-category', |
| 48 |
'customer-value', |
| 49 |
'cart-tag', |
| 50 |
'shipping-country', |
| 51 |
'shipping-country-checkout', |
| 52 |
'billing-country', |
| 53 |
'billing-country-checkout', |
| 54 |
'cart-category', |
| 55 |
'cart-item', |
| 56 |
'referral-source-internal-post', |
| 57 |
'referral-source-product-category', |
| 58 |
'referral-source-post-category', |
| 59 |
'visitor-country', |
| 60 |
'visitor-timezone', |
| 61 |
'visitor-currency', |
| 62 |
'visitor-language', |
| 63 |
'customer-value', |
| 64 |
]; |
| 65 |
} |
| 66 |
|
| 67 |
/** |
| 68 |
* Condition title. |
| 69 |
* |
| 70 |
* @since 1.1.0 |
| 71 |
* @param mixed $value mixed The value of current value. |
| 72 |
* @param mixed $condition_value The value of condition input. |
| 73 |
*/ |
| 74 |
public function is_valid( $value, $condition_value ) { |
| 75 |
if ( ! is_array( $value ) ) { |
| 76 |
$value = [ $value ]; |
| 77 |
} |
| 78 |
|
| 79 |
if ( empty( array_intersect( $value, $condition_value ) ) ) { |
| 80 |
return true; |
| 81 |
} |
| 82 |
|
| 83 |
return false; |
| 84 |
} |
| 85 |
} |
| 86 |
|