1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/* |
4
|
|
|
* ACF Email Field Class |
5
|
|
|
* |
6
|
|
|
* All the logic for this field type |
7
|
|
|
* |
8
|
|
|
* @class acf_field_email |
9
|
|
|
* @extends acf_field |
10
|
|
|
* @package ACF |
11
|
|
|
* @subpackage Fields |
12
|
|
|
*/ |
13
|
|
|
|
14
|
|
|
if( ! class_exists('acf_field_email') ) : |
15
|
|
|
|
16
|
|
|
class acf_field_email extends acf_field { |
17
|
|
|
|
18
|
|
|
|
19
|
|
|
/* |
20
|
|
|
* __construct |
21
|
|
|
* |
22
|
|
|
* This function will setup the field type data |
23
|
|
|
* |
24
|
|
|
* @type function |
25
|
|
|
* @date 5/03/2014 |
26
|
|
|
* @since 5.0.0 |
27
|
|
|
* |
28
|
|
|
* @param n/a |
29
|
|
|
* @return n/a |
30
|
|
|
*/ |
|
|
|
|
31
|
|
|
|
32
|
|
View Code Duplication |
function __construct() { |
|
|
|
|
33
|
|
|
|
34
|
|
|
// vars |
35
|
|
|
$this->name = 'email'; |
36
|
|
|
$this->label = __("Email",'acf'); |
|
|
|
|
37
|
|
|
$this->defaults = array( |
38
|
|
|
'default_value' => '', |
39
|
|
|
'placeholder' => '', |
40
|
|
|
'prepend' => '', |
41
|
|
|
'append' => '' |
42
|
|
|
); |
43
|
|
|
|
44
|
|
|
|
45
|
|
|
// do not delete! |
46
|
|
|
parent::__construct(); |
47
|
|
|
} |
48
|
|
|
|
49
|
|
|
|
50
|
|
|
/* |
51
|
|
|
* render_field() |
52
|
|
|
* |
53
|
|
|
* Create the HTML interface for your field |
54
|
|
|
* |
55
|
|
|
* @param $field - an array holding all the field's data |
56
|
|
|
* |
57
|
|
|
* @type action |
58
|
|
|
* @since 3.6 |
59
|
|
|
* @date 23/01/13 |
60
|
|
|
*/ |
61
|
|
|
|
62
|
|
|
function render_field( $field ) { |
|
|
|
|
63
|
|
|
|
64
|
|
|
// vars |
65
|
|
|
$o = array( 'type', 'id', 'class', 'name', 'value', 'placeholder' ); |
66
|
|
|
$e = ''; |
67
|
|
|
|
68
|
|
|
|
69
|
|
|
// prepend |
70
|
|
View Code Duplication |
if( $field['prepend'] !== "" ) { |
|
|
|
|
71
|
|
|
|
72
|
|
|
$field['class'] .= ' acf-is-prepended'; |
73
|
|
|
$e .= '<div class="acf-input-prepend">' . $field['prepend'] . '</div>'; |
74
|
|
|
|
75
|
|
|
} |
76
|
|
|
|
77
|
|
|
|
78
|
|
|
// append |
79
|
|
View Code Duplication |
if( $field['append'] !== "" ) { |
|
|
|
|
80
|
|
|
|
81
|
|
|
$field['class'] .= ' acf-is-appended'; |
82
|
|
|
$e .= '<div class="acf-input-append">' . $field['append'] . '</div>'; |
83
|
|
|
|
84
|
|
|
} |
85
|
|
|
|
86
|
|
|
|
87
|
|
|
// populate atts |
88
|
|
|
$atts = array(); |
89
|
|
|
foreach( $o as $k ) { |
90
|
|
|
|
91
|
|
|
$atts[ $k ] = $field[ $k ]; |
92
|
|
|
|
93
|
|
|
} |
94
|
|
|
|
95
|
|
|
|
96
|
|
|
// render |
97
|
|
|
$e .= '<div class="acf-input-wrap">'; |
98
|
|
|
$e .= '<input ' . acf_esc_attr( $atts ) . ' />'; |
99
|
|
|
$e .= '</div>'; |
100
|
|
|
|
101
|
|
|
|
102
|
|
|
// return |
103
|
|
|
echo $e; |
104
|
|
|
} |
105
|
|
|
|
106
|
|
|
|
107
|
|
|
/* |
108
|
|
|
* render_field_settings() |
109
|
|
|
* |
110
|
|
|
* Create extra options for your field. This is rendered when editing a field. |
111
|
|
|
* The value of $field['name'] can be used (like bellow) to save extra data to the $field |
112
|
|
|
* |
113
|
|
|
* @type action |
114
|
|
|
* @since 3.6 |
115
|
|
|
* @date 23/01/13 |
116
|
|
|
* |
117
|
|
|
* @param $field - an array holding all the field's data |
118
|
|
|
*/ |
119
|
|
|
|
120
|
|
|
function render_field_settings( $field ) { |
|
|
|
|
121
|
|
|
|
122
|
|
|
// default_value |
123
|
|
|
acf_render_field_setting( $field, array( |
124
|
|
|
'label' => __('Default Value','acf'), |
125
|
|
|
'instructions' => __('Appears when creating a new post','acf'), |
126
|
|
|
'type' => 'text', |
127
|
|
|
'name' => 'default_value', |
128
|
|
|
)); |
129
|
|
|
|
130
|
|
|
|
131
|
|
|
// placeholder |
132
|
|
|
acf_render_field_setting( $field, array( |
133
|
|
|
'label' => __('Placeholder Text','acf'), |
134
|
|
|
'instructions' => __('Appears within the input','acf'), |
135
|
|
|
'type' => 'text', |
136
|
|
|
'name' => 'placeholder', |
137
|
|
|
)); |
138
|
|
|
|
139
|
|
|
|
140
|
|
|
// prepend |
141
|
|
|
acf_render_field_setting( $field, array( |
142
|
|
|
'label' => __('Prepend','acf'), |
143
|
|
|
'instructions' => __('Appears before the input','acf'), |
144
|
|
|
'type' => 'text', |
145
|
|
|
'name' => 'prepend', |
146
|
|
|
)); |
147
|
|
|
|
148
|
|
|
|
149
|
|
|
// append |
150
|
|
|
acf_render_field_setting( $field, array( |
151
|
|
|
'label' => __('Append','acf'), |
152
|
|
|
'instructions' => __('Appears after the input','acf'), |
153
|
|
|
'type' => 'text', |
154
|
|
|
'name' => 'append', |
155
|
|
|
)); |
156
|
|
|
|
157
|
|
|
} |
158
|
|
|
|
159
|
|
|
} |
160
|
|
|
|
161
|
|
|
new acf_field_email(); |
162
|
|
|
|
163
|
|
|
endif; |
164
|
|
|
|
165
|
|
|
?> |
|
|
|
|
166
|
|
|
|
This check marks PHPDoc comments that could not be parsed by our parser. To see which comment annotations we can parse, please refer to our documentation on supported doc-types.