| 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 Dates Between. |
| 11 |
* |
| 12 |
* @package Sellkit\Contact_Segmentation\Conditions |
| 13 |
* @since 1.1.0 |
| 14 |
*/ |
| 15 |
class Dates_Between extends Operator_Base { |
| 16 |
|
| 17 |
/** |
| 18 |
* Condition name. |
| 19 |
* |
| 20 |
* @since 1.1.0 |
| 21 |
*/ |
| 22 |
public function get_name() { |
| 23 |
return 'dates-between'; |
| 24 |
} |
| 25 |
|
| 26 |
/** |
| 27 |
* Condition title. |
| 28 |
* |
| 29 |
* @since 1.1.0 |
| 30 |
*/ |
| 31 |
public function get_title() { |
| 32 |
return __( 'dates between', 'sellkit' ); |
| 33 |
} |
| 34 |
|
| 35 |
/** |
| 36 |
* Conditions. |
| 37 |
* |
| 38 |
* @since 1.1.0 |
| 39 |
*/ |
| 40 |
public function get_conditions() { |
| 41 |
return [ |
| 42 |
'first-order-date', |
| 43 |
'last-order-date', |
| 44 |
'signup-date', |
| 45 |
]; |
| 46 |
} |
| 47 |
|
| 48 |
/** |
| 49 |
* Condition title. |
| 50 |
* |
| 51 |
* @since 1.1.0 |
| 52 |
* @param mixed $value mixed The value of current value. |
| 53 |
* @param mixed $condition_value The value of condition input. |
| 54 |
*/ |
| 55 |
public function is_valid( $value, $condition_value ) { |
| 56 |
$start_date = $condition_value['start_date']; |
| 57 |
$end_date = $condition_value['end_date']; |
| 58 |
|
| 59 |
if ( $value > $start_date && $value < $end_date ) { |
| 60 |
return true; |
| 61 |
} |
| 62 |
|
| 63 |
return false; |
| 64 |
} |
| 65 |
} |
| 66 |
|