PluginProbe
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More / 6.24
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More v6.24
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 +43 -107 6.276.24 View file →
@@ -18,10 +18,9 @@
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 - if ( ! $fields ) {
22 + if ( empty( $fields ) ) {
24 23 wp_die();
25 24 }
26 25
27 26 $_GET['page'] = 'formidable';
@@ -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 }
@@ -49,10 +47,11 @@
49 47 $field->default_value = json_decode( json_encode( $field->default_value ), true );
50 48
51 49 ob_start();
52 50 self::load_single_field( $field, $values );
53 - $field_html[ absint( $field->id ) ] = ob_get_clean();
54 - }//end foreach
51 + $field_html[ absint( $field->id ) ] = ob_get_contents();
52 + ob_end_clean();
53 + }
55 54
56 55 echo json_encode( $field_html );
57 56
58 57 wp_die();
@@ -90,9 +89,9 @@
90 89 */
91 90 public static function include_new_field( $field_type, $form_id, $field_options = array() ) {
92 91 $field_values = FrmFieldsHelper::setup_new_vars( $field_type, $form_id );
93 92
94 - if ( $field_options ) {
93 + if ( ! empty( $field_options ) ) {
95 94 $field_values['field_options'] = array_merge( $field_values['field_options'], $field_options );
96 95 }
97 96
98 97 // When a new field is added to the form, flag it as draft and hide it from the front-end.
@@ -107,15 +106,15 @@
107 106 if ( ! $field_id ) {
108 107 return false;
109 108 }
110 109
111 - $field = self::get_field_array_from_id( $field_id );
110 + $field = self::get_field_array_from_id( $field_id );
111 +
112 112 $values = array();
113 -
114 113 if ( FrmAppHelper::pro_is_installed() ) {
115 114 $values['post_type'] = FrmProFormsHelper::post_type( $form_id );
116 - $parent_form_id = FrmDb::get_var( 'frm_forms', array( 'id' => $form_id ), 'parent_form_id' );
117 115
116 + $parent_form_id = FrmDb::get_var( 'frm_forms', array( 'id' => $form_id ), 'parent_form_id' );
118 117 if ( $parent_form_id ) {
119 118 $field['parent_form_id'] = $parent_form_id;
120 119 }
121 120 }
@@ -128,10 +127,11 @@
128 127 public static function duplicate() {
129 128 FrmAppHelper::permission_check( 'frm_edit_forms' );
130 129 check_ajax_referer( 'frm_ajax', 'nonce' );
131 130
132 - $field_id = FrmAppHelper::get_post_param( 'field_id', 0, 'absint' );
133 - $form_id = FrmAppHelper::get_post_param( 'form_id', 0, 'absint' );
131 + $field_id = FrmAppHelper::get_post_param( 'field_id', 0, 'absint' );
132 + $form_id = FrmAppHelper::get_post_param( 'form_id', 0, 'absint' );
133 +
134 134 $new_field = FrmField::duplicate_single_field( $field_id, $form_id );
135 135
136 136 if ( is_array( $new_field ) && ! empty( $new_field['field_id'] ) ) {
137 137 self::load_single_field( $new_field['field_id'], $new_field['values'] );
@@ -148,8 +148,9 @@
148 148 * @return array
149 149 */
150 150 public static function get_field_array_from_id( $field_id ) {
151 151 $field = FrmField::getOne( $field_id );
152 +
152 153 return FrmFieldsHelper::setup_edit_vars( $field );
153 154 }
154 155
155 156 /**
@@ -157,10 +158,8 @@
157 158 *
158 159 * @param array|int|object $field_object
159 160 * @param array $values
160 161 * @param int $form_id
161 - *
162 - * @return void
163 162 */
164 163 public static function load_single_field( $field_object, $values, $form_id = 0 ) {
165 164 global $frm_vars;
166 165 $frm_vars['is_admin'] = true;
@@ -171,10 +170,11 @@
171 170 $field = $field_object;
172 171 $field_object = FrmField::getOne( $field['id'] );
173 172 }
174 173
175 - $field_obj = FrmFieldFactory::get_field_factory( $field_object );
176 - $display = self::display_field_options( array(), $field_obj );
174 + $field_obj = FrmFieldFactory::get_field_factory( $field_object );
175 + $display = self::display_field_options( array(), $field_obj );
176 +
177 177 $ajax_loading = ! empty( $values['ajax_load'] );
178 178 $ajax_this_field = isset( $values['count'] ) && $values['count'] > 10 && ! in_array( $field_object->type, array( 'divider', 'end_divider' ), true );
179 179
180 180 if ( $ajax_loading && $ajax_this_field ) {
@@ -183,9 +183,9 @@
183 183 return;
184 184 }
185 185
186 186 if ( ! isset( $field ) && is_object( $field_object ) ) {
187 - $field_object->parent_form_id = $values['id'] ?? $field_object->form_id;
187 + $field_object->parent_form_id = isset( $values['id'] ) ? $values['id'] : $field_object->form_id;
188 188 $field = FrmFieldsHelper::setup_edit_vars( $field_object );
189 189 }
190 190
191 191 /**
@@ -210,9 +210,8 @@
210 210 *
211 211 * @param array $field
212 212 * @param array $display
213 213 * @param FrmFieldType $field_info
214 - *
215 214 * @return string
216 215 */
217 216 private static function get_classes_for_builder_field( $field, $display, $field_info ) {
218 217 $li_classes = $field_info->form_builder_classes( $display['type'] );
@@ -260,9 +259,8 @@
260 259 *
261 260 * @since 6.8.4
262 261 *
263 262 * @param array $bulk_edit_types
264 - *
265 263 * @return array
266 264 */
267 265 $bulk_edit_types = apply_filters( 'frm_bulk_edit_field_types', $bulk_edit_types );
268 266
@@ -270,19 +268,18 @@
270 268 return;
271 269 }
272 270
273 271 $field = FrmFieldsHelper::setup_edit_vars( $field );
272 + $opts = FrmAppHelper::get_param( 'opts', '', 'post', 'wp_kses_post' );
273 + $opts = explode( "\n", rtrim( $opts, "\n" ) );
274 + $opts = array_map( 'trim', $opts );
274 275
275 - $opts = FrmAppHelper::get_param( 'opts', '', 'post', 'wp_kses_post' );
276 - $opts = explode( "\n", rtrim( $opts, "\n" ) );
277 - $opts = array_map( 'trim', $opts );
278 -
279 276 $separate = FrmAppHelper::get_param( 'separate', '', 'post', 'sanitize_text_field' );
280 277 $field['separate_value'] = $separate === 'true';
281 278
282 279 if ( $field['separate_value'] ) {
283 280 foreach ( $opts as $opt_key => $opt ) {
284 - if ( str_contains( $opt, '|' ) ) {
281 + if ( strpos( $opt, '|' ) !== false ) {
285 282 $vals = explode( '|', $opt );
286 283 $opts[ $opt_key ] = array(
287 284 'label' => trim( $vals[0] ),
288 285 'value' => trim( $vals[1] ),
@@ -293,12 +290,10 @@
293 290 }
294 291 }
295 292
296 293 // Keep other options after bulk update.
297 - // phpcs:ignore Universal.Operators.StrictComparisons
298 - if ( ! empty( $field['field_options']['other'] ) ) {
294 + if ( isset( $field['field_options']['other'] ) && $field['field_options']['other'] == true ) {
299 295 $other_array = array();
300 -
301 296 foreach ( $field['options'] as $opt_key => $opt ) {
302 297 if ( FrmFieldsHelper::is_other_opt( $opt_key ) ) {
303 298 $other_array[ $opt_key ] = $opt;
304 299 }
@@ -303,10 +298,9 @@
303 298 $other_array[ $opt_key ] = $opt;
304 299 }
305 300 unset( $opt_key, $opt );
306 301 }
307 -
308 - if ( $other_array ) {
302 + if ( ! empty( $other_array ) ) {
309 303 $opts = array_merge( $opts, $other_array );
310 304 }
311 305 }
312 306
@@ -320,9 +314,8 @@
320 314 /**
321 315 * @since 4.0
322 316 *
323 317 * @param array $atts - Includes field array, field_obj, display array, values array.
324 - *
325 318 * @return void
326 319 */
327 320 public static function load_single_field_settings( $atts ) {
328 321 $field = $atts['field'];
@@ -348,9 +341,9 @@
348 341 if ( ! isset( $all_field_types[ $field['type'] ] ) ) {
349 342 // Add fallback for an add-on field type that has been deactivated.
350 343 $all_field_types[ $field['type'] ] = array(
351 344 'name' => ucfirst( $field['type'] ),
352 - 'icon' => 'frmfont frm_pencil_icon',
345 + 'icon' => 'frm_icon_font frm_pencil_icon',
353 346 );
354 347 } elseif ( ! is_array( $all_field_types[ $field['type'] ] ) ) {
355 348 // Fallback for fields added in a more basic way.
356 349 FrmFormsHelper::prepare_field_type( $all_field_types[ $field['type'] ] );
@@ -356,9 +349,8 @@
356 349 FrmFormsHelper::prepare_field_type( $all_field_types[ $field['type'] ] );
357 350 }
358 351
359 352 $type_name = $all_field_types[ $field['type'] ]['name'];
360 -
361 353 if ( $field['type'] === 'divider' && FrmField::is_option_true( $field, 'repeat' ) ) {
362 354 $type_name = $all_field_types['divider|repeat']['name'];
363 355 }
364 356
@@ -391,9 +383,8 @@
391 383 * @since 4.0
392 384 *
393 385 * @param array $field
394 386 * @param array $atts
395 - *
396 387 * @return array
397 388 */
398 389 private static function default_value_types( $field, $atts ) {
399 390 $types = array(
@@ -398,9 +389,9 @@
398 389 private static function default_value_types( $field, $atts ) {
399 390 $types = array(
400 391 'default_value' => array(
401 392 'class' => '',
402 - 'icon' => 'frmfont frm_text2_icon',
393 + 'icon' => 'frm_icon_font frm_text2_icon',
403 394 'title' => __( 'Default Value', 'formidable' ),
404 395 'data' => array(
405 396 'frmshow' => '#default-value-for-',
406 397 ),
@@ -407,9 +398,9 @@
407 398 ),
408 399 'calc' => array(
409 400 'class' => 'frm_show_upgrade frm_noallow',
410 401 'title' => __( 'Calculate Value', 'formidable' ),
411 - 'icon' => 'frmfont frm_calculator_icon',
402 + 'icon' => 'frm_icon_font frm_calculator_icon',
412 403 'data' => array(
413 404 'medium' => 'calculations',
414 405 'upgrade' => __( 'Calculator forms', 'formidable' ),
415 406 ),
@@ -417,9 +408,9 @@
417 408 ),
418 409 'get_values_field' => array(
419 410 'class' => 'frm_show_upgrade frm_noallow',
420 411 'title' => __( 'Lookup', 'formidable' ),
421 - 'icon' => 'frmfont frm_search_icon',
412 + 'icon' => 'frm_icon_font frm_search_icon',
422 413 'data' => array(
423 414 'medium' => 'lookup',
424 415 'upgrade' => __( 'Lookup fields', 'formidable' ),
425 416 ),
@@ -448,9 +439,8 @@
448 439 }
449 440
450 441 /**
451 442 * @param string $type
452 - *
453 443 * @return string
454 444 */
455 445 public static function change_type( $type ) {
456 446 $type_switch = array(
@@ -460,9 +450,8 @@
460 450 'rte' => 'textarea',
461 451 'website' => 'url',
462 452 'image' => 'url',
463 453 );
464 -
465 454 if ( isset( $type_switch[ $type ] ) ) {
466 455 $type = $type_switch[ $type ];
467 456 }
468 457
@@ -501,9 +490,8 @@
501 490 * @since 3.0
502 491 *
503 492 * @param array $field Field data.
504 493 * @param bool $is_hidden Whether the format option should be hidden.
505 - *
506 494 * @return void
507 495 */
508 496 public static function show_format_option( $field, $is_hidden = false ) {
509 497 $attributes = array(
@@ -517,14 +505,8 @@
517 505
518 506 include FrmAppHelper::plugin_path() . '/classes/views/frm-fields/back-end/value-format.php';
519 507 }
520 508
521 - /**
522 - * @param array $field
523 - * @param bool $echo
524 - *
525 - * @return string
526 - */
527 509 public static function input_html( $field, $echo = true ) {
528 510 $class = array();
529 511 self::add_input_classes( $field, $class );
530 512
@@ -553,9 +535,8 @@
553 535
554 536 /**
555 537 * @param array $field
556 538 * @param array $class
557 - *
558 539 * @return void
559 540 */
560 541 private static function add_input_classes( $field, array &$class ) {
561 542 if ( ! empty( $field['input_class'] ) ) {
@@ -573,9 +554,8 @@
573 554
574 555 /**
575 556 * @param array $field
576 557 * @param array $add_html
577 - *
578 558 * @return void
579 559 */
580 560 private static function add_html_size( $field, array &$add_html ) {
581 561 $size_fields = array(
@@ -608,9 +588,8 @@
608 588
609 589 /**
610 590 * @param array $field
611 591 * @param array $add_html
612 - *
613 592 * @return void
614 593 */
615 594 private static function add_html_cols( $field, array &$add_html ) {
616 595 if ( ! in_array( $field['type'], array( 'textarea', 'rte' ), true ) ) {
@@ -631,9 +610,10 @@
631 610 if ( ! isset( $calc[ $unit ] ) ) {
632 611 return;
633 612 }
634 613
635 - $size = (float) str_replace( $unit, '', $field['size'] ) / $calc[ $unit ];
614 + $size = (float) str_replace( $unit, '', $field['size'] ) / $calc[ $unit ];
615 +
636 616 $add_html['cols'] = 'cols="' . absint( $size ) . '"';
637 617 }
638 618
639 619 /**
@@ -638,9 +618,8 @@
638 618
639 619 /**
640 620 * @param array $field
641 621 * @param array $add_html
642 - *
643 622 * @return void
644 623 */
645 624 private static function add_html_length( $field, array &$add_html ) {
646 625 // Check for max setting and if this field accepts maxlength.
@@ -666,13 +645,11 @@
666 645 /**
667 646 * @param array $field
668 647 * @param array $add_html
669 648 * @param array $class
670 - *
671 649 * @return void
672 650 */
673 651 private static function add_html_placeholder( $field, array &$add_html, array &$class ) {
674 - // phpcs:ignore Universal.Operators.StrictComparisons
675 652 if ( $field['default_value'] != '' ) {
676 653 if ( is_array( $field['default_value'] ) ) {
677 654 $add_html['data-frmval'] = 'data-frmval="' . esc_attr( json_encode( $field['default_value'] ) ) . '"';
678 655 } else {
@@ -680,10 +657,8 @@
680 657 }
681 658 }
682 659
683 660 $field['placeholder'] = self::prepare_placeholder( $field );
684 -
685 - // phpcs:ignore Universal.Operators.StrictComparisons
686 661 if ( $field['placeholder'] == '' || is_array( $field['placeholder'] ) ) {
687 662 // don't include a json placeholder
688 663 return;
689 664 }
@@ -696,13 +671,14 @@
696 671 *
697 672 * @since 5.4 This doesn't call `FrmFieldsController::get_default_value_from_name()` anymore.
698 673 *
699 674 * @param array $field Field array.
700 - *
701 675 * @return string
702 676 */
703 677 private static function prepare_placeholder( $field ) {
704 - return $field['placeholder'] ?? '';
678 + $placeholder = isset( $field['placeholder'] ) ? $field['placeholder'] : '';
679 +
680 + return $placeholder;
705 681 }
706 682
707 683 /**
708 684 * If the label position is "inside",
@@ -723,17 +699,13 @@
723 699 * Maybe add a blank placeholder option before any options
724 700 * in a dropdown.
725 701 *
726 702 * @since 4.04
727 - *
728 - * @param array|object $field
729 - *
730 703 * @return bool True if placeholder was added.
731 704 */
732 705 public static function add_placeholder_to_select( $field ) {
733 706 $placeholder = FrmField::get_option( $field, 'placeholder' );
734 -
735 - if ( ! $placeholder ) {
707 + if ( empty( $placeholder ) ) {
736 708 $placeholder = self::get_default_value_from_name( $field );
737 709 }
738 710
739 711 $use_placeholder = $placeholder;
@@ -740,9 +712,8 @@
740 712 $autocomplete = FrmField::get_option( $field, 'autocom' );
741 713
742 714 if ( $autocomplete ) {
743 715 $use_chosen = ! is_callable( 'FrmProAppHelper::use_chosen_js' ) || FrmProAppHelper::use_chosen_js();
744 -
745 716 if ( $use_chosen ) {
746 717 $use_placeholder = '';
747 718 }
748 719 }
@@ -765,9 +736,8 @@
765 736 * Use HTML5 placeholder with js fallback.
766 737 *
767 738 * @param array $field
768 739 * @param array $add_html
769 - *
770 740 * @return void
771 741 */
772 742 private static function add_placeholder_to_input( $field, &$add_html ) {
773 743 if ( FrmFieldsHelper::is_placeholder_field_type( $field['type'] ) ) {
@@ -777,13 +747,11 @@
777 747
778 748 /**
779 749 * @param array $field
780 750 * @param array $add_html
781 - *
782 751 * @return void
783 752 */
784 753 private static function add_frmval_to_input( $field, &$add_html ) {
785 - // phpcs:ignore Universal.Operators.StrictComparisons
786 754 if ( $field['placeholder'] != '' ) {
787 755 $add_html['data-frmval'] = 'data-frmval="' . esc_attr( $field['placeholder'] ) . '"';
788 756
789 757 if ( 'select' === $field['type'] ) {
@@ -790,20 +758,13 @@
790 758 $add_html['data-frmplaceholder'] = 'data-frmplaceholder="' . esc_attr( $field['placeholder'] ) . '"';
791 759 }
792 760 }
793 761
794 - // phpcs:ignore Universal.Operators.StrictComparisons
795 762 if ( $field['default_value'] != '' ) {
796 763 $add_html['data-frmval'] = 'data-frmval="' . esc_attr( $field['default_value'] ) . '"';
797 764 }
798 765 }
799 766
800 - /**
801 - * @param array $field
802 - * @param array $add_html
803 - *
804 - * @return void
805 - */
806 767 private static function add_validation_messages( $field, array &$add_html ) {
807 768 $field_validation_messages_status = self::get_validation_data_attribute_visibility_info( $field );
808 769
809 770 if ( FrmField::is_required( $field ) && ! empty( $field_validation_messages_status['data-reqmsg'] ) ) {
@@ -827,9 +788,8 @@
827 788 *
828 789 * @since 6.9
829 790 *
830 791 * @param array|object $field
831 - *
832 792 * @return array
833 793 */
834 794 private static function get_validation_data_attribute_visibility_info( $field ) {
835 795 if ( FrmField::get_field_type( $field ) === 'hidden' ) {
@@ -859,20 +819,17 @@
859 819 * @since 5.0.03
860 820 *
861 821 * @param array $field
862 822 * @param array $add_html
863 - *
864 823 * @return void
865 824 */
866 825 private static function maybe_add_error_html_for_js_validation( $field, array &$add_html ) {
867 826 $form = self::get_form_for_js_validation( $field );
868 -
869 827 if ( false === $form ) {
870 828 return;
871 829 }
872 830
873 831 $error_body = self::pull_custom_error_body_from_custom_html( $form, $field );
874 -
875 832 if ( false !== $error_body ) {
876 833 $error_body = urlencode( $error_body );
877 834 $add_html['data-error-html'] = 'data-error-html="' . esc_attr( $error_body ) . '"';
878 835 }
@@ -881,24 +838,20 @@
881 838 /**
882 839 * @since 5.0.03
883 840 *
884 841 * @param array $field
885 - *
886 842 * @return false|stdClass false if there is no form object found with JS validation active.
887 843 */
888 844 private static function get_form_for_js_validation( $field ) {
889 845 global $frm_vars;
890 -
891 846 if ( ! empty( $frm_vars['js_validate_forms'] ) ) {
892 847 if ( isset( $frm_vars['js_validate_forms'][ $field['form_id'] ] ) ) {
893 848 return $frm_vars['js_validate_forms'][ $field['form_id'] ];
894 849 }
895 -
896 850 if ( ! empty( $field['parent_form_id'] ) && isset( $frm_vars['js_validate_forms'][ $field['parent_form_id'] ] ) ) {
897 851 return $frm_vars['js_validate_forms'][ $field['parent_form_id'] ];
898 852 }
899 853 }
900 -
901 854 return false;
902 855 }
903 856
904 857 /**
@@ -904,9 +857,8 @@
904 857 /**
905 858 * @param stdClass $form
906 859 * @param array $field
907 860 * @param array $errors
908 - *
909 861 * @return false|string
910 862 */
911 863 public static function pull_custom_error_body_from_custom_html( $form, $field, $errors = array() ) {
912 864 if ( empty( $field['custom_html'] ) ) {
@@ -914,16 +866,15 @@
914 866 }
915 867
916 868 $custom_html = $field['custom_html'];
917 869 $custom_html = apply_filters( 'frm_before_replace_shortcodes', $custom_html, $field, $errors, $form );
918 - $start = strpos( $custom_html, '[if error]' );
919 870
871 + $start = strpos( $custom_html, '[if error]' );
920 872 if ( false === $start ) {
921 873 return false;
922 874 }
923 875
924 876 $end = strpos( $custom_html, '[/if error]' );
925 -
926 877 if ( false === $end || $end < $start ) {
927 878 return false;
928 879 }
929 880
@@ -934,9 +885,13 @@
934 885 '<div class="frm_error">[error]</div>',
935 886 '<div class="frm_error" role="alert">[error]</div>',
936 887 );
937 888
938 - return in_array( $error_body, $default_html, true ) ? false : $error_body;
889 + if ( in_array( $error_body, $default_html, true ) ) {
890 + return false;
891 + }
892 +
893 + return $error_body;
939 894 }
940 895
941 896 /**
942 897 * If 'required' is added to a conditionally hidden field, the form won't
@@ -943,12 +898,10 @@
943 898 * submit in many browsers. Check to make sure the javascript to conditionally
944 899 * remove it is present if needed.
945 900 *
946 901 * @since 3.06.01
947 - *
948 902 * @param array $field
949 903 * @param array $add_html
950 - *
951 904 * @return void
952 905 */
953 906 private static function maybe_add_html_required( $field, array &$add_html ) {
954 907 $excluded_field_types =
@@ -967,9 +920,8 @@
967 920
968 921 /**
969 922 * @param array $field
970 923 * @param array $add_html
971 - *
972 924 * @return void
973 925 */
974 926 private static function add_shortcodes_to_html( $field, array &$add_html ) {
975 927 if ( FrmField::is_option_empty( $field, 'shortcodes' ) ) {
@@ -980,11 +932,10 @@
980 932 unset( $field['shortcodes']['autocomplete'] );
981 933 }
982 934
983 935 foreach ( $field['shortcodes'] as $k => $v ) {
984 - if ( isset( $field['subfield_name'] ) && str_starts_with( $k, 'aria-invalid' ) ) {
936 + if ( isset( $field['subfield_name'] ) && 0 === strpos( $k, 'aria-invalid' ) ) {
985 937 $subfield_name = $field['subfield_name'];
986 -
987 938 if ( ! isset( $field['shortcodes'][ 'aria-invalid-' . $subfield_name ] ) ) {
988 939 continue;
989 940 }
990 941 // Change the key to the correct aria-invalid value so that $add_html is set correctly for the current subfield of a combo field.
@@ -991,14 +942,13 @@
991 942 $k = 'aria-invalid';
992 943 $v = $field['shortcodes'][ 'aria-invalid-' . $subfield_name ];
993 944 unset( $field['shortcodes'][ 'aria-invalid-' . $subfield_name ] );
994 945 }
995 -
996 946 if ( 'opt' === $k || ! self::should_allow_input_attribute( $k ) ) {
997 947 continue;
998 948 }
999 949
1000 - if ( is_numeric( $k ) && str_contains( $v, '=' ) ) {
950 + if ( is_numeric( $k ) && strpos( $v, '=' ) ) {
1001 951 $add_html[] = $v;
1002 952 } elseif ( ! empty( $k ) && isset( $add_html[ $k ] ) ) {
1003 953 $add_html[ $k ] = str_replace( $k . '="', $k . '="' . $v, $add_html[ $k ] );
1004 954 } else {
@@ -1014,9 +964,8 @@
1014 964 *
1015 965 * @since 6.11.2
1016 966 *
1017 967 * @param string $key The option key.
1018 - *
1019 968 * @return bool
1020 969 */
1021 970 private static function should_allow_input_attribute( $key ) {
1022 971 if ( ! FrmAppHelper::should_never_allow_unfiltered_html() ) {
@@ -1031,9 +980,8 @@
1031 980 * @since 3.0
1032 981 *
1033 982 * @param array $field
1034 983 * @param array $add_html
1035 - *
1036 984 * @return void
1037 985 */
1038 986 private static function add_pattern_attribute( $field, array &$add_html ) {
1039 987 $format_value = FrmField::get_option( $field, 'format' );
@@ -1047,21 +995,14 @@
1047 995 $add_html['pattern'] = 'pattern="' . esc_attr( $format ) . '"';
1048 996 }
1049 997 }
1050 998
1051 - /**
1052 - * @param mixed $opt
1053 - * @param mixed $opt_key
1054 - * @param array|object $field
1055 - *
1056 - * @return mixed
1057 - */
1058 999 public static function check_value( $opt, $opt_key, $field ) {
1059 1000 if ( is_array( $opt ) ) {
1060 1001 if ( FrmField::is_option_true( $field, 'separate_value' ) ) {
1061 - $opt = $opt['value'] ?? $opt['label'] ?? reset( $opt );
1002 + $opt = isset( $opt['value'] ) ? $opt['value'] : ( isset( $opt['label'] ) ? $opt['label'] : reset( $opt ) );
1062 1003 } else {
1063 - $opt = $opt['label'] ?? reset( $opt );
1004 + $opt = isset( $opt['label'] ) ? $opt['label'] : reset( $opt );
1064 1005 }
1065 1006 }
1066 1007
1067 1008 return $opt;
@@ -1066,16 +1007,11 @@
1066 1007
1067 1008 return $opt;
1068 1009 }
1069 1010
1070 - /**
1071 - * @param mixed $opt
1072 - *
1073 - * @return mixed
1074 - */
1075 1011 public static function check_label( $opt ) {
1076 1012 if ( is_array( $opt ) ) {
1077 - $opt = $opt['label'] ?? reset( $opt );
1013 + $opt = isset( $opt['label'] ) ? $opt['label'] : reset( $opt );
1078 1014 }
1079 1015
1080 1016 return $opt;
1081 1017 }