1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace EventEspresso\core\services\form\meta\inputs; |
4
|
|
|
|
5
|
|
|
class Text |
6
|
|
|
{ |
7
|
|
|
/** |
8
|
|
|
* indicates that the HTML input type is 'email' |
9
|
|
|
*/ |
10
|
|
|
public const TYPE_EMAIL = 'email'; |
11
|
|
|
|
12
|
|
|
/** |
13
|
|
|
* indicates that the input is used to confirm an email address |
14
|
|
|
*/ |
15
|
|
|
public const TYPE_EMAIL_CONFIRM = 'email-confirmation'; |
16
|
|
|
|
17
|
|
|
/** |
18
|
|
|
* indicates that the HTML input type is 'text' |
19
|
|
|
*/ |
20
|
|
|
public const TYPE_TEXT = 'text'; |
21
|
|
|
|
22
|
|
|
/** |
23
|
|
|
* indicates that the input is a TEXTAREA that only allows plain text |
24
|
|
|
*/ |
25
|
|
|
public const TYPE_TEXTAREA = 'textarea'; |
26
|
|
|
|
27
|
|
|
/** |
28
|
|
|
* indicates that the input is a TEXTAREA that allows simple html |
29
|
|
|
*/ |
30
|
|
|
public const TYPE_TEXTAREA_HTML = 'textarea-html'; |
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_Text__valid_type_options', |
43
|
|
|
[ |
44
|
|
|
Text::TYPE_EMAIL => esc_html__('Email', 'event_espresso'), |
45
|
|
|
Text::TYPE_EMAIL_CONFIRM => esc_html__('Email Confirmation', 'event_espresso'), |
46
|
|
|
Text::TYPE_TEXT => esc_html__('Plain Text', 'event_espresso'), |
47
|
|
|
Text::TYPE_TEXTAREA => esc_html__('Plain Textarea', 'event_espresso'), |
48
|
|
|
Text::TYPE_TEXTAREA_HTML => esc_html__('Simple HTML Textarea', 'event_espresso'), |
49
|
|
|
] |
50
|
|
|
); |
51
|
|
|
} |
52
|
|
|
|
53
|
|
|
|
54
|
|
|
/** |
55
|
|
|
* @param bool $constants_only |
56
|
|
|
* @return array |
57
|
|
|
*/ |
58
|
|
|
public function validTypeOptions(bool $constants_only = false): array |
59
|
|
|
{ |
60
|
|
|
return $constants_only |
61
|
|
|
? array_keys($this->valid_type_options) |
62
|
|
|
: $this->valid_type_options; |
63
|
|
|
} |
64
|
|
|
} |
65
|
|
|
|