| @@ -1,5 +1,15 @@ | ||
| 1 | 1 | <?php |
| 2 | +/** | |
| 3 | + * Radio field front-end input. | |
| 4 | + * | |
| 5 | + * @package Formidable | |
| 6 | + * | |
| 7 | + * @var array $field Field data including 'post_field', 'type', 'options', 'value'. | |
| 8 | + * @var string $field_name HTML name attribute for the radio inputs. | |
| 9 | + * @var string $html_id HTML id prefix for each radio option. | |
| 10 | + */ | |
| 11 | + | |
| 2 | 12 | if ( ! defined( 'ABSPATH' ) ) { |
| 3 | 13 | die( 'You are not allowed to call this page directly.' ); |
| 4 | 14 | } |
| 5 | 15 | |
| @@ -6,21 +16,17 @@ | ||
| 6 | 16 | if ( isset( $field['post_field'] ) && $field['post_field'] === 'post_category' ) { |
| 7 | 17 | $type = $field['type']; |
| 8 | 18 | do_action( 'frm_after_checkbox', compact( 'field', 'field_name', 'type' ) ); |
| 9 | 19 | } elseif ( is_array( $field['options'] ) ) { |
| 10 | - | |
| 11 | 20 | foreach ( $field['options'] as $opt_key => $opt ) { |
| 12 | - | |
| 13 | 21 | $field_val = FrmFieldsHelper::get_value_from_array( $opt, $opt_key, $field ); |
| 14 | - $opt = FrmFieldsHelper::get_label_from_array( $opt, $opt_key, $field ); | |
| 22 | + $opt = FrmFieldsHelper::get_label_from_array( $opt, $opt_key, $field ); | |
| 15 | 23 | ?> |
| 16 | 24 | <div class="frm_radio"> |
| 17 | 25 | <label for="<?php echo esc_attr( $html_id . '-' . $opt_key ); ?>"> |
| 18 | 26 | <?php |
| 19 | - | |
| 20 | - $checked = FrmAppHelper::check_selected( $field['value'], $field_val ) ? 'checked="checked" ' : ' '; | |
| 21 | - | |
| 22 | - $other_opt = false; | |
| 27 | + $checked = FrmAppHelper::check_selected( $field['value'], $field_val ) ? 'checked="checked" ' : ' '; | |
| 28 | + $other_opt = false; | |
| 23 | 29 | $other_args = FrmFieldsHelper::prepare_other_input( compact( 'field_name', 'opt_key', 'field' ), $other_opt, $checked ); |
| 24 | 30 | ?> |
| 25 | 31 | <input type="radio" name="<?php echo esc_attr( $field_name ); ?>" id="<?php echo esc_attr( $html_id . '-' . $opt_key ); ?>" value="<?php echo esc_attr( $field_val ); ?>" <?php |
| 26 | 32 | echo $checked; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
| @@ -25,9 +31,12 @@ | ||
| 25 | 31 | <input type="radio" name="<?php echo esc_attr( $field_name ); ?>" id="<?php echo esc_attr( $html_id . '-' . $opt_key ); ?>" value="<?php echo esc_attr( $field_val ); ?>" <?php |
| 26 | 32 | echo $checked; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
| 27 | 33 | do_action( 'frm_field_input_html', $field ); |
| 28 | 34 | ?>/> |
| 29 | - <?php echo ' ' . FrmAppHelper::kses( $opt, 'all' ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?> | |
| 35 | + <?php | |
| 36 | + echo ' '; | |
| 37 | + FrmAppHelper::kses_echo( $opt, 'all' ); | |
| 38 | + ?> | |
| 30 | 39 | </label> |
| 31 | 40 | <?php |
| 32 | 41 | FrmFieldsHelper::include_other_input( |
| 33 | 42 | array( |
| @@ -46,6 +55,6 @@ | ||
| 46 | 55 | unset( $other_opt, $other_args ); |
| 47 | 56 | ?> |
| 48 | 57 | </div> |
| 49 | 58 | <?php |
| 50 | - } | |
| 51 | -} | |
| 59 | + }//end foreach | |
| 60 | +}//end if | |