PluginProbe ʕ •ᴥ•ʔ
Everest Forms – Contact Form, Payment Form, Quiz, Survey & Custom Form Builder with AI / 2.0.4
Everest Forms – Contact Form, Payment Form, Quiz, Survey & Custom Form Builder with AI v2.0.4
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 2 years ago plugin-updates 8 years ago settings 2 years ago views 2 years ago class-evf-admin-addons.php 4 years ago class-evf-admin-assets.php 2 years ago class-evf-admin-builder.php 7 years ago class-evf-admin-deactivation-feedback.php 3 years ago class-evf-admin-editor.php 4 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 3 years ago class-evf-admin-forms-table-list.php 3 years ago class-evf-admin-forms.php 3 years ago class-evf-admin-import-export.php 4 years ago class-evf-admin-menus.php 2 years ago class-evf-admin-notices.php 3 years ago class-evf-admin-settings.php 2 years ago class-evf-admin-tools.php 4 years ago class-evf-admin-welcome.php 2 years ago class-evf-admin.php 2 years ago evf-admin-functions.php 2 years ago
evf-admin-functions.php
571 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 'dashboard_page_evf-welcome',
20 'toplevel_page_' . $evf_screen_id,
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 dirname( __FILE__ ) . '/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 dirname( __FILE__ ) . '/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 dirname( __FILE__ ) . '/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 $data_attr = '';
196 $output = '';
197
198 // Check if we should store values in a parent array.
199 if ( ! empty( $parent ) ) {
200 if ( ! empty( $subsection ) ) {
201 $field_name = sprintf( '%s[%s][%s][%s]', $parent, $panel, $subsection, $field );
202 $value = isset( $form_data[ $parent ][ $panel ][ $subsection ][ $field ] ) ? $form_data[ $parent ][ $panel ][ $subsection ][ $field ] : $default;
203 $panel_id = sanitize_html_class( $panel . '-' . $subsection );
204 } else {
205 $field_name = sprintf( '%s[%s][%s]', $parent, $panel, $field );
206 $value = isset( $form_data[ $parent ][ $panel ][ $field ] ) ? $form_data[ $parent ][ $panel ][ $field ] : $default;
207 }
208 } else {
209
210 $field_name = sprintf( '%s[%s]', $panel, $field );
211 $value = isset( $form_data[ $panel ][ $field ] ) ? $form_data[ $panel ][ $field ] : $default;
212 }
213
214 // Check for data attributes.
215 if ( ! empty( $args['data'] ) ) {
216 foreach ( $args['data'] as $key => $val ) {
217 if ( is_array( $val ) ) {
218 $val = wp_json_encode( $val );
219 }
220 $data_attr .= ' data-' . $key . '=\'' . $val . '\'';
221 }
222 }
223
224 // Check for the custom attributes.
225 $custom_attributes = '';
226 if ( ! empty( $args['custom_attributes'] ) ) {
227 foreach ( $args['custom_attributes'] as $attribute => $attribute_value ) {
228 if ( is_array( $attribute_value ) ) {
229 $attribute_value = wp_json_encode( $attribute_value );
230 }
231 $custom_attributes .= ' ' . $attribute . '=\'' . $attribute_value . '\'';
232 }
233 }
234
235 // Determine what field type to output.
236 switch ( $option ) {
237
238 // Text input.
239 case 'number':
240 case 'text':
241 $output = sprintf(
242 '<input type="%s" id="everest-forms-panel-field-%s-%s" name="%s" value="%s" placeholder="%s" class="widefat %s" %s %s>',
243 $option,
244 sanitize_html_class( $panel_id ),
245 sanitize_html_class( $field ),
246 $field_name,
247 esc_attr( $value ),
248 $placeholder,
249 $input_class,
250 $data_attr,
251 $custom_attributes
252 );
253 break;
254
255 // Textarea.
256 case 'textarea':
257 $rows = ! empty( $args['rows'] ) ? (int) $args['rows'] : '3';
258 $output = sprintf(
259 '<textarea id="everest-forms-panel-field-%s-%s" name="%s" rows="%d" placeholder="%s" class="widefat %s" %s>%s</textarea>',
260 sanitize_html_class( $panel_id ),
261 sanitize_html_class( $field ),
262 $field_name,
263 $rows,
264 $placeholder,
265 $input_class,
266 $data_attr,
267 esc_textarea( $value )
268 );
269 break;
270
271 // TinyMCE.
272 case 'tinymce':
273 $arguments = wp_parse_args(
274 $tinymce,
275 array(
276 'media_buttons' => false,
277 'tinymce' => false,
278 )
279 );
280 $arguments['textarea_name'] = $field_name;
281 $arguments['teeny'] = true;
282 $id = 'everest-forms-panel-field-' . sanitize_html_class( $panel_id ) . '-' . sanitize_html_class( $field );
283 $id = str_replace( '-', '_', $id );
284 ob_start();
285 wp_editor( $value, $id, $arguments );
286 $output = ob_get_clean();
287 break;
288
289 // Checkbox.
290 case 'checkbox':
291 $checked = checked( '1', $value, false );
292 $checkbox = sprintf(
293 '<input type="hidden" name="%s" value="0" class="widefat %s" %s %s>',
294 $field_name,
295 $input_class,
296 $checked,
297 $data_attr
298 );
299 $checkbox .= sprintf(
300 '<input type="checkbox" id="everest-forms-panel-field-%s-%s" name="%s" value="1" class="%s" %s %s>',
301 sanitize_html_class( $panel_id ),
302 sanitize_html_class( $field ),
303 $field_name,
304 $input_class,
305 $checked,
306 $data_attr
307 );
308 $output = sprintf(
309 '<label for="everest-forms-panel-field-%s-%s" class="inline">%s',
310 sanitize_html_class( $panel_id ),
311 sanitize_html_class( $field ),
312 $checkbox . $label
313 );
314 if ( ! empty( $args['tooltip'] ) ) {
315 $output .= sprintf( ' <i class="dashicons dashicons-editor-help everest-forms-help-tooltip" title="%s"></i>', esc_attr( $args['tooltip'] ) );
316 }
317 $output .= '</label>';
318 break;
319
320 // Radio.
321 case 'radio':
322 $options = $args['options'];
323 $x = 1;
324 $output = '';
325 foreach ( $options as $key => $item ) {
326 if ( empty( $item['label'] ) ) {
327 continue;
328 }
329 $checked = checked( $key, $value, false );
330 $output .= sprintf(
331 '<span class="row"><input type="radio" id="everest-forms-panel-field-%s-%s-%d" name="%s" value="%s" class="widefat %s" %s %s>',
332 sanitize_html_class( $panel_id ),
333 sanitize_html_class( $field ),
334 $x,
335 $field_name,
336 $key,
337 $input_class,
338 $checked,
339 $data_attr
340 );
341 $output .= sprintf(
342 '<label for="everest-forms-panel-field-%s-%s-%d" class="inline">%s',
343 sanitize_html_class( $panel_id ),
344 sanitize_html_class( $field ),
345 $x,
346 $item['label']
347 );
348 if ( ! empty( $item['tooltip'] ) ) {
349 $output .= sprintf( ' <i class="dashicons dashicons-editor-help everest-forms-help-tooltip" title="%s"></i>', esc_attr( $item['tooltip'] ) );
350 }
351 $output .= '</label></span>';
352 $x ++;
353 }
354 break;
355
356 // Select.
357 case 'select':
358 $is_multiple = isset( $args['multiple'] ) && true === $args['multiple'];
359 if ( empty( $args['options'] ) && empty( $args['field_map'] ) ) {
360 return '';
361 }
362
363 if ( true === $is_multiple && is_string( $value ) ) {
364 $value = ! empty( $value ) ? json_decode( $value, true ) : array();
365 }
366
367 if ( ! empty( $args['field_map'] ) ) {
368 $options = array();
369 $available_fields = evf_get_form_fields( $form_data, $args['field_map'] );
370 if ( ! empty( $available_fields ) ) {
371 foreach ( $available_fields as $id => $available_field ) {
372 $lbl = ! empty( $available_field['label'] ) ? esc_attr( $available_field['label'] ) : esc_html__( 'Field #', 'everest-forms' ) . $id;
373 $options[ $id ] = $lbl;
374 }
375 }
376 $input_class .= ' everest-forms-field-map-select';
377 $data_attr .= ' data-field-map-allowed="' . implode( ' ', $args['field_map'] ) . '"';
378 if ( ! empty( $placeholder ) ) {
379 $data_attr .= ' data-field-map-placeholder="' . esc_attr( $placeholder ) . '"';
380 }
381 } else {
382 $options = $args['options'];
383 }
384
385 if ( true === $is_multiple ) {
386 $multiple = 'multiple';
387 $field_name .= '[]';
388 } else {
389 $multiple = '';
390 }
391
392 $output = sprintf(
393 '<select id="everest-forms-panel-field-%s-%s" name="%s" class="widefat %s" %s ' . $multiple . '>',
394 sanitize_html_class( $panel_id ),
395 sanitize_html_class( $field ),
396 $field_name,
397 $input_class,
398 $data_attr
399 );
400
401 if ( ! empty( $placeholder ) ) {
402 $output .= '<option value="">' . $placeholder . '</option>';
403 }
404
405 foreach ( $options as $key => $item ) {
406 if ( true === $is_multiple && is_array( $value ) ) {
407 $output .= sprintf( '<option value="%s" %s>%s</option>', esc_attr( $key ), selected( in_array( $key, $value, true ), true, false ), $item );
408 } else {
409 $output .= sprintf( '<option value="%s" %s>%s</option>', esc_attr( $key ), selected( $key, $value, false ), $item );
410 }
411 }
412 $output .= '</select>';
413 break;
414 // Toggle input.
415 case 'toggle':
416 if ( 'yes' === $value ) {
417 $checked = checked( 'yes', $value, false );
418 } else {
419 $checked = checked( '1', $value, false );
420 }
421 $output = sprintf(
422 '<div class="evf-toggle-section"><span class="everest-forms-toggle-form"><input type="hidden" name="%s" value="0" class="widefat %s" %s %s>',
423 $field_name,
424 $input_class,
425 $checked,
426 $data_attr
427 );
428 $output .= sprintf(
429 '<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>',
430 sanitize_html_class( $panel_id ),
431 sanitize_html_class( $field ),
432 $field_name,
433 $placeholder,
434 $input_class,
435 $data_attr,
436 $checked
437 );
438 break;
439
440 // Radio image inputs.
441 case 'radio-image':
442 $options = $args['options'];
443 $x = 1;
444 $output = '<div class="everest-forms-layout">';
445 foreach ( $options as $key => $item ) {
446 $checked = checked( $key, $value, false );
447 $output .= sprintf(
448 '<label for="everest-forms-panel-field-%s-%s-%d" class="inline">',
449 sanitize_html_class( $panel_id ),
450 sanitize_html_class( $field ),
451 $x
452 );
453 if ( ! empty( $item['tooltip'] ) ) {
454 $output .= sprintf( ' <i class="dashicons dashicons-editor-help everest-forms-help-tooltip" title="%s"></i>', esc_attr( $item['tooltip'] ) );
455 }
456 $output .= sprintf(
457 '<input type="radio" id="everest-forms-panel-field-%s-%s-%d" name="%s" value="%s" class="widefat %s" %s %s><img src="%s">',
458 sanitize_html_class( $panel_id ),
459 sanitize_html_class( $field ),
460 $x,
461 $field_name,
462 $key,
463 $input_class,
464 $checked,
465 $data_attr,
466 esc_html( $item['image'] )
467 );
468 $output .= '</label>';
469 $x ++;
470 }
471 $output .= '</div>';
472 break;
473 case 'image':
474 if ( '' !== $value ) {
475 $headers = get_headers( $value, 1 );
476 if ( strpos( $headers['Content-Type'], 'image/' ) === false ) {
477 $value = '';
478 }
479 }
480
481 $hidden_class = empty( $value ) ? 'everest-forms-hidden' : '';
482 $alt = isset( $args['image']['alt'] ) ? $args['image']['alt'] : 'Unknown';
483 $button_text = isset( $args['image']['button-text'] ) ? $args['image']['button-text'] : 'Upload Image';
484 $output = sprintf( '<div class="everest-forms-custom-image-container ' . esc_attr( $hidden_class ) . '">' );
485 /* translators: %2$s : Image Alt Text. */
486 $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
487 $output .= sprintf( '</a></div>' );
488 /* translators: %2$s : Upload Image button Text. */
489 $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
490 $output .= sprintf(
491 '<input type="hidden" id="everest-forms-panel-field-%s-%s" name="%s" value="%s" placeholder="%s" class="widefat %s" %s></div>',
492 sanitize_html_class( $panel_id ),
493 sanitize_html_class( $field ),
494 $field_name,
495 esc_attr( $value ),
496 $placeholder,
497 $input_class,
498 $data_attr
499 );
500 wp_enqueue_script( 'jquery' );
501 wp_enqueue_media();
502 wp_enqueue_script( 'evf-file-uploader' );
503 break;
504 }
505
506 $smarttags_class = ! empty( $args['smarttags'] ) ? 'evf_smart_tag' : '';
507
508 // Put the pieces together....
509 $field_open = sprintf(
510 '<div id="everest-forms-panel-field-%s-%s-wrap" class="everest-forms-panel-field %s %s %s">',
511 sanitize_html_class( $panel_id ),
512 sanitize_html_class( $field ),
513 $class,
514 $smarttags_class,
515 'everest-forms-panel-field-' . sanitize_html_class( $option )
516 );
517 $field_open .= ! empty( $args['before'] ) ? $args['before'] : '';
518 if ( ! in_array( $option, array( 'checkbox' ), true ) && ! empty( $label ) ) {
519 $field_label = sprintf(
520 '<label for="everest-forms-panel-field-%s-%s">%s',
521 sanitize_html_class( $panel_id ),
522 sanitize_html_class( $field ),
523 $label
524 );
525 if ( ! empty( $args['tooltip'] ) ) {
526 $field_label .= sprintf( ' <i class="dashicons dashicons-editor-help everest-forms-help-tooltip" title="%s"></i>', esc_attr( $args['tooltip'] ) );
527 }
528 if ( ! empty( $args['after_tooltip'] ) ) {
529 $field_label .= $args['after_tooltip'];
530 }
531 if ( ! empty( $args['smarttags'] ) ) {
532 $smart_tag = '';
533
534 $type = ! empty( $args['smarttags']['type'] ) ? esc_attr( $args['smarttags']['type'] ) : 'form_fields';
535 $form_fields = ! empty( $args['smarttags']['form_fields'] ) ? esc_attr( $args['smarttags']['form_fields'] ) : '';
536
537 $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>';
538 $smart_tag .= '<div class="evf-smart-tag-lists" style="display: none">';
539 $smart_tag .= '<div class="smart-tag-title">';
540 $smart_tag .= esc_html__( 'Available Fields', 'everest-forms' );
541 $smart_tag .= '</div><ul class="evf-fields"></ul>';
542 if ( 'all' === $type || 'other' === $type ) {
543 $smart_tag .= '<div class="smart-tag-title other-tag-title">';
544 $smart_tag .= esc_html__( 'Others', 'everest-forms' );
545 $smart_tag .= '</div><ul class="evf-others"></ul>';
546 }
547 $smart_tag .= '</div>';
548 } else {
549 $smart_tag = '';
550 }
551
552 $field_label .= '</label>';
553 if ( ! empty( $args['after_label'] ) ) {
554 $field_label .= $args['after_label'];
555 }
556 } else {
557 $field_label = '';
558 $smart_tag = '';
559 }
560 $field_close = ! empty( $args['after'] ) ? $args['after'] : '';
561 $field_close .= '</div>';
562 $output = $field_open . $field_label . $output . $smart_tag . $field_close;
563
564 // Wash our hands.
565 if ( $echo ) {
566 echo wp_kses( $output, evf_get_allowed_html_tags( 'builder' ) );
567 } else {
568 return $output;
569 }
570 }
571