PluginProbe ʕ •ᴥ•ʔ
Everest Forms – Contact Form, Payment Form, Quiz, Survey & Custom Form Builder with AI / 3.0.5
Everest Forms – Contact Form, Payment Form, Quiz, Survey & Custom Form Builder with AI v3.0.5
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 / admin / evf-admin-functions.php
everest-forms / includes / admin Last commit date
builder 1 year ago form-migrator 2 years ago plugin-updates 8 years ago settings 1 year ago views 1 year ago class-evf-admin-addons.php 2 years ago class-evf-admin-assets.php 1 year ago class-evf-admin-builder.php 8 years ago class-evf-admin-dashboard.php 2 years ago class-evf-admin-deactivation-feedback.php 3 years ago class-evf-admin-editor.php 4 years ago class-evf-admin-embed-wizard.php 2 years ago class-evf-admin-entries-table-list.php 2 years ago class-evf-admin-entries.php 2 years ago class-evf-admin-form-templates.php 1 year ago class-evf-admin-forms-table-list.php 2 years ago class-evf-admin-forms.php 2 years ago class-evf-admin-import-export.php 4 years ago class-evf-admin-menus.php 2 years ago class-evf-admin-notices.php 1 year ago class-evf-admin-preview-confirmation.php 1 year ago class-evf-admin-settings.php 1 year ago class-evf-admin-tools.php 2 years ago class-evf-admin-welcome.php 2 years ago class-evf-admin.php 2 years ago evf-admin-functions.php 1 year ago
evf-admin-functions.php
575 lines
1 <?php
2 /**
3 * EverestForms Admin Functions
4 *
5 * @package EverestForms/Admin/Functions
6 * @version 1.0.0
7 */
8
9 defined( 'ABSPATH' ) || exit;
10
11 /**
12 * Get all EverestForms screen ids.
13 *
14 * @return array
15 */
16 function evf_get_screen_ids() {
17 $evf_screen_id = sanitize_title( esc_html__( 'Everest Forms', 'everest-forms' ) );
18 $screen_ids = array(
19 'toplevel_page_' . $evf_screen_id,
20 $evf_screen_id . '_page_evf-dashboard',
21 $evf_screen_id . '_page_evf-builder',
22 $evf_screen_id . '_page_evf-entries',
23 $evf_screen_id . '_page_evf-settings',
24 $evf_screen_id . '_page_evf-tools',
25 $evf_screen_id . '_page_evf-addons',
26 $evf_screen_id . '_page_evf-email-templates',
27 );
28
29 return apply_filters( 'everest_forms_screen_ids', $screen_ids );
30 }
31
32 /**
33 * Create a page and store the ID in an option.
34 *
35 * @param mixed $slug Slug for the new page.
36 * @param string $option Option name to store the page's ID.
37 * @param string $page_title (default: '') Title for the new page.
38 * @param string $page_content (default: '') Content for the new page.
39 * @param int $post_parent (default: 0) Parent for the new page.
40 *
41 * @return int page ID
42 */
43 function evf_create_page( $slug, $option = '', $page_title = '', $page_content = '', $post_parent = 0 ) {
44 global $wpdb;
45
46 $option_value = get_option( $option );
47 $page_object = get_post( $option_value );
48
49 if ( $option_value > 0 && $page_object ) {
50 if ( 'page' === $page_object->post_type && ! in_array(
51 $page_object->post_status,
52 array(
53 'pending',
54 'trash',
55 'future',
56 'auto-draft',
57 ),
58 true
59 ) ) {
60 // Valid page is already in place.
61 return $page_object->ID;
62 }
63 }
64
65 if ( strlen( $page_content ) > 0 ) {
66 // Search for an existing page with the specified page content (typically a shortcode).
67 $valid_page_found = $wpdb->get_var( $wpdb->prepare( "SELECT ID FROM $wpdb->posts WHERE post_type='page' AND post_status NOT IN ( 'pending', 'trash', 'future', 'auto-draft' ) AND post_content LIKE %s LIMIT 1;", "%{$page_content}%" ) );
68 } else {
69 // Search for an existing page with the specified page slug.
70 $valid_page_found = $wpdb->get_var( $wpdb->prepare( "SELECT ID FROM $wpdb->posts WHERE post_type='page' AND post_status NOT IN ( 'pending', 'trash', 'future', 'auto-draft' ) AND post_name = %s LIMIT 1;", $slug ) );
71 }
72
73 $valid_page_found = apply_filters( 'everest_forms_create_page_id', $valid_page_found, $slug, $page_content );
74
75 if ( $valid_page_found ) {
76 if ( $option ) {
77 update_option( $option, $valid_page_found );
78 }
79
80 return $valid_page_found;
81 }
82
83 // Search for a matching valid trashed page.
84 if ( strlen( $page_content ) > 0 ) {
85 // Search for an existing page with the specified page content (typically a shortcode).
86 $trashed_page_found = $wpdb->get_var( $wpdb->prepare( "SELECT ID FROM $wpdb->posts WHERE post_type='page' AND post_status = 'trash' AND post_content LIKE %s LIMIT 1;", "%{$page_content}%" ) );
87 } else {
88 // Search for an existing page with the specified page slug.
89 $trashed_page_found = $wpdb->get_var( $wpdb->prepare( "SELECT ID FROM $wpdb->posts WHERE post_type='page' AND post_status = 'trash' AND post_name = %s LIMIT 1;", $slug ) );
90 }
91
92 if ( $trashed_page_found ) {
93 $page_id = $trashed_page_found;
94 $page_data = array(
95 'ID' => $page_id,
96 'post_status' => 'publish',
97 );
98 wp_update_post( $page_data );
99 } else {
100 $page_data = array(
101 'post_status' => 'publish',
102 'post_type' => 'page',
103 'post_author' => 1,
104 'post_name' => $slug,
105 'post_title' => $page_title,
106 'post_content' => $page_content,
107 'post_parent' => $post_parent,
108 'comment_status' => 'closed',
109 );
110 $page_id = wp_insert_post( $page_data );
111 }
112
113 if ( $option ) {
114 update_option( $option, $page_id );
115 }
116
117 return $page_id;
118 }
119
120 /**
121 * Output admin fields.
122 *
123 * Loops though the EverestFormsoptions array and outputs each field.
124 *
125 * @param array[] $options Opens array to output.
126 */
127 function everest_forms_admin_fields( $options ) {
128 if ( ! class_exists( 'EVF_Admin_Settings', false ) ) {
129 include __DIR__ . '/class-evf-admin-settings.php';
130 }
131
132 EVF_Admin_Settings::output_fields( $options );
133 }
134
135 /**
136 * Update all settings which are passed.
137 *
138 * @param array $options Options array to output.
139 * @param array $data Optional. Data to use for saving. Defaults to $_POST.
140 */
141 function everest_forms_update_options( $options, $data = null ) {
142 if ( ! class_exists( 'EVF_Admin_Settings', false ) ) {
143 include __DIR__ . '/class-evf-admin-settings.php';
144 }
145
146 EVF_Admin_Settings::save_fields( $options, $data );
147 }
148
149 /**
150 * Get a setting from the settings API.
151 *
152 * @param string $option_name Option name.
153 * @param mixed $default Default value.
154 *
155 * @return string
156 */
157 function everest_forms_settings_get_option( $option_name, $default = '' ) {
158 if ( ! class_exists( 'EVF_Admin_Settings', false ) ) {
159 include __DIR__ . '/class-evf-admin-settings.php';
160 }
161
162 return EVF_Admin_Settings::get_option( $option_name, $default );
163 }
164
165 /**
166 * Outputs fields to be used on panels (settings etc).
167 *
168 * @param string $option Option.
169 * @param string $panel Panel.
170 * @param string $field Field.
171 * @param array $form_data Form data.
172 * @param string $label Label.
173 * @param array $args Arguments.
174 * @param boolean $echo True to echo else return.
175 *
176 * @return string
177 */
178 function everest_forms_panel_field( $option, $panel, $field, $form_data, $label, $args = array(), $echo = true ) {
179 // Required params.
180 if ( empty( $option ) || empty( $panel ) || empty( $field ) ) {
181 return '';
182 }
183 // Setup basic vars.
184 $panel = esc_attr( $panel );
185 $field = esc_attr( $field );
186 $panel_id = sanitize_html_class( $panel );
187 $parent = ! empty( $args['parent'] ) ? esc_attr( $args['parent'] ) : '';
188 $subsection = ! empty( $args['subsection'] ) ? esc_attr( $args['subsection'] ) : '';
189 $label = ! empty( $label ) ? $label : '';
190 $class = ! empty( $args['class'] ) ? esc_attr( $args['class'] ) : '';
191 $input_class = ! empty( $args['input_class'] ) ? esc_attr( $args['input_class'] ) : '';
192 $default = isset( $args['default'] ) ? $args['default'] : '';
193 $tinymce = isset( $args['tinymce'] ) ? $args['tinymce'] : '';
194 $placeholder = ! empty( $args['placeholder'] ) ? esc_attr( $args['placeholder'] ) : '';
195 $min_value = ! empty( $args['min_value'] ) ? esc_attr( $args['min_value'] ) : '';
196 $data_attr = '';
197 $output = '';
198
199 // Check if we should store values in a parent array.
200 if ( ! empty( $parent ) ) {
201 if ( ! empty( $subsection ) ) {
202 $field_name = sprintf( '%s[%s][%s][%s]', $parent, $panel, $subsection, $field );
203 $value = isset( $form_data[ $parent ][ $panel ][ $subsection ][ $field ] ) ? $form_data[ $parent ][ $panel ][ $subsection ][ $field ] : $default;
204 $panel_id = sanitize_html_class( $panel . '-' . $subsection );
205 } else {
206 $field_name = sprintf( '%s[%s][%s]', $parent, $panel, $field );
207 $value = isset( $form_data[ $parent ][ $panel ][ $field ] ) ? $form_data[ $parent ][ $panel ][ $field ] : $default;
208 }
209 } else {
210
211 $field_name = sprintf( '%s[%s]', $panel, $field );
212 $value = isset( $form_data[ $panel ][ $field ] ) ? $form_data[ $panel ][ $field ] : $default;
213 }
214
215 // Check for data attributes.
216 if ( ! empty( $args['data'] ) ) {
217 foreach ( $args['data'] as $key => $val ) {
218 if ( is_array( $val ) ) {
219 $val = wp_json_encode( $val );
220 }
221 $data_attr .= ' data-' . $key . '=\'' . $val . '\'';
222 }
223 }
224
225 // Check for the custom attributes.
226 $custom_attributes = '';
227 if ( ! empty( $args['custom_attributes'] ) ) {
228 foreach ( $args['custom_attributes'] as $attribute => $attribute_value ) {
229 if ( is_array( $attribute_value ) ) {
230 $attribute_value = wp_json_encode( $attribute_value );
231 }
232 $custom_attributes .= ' ' . $attribute . '=\'' . $attribute_value . '\'';
233 }
234 }
235
236 // Determine what field type to output.
237 switch ( $option ) {
238
239 // Text input.
240 case 'number':
241 case 'text':
242 $output = sprintf(
243 '<input type="%s" id="everest-forms-panel-field-%s-%s" name="%s" value="%s" placeholder="%s" min=%d class="widefat %s" %s %s>',
244 $option,
245 sanitize_html_class( $panel_id ),
246 sanitize_html_class( $field ),
247 $field_name,
248 esc_attr( $value ),
249 $placeholder,
250 $min_value,
251 $input_class,
252 $data_attr,
253 $custom_attributes
254 );
255 break;
256
257 // Textarea.
258 case 'textarea':
259 $rows = ! empty( $args['rows'] ) ? (int) $args['rows'] : '3';
260 $output = sprintf(
261 '<textarea id="everest-forms-panel-field-%s-%s" name="%s" rows="%d" placeholder="%s" class="widefat %s" %s>%s</textarea>',
262 sanitize_html_class( $panel_id ),
263 sanitize_html_class( $field ),
264 $field_name,
265 $rows,
266 $placeholder,
267 $input_class,
268 $data_attr,
269 esc_textarea( $value )
270 );
271 break;
272
273 // TinyMCE.
274 case 'tinymce':
275 $arguments = wp_parse_args(
276 $tinymce,
277 array(
278 'media_buttons' => false,
279 'tinymce' => false,
280 )
281 );
282 $arguments['textarea_name'] = $field_name;
283 $arguments['teeny'] = true;
284 $id = 'everest-forms-panel-field-' . sanitize_html_class( $panel_id ) . '-' . sanitize_html_class( $field );
285 $id = str_replace( '-', '_', $id );
286 ob_start();
287 wp_editor( $value, $id, $arguments );
288 $output = ob_get_clean();
289 break;
290
291 // Checkbox.
292 case 'checkbox':
293 $checked = checked( '1', $value, false );
294 $checkbox = sprintf(
295 '<input type="hidden" name="%s" value="0" class="widefat %s" %s %s>',
296 $field_name,
297 $input_class,
298 $checked,
299 $data_attr
300 );
301 $checkbox .= sprintf(
302 '<input type="checkbox" id="everest-forms-panel-field-%s-%s" name="%s" value="1" class="%s" %s %s>',
303 sanitize_html_class( $panel_id ),
304 sanitize_html_class( $field ),
305 $field_name,
306 $input_class,
307 $checked,
308 $data_attr
309 );
310 $output = sprintf(
311 '<label for="everest-forms-panel-field-%s-%s" class="inline">%s',
312 sanitize_html_class( $panel_id ),
313 sanitize_html_class( $field ),
314 $checkbox . $label
315 );
316 if ( ! empty( $args['tooltip'] ) ) {
317 $output .= sprintf( ' <i class="dashicons dashicons-editor-help everest-forms-help-tooltip" title="%s"></i>', esc_attr( $args['tooltip'] ) );
318 }
319 $output .= '</label>';
320 break;
321
322 // Radio.
323 case 'radio':
324 $options = $args['options'];
325 $x = 1;
326 $output = '';
327 foreach ( $options as $key => $item ) {
328 if ( empty( $item['label'] ) ) {
329 continue;
330 }
331 $checked = checked( $key, $value, false );
332 $output .= sprintf(
333 '<span class="row"><input type="radio" id="everest-forms-panel-field-%s-%s-%d" name="%s" value="%s" class="widefat %s" %s %s>',
334 sanitize_html_class( $panel_id ),
335 sanitize_html_class( $field ),
336 $x,
337 $field_name,
338 $key,
339 $input_class,
340 $checked,
341 $data_attr
342 );
343 $output .= sprintf(
344 '<label for="everest-forms-panel-field-%s-%s-%d" class="inline">%s',
345 sanitize_html_class( $panel_id ),
346 sanitize_html_class( $field ),
347 $x,
348 $item['label']
349 );
350 if ( ! empty( $item['tooltip'] ) ) {
351 $output .= sprintf( ' <i class="dashicons dashicons-editor-help everest-forms-help-tooltip" title="%s"></i>', esc_attr( $item['tooltip'] ) );
352 }
353 $output .= '</label></span>';
354 ++$x;
355 }
356 break;
357
358 // Select.
359 case 'select':
360 $is_multiple = isset( $args['multiple'] ) && true === $args['multiple'];
361 if ( empty( $args['options'] ) && empty( $args['field_map'] ) ) {
362 return '';
363 }
364
365 if ( true === $is_multiple && is_string( $value ) ) {
366 $value = ! empty( $value ) ? json_decode( $value, true ) : array();
367 }
368
369 if ( ! empty( $args['field_map'] ) ) {
370 $options = array();
371 $available_fields = evf_get_form_fields( $form_data, $args['field_map'] );
372 if ( ! empty( $available_fields ) ) {
373 foreach ( $available_fields as $id => $available_field ) {
374 $lbl = ! empty( $available_field['label'] ) ? esc_attr( $available_field['label'] ) : esc_html__( 'Field #', 'everest-forms' ) . $id;
375 $options[ $id ] = $lbl;
376 }
377 }
378 $input_class .= ' everest-forms-field-map-select';
379 $data_attr .= ' data-field-map-allowed="' . implode( ' ', $args['field_map'] ) . '"';
380 if ( ! empty( $placeholder ) ) {
381 $data_attr .= ' data-field-map-placeholder="' . esc_attr( $placeholder ) . '"';
382 }
383 } else {
384 $options = $args['options'];
385 }
386
387 if ( true === $is_multiple ) {
388 $multiple = 'multiple';
389 $field_name .= '[]';
390 } else {
391 $multiple = '';
392 }
393
394 $output = sprintf(
395 '<select id="everest-forms-panel-field-%s-%s" name="%s" class="widefat %s" %s ' . $multiple . '>',
396 sanitize_html_class( $panel_id ),
397 sanitize_html_class( $field ),
398 $field_name,
399 $input_class,
400 $data_attr
401 );
402
403 if ( ! empty( $placeholder ) ) {
404 $output .= '<option value="">' . $placeholder . '</option>';
405 }
406
407 foreach ( $options as $key => $item ) {
408 if ( true === $is_multiple && is_array( $value ) ) {
409 $output .= sprintf( '<option value="%s" %s>%s</option>', esc_attr( $key ), selected( in_array( $key, $value, true ), true, false ), $item );
410 } else {
411 $output .= sprintf( '<option value="%s" %s>%s</option>', esc_attr( $key ), selected( $key, $value, false ), $item );
412 }
413 }
414 $output .= '</select>';
415 break;
416 // Toggle input.
417 case 'toggle':
418 if ( 'yes' === $value ) {
419 $checked = checked( 'yes', $value, false );
420 } else {
421 $checked = checked( '1', $value, false );
422 }
423 $output = sprintf(
424 '<div class="evf-toggle-section"><span class="everest-forms-toggle-form"><input type="hidden" name="%s" value="0" class="widefat %s" %s %s>',
425 $field_name,
426 $input_class,
427 $checked,
428 $data_attr
429 );
430 $output .= sprintf(
431 '<input type="checkbox" id="everest-forms-panel-field-%s-%s" name="%s" value="1" placeholder="%s" class="widefat %s" %s %s><span class="slider round"></span></span></div>',
432 sanitize_html_class( $panel_id ),
433 sanitize_html_class( $field ),
434 $field_name,
435 $placeholder,
436 $input_class,
437 $data_attr,
438 $checked
439 );
440 break;
441
442 // Radio image inputs.
443 case 'radio-image':
444 $options = $args['options'];
445 $x = 1;
446 $output = '<div class="everest-forms-layout">';
447 foreach ( $options as $key => $item ) {
448 $checked = checked( $key, $value, false );
449 $output .= sprintf(
450 '<label for="everest-forms-panel-field-%s-%s-%d" class="inline">',
451 sanitize_html_class( $panel_id ),
452 sanitize_html_class( $field ),
453 $x
454 );
455 if ( ! empty( $item['tooltip'] ) ) {
456 $output .= sprintf( ' <i class="dashicons dashicons-editor-help everest-forms-help-tooltip" title="%s"></i>', esc_attr( $item['tooltip'] ) );
457 }
458 $output .= sprintf(
459 '<input type="radio" id="everest-forms-panel-field-%s-%s-%d" name="%s" value="%s" class="widefat %s" %s %s><img src="%s">',
460 sanitize_html_class( $panel_id ),
461 sanitize_html_class( $field ),
462 $x,
463 $field_name,
464 $key,
465 $input_class,
466 $checked,
467 $data_attr,
468 esc_html( $item['image'] )
469 );
470 $output .= '</label>';
471 ++$x;
472 }
473 $output .= '</div>';
474 break;
475 case 'image':
476 if ( '' !== $value ) {
477 $headers = get_headers( $value, 1 );
478 $content_type = is_array( $headers['Content-Type'] ) ? implode( ' ', $headers['Content-Type'] ) : $headers['Content-Type'];
479
480 if ( strpos( $content_type, 'image/' ) === false ) {
481 $value = '';
482 }
483 }
484
485 $hidden_class = empty( $value ) ? 'everest-forms-hidden' : '';
486 $alt = isset( $args['image']['alt'] ) ? $args['image']['alt'] : 'Unknown';
487 $button_text = isset( $args['image']['button-text'] ) ? $args['image']['button-text'] : 'Upload Image';
488 $output = sprintf( '<div class="everest-forms-custom-image-container ' . esc_attr( $hidden_class ) . '">' );
489 /* translators: %2$s : Image Alt Text. */
490 $output .= sprintf( '<a href="#" class="everest-forms-custom-image-delete"><i class="evf-icon evf-icon-delete"></i><img src="%1$s" alt="' . __( ' %2$s', 'everest-forms' ) . '" class="evf-custom-image-uploader %3$s" height="100" width="auto">', esc_attr( $value ), esc_attr( $alt ), ( empty( $value ) ? 'everest-forms-hidden' : '' ) ); // phpcs:ignore
491 $output .= sprintf( '</a></div>' );
492 /* translators: %2$s : Upload Image button Text. */
493 $output .= sprintf( '<div class="everest-forms-custom-image-button"><button type="button" class="evf-custom-image-uploader-button evf-custom-image-button %1$s">' . __( '%2$s', 'everest-forms' ) . '</button>', ( empty( $value ) ? 'button-secondary' : 'everest-forms-hidden' ), esc_html( $button_text ) ); // phpcs:ignore
494 $output .= sprintf(
495 '<input type="hidden" id="everest-forms-panel-field-%s-%s" name="%s" value="%s" placeholder="%s" class="widefat %s" %s></div>',
496 sanitize_html_class( $panel_id ),
497 sanitize_html_class( $field ),
498 $field_name,
499 esc_attr( $value ),
500 $placeholder,
501 $input_class,
502 $data_attr
503 );
504 wp_enqueue_script( 'jquery' );
505 wp_enqueue_media();
506 wp_enqueue_script( 'evf-file-uploader' );
507 break;
508 }
509
510 $smarttags_class = ! empty( $args['smarttags'] ) ? 'evf_smart_tag' : '';
511
512 // Put the pieces together....
513 $field_open = sprintf(
514 '<div id="everest-forms-panel-field-%s-%s-wrap" class="everest-forms-panel-field %s %s %s">',
515 sanitize_html_class( $panel_id ),
516 sanitize_html_class( $field ),
517 $class,
518 $smarttags_class,
519 'everest-forms-panel-field-' . sanitize_html_class( $option )
520 );
521 $field_open .= ! empty( $args['before'] ) ? $args['before'] : '';
522 if ( ! in_array( $option, array( 'checkbox' ), true ) && ! empty( $label ) ) {
523 $field_label = sprintf(
524 '<label for="everest-forms-panel-field-%s-%s">%s',
525 sanitize_html_class( $panel_id ),
526 sanitize_html_class( $field ),
527 $label
528 );
529 if ( ! empty( $args['tooltip'] ) ) {
530 $field_label .= sprintf( ' <i class="dashicons dashicons-editor-help everest-forms-help-tooltip" title="%s"></i>', esc_attr( $args['tooltip'] ) );
531 }
532 if ( ! empty( $args['after_tooltip'] ) ) {
533 $field_label .= $args['after_tooltip'];
534 }
535 if ( ! empty( $args['smarttags'] ) ) {
536 $smart_tag = '';
537
538 $type = ! empty( $args['smarttags']['type'] ) ? esc_attr( $args['smarttags']['type'] ) : 'form_fields';
539 $form_fields = ! empty( $args['smarttags']['form_fields'] ) ? esc_attr( $args['smarttags']['form_fields'] ) : '';
540
541 $smart_tag .= '<a href="#" class="evf-toggle-smart-tag-display" data-type="' . $type . '" data-fields="' . $form_fields . '"><span class="dashicons dashicons-editor-code"></span></a>';
542 $smart_tag .= '<div class="evf-smart-tag-lists" style="display: none">';
543 $smart_tag .= '<div class="smart-tag-title">';
544 $smart_tag .= esc_html__( 'Available Fields', 'everest-forms' );
545 $smart_tag .= '</div><ul class="evf-fields"></ul>';
546 if ( 'all' === $type || 'other' === $type ) {
547 $smart_tag .= '<div class="smart-tag-title other-tag-title">';
548 $smart_tag .= esc_html__( 'Others', 'everest-forms' );
549 $smart_tag .= '</div><ul class="evf-others"></ul>';
550 }
551 $smart_tag .= '</div>';
552 } else {
553 $smart_tag = '';
554 }
555
556 $field_label .= '</label>';
557 if ( ! empty( $args['after_label'] ) ) {
558 $field_label .= $args['after_label'];
559 }
560 } else {
561 $field_label = '';
562 $smart_tag = '';
563 }
564 $field_close = ! empty( $args['after'] ) ? $args['after'] : '';
565 $field_close .= '</div>';
566 $output = $field_open . $field_label . $output . $smart_tag . $field_close;
567
568 // Wash our hands.
569 if ( $echo ) {
570 echo wp_kses( $output, evf_get_allowed_html_tags( 'builder' ) );
571 } else {
572 return $output;
573 }
574 }
575