PluginProbe ʕ •ᴥ•ʔ
Everest Forms – Contact Form, Payment Form, Quiz, Survey & Custom Form Builder with AI / 3.5.2
Everest Forms – Contact Form, Payment Form, Quiz, Survey & Custom Form Builder with AI v3.5.2
3.5.2 3.5.1 3.5.0 3.4.8 3.4.7 3.4.6 1.1.0 1.1.1 1.1.2 1.1.3 1.1.4 1.1.5 1.1.5.1 1.1.6 1.1.7 1.1.8 1.1.9 1.2.0 1.2.1 1.2.2 1.2.3 1.2.4 1.3.0 1.3.1 1.3.2 1.3.3 1.3.4 1.4.0 1.4.1 1.4.2 1.4.3 1.4.4 1.4.5 1.4.6 1.4.7 1.4.8 1.4.9 1.5.0 1.5.1 1.5.10 1.5.2 1.5.3 1.5.4 1.5.5 1.5.6 1.5.7 1.5.8 1.5.9 1.6.0 1.6.1 1.6.2 1.6.3 1.6.4 1.6.5 1.6.6 1.6.6.1 1.6.7 1.7.0 1.7.0.1 1.7.0.2 1.7.0.3 1.7.1 1.7.2 1.7.2.1 1.7.2.2 1.7.3 1.7.4 1.7.5 1.7.5.1 1.7.5.2 1.7.6 1.7.7 1.7.7.1 1.7.7.2 1.7.8 1.7.9 1.8.0 1.8.0.1 1.8.1 1.8.2 1.8.2.1 1.8.2.2 1.8.2.3 1.8.3 1.8.4 1.8.5 1.8.6 1.8.7 1.8.8 1.8.9 1.9.0 1.9.0.1 1.9.1 1.9.2 1.9.3 1.9.4 1.9.4.1 1.9.5 1.9.6 1.9.7 1.9.8 1.9.9 2.0.0 2.0.0.1 2.0.1 2.0.2 2.0.3 2.0.3.1 2.0.4 2.0.4.1 2.0.5 2.0.6 2.0.7 2.0.8 2.0.8.1 2.0.9 3.0.0 3.0.0.1 3.0.1 3.0.2 3.0.3 3.0.3.1 3.0.4 3.0.4.1 3.0.4.2 3.0.5 3.0.5.1 3.0.5.2 3.0.6 3.0.6.1 3.0.7.1 3.0.8 3.0.8.1 3.0.9 3.0.9.1 3.0.9.2 3.0.9.3 3.0.9.4 3.0.9.5 3.1.0 3.1.1 3.1.2 3.2.0 3.2.1 3.2.2 3.2.3 3.2.4 3.2.5 3.2.6 3.3.0 3.4.0 3.4.1 3.4.2 3.4.2.1 3.4.3 3.4.4 3.4.5 trunk 1.0 1.0.1 1.0.2 1.0.3
everest-forms / includes / fields / class-evf-field-phone.php
everest-forms / includes / fields Last commit date
class-evf-field-address.php 1 year ago class-evf-field-ai.php 1 year ago class-evf-field-captcha.php 1 month ago class-evf-field-checkbox.php 3 months ago class-evf-field-color.php 1 month ago class-evf-field-country.php 3 months ago class-evf-field-credit-card.php 1 month ago class-evf-field-date-time.php 1 month ago class-evf-field-divider.php 2 years ago class-evf-field-email.php 1 year ago class-evf-field-file-upload.php 1 year ago class-evf-field-first-name.php 1 year ago class-evf-field-hcaptcha.php 4 months ago class-evf-field-hidden.php 1 year ago class-evf-field-html.php 9 months ago class-evf-field-image-upload.php 1 year ago class-evf-field-last-name.php 1 year ago class-evf-field-likert.php 1 year ago class-evf-field-lookup.php 1 month ago class-evf-field-number.php 1 year ago class-evf-field-password.php 1 month ago class-evf-field-payment-authorize-net.php 1 month ago class-evf-field-payment-checkbox.php 1 month ago class-evf-field-payment-coupon.php 1 month ago class-evf-field-payment-gateway-selector.php 1 month ago class-evf-field-payment-quantity.php 1 month ago class-evf-field-payment-radio.php 1 month ago class-evf-field-payment-single.php 1 month ago class-evf-field-payment-square.php 1 year ago class-evf-field-payment-subscription-plan.php 1 month ago class-evf-field-payment-subtotal.php 1 month ago class-evf-field-payment-total.php 1 month ago class-evf-field-phone.php 1 year ago class-evf-field-privacy-policy.php 3 months ago class-evf-field-private-note.php 1 year ago class-evf-field-progress.php 1 month ago class-evf-field-radio.php 3 months ago class-evf-field-range-slider.php 1 month ago class-evf-field-rating.php 3 months ago class-evf-field-recaptcha.php 4 months ago class-evf-field-repeater.php 1 month ago class-evf-field-reset.php 1 month ago class-evf-field-scale-rating.php 1 year ago class-evf-field-select.php 1 year ago class-evf-field-signature.php 1 month ago class-evf-field-text.php 1 year ago class-evf-field-textarea.php 1 year ago class-evf-field-title.php 2 years ago class-evf-field-turnstile.php 4 months ago class-evf-field-url.php 1 year ago class-evf-field-wysiwyg.php 3 months ago class-evf-field-yes-no.php 1 year ago payment-amount-helpers.php 1 month ago
class-evf-field-phone.php
232 lines
1 <?php
2 /**
3 * Phone number field
4 *
5 * @package EverestForms\Fields
6 * @since 3.0.0
7 */
8
9 defined( 'ABSPATH' ) || exit;
10
11 /**
12 * EVF_Field_Phone Class.
13 */
14 class EVF_Field_Phone extends EVF_Form_Fields {
15
16 /**
17 * Constructor.
18 */
19 public function __construct() {
20 $this->name = esc_html__( 'Phone', 'everest-forms' );
21 $this->type = 'phone';
22 $this->icon = 'evf-icon evf-icon-phone';
23 $this->order = 60;
24 $this->group = 'advanced';
25 $this->settings = array(
26 'basic-options' => array(
27 'field_options' => array(
28 'label',
29 'choose_format',
30 'description',
31 'input_mask',
32 'required',
33 'required_field_message_setting',
34 'required_field_message',
35 ),
36 ),
37 'advanced-options' => array(
38 'field_options' => array(
39 'placeholder',
40 'meta',
41 'label_hide',
42 'default_value',
43 'css',
44 ),
45 ),
46 );
47
48 parent::__construct();
49 }
50
51 /**
52 * Hook in tabs.
53 */
54 public function init_hooks() {
55 add_filter( 'everest_forms_field_properties_' . $this->type, array( $this, 'field_properties' ), 5, 3 );
56 }
57
58 /**
59 * Date field format option.
60 *
61 * @since 1.2.9
62 * @param array $field Field Data.
63 */
64 public function choose_format( $field ) {
65 $format = ! empty( $field['phone_format'] ) ? esc_attr( $field['phone_format'] ) : 'smart';
66 $format_label = $this->field_element(
67 'label',
68 $field,
69 array(
70 'slug' => 'phone_format',
71 'value' => __( 'Format', 'everest-forms' ),
72 'tooltip' => __( 'Select a format for the phone field.', 'everest-forms' ),
73 ),
74 false
75 );
76 $format_select = $this->field_element(
77 'select',
78 $field,
79 array(
80 'slug' => 'phone_format',
81 'value' => $format,
82 'options' => array(
83 'default' => __( 'Default', 'everest-forms' ),
84 'smart' => __( 'Smart', 'everest-forms' ),
85 ),
86 ),
87 false
88 );
89 $args = array(
90 'slug' => 'phone_format',
91 'content' => $format_label . $format_select,
92 );
93 $this->field_element( 'row', $field, $args );
94 }
95
96 /**
97 * Input mask field option.
98 *
99 * @param array $field Field Data.
100 */
101 public function input_mask( $field ) {
102 $format = ! empty( $field['phone_format'] ) ? esc_attr( $field['phone_format'] ) : 'smart';
103
104 // Input Mask.
105 $input_mask_label = $this->field_element(
106 'label',
107 $field,
108 array(
109 'slug' => 'input_mask',
110 'value' => esc_html__( 'Input Mask', 'everest-forms' ),
111 'tooltip' => esc_html__( 'Enter your custom input mask.', 'everest-forms' ),
112 'after_tooltip' => '<a href="https://docs.everestforms.net/docs/how-to-use-custom-input-mask/" class="after-label-description" target="_blank" rel="noopener noreferrer">' . esc_html__( 'See Examples & Docs', 'everest-forms' ) . '</a>',
113 ),
114 false
115 );
116 $input_mask_field = $this->field_element(
117 'text',
118 $field,
119 array(
120 'slug' => 'input_mask',
121 'value' => ! empty( $field['input_mask'] ) ? esc_attr( $field['input_mask'] ) : '(999) 999-9999',
122 ),
123 false
124 );
125
126 echo '<div class="format-selected-' . esc_attr( $format ) . ' format-selected">';
127
128 $this->field_element(
129 'row',
130 $field,
131 array(
132 'slug' => 'input_mask',
133 'content' => $input_mask_label . $input_mask_field,
134 )
135 );
136
137 echo '</div>';
138 }
139
140 /**
141 * Define additional field properties.
142 *
143 * @since 1.0.0
144 *
145 * @param array $properties Field properties.
146 * @param array $field Field settings.
147 * @param array $form_data Form data and settings.
148 *
149 * @return array of additional field properties.
150 */
151 public function field_properties( $properties, $field, $form_data ) {
152 // Input primary: add validation rule and class for smart phone field.
153 if ( ! empty( $field['phone_format'] ) && 'smart' === $field['phone_format'] ) {
154 $properties['inputs']['primary']['class'][] = 'evf-smart-phone-field';
155 $properties['inputs']['primary']['data']['rule-smart-phone-field'] = 'true';
156 } else {
157 $properties['inputs']['primary']['data']['rule-phone-field'] = 'true';
158
159 if ( ! empty( $field['input_mask'] ) ) {
160 // Add class that will trigger custom mask.
161 $properties['inputs']['primary']['class'][] = 'evf-masked-input';
162
163 // Register string for translation.
164 $field['input_mask'] = evf_string_translation( $form_data['id'], $field['id'], $field['input_mask'], '-input-mask' );
165
166 if ( false !== strpos( $field['input_mask'], 'alias:' ) ) {
167 $mask = str_replace( 'alias:', '', $field['input_mask'] );
168 $properties['inputs']['primary']['data']['inputmask-alias'] = $mask;
169 } elseif ( false !== strpos( $field['input_mask'], 'regex:' ) ) {
170 $mask = str_replace( 'regex:', '', $field['input_mask'] );
171 $properties['inputs']['primary']['data']['inputmask-regex'] = $mask;
172 } else {
173 $properties['inputs']['primary']['data']['inputmask-mask'] = $field['input_mask'];
174 }
175
176 // Input primary: RTL support for input masks.
177 if ( is_rtl() ) {
178 $properties['inputs']['primary']['attr']['dir'] = 'rtl';
179 }
180 }
181 }
182
183 return $properties;
184 }
185
186 /**
187 * Field preview inside the builder.
188 *
189 * @since 1.0.0
190 *
191 * @param array $field Field data and settings.
192 */
193 public function field_preview( $field ) {
194
195 // Define data.
196 $placeholder = ! empty( $field['placeholder'] ) ? esc_attr( $field['placeholder'] ) : '';
197
198 // Label.
199 $this->field_preview_option( 'label', $field );
200
201 // Primary input.
202 echo '<input type="text" placeholder="' . esc_attr( $placeholder ) . '" class="widefat primary-input" disabled>';
203
204 // Description.
205 $this->field_preview_option( 'description', $field );
206 }
207
208 /**
209 * Field display on the form front-end.
210 *
211 * @since 1.0.0
212 *
213 * @param array $field Field Data.
214 * @param array $field_atts Field attributes.
215 * @param array $form_data All Form Data.
216 */
217 public function field_display( $field, $field_atts, $form_data ) {
218 // Define data.
219 $primary = $field['properties']['inputs']['primary'];
220
221 // Allow input type to be changed for this particular field.
222 $type = apply_filters( 'everest_forms_phone_field_input_type', 'tel' );
223 // Primary field.
224 printf(
225 '<input type="%s" %s %s>',
226 esc_attr( $type ),
227 evf_html_attributes( $primary['id'], $primary['class'], $primary['data'], $primary['attr'] ),
228 esc_attr( $primary['required'] )
229 );
230 }
231 }
232