PluginProbe
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More / 6.14.1
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More v6.14.1
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 +35 -135 6.266.14.1 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
@@ -503,20 +467,17 @@
503 467 * Display the format option
504 468 *
505 469 * @since 3.0
506 470 *
507 - * @param array $field Field data.
508 - * @param bool $is_hidden Whether the format option should be hidden.
509 - *
471 + * @param array $field
510 472 * @return void
511 473 */
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 - );
474 + public static function show_format_option( $field ) {
475 + $attributes = array();
476 + $attributes['class'] = 'frm-has-modal';
517 477
518 - if ( $is_hidden ) {
478 + if ( 'phone' === $field['type'] ) {
479 + $attributes['id'] = 'frm-phone-field-custom-format-' . $field['id'];
519 480 $attributes['class'] .= ' frm_hidden';
520 481 }
521 482
522 483 include FrmAppHelper::plugin_path() . '/classes/views/frm-fields/back-end/value-format.php';
@@ -521,14 +482,8 @@
521 482
522 483 include FrmAppHelper::plugin_path() . '/classes/views/frm-fields/back-end/value-format.php';
523 484 }
524 485
525 - /**
526 - * @param array $field
527 - * @param bool $echo
528 - *
529 - * @return string
530 - */
531 486 public static function input_html( $field, $echo = true ) {
532 487 $class = array();
533 488 self::add_input_classes( $field, $class );
534 489
@@ -557,9 +512,8 @@
557 512
558 513 /**
559 514 * @param array $field
560 515 * @param array $class
561 - *
562 516 * @return void
563 517 */
564 518 private static function add_input_classes( $field, array &$class ) {
565 519 if ( ! empty( $field['input_class'] ) ) {
@@ -577,9 +531,8 @@
577 531
578 532 /**
579 533 * @param array $field
580 534 * @param array $add_html
581 - *
582 535 * @return void
583 536 */
584 537 private static function add_html_size( $field, array &$add_html ) {
585 538 $size_fields = array(
@@ -612,9 +565,8 @@
612 565
613 566 /**
614 567 * @param array $field
615 568 * @param array $add_html
616 - *
617 569 * @return void
618 570 */
619 571 private static function add_html_cols( $field, array &$add_html ) {
620 572 if ( ! in_array( $field['type'], array( 'textarea', 'rte' ), true ) ) {
@@ -643,9 +595,8 @@
643 595
644 596 /**
645 597 * @param array $field
646 598 * @param array $add_html
647 - *
648 599 * @return void
649 600 */
650 601 private static function add_html_length( $field, array &$add_html ) {
651 602 // Check for max setting and if this field accepts maxlength.
@@ -671,9 +622,8 @@
671 622 /**
672 623 * @param array $field
673 624 * @param array $add_html
674 625 * @param array $class
675 - *
676 626 * @return void
677 627 */
678 628 private static function add_html_placeholder( $field, array &$add_html, array &$class ) {
679 629 if ( $field['default_value'] != '' ) {
@@ -684,9 +634,8 @@
684 634 }
685 635 }
686 636
687 637 $field['placeholder'] = self::prepare_placeholder( $field );
688 -
689 638 if ( $field['placeholder'] == '' || is_array( $field['placeholder'] ) ) {
690 639 // don't include a json placeholder
691 640 return;
692 641 }
@@ -699,13 +648,12 @@
699 648 *
700 649 * @since 5.4 This doesn't call `FrmFieldsController::get_default_value_from_name()` anymore.
701 650 *
702 651 * @param array $field Field array.
703 - *
704 652 * @return string
705 653 */
706 654 private static function prepare_placeholder( $field ) {
707 - $placeholder = $field['placeholder'] ?? '';
655 + $placeholder = isset( $field['placeholder'] ) ? $field['placeholder'] : '';
708 656
709 657 return $placeholder;
710 658 }
711 659
@@ -728,16 +676,12 @@
728 676 * Maybe add a blank placeholder option before any options
729 677 * in a dropdown.
730 678 *
731 679 * @since 4.04
732 - *
733 - * @param array|object $field
734 - *
735 680 * @return bool True if placeholder was added.
736 681 */
737 682 public static function add_placeholder_to_select( $field ) {
738 683 $placeholder = FrmField::get_option( $field, 'placeholder' );
739 -
740 684 if ( empty( $placeholder ) ) {
741 685 $placeholder = self::get_default_value_from_name( $field );
742 686 }
743 687
@@ -745,9 +689,8 @@
745 689 $autocomplete = FrmField::get_option( $field, 'autocom' );
746 690
747 691 if ( $autocomplete ) {
748 692 $use_chosen = ! is_callable( 'FrmProAppHelper::use_chosen_js' ) || FrmProAppHelper::use_chosen_js();
749 -
750 693 if ( $use_chosen ) {
751 694 $use_placeholder = '';
752 695 }
753 696 }
@@ -758,8 +701,13 @@
758 701 'value' => '',
759 702 'data-placeholder' => 'true',
760 703 );
761 704
705 + if ( $autocomplete && empty( $use_chosen ) ) {
706 + // This is required for Slim Select.
707 + $placeholder_attributes['data-placeholder'] = 'true';
708 + }
709 +
762 710 FrmHtmlHelper::echo_dropdown_option( $use_placeholder, false, $placeholder_attributes );
763 711 return true;
764 712 }
765 713
@@ -770,9 +718,8 @@
770 718 * Use HTML5 placeholder with js fallback.
771 719 *
772 720 * @param array $field
773 721 * @param array $add_html
774 - *
775 722 * @return void
776 723 */
777 724 private static function add_placeholder_to_input( $field, &$add_html ) {
778 725 if ( FrmFieldsHelper::is_placeholder_field_type( $field['type'] ) ) {
@@ -782,9 +729,8 @@
782 729
783 730 /**
784 731 * @param array $field
785 732 * @param array $add_html
786 - *
787 733 * @return void
788 734 */
789 735 private static function add_frmval_to_input( $field, &$add_html ) {
790 736 if ( $field['placeholder'] != '' ) {
@@ -799,14 +745,8 @@
799 745 $add_html['data-frmval'] = 'data-frmval="' . esc_attr( $field['default_value'] ) . '"';
800 746 }
801 747 }
802 748
803 - /**
804 - * @param array $field
805 - * @param array $add_html
806 - *
807 - * @return void
808 - */
809 749 private static function add_validation_messages( $field, array &$add_html ) {
810 750 $field_validation_messages_status = self::get_validation_data_attribute_visibility_info( $field );
811 751
812 752 if ( FrmField::is_required( $field ) && ! empty( $field_validation_messages_status['data-reqmsg'] ) ) {
@@ -830,9 +770,8 @@
830 770 *
831 771 * @since 6.9
832 772 *
833 773 * @param array|object $field
834 - *
835 774 * @return array
836 775 */
837 776 private static function get_validation_data_attribute_visibility_info( $field ) {
838 777 if ( FrmField::get_field_type( $field ) === 'hidden' ) {
@@ -862,20 +801,17 @@
862 801 * @since 5.0.03
863 802 *
864 803 * @param array $field
865 804 * @param array $add_html
866 - *
867 805 * @return void
868 806 */
869 807 private static function maybe_add_error_html_for_js_validation( $field, array &$add_html ) {
870 808 $form = self::get_form_for_js_validation( $field );
871 -
872 809 if ( false === $form ) {
873 810 return;
874 811 }
875 812
876 813 $error_body = self::pull_custom_error_body_from_custom_html( $form, $field );
877 -
878 814 if ( false !== $error_body ) {
879 815 $error_body = urlencode( $error_body );
880 816 $add_html['data-error-html'] = 'data-error-html="' . esc_attr( $error_body ) . '"';
881 817 }
@@ -884,19 +820,16 @@
884 820 /**
885 821 * @since 5.0.03
886 822 *
887 823 * @param array $field
888 - *
889 824 * @return false|stdClass false if there is no form object found with JS validation active.
890 825 */
891 826 private static function get_form_for_js_validation( $field ) {
892 827 global $frm_vars;
893 -
894 828 if ( ! empty( $frm_vars['js_validate_forms'] ) ) {
895 829 if ( isset( $frm_vars['js_validate_forms'][ $field['form_id'] ] ) ) {
896 830 return $frm_vars['js_validate_forms'][ $field['form_id'] ];
897 831 }
898 -
899 832 if ( ! empty( $field['parent_form_id'] ) && isset( $frm_vars['js_validate_forms'][ $field['parent_form_id'] ] ) ) {
900 833 return $frm_vars['js_validate_forms'][ $field['parent_form_id'] ];
901 834 }
902 835 }
@@ -906,9 +839,8 @@
906 839 /**
907 840 * @param stdClass $form
908 841 * @param array $field
909 842 * @param array $errors
910 - *
911 843 * @return false|string
912 844 */
913 845 public static function pull_custom_error_body_from_custom_html( $form, $field, $errors = array() ) {
914 846 if ( empty( $field['custom_html'] ) ) {
@@ -918,15 +850,13 @@
918 850 $custom_html = $field['custom_html'];
919 851 $custom_html = apply_filters( 'frm_before_replace_shortcodes', $custom_html, $field, $errors, $form );
920 852
921 853 $start = strpos( $custom_html, '[if error]' );
922 -
923 854 if ( false === $start ) {
924 855 return false;
925 856 }
926 857
927 858 $end = strpos( $custom_html, '[/if error]' );
928 -
929 859 if ( false === $end || $end < $start ) {
930 860 return false;
931 861 }
932 862
@@ -950,12 +880,10 @@
950 880 * submit in many browsers. Check to make sure the javascript to conditionally
951 881 * remove it is present if needed.
952 882 *
953 883 * @since 3.06.01
954 - *
955 884 * @param array $field
956 885 * @param array $add_html
957 - *
958 886 * @return void
959 887 */
960 888 private static function maybe_add_html_required( $field, array &$add_html ) {
961 889 $excluded_field_types =
@@ -974,9 +902,8 @@
974 902
975 903 /**
976 904 * @param array $field
977 905 * @param array $add_html
978 - *
979 906 * @return void
980 907 */
981 908 private static function add_shortcodes_to_html( $field, array &$add_html ) {
982 909 if ( FrmField::is_option_empty( $field, 'shortcodes' ) ) {
@@ -987,20 +914,8 @@
987 914 unset( $field['shortcodes']['autocomplete'] );
988 915 }
989 916
990 917 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 918 if ( 'opt' === $k || ! self::should_allow_input_attribute( $k ) ) {
1004 919 continue;
1005 920 }
1006 921
@@ -1012,9 +927,9 @@
1012 927 $add_html[ $k ] = $k . '="' . esc_attr( $v ) . '"';
1013 928 }
1014 929
1015 930 unset( $k, $v );
1016 - }//end foreach
931 + }
1017 932 }
1018 933
1019 934 /**
1020 935 * Disallow possibly unsafe attributees (that trigger JavaScript) when unasfe HTML is not allowed.
@@ -1021,9 +936,8 @@
1021 936 *
1022 937 * @since 6.11.2
1023 938 *
1024 939 * @param string $key The option key.
1025 - *
1026 940 * @return bool
1027 941 */
1028 942 private static function should_allow_input_attribute( $key ) {
1029 943 if ( ! FrmAppHelper::should_never_allow_unfiltered_html() ) {
@@ -1038,14 +952,12 @@
1038 952 * @since 3.0
1039 953 *
1040 954 * @param array $field
1041 955 * @param array $add_html
1042 - *
1043 956 * @return void
1044 957 */
1045 958 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 );
959 + $has_format = FrmField::is_option_true_in_array( $field, 'format' );
1048 960 $format_field = FrmField::is_field_type( $field, 'text' );
1049 961
1050 962 if ( $field['type'] === 'phone' || ( $has_format && $format_field ) ) {
1051 963 $format = FrmEntryValidate::phone_format( $field );
@@ -1054,21 +966,14 @@
1054 966 $add_html['pattern'] = 'pattern="' . esc_attr( $format ) . '"';
1055 967 }
1056 968 }
1057 969
1058 - /**
1059 - * @param mixed $opt
1060 - * @param mixed $opt_key
1061 - * @param array|object $field
1062 - *
1063 - * @return mixed
1064 - */
1065 970 public static function check_value( $opt, $opt_key, $field ) {
1066 971 if ( is_array( $opt ) ) {
1067 972 if ( FrmField::is_option_true( $field, 'separate_value' ) ) {
1068 - $opt = $opt['value'] ?? $opt['label'] ?? reset( $opt );
973 + $opt = isset( $opt['value'] ) ? $opt['value'] : ( isset( $opt['label'] ) ? $opt['label'] : reset( $opt ) );
1069 974 } else {
1070 - $opt = $opt['label'] ?? reset( $opt );
975 + $opt = isset( $opt['label'] ) ? $opt['label'] : reset( $opt );
1071 976 }
1072 977 }
1073 978
1074 979 return $opt;
@@ -1073,16 +978,11 @@
1073 978
1074 979 return $opt;
1075 980 }
1076 981
1077 - /**
1078 - * @param mixed $opt
1079 - *
1080 - * @return mixed
1081 - */
1082 982 public static function check_label( $opt ) {
1083 983 if ( is_array( $opt ) ) {
1084 - $opt = $opt['label'] ?? reset( $opt );
984 + $opt = isset( $opt['label'] ) ? $opt['label'] : reset( $opt );
1085 985 }
1086 986
1087 987 return $opt;
1088 988 }