1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace EventEspresso\core\services\form\meta\inputs; |
4
|
|
|
|
5
|
|
|
class DateTime |
6
|
|
|
{ |
7
|
|
|
|
8
|
|
|
/** |
9
|
|
|
* indicates that the HTML input type is 'date' |
10
|
|
|
*/ |
11
|
|
|
public const TYPE_DATE = 'date'; |
12
|
|
|
|
13
|
|
|
/** |
14
|
|
|
* indicates that the HTML input type is 'datetime-local' |
15
|
|
|
*/ |
16
|
|
|
public const TYPE_DATETIME_LOCAL = 'datetime-local'; |
17
|
|
|
|
18
|
|
|
/** |
19
|
|
|
* indicates that the HTML input type is 'month' |
20
|
|
|
*/ |
21
|
|
|
public const TYPE_MONTH = 'month'; |
22
|
|
|
|
23
|
|
|
/** |
24
|
|
|
* indicates that the HTML input type is 'time' |
25
|
|
|
*/ |
26
|
|
|
public const TYPE_TIME = 'time'; |
27
|
|
|
|
28
|
|
|
/** |
29
|
|
|
* indicates that the HTML input type is 'week' |
30
|
|
|
*/ |
31
|
|
|
public const TYPE_WEEK = 'week'; |
32
|
|
|
|
33
|
|
|
// CUSTOM EE DATE TYPES |
34
|
|
|
|
35
|
|
|
/** |
36
|
|
|
* indicates that the input is an HTML dropdown used for selecting the day for a date |
37
|
|
|
*/ |
38
|
|
|
public const TYPE_SELECT_DAY = 'day-select'; |
39
|
|
|
|
40
|
|
|
/** |
41
|
|
|
* indicates that the input is an HTML dropdown used for selecting the month for a date |
42
|
|
|
*/ |
43
|
|
|
public const TYPE_SELECT_MONTH = 'month-select'; |
44
|
|
|
|
45
|
|
|
/** |
46
|
|
|
* indicates that the input is an HTML dropdown used for selecting the year for a date |
47
|
|
|
*/ |
48
|
|
|
public const TYPE_SELECT_YEAR = 'year-select'; |
49
|
|
|
|
50
|
|
|
|
51
|
|
|
/** |
52
|
|
|
* @var array |
53
|
|
|
*/ |
54
|
|
|
private $valid_type_options; |
55
|
|
|
|
56
|
|
|
|
57
|
|
|
public function __construct() |
58
|
|
|
{ |
59
|
|
|
$this->valid_type_options = apply_filters( |
60
|
|
|
'FHEE__EventEspresso_core_services_form_meta_inputs_DateTime__valid_type_options', |
61
|
|
|
[ |
62
|
|
|
DateTime::TYPE_DATE => esc_html__('Date Picker', 'event_espresso'), |
63
|
|
|
DateTime::TYPE_DATETIME_LOCAL => esc_html__('Local Date Picker', 'event_espresso'), |
64
|
|
|
DateTime::TYPE_MONTH => esc_html__('Month Picker', 'event_espresso'), |
65
|
|
|
DateTime::TYPE_TIME => esc_html__('Time Picker', 'event_espresso'), |
66
|
|
|
DateTime::TYPE_WEEK => esc_html__('Week Picker', 'event_espresso'), |
67
|
|
|
DateTime::TYPE_SELECT_DAY => esc_html__('Day Selector', 'event_espresso'), |
68
|
|
|
DateTime::TYPE_SELECT_MONTH => esc_html__('Month Selector', 'event_espresso'), |
69
|
|
|
DateTime::TYPE_SELECT_YEAR => esc_html__('Year Selector', 'event_espresso'), |
70
|
|
|
] |
71
|
|
|
); |
72
|
|
|
} |
73
|
|
|
|
74
|
|
|
|
75
|
|
|
/** |
76
|
|
|
* @param bool $constants_only |
77
|
|
|
* @return array |
78
|
|
|
*/ |
79
|
|
|
public function validTypeOptions(bool $constants_only = false): array |
80
|
|
|
{ |
81
|
|
|
return $constants_only |
82
|
|
|
? array_keys($this->valid_type_options) |
83
|
|
|
: $this->valid_type_options; |
84
|
|
|
} |
85
|
|
|
} |
86
|
|
|
|