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