PluginProbe
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More / 6.12
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More v6.12
6.35 6.34 6.33.1 6.33 6.32.1 6.32 6.31 6.25 6.25.1 6.26 6.26.1 6.27 6.28 6.29 6.3 6.3.1 6.3.2 6.30 6.4 6.4.1 6.4.2 6.5 6.5.1 6.5.2 6.5.3 All 141 releases
← All changes | classes/controllers/FrmFieldsController.php +38 -140 6.266.12 View file →
@@ -18,9 +18,8 @@
18 18
19 19 // Javascript may be included in some field settings.
20 20 // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
21 21 $fields = isset( $_POST['field'] ) ? wp_unslash( $_POST['field'] ) : array();
22 -
23 22 if ( empty( $fields ) ) {
24 23 wp_die();
25 24 }
26 25
@@ -34,9 +33,8 @@
34 33
35 34 foreach ( $fields as $field ) {
36 35 $field = htmlspecialchars_decode( nl2br( $field ) );
37 36 $field = json_decode( $field );
38 -
39 37 if ( ! isset( $field->id ) || ! is_numeric( $field->id ) ) {
40 38 // this field may have already been loaded
41 39 continue;
42 40 }
@@ -51,9 +49,9 @@
51 49 ob_start();
52 50 self::load_single_field( $field, $values );
53 51 $field_html[ absint( $field->id ) ] = ob_get_contents();
54 52 ob_end_clean();
55 - }//end foreach
53 + }
56 54
57 55 echo json_encode( $field_html );
58 56
59 57 wp_die();
@@ -65,15 +63,14 @@
65 63 public static function create() {
66 64 FrmAppHelper::permission_check( 'frm_edit_forms' );
67 65 check_ajax_referer( 'frm_ajax', 'nonce' );
68 66
69 - $field_type = FrmAppHelper::get_post_param( 'field_type', '', 'sanitize_text_field' );
70 - $form_id = FrmAppHelper::get_post_param( 'form_id', 0, 'absint' );
71 - $field_options = FrmAppHelper::get_post_param( 'field_options', array(), 'wp_kses_post' );
67 + $field_type = FrmAppHelper::get_post_param( 'field_type', '', 'sanitize_text_field' );
68 + $form_id = FrmAppHelper::get_post_param( 'form_id', 0, 'absint' );
72 69
73 70 do_action( 'frm_before_create_field', $field_type, $form_id );
74 71
75 - $field = self::include_new_field( $field_type, $form_id, $field_options );
72 + $field = self::include_new_field( $field_type, $form_id );
76 73
77 74 // this hook will allow for multiple fields to be added at once
78 75 do_action( 'frm_after_field_created', $field, $form_id );
79 76
@@ -84,19 +81,14 @@
84 81 * Set up and create a new field
85 82 *
86 83 * @param string $field_type
87 84 * @param int $form_id
88 - * @param array $field_options
89 85 *
90 86 * @return array|false
91 87 */
92 - public static function include_new_field( $field_type, $form_id, $field_options = array() ) {
88 + public static function include_new_field( $field_type, $form_id ) {
93 89 $field_values = FrmFieldsHelper::setup_new_vars( $field_type, $form_id );
94 90
95 - if ( ! empty( $field_options ) ) {
96 - $field_values['field_options'] = array_merge( $field_values['field_options'], $field_options );
97 - }
98 -
99 91 // When a new field is added to the form, flag it as draft and hide it from the front-end.
100 92 $field_values['field_options']['draft'] = 1;
101 93
102 94 /**
@@ -111,14 +103,12 @@
111 103
112 104 $field = self::get_field_array_from_id( $field_id );
113 105
114 106 $values = array();
115 -
116 107 if ( FrmAppHelper::pro_is_installed() ) {
117 108 $values['post_type'] = FrmProFormsHelper::post_type( $form_id );
118 109
119 110 $parent_form_id = FrmDb::get_var( 'frm_forms', array( 'id' => $form_id ), 'parent_form_id' );
120 -
121 111 if ( $parent_form_id ) {
122 112 $field['parent_form_id'] = $parent_form_id;
123 113 }
124 114 }
@@ -162,10 +152,8 @@
162 152 *
163 153 * @param array|int|object $field_object
164 154 * @param array $values
165 155 * @param int $form_id
166 - *
167 - * @return void
168 156 */
169 157 public static function load_single_field( $field_object, $values, $form_id = 0 ) {
170 158 global $frm_vars;
171 159 $frm_vars['is_admin'] = true;
@@ -189,23 +177,12 @@
189 177 return;
190 178 }
191 179
192 180 if ( ! isset( $field ) && is_object( $field_object ) ) {
193 - $field_object->parent_form_id = $values['id'] ?? $field_object->form_id;
181 + $field_object->parent_form_id = isset( $values['id'] ) ? $values['id'] : $field_object->form_id;
194 182 $field = FrmFieldsHelper::setup_edit_vars( $field_object );
195 183 }
196 184
197 - /**
198 - * Filter for adding extra attributes to the field container.
199 - *
200 - * @since 6.23
201 - *
202 - * @param array $extra_field_attributes
203 - * @param array $field
204 - * @param array $display
205 - */
206 - $extra_field_attributes = apply_filters( 'frm_field_container_extra_attributes', array(), $field, $display );
207 -
208 185 $li_classes = self::get_classes_for_builder_field( $field, $display, $field_obj );
209 186 $li_classes .= ' ui-state-default widgets-holder-wrap';
210 187
211 188 require FrmAppHelper::plugin_path() . '/classes/views/frm-forms/add_field.php';
@@ -216,9 +193,8 @@
216 193 *
217 194 * @param array $field
218 195 * @param array $display
219 196 * @param FrmFieldType $field_info
220 - *
221 197 * @return string
222 198 */
223 199 private static function get_classes_for_builder_field( $field, $display, $field_info ) {
224 200 $li_classes = $field_info->form_builder_classes( $display['type'] );
@@ -266,9 +242,8 @@
266 242 *
267 243 * @since 6.8.4
268 244 *
269 245 * @param array $bulk_edit_types
270 - *
271 246 * @return array
272 247 */
273 248 $bulk_edit_types = apply_filters( 'frm_bulk_edit_field_types', $bulk_edit_types );
274 249
@@ -300,9 +275,8 @@
300 275
301 276 // Keep other options after bulk update.
302 277 if ( isset( $field['field_options']['other'] ) && $field['field_options']['other'] == true ) {
303 278 $other_array = array();
304 -
305 279 foreach ( $field['options'] as $opt_key => $opt ) {
306 280 if ( FrmFieldsHelper::is_other_opt( $opt_key ) ) {
307 281 $other_array[ $opt_key ] = $opt;
308 282 }
@@ -307,9 +281,8 @@
307 281 $other_array[ $opt_key ] = $opt;
308 282 }
309 283 unset( $opt_key, $opt );
310 284 }
311 -
312 285 if ( ! empty( $other_array ) ) {
313 286 $opts = array_merge( $opts, $other_array );
314 287 }
315 288 }
@@ -324,9 +297,8 @@
324 297 /**
325 298 * @since 4.0
326 299 *
327 300 * @param array $atts - Includes field array, field_obj, display array, values array.
328 - *
329 301 * @return void
330 302 */
331 303 public static function load_single_field_settings( $atts ) {
332 304 $field = $atts['field'];
@@ -360,9 +332,8 @@
360 332 FrmFormsHelper::prepare_field_type( $all_field_types[ $field['type'] ] );
361 333 }
362 334
363 335 $type_name = $all_field_types[ $field['type'] ]['name'];
364 -
365 336 if ( $field['type'] === 'divider' && FrmField::is_option_true( $field, 'repeat' ) ) {
366 337 $type_name = $all_field_types['divider|repeat']['name'];
367 338 }
368 339
@@ -395,9 +366,8 @@
395 366 * @since 4.0
396 367 *
397 368 * @param array $field
398 369 * @param array $atts
399 - *
400 370 * @return array
401 371 */
402 372 private static function default_value_types( $field, $atts ) {
403 373 $types = array(
@@ -403,32 +373,30 @@
403 373 $types = array(
404 374 'default_value' => array(
405 375 'class' => '',
406 376 'icon' => 'frm_icon_font frm_text2_icon',
407 - 'title' => __( 'Default Value', 'formidable' ),
377 + 'title' => __( 'Default Value (Text)', 'formidable' ),
408 378 'data' => array(
409 379 'frmshow' => '#default-value-for-',
410 380 ),
411 381 ),
412 382 'calc' => array(
413 - 'class' => 'frm_show_upgrade frm_noallow',
414 - 'title' => __( 'Calculate Value', 'formidable' ),
415 - 'icon' => 'frm_icon_font frm_calculator_icon',
416 - 'data' => array(
383 + 'class' => 'frm_show_upgrade frm_noallow',
384 + 'title' => __( 'Default Value (Calculation)', 'formidable' ),
385 + 'icon' => 'frm_icon_font frm_calculator_icon',
386 + 'data' => array(
417 387 'medium' => 'calculations',
418 388 'upgrade' => __( 'Calculator forms', 'formidable' ),
419 389 ),
420 - 'tooltip' => __( 'Automatically calculate the value of this field based on values from other fields.', 'formidable' ),
421 390 ),
422 391 'get_values_field' => array(
423 - 'class' => 'frm_show_upgrade frm_noallow',
424 - 'title' => __( 'Lookup', 'formidable' ),
425 - 'icon' => 'frm_icon_font frm_search_icon',
426 - 'data' => array(
392 + 'class' => 'frm_show_upgrade frm_noallow',
393 + 'title' => __( 'Default Value (Lookup)', 'formidable' ),
394 + 'icon' => 'frm_icon_font frm_search_icon',
395 + 'data' => array(
427 396 'medium' => 'lookup',
428 397 'upgrade' => __( 'Lookup fields', 'formidable' ),
429 398 ),
430 - 'tooltip' => __( 'Dynamically retrieve the value of this field from a lookup field.', 'formidable' ),
431 399 ),
432 400 );
433 401
434 402 $types = apply_filters( 'frm_default_value_types', $types, $atts );
@@ -436,13 +404,11 @@
436 404 // Set active class.
437 405 $settings = array_keys( $types );
438 406 $active = 'default_value';
439 407
440 - if ( FrmAppHelper::pro_is_connected() ) {
441 - foreach ( $settings as $type ) {
442 - if ( ! empty( $field[ $type ] ) ) {
443 - $active = $type;
444 - }
408 + foreach ( $settings as $type ) {
409 + if ( ! empty( $field[ $type ] ) ) {
410 + $active = $type;
445 411 }
446 412 }
447 413
448 414 $types[ $active ]['class'] .= ' current';
@@ -452,9 +418,8 @@
452 418 }
453 419
454 420 /**
455 421 * @param string $type
456 - *
457 422 * @return string
458 423 */
459 424 public static function change_type( $type ) {
460 425 $type_switch = array(
@@ -464,9 +429,8 @@
464 429 'rte' => 'textarea',
465 430 'website' => 'url',
466 431 'image' => 'url',
467 432 );
468 -
469 433 if ( isset( $type_switch[ $type ] ) ) {
470 434 $type = $type_switch[ $type ];
471 435 }
472 436
@@ -482,18 +446,16 @@
482 446 return $type;
483 447 }
484 448
485 449 /**
486 - * @param array $settings
487 - * @param FrmFieldType|null $field_info
450 + * @param array $settings
451 + * @param object|null $field_info
488 452 *
489 453 * @return array
490 454 */
491 455 public static function display_field_options( $settings, $field_info = null ) {
492 456 if ( $field_info ) {
493 - $settings = $field_info->display_field_settings();
494 -
495 - // Field appears to be protected but there is a __get function in FrmFieldType that makes this public.
457 + $settings = $field_info->display_field_settings();
496 458 $settings['field_data'] = $field_info->field;
497 459 }
498 460
499 461 return apply_filters( 'frm_display_field_options', $settings );
@@ -503,20 +465,17 @@
503 465 * Display the format option
504 466 *
505 467 * @since 3.0
506 468 *
507 - * @param array $field Field data.
508 - * @param bool $is_hidden Whether the format option should be hidden.
509 - *
469 + * @param array $field
510 470 * @return void
511 471 */
512 - public static function show_format_option( $field, $is_hidden = false ) {
513 - $attributes = array(
514 - 'class' => 'frm-has-modal',
515 - 'id' => 'frm-field-format-custom-' . $field['id'],
516 - );
472 + public static function show_format_option( $field ) {
473 + $attributes = array();
474 + $attributes['class'] = 'frm-has-modal';
517 475
518 - if ( $is_hidden ) {
476 + if ( 'phone' === $field['type'] ) {
477 + $attributes['id'] = 'frm-phone-field-custom-format-' . $field['id'];
519 478 $attributes['class'] .= ' frm_hidden';
520 479 }
521 480
522 481 include FrmAppHelper::plugin_path() . '/classes/views/frm-fields/back-end/value-format.php';
@@ -521,14 +480,8 @@
521 480
522 481 include FrmAppHelper::plugin_path() . '/classes/views/frm-fields/back-end/value-format.php';
523 482 }
524 483
525 - /**
526 - * @param array $field
527 - * @param bool $echo
528 - *
529 - * @return string
530 - */
531 484 public static function input_html( $field, $echo = true ) {
532 485 $class = array();
533 486 self::add_input_classes( $field, $class );
534 487
@@ -557,9 +510,8 @@
557 510
558 511 /**
559 512 * @param array $field
560 513 * @param array $class
561 - *
562 514 * @return void
563 515 */
564 516 private static function add_input_classes( $field, array &$class ) {
565 517 if ( ! empty( $field['input_class'] ) ) {
@@ -577,9 +529,8 @@
577 529
578 530 /**
579 531 * @param array $field
580 532 * @param array $add_html
581 - *
582 533 * @return void
583 534 */
584 535 private static function add_html_size( $field, array &$add_html ) {
585 536 $size_fields = array(
@@ -612,9 +563,8 @@
612 563
613 564 /**
614 565 * @param array $field
615 566 * @param array $add_html
616 - *
617 567 * @return void
618 568 */
619 569 private static function add_html_cols( $field, array &$add_html ) {
620 570 if ( ! in_array( $field['type'], array( 'textarea', 'rte' ), true ) ) {
@@ -643,9 +593,8 @@
643 593
644 594 /**
645 595 * @param array $field
646 596 * @param array $add_html
647 - *
648 597 * @return void
649 598 */
650 599 private static function add_html_length( $field, array &$add_html ) {
651 600 // Check for max setting and if this field accepts maxlength.
@@ -671,9 +620,8 @@
671 620 /**
672 621 * @param array $field
673 622 * @param array $add_html
674 623 * @param array $class
675 - *
676 624 * @return void
677 625 */
678 626 private static function add_html_placeholder( $field, array &$add_html, array &$class ) {
679 627 if ( $field['default_value'] != '' ) {
@@ -684,9 +632,8 @@
684 632 }
685 633 }
686 634
687 635 $field['placeholder'] = self::prepare_placeholder( $field );
688 -
689 636 if ( $field['placeholder'] == '' || is_array( $field['placeholder'] ) ) {
690 637 // don't include a json placeholder
691 638 return;
692 639 }
@@ -699,13 +646,12 @@
699 646 *
700 647 * @since 5.4 This doesn't call `FrmFieldsController::get_default_value_from_name()` anymore.
701 648 *
702 649 * @param array $field Field array.
703 - *
704 650 * @return string
705 651 */
706 652 private static function prepare_placeholder( $field ) {
707 - $placeholder = $field['placeholder'] ?? '';
653 + $placeholder = isset( $field['placeholder'] ) ? $field['placeholder'] : '';
708 654
709 655 return $placeholder;
710 656 }
711 657
@@ -728,16 +674,12 @@
728 674 * Maybe add a blank placeholder option before any options
729 675 * in a dropdown.
730 676 *
731 677 * @since 4.04
732 - *
733 - * @param array|object $field
734 - *
735 678 * @return bool True if placeholder was added.
736 679 */
737 680 public static function add_placeholder_to_select( $field ) {
738 681 $placeholder = FrmField::get_option( $field, 'placeholder' );
739 -
740 682 if ( empty( $placeholder ) ) {
741 683 $placeholder = self::get_default_value_from_name( $field );
742 684 }
743 685
@@ -745,9 +687,8 @@
745 687 $autocomplete = FrmField::get_option( $field, 'autocom' );
746 688
747 689 if ( $autocomplete ) {
748 690 $use_chosen = ! is_callable( 'FrmProAppHelper::use_chosen_js' ) || FrmProAppHelper::use_chosen_js();
749 -
750 691 if ( $use_chosen ) {
751 692 $use_placeholder = '';
752 693 }
753 694 }
@@ -758,8 +699,13 @@
758 699 'value' => '',
759 700 'data-placeholder' => 'true',
760 701 );
761 702
703 + if ( $autocomplete && empty( $use_chosen ) ) {
704 + // This is required for Slim Select.
705 + $placeholder_attributes['data-placeholder'] = 'true';
706 + }
707 +
762 708 FrmHtmlHelper::echo_dropdown_option( $use_placeholder, false, $placeholder_attributes );
763 709 return true;
764 710 }
765 711
@@ -770,9 +716,8 @@
770 716 * Use HTML5 placeholder with js fallback.
771 717 *
772 718 * @param array $field
773 719 * @param array $add_html
774 - *
775 720 * @return void
776 721 */
777 722 private static function add_placeholder_to_input( $field, &$add_html ) {
778 723 if ( FrmFieldsHelper::is_placeholder_field_type( $field['type'] ) ) {
@@ -782,9 +727,8 @@
782 727
783 728 /**
784 729 * @param array $field
785 730 * @param array $add_html
786 - *
787 731 * @return void
788 732 */
789 733 private static function add_frmval_to_input( $field, &$add_html ) {
790 734 if ( $field['placeholder'] != '' ) {
@@ -799,14 +743,8 @@
799 743 $add_html['data-frmval'] = 'data-frmval="' . esc_attr( $field['default_value'] ) . '"';
800 744 }
801 745 }
802 746
803 - /**
804 - * @param array $field
805 - * @param array $add_html
806 - *
807 - * @return void
808 - */
809 747 private static function add_validation_messages( $field, array &$add_html ) {
810 748 $field_validation_messages_status = self::get_validation_data_attribute_visibility_info( $field );
811 749
812 750 if ( FrmField::is_required( $field ) && ! empty( $field_validation_messages_status['data-reqmsg'] ) ) {
@@ -830,9 +768,8 @@
830 768 *
831 769 * @since 6.9
832 770 *
833 771 * @param array|object $field
834 - *
835 772 * @return array
836 773 */
837 774 private static function get_validation_data_attribute_visibility_info( $field ) {
838 775 if ( FrmField::get_field_type( $field ) === 'hidden' ) {
@@ -862,20 +799,17 @@
862 799 * @since 5.0.03
863 800 *
864 801 * @param array $field
865 802 * @param array $add_html
866 - *
867 803 * @return void
868 804 */
869 805 private static function maybe_add_error_html_for_js_validation( $field, array &$add_html ) {
870 806 $form = self::get_form_for_js_validation( $field );
871 -
872 807 if ( false === $form ) {
873 808 return;
874 809 }
875 810
876 811 $error_body = self::pull_custom_error_body_from_custom_html( $form, $field );
877 -
878 812 if ( false !== $error_body ) {
879 813 $error_body = urlencode( $error_body );
880 814 $add_html['data-error-html'] = 'data-error-html="' . esc_attr( $error_body ) . '"';
881 815 }
@@ -884,19 +818,16 @@
884 818 /**
885 819 * @since 5.0.03
886 820 *
887 821 * @param array $field
888 - *
889 822 * @return false|stdClass false if there is no form object found with JS validation active.
890 823 */
891 824 private static function get_form_for_js_validation( $field ) {
892 825 global $frm_vars;
893 -
894 826 if ( ! empty( $frm_vars['js_validate_forms'] ) ) {
895 827 if ( isset( $frm_vars['js_validate_forms'][ $field['form_id'] ] ) ) {
896 828 return $frm_vars['js_validate_forms'][ $field['form_id'] ];
897 829 }
898 -
899 830 if ( ! empty( $field['parent_form_id'] ) && isset( $frm_vars['js_validate_forms'][ $field['parent_form_id'] ] ) ) {
900 831 return $frm_vars['js_validate_forms'][ $field['parent_form_id'] ];
901 832 }
902 833 }
@@ -906,9 +837,8 @@
906 837 /**
907 838 * @param stdClass $form
908 839 * @param array $field
909 840 * @param array $errors
910 - *
911 841 * @return false|string
912 842 */
913 843 public static function pull_custom_error_body_from_custom_html( $form, $field, $errors = array() ) {
914 844 if ( empty( $field['custom_html'] ) ) {
@@ -918,15 +848,13 @@
918 848 $custom_html = $field['custom_html'];
919 849 $custom_html = apply_filters( 'frm_before_replace_shortcodes', $custom_html, $field, $errors, $form );
920 850
921 851 $start = strpos( $custom_html, '[if error]' );
922 -
923 852 if ( false === $start ) {
924 853 return false;
925 854 }
926 855
927 856 $end = strpos( $custom_html, '[/if error]' );
928 -
929 857 if ( false === $end || $end < $start ) {
930 858 return false;
931 859 }
932 860
@@ -950,12 +878,10 @@
950 878 * submit in many browsers. Check to make sure the javascript to conditionally
951 879 * remove it is present if needed.
952 880 *
953 881 * @since 3.06.01
954 - *
955 882 * @param array $field
956 883 * @param array $add_html
957 - *
958 884 * @return void
959 885 */
960 886 private static function maybe_add_html_required( $field, array &$add_html ) {
961 887 $excluded_field_types =
@@ -974,9 +900,8 @@
974 900
975 901 /**
976 902 * @param array $field
977 903 * @param array $add_html
978 - *
979 904 * @return void
980 905 */
981 906 private static function add_shortcodes_to_html( $field, array &$add_html ) {
982 907 if ( FrmField::is_option_empty( $field, 'shortcodes' ) ) {
@@ -987,20 +912,8 @@
987 912 unset( $field['shortcodes']['autocomplete'] );
988 913 }
989 914
990 915 foreach ( $field['shortcodes'] as $k => $v ) {
991 - if ( isset( $field['subfield_name'] ) && 0 === strpos( $k, 'aria-invalid' ) ) {
992 - $subfield_name = $field['subfield_name'];
993 -
994 - if ( ! isset( $field['shortcodes'][ 'aria-invalid-' . $subfield_name ] ) ) {
995 - continue;
996 - }
997 - // Change the key to the correct aria-invalid value so that $add_html is set correctly for the current subfield of a combo field.
998 - $k = 'aria-invalid';
999 - $v = $field['shortcodes'][ 'aria-invalid-' . $subfield_name ];
1000 - unset( $field['shortcodes'][ 'aria-invalid-' . $subfield_name ] );
1001 - }
1002 -
1003 916 if ( 'opt' === $k || ! self::should_allow_input_attribute( $k ) ) {
1004 917 continue;
1005 918 }
1006 919
@@ -1012,9 +925,9 @@
1012 925 $add_html[ $k ] = $k . '="' . esc_attr( $v ) . '"';
1013 926 }
1014 927
1015 928 unset( $k, $v );
1016 - }//end foreach
929 + }
1017 930 }
1018 931
1019 932 /**
1020 933 * Disallow possibly unsafe attributees (that trigger JavaScript) when unasfe HTML is not allowed.
@@ -1021,9 +934,8 @@
1021 934 *
1022 935 * @since 6.11.2
1023 936 *
1024 937 * @param string $key The option key.
1025 - *
1026 938 * @return bool
1027 939 */
1028 940 private static function should_allow_input_attribute( $key ) {
1029 941 if ( ! FrmAppHelper::should_never_allow_unfiltered_html() ) {
@@ -1038,14 +950,12 @@
1038 950 * @since 3.0
1039 951 *
1040 952 * @param array $field
1041 953 * @param array $add_html
1042 - *
1043 954 * @return void
1044 955 */
1045 956 private static function add_pattern_attribute( $field, array &$add_html ) {
1046 - $format_value = FrmField::get_option( $field, 'format' );
1047 - $has_format = $format_value && ! FrmCurrencyHelper::is_currency_format( $format_value );
957 + $has_format = FrmField::is_option_true_in_array( $field, 'format' );
1048 958 $format_field = FrmField::is_field_type( $field, 'text' );
1049 959
1050 960 if ( $field['type'] === 'phone' || ( $has_format && $format_field ) ) {
1051 961 $format = FrmEntryValidate::phone_format( $field );
@@ -1054,21 +964,14 @@
1054 964 $add_html['pattern'] = 'pattern="' . esc_attr( $format ) . '"';
1055 965 }
1056 966 }
1057 967
1058 - /**
1059 - * @param mixed $opt
1060 - * @param mixed $opt_key
1061 - * @param array|object $field
1062 - *
1063 - * @return mixed
1064 - */
1065 968 public static function check_value( $opt, $opt_key, $field ) {
1066 969 if ( is_array( $opt ) ) {
1067 970 if ( FrmField::is_option_true( $field, 'separate_value' ) ) {
1068 - $opt = $opt['value'] ?? $opt['label'] ?? reset( $opt );
971 + $opt = isset( $opt['value'] ) ? $opt['value'] : ( isset( $opt['label'] ) ? $opt['label'] : reset( $opt ) );
1069 972 } else {
1070 - $opt = $opt['label'] ?? reset( $opt );
973 + $opt = isset( $opt['label'] ) ? $opt['label'] : reset( $opt );
1071 974 }
1072 975 }
1073 976
1074 977 return $opt;
@@ -1073,16 +976,11 @@
1073 976
1074 977 return $opt;
1075 978 }
1076 979
1077 - /**
1078 - * @param mixed $opt
1079 - *
1080 - * @return mixed
1081 - */
1082 980 public static function check_label( $opt ) {
1083 981 if ( is_array( $opt ) ) {
1084 - $opt = $opt['label'] ?? reset( $opt );
982 + $opt = isset( $opt['label'] ) ? $opt['label'] : reset( $opt );
1085 983 }
1086 984
1087 985 return $opt;
1088 986 }