1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace EventEspresso\core\services\form\meta\inputs; |
4
|
|
|
|
5
|
|
|
class Select |
6
|
|
|
{ |
7
|
|
|
|
8
|
|
|
/** |
9
|
|
|
* indicates that the input is an HTML dropdown (select input) that accepts only one value |
10
|
|
|
*/ |
11
|
|
|
public const TYPE_SELECT = 'select'; |
12
|
|
|
|
13
|
|
|
/** |
14
|
|
|
* indicates that the input is an HTML dropdown (select input) that accepts multiple values |
15
|
|
|
*/ |
16
|
|
|
public const TYPE_SELECT_MULTI = 'select-multi'; |
17
|
|
|
|
18
|
|
|
// CUSTOM EE SELECT TYPES |
19
|
|
|
|
20
|
|
|
/** |
21
|
|
|
* indicates that input is an HTML dropdown (select input) |
22
|
|
|
* populated with names of countries that are enabled for the site |
23
|
|
|
*/ |
24
|
|
|
public const TYPE_SELECT_COUNTRY = 'select-country'; |
25
|
|
|
|
26
|
|
|
/** |
27
|
|
|
* indicates that the input is an HTML dropdown (select input) |
28
|
|
|
* populated with names of states for the countries that are enabled for the site |
29
|
|
|
*/ |
30
|
|
|
public const TYPE_SELECT_STATE = 'select-state'; |
31
|
|
|
|
32
|
|
|
|
33
|
|
|
/** |
34
|
|
|
* @var array |
35
|
|
|
*/ |
36
|
|
|
private $valid_type_options; |
37
|
|
|
|
38
|
|
|
|
39
|
|
|
public function __construct() |
40
|
|
|
{ |
41
|
|
|
$this->valid_type_options = apply_filters( |
42
|
|
|
'FHEE__EventEspresso_core_services_form_meta_inputs_Select__valid_type_options', |
43
|
|
|
[ |
44
|
|
|
Select::TYPE_SELECT => esc_html__('Dropdown', 'event_espresso'), |
45
|
|
|
Select::TYPE_SELECT_MULTI => esc_html__('Multi-Select Dropdown', 'event_espresso'), |
46
|
|
|
Select::TYPE_SELECT_COUNTRY => esc_html__('Country Selector', 'event_espresso'), |
47
|
|
|
Select::TYPE_SELECT_STATE => esc_html__('State Selector', 'event_espresso'), |
48
|
|
|
] |
49
|
|
|
); |
50
|
|
|
} |
51
|
|
|
|
52
|
|
|
|
53
|
|
|
/** |
54
|
|
|
* @param bool $constants_only |
55
|
|
|
* @return array |
56
|
|
|
*/ |
57
|
|
|
public function validTypeOptions(bool $constants_only = false): array |
58
|
|
|
{ |
59
|
|
|
return $constants_only |
60
|
|
|
? array_keys($this->valid_type_options) |
61
|
|
|
: $this->valid_type_options; |
62
|
|
|
} |
63
|
|
|
} |
64
|
|
|
|