PluginProbe
Advanced Custom Fields (ACF®) / 4.4.12
Advanced Custom Fields (ACF®) v4.4.12
6.8.9 6.8.8 6.8.7 6.8.6 6.8.5 6.8.4 6.8.3 6.8.2 6.8.1 5.8.5 5.8.6 5.8.7 5.8.8 5.8.9 5.9.0 5.9.1 5.9.2 5.9.3 5.9.4 5.9.5 5.9.6 5.9.7 5.9.8 5.9.9 6.0.0 All 230 releases
advanced-custom-fields / core / fields / email.php
email.php
173 lines 3.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 class acf_field_email extends acf_field
4 {
5
6 /*
7 * __construct
8 *
9 * Set name / label needed for actions / filters
10 *
11 * @since 3.6
12 * @date 23/01/13
13 */
14
15 function __construct()
16 {
17 // vars
18 $this->name = 'email';
19 $this->label = __("Email",'acf');
20 $this->defaults = array(
21 'default_value' => '',
22 'placeholder' => '',
23 'prepend' => '',
24 'append' => ''
25 );
26
27
28 // do not delete!
29 parent::__construct();
30 }
31
32
33 /*
34 * create_field()
35 *
36 * Create the HTML interface for your field
37 *
38 * @param $field - an array holding all the field's data
39 *
40 * @type action
41 * @since 3.6
42 * @date 23/01/13
43 */
44
45 function create_field( $field )
46 {
47 // vars
48 $o = array( 'id', 'class', 'name', 'value', 'placeholder' );
49 $e = '';
50
51
52 // prepend
53 if( $field['prepend'] !== "" )
54 {
55 $field['class'] .= ' acf-is-prepended';
56 $e .= '<div class="acf-input-prepend">' . $field['prepend'] . '</div>';
57 }
58
59
60 // append
61 if( $field['append'] !== "" )
62 {
63 $field['class'] .= ' acf-is-appended';
64 $e .= '<div class="acf-input-append">' . $field['append'] . '</div>';
65 }
66
67
68 $e .= '<div class="acf-input-wrap">';
69 $e .= '<input type="email"';
70
71 foreach( $o as $k )
72 {
73 $e .= ' ' . $k . '="' . esc_attr( $field[ $k ] ) . '"';
74 }
75
76 $e .= ' />';
77 $e .= '</div>';
78
79
80 // return
81 echo $e;
82 }
83
84
85 /*
86 * create_options()
87 *
88 * Create extra options for your field. This is rendered when editing a field.
89 * The value of $field['name'] can be used (like bellow) to save extra data to the $field
90 *
91 * @type action
92 * @since 3.6
93 * @date 23/01/13
94 *
95 * @param $field - an array holding all the field's data
96 */
97
98 function create_options( $field )
99 {
100 // vars
101 $key = $field['name'];
102
103 ?>
104 <tr class="field_option field_option_<?php echo $this->name; ?>">
105 <td class="label">
106 <label><?php _e("Default Value",'acf'); ?></label>
107 <p><?php _e("Appears when creating a new post",'acf') ?></p>
108 </td>
109 <td>
110 <?php
111
112 do_action('acf/create_field', array(
113 'type' => 'text',
114 'name' => 'fields['.$key.'][default_value]',
115 'value' => $field['default_value'],
116 ));
117
118 ?>
119 </td>
120 </tr>
121 <tr class="field_option field_option_<?php echo $this->name; ?>">
122 <td class="label">
123 <label><?php _e("Placeholder Text",'acf'); ?></label>
124 <p><?php _e("Appears within the input",'acf') ?></p>
125 </td>
126 <td>
127 <?php
128 do_action('acf/create_field', array(
129 'type' => 'text',
130 'name' => 'fields[' .$key.'][placeholder]',
131 'value' => $field['placeholder'],
132 ));
133 ?>
134 </td>
135 </tr>
136 <tr class="field_option field_option_<?php echo $this->name; ?>">
137 <td class="label">
138 <label><?php _e("Prepend",'acf'); ?></label>
139 <p><?php _e("Appears before the input",'acf') ?></p>
140 </td>
141 <td>
142 <?php
143 do_action('acf/create_field', array(
144 'type' => 'text',
145 'name' => 'fields[' .$key.'][prepend]',
146 'value' => $field['prepend'],
147 ));
148 ?>
149 </td>
150 </tr>
151 <tr class="field_option field_option_<?php echo $this->name; ?>">
152 <td class="label">
153 <label><?php _e("Append",'acf'); ?></label>
154 <p><?php _e("Appears after the input",'acf') ?></p>
155 </td>
156 <td>
157 <?php
158 do_action('acf/create_field', array(
159 'type' => 'text',
160 'name' => 'fields[' .$key.'][append]',
161 'value' => $field['append'],
162 ));
163 ?>
164 </td>
165 </tr>
166 <?php
167 }
168
169 }
170
171 new acf_field_email();
172
173 ?>