PluginProbe ʕ •ᴥ•ʔ
Secure Custom Fields / 6.9.1
Secure Custom Fields v6.9.1
6.9.1 6.9.0 6.8.9 6.8.7 6.8.8 6.8.6 6.8.4 6.8.5 trunk 6.4.0-beta1 6.4.0-beta2 6.4.1 6.4.1-beta3 6.4.1-beta4 6.4.1-beta5 6.4.1-beta6 6.4.1-beta7 6.4.2 6.5.0 6.5.1 6.5.2 6.5.3 6.5.4 6.5.5 6.5.6 6.5.7 6.6.0 6.7.0 6.7.1 6.8.0 6.8.1 6.8.2 6.8.3
secure-custom-fields / includes / fields / class-acf-field-email.php
secure-custom-fields / includes / fields Last commit date
FlexibleContent 2 months ago class-acf-field-accordion.php 2 months ago class-acf-field-button-group.php 2 months ago class-acf-field-checkbox.php 2 days ago class-acf-field-clone.php 2 months ago class-acf-field-color_picker.php 2 months ago class-acf-field-date_picker.php 2 months ago class-acf-field-date_time_picker.php 2 months ago class-acf-field-email.php 2 months ago class-acf-field-file.php 2 months ago class-acf-field-flexible-content.php 1 week ago class-acf-field-gallery.php 3 weeks ago class-acf-field-google-map.php 2 months ago class-acf-field-group.php 2 months ago class-acf-field-icon_picker.php 7 months ago class-acf-field-image.php 2 months ago class-acf-field-link.php 2 months ago class-acf-field-message.php 1 year ago class-acf-field-nav-menu.php 1 week ago class-acf-field-number.php 2 months ago class-acf-field-oembed.php 3 weeks ago class-acf-field-output.php 1 year ago class-acf-field-page_link.php 3 weeks ago class-acf-field-password.php 2 months ago class-acf-field-post_object.php 3 weeks ago class-acf-field-radio.php 2 days ago class-acf-field-range.php 2 months ago class-acf-field-relationship.php 3 weeks ago class-acf-field-repeater.php 3 weeks ago class-acf-field-select.php 2 days ago class-acf-field-separator.php 1 year ago class-acf-field-tab.php 1 year ago class-acf-field-taxonomy.php 3 weeks ago class-acf-field-text.php 3 weeks ago class-acf-field-textarea.php 3 weeks ago class-acf-field-time_picker.php 2 months ago class-acf-field-true_false.php 2 months ago class-acf-field-url.php 3 weeks ago class-acf-field-user.php 3 weeks ago class-acf-field-wysiwyg.php 2 months ago class-acf-field.php 2 months ago class-acf-repeater-table.php 1 year ago index.php 1 year ago
class-acf-field-email.php
204 lines
1 <?php
2
3 if ( ! class_exists( 'acf_field_email' ) ) :
4
5 class acf_field_email extends acf_field {
6
7
8
9 /**
10 * This function will setup the field type data
11 *
12 * @type function
13 * @date 5/03/2014
14 * @since ACF 5.0.0
15 *
16 * @param n/a
17 * @return n/a
18 */
19 function initialize() {
20
21 // vars
22 $this->name = 'email';
23 $this->label = __( 'Email', 'secure-custom-fields' );
24 $this->description = __( 'A text input specifically designed for storing email addresses.', 'secure-custom-fields' );
25 $this->preview_image = acf_get_url() . '/assets/images/field-type-previews/field-preview-email.png';
26 $this->doc_url = 'https://developer.wordpress.org/secure-custom-fields/features/fields/email/';
27 $this->tutorial_url = 'https://developer.wordpress.org/secure-custom-fields/features/fields/email/email-tutorial/';
28 $this->defaults = array(
29 'default_value' => '',
30 'placeholder' => '',
31 'prepend' => '',
32 'append' => '',
33 );
34 }
35
36
37 /**
38 * Create the HTML interface for your field
39 *
40 * @param $field - an array holding all the field's data
41 *
42 * @type action
43 * @since ACF 3.6
44 * @date 23/01/13
45 */
46 function render_field( $field ) {
47
48 // vars
49 $atts = array();
50 $keys = array( 'type', 'id', 'class', 'name', 'value', 'placeholder', 'pattern' );
51 $keys2 = array( 'readonly', 'disabled', 'required', 'multiple' );
52 $html = '';
53
54 // prepend
55 if ( $field['prepend'] !== '' ) {
56 $field['class'] .= ' acf-is-prepended';
57 $html .= '<div class="acf-input-prepend">' . acf_esc_html( $field['prepend'] ) . '</div>';
58 }
59
60 // append
61 if ( $field['append'] !== '' ) {
62 $field['class'] .= ' acf-is-appended';
63 $html .= '<div class="acf-input-append">' . acf_esc_html( $field['append'] ) . '</div>';
64 }
65
66 // atts (value="123")
67 foreach ( $keys as $k ) {
68 if ( isset( $field[ $k ] ) ) {
69 $atts[ $k ] = $field[ $k ];
70 }
71 }
72
73 // atts2 (disabled="disabled")
74 foreach ( $keys2 as $k ) {
75 if ( ! empty( $field[ $k ] ) ) {
76 $atts[ $k ] = $k;
77 }
78 }
79
80 // remove empty atts
81 $atts = acf_clean_atts( $atts );
82
83 // render
84 $html .= '<div class="acf-input-wrap">' . acf_get_text_input( $atts ) . '</div>';
85
86 // return
87 echo $html; //phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- safe HTML escaped by acf_get_text_input
88 }
89
90
91 /**
92 * Create extra options for your field. This is rendered when editing a field.
93 * The value of $field['name'] can be used (like bellow) to save extra data to the $field
94 *
95 * @type action
96 * @since ACF 3.6
97 * @date 23/01/13
98 *
99 * @param $field - an array holding all the field's data
100 */
101 function render_field_settings( $field ) {
102 acf_render_field_setting(
103 $field,
104 array(
105 'label' => __( 'Default Value', 'secure-custom-fields' ),
106 'instructions' => __( 'Appears when creating a new post', 'secure-custom-fields' ),
107 'type' => 'text',
108 'name' => 'default_value',
109 )
110 );
111 }
112
113 /**
114 * Renders the field settings used in the "Presentation" tab.
115 *
116 * @since ACF 6.0
117 *
118 * @param array $field The field settings array.
119 * @return void
120 */
121 function render_field_presentation_settings( $field ) {
122 acf_render_field_setting(
123 $field,
124 array(
125 'label' => __( 'Placeholder Text', 'secure-custom-fields' ),
126 'instructions' => __( 'Appears within the input', 'secure-custom-fields' ),
127 'type' => 'text',
128 'name' => 'placeholder',
129 )
130 );
131
132 acf_render_field_setting(
133 $field,
134 array(
135 'label' => __( 'Prepend', 'secure-custom-fields' ),
136 'instructions' => __( 'Appears before the input', 'secure-custom-fields' ),
137 'type' => 'text',
138 'name' => 'prepend',
139 )
140 );
141
142 acf_render_field_setting(
143 $field,
144 array(
145 'label' => __( 'Append', 'secure-custom-fields' ),
146 'instructions' => __( 'Appears after the input', 'secure-custom-fields' ),
147 'type' => 'text',
148 'name' => 'append',
149 )
150 );
151 }
152
153 /**
154 * Validate the email value. If this method returns TRUE, the input value is valid. If
155 * FALSE or a string is returned, the input value is invalid and the user is shown a
156 * notice. If a string is returned, the string is show as the message text.
157 *
158 * @param boolean $valid Whether the value is valid.
159 * @param mixed $value The field value.
160 * @param array $field The field array.
161 * @param string $input The request variable name for the inbound field.
162 * @return boolean|string
163 */
164 public function validate_value( $valid, $value, $field, $input ) {
165 $flags = defined( 'FILTER_FLAG_EMAIL_UNICODE' ) ? FILTER_FLAG_EMAIL_UNICODE : 0;
166
167 if ( $value && filter_var( wp_unslash( $value ), FILTER_VALIDATE_EMAIL, $flags ) === false ) {
168 /* translators: %s: form field value */
169 return sprintf( __( "'%s' is not a valid email address", 'secure-custom-fields' ), esc_html( $value ) );
170 }
171
172 return $valid;
173 }
174
175 /**
176 * Return the schema array for the REST API.
177 *
178 * @param array $field
179 * @return array
180 */
181 public function get_rest_schema( array $field ) {
182 $schema = parent::get_rest_schema( $field );
183 $schema['format'] = 'email';
184
185 return $schema;
186 }
187
188 /**
189 * Returns an array of JSON-LD Property output types that are supported by this field type.
190 *
191 * @since 6.8
192 *
193 * @return string[]
194 */
195 public function get_jsonld_output_types(): array {
196 return array( 'Text' );
197 }
198 }
199
200
201 // initialize
202 acf_register_field_type( 'acf_field_email' );
203 endif; // class_exists check
204