PluginProbe
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More / trunk
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More vtrunk
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
formidable / classes / views / frm-fields / front-end / radio-field.php

radio-field.php in Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More trunk, at classes/views/frm-fields/front-end/radio-field.php

110 lines 3.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 if ( ! defined( 'ABSPATH' ) ) {
3 die( 'You are not allowed to call this page directly.' );
4 }
5
6 /**
7 * Show the radio field on the front-end.
8 * Extra line breaks show as space on the front-end when
9 * the form is double filtered and not minimized.
10 *
11 * @var array $field
12 * @var string $field_name
13 * @var bool $read_only
14 * @var string $html_id
15 * @var array|null $args
16 *
17 * @phpcs:disable Generic.WhiteSpace.ScopeIndent
18 *
19 * @since 6.30 Added `$hide_label`.
20 *
21 * @var bool $hide_label
22 */
23
24 if ( isset( $field['post_field'] ) && $field['post_field'] === 'post_category' ) {
25 $type = $field['type'];
26 do_action( 'frm_after_checkbox', compact( 'field', 'field_name', 'type' ) );
27 } elseif ( is_array( $field['options'] ) ) {
28 if ( FrmFieldsHelper::should_skip_rendering_choices_for_field( $field ) ) {
29 return;
30 }
31
32 foreach ( $field['options'] as $opt_key => $opt ) {
33 if ( isset( $shortcode_atts ) && isset( $shortcode_atts['opt'] ) && $shortcode_atts['opt'] !== $opt_key ) {
34 continue;
35 }
36
37 if ( FrmFieldsHelper::should_hide_field_choice( $opt_key, $field ) ) {
38 continue;
39 }
40
41 $field_val = FrmFieldsHelper::get_value_from_array( $opt, $opt_key, $field );
42 $opt = FrmFieldsHelper::get_label_from_array( $opt, $opt_key, $field );
43
44 /**
45 * Allows changing the HTML of option label in choice field (radio, checkbox,...).
46 *
47 * @since 5.0.04
48 *
49 * @param string $label Label HTML.
50 * @param array $args The arguments. Contains `field` and `field_val`.
51 */
52 $label = apply_filters( 'frm_choice_field_option_label', $opt, compact( 'field', 'field_val' ) );
53 ?>
54 <div class="<?php echo esc_attr( apply_filters( 'frm_radio_class', 'frm_radio', $field, $field_val ) ); ?>" id="<?php echo esc_attr( FrmFieldsHelper::get_checkbox_id( $field, $opt_key, 'radio' ) ); ?>"><?php
55
56 $checked = FrmAppHelper::check_selected( $field['value'], $field_val ) ? 'checked="checked" ' : ' ';
57 $should_echo_disabled_att = FrmFieldsHelper::should_disable_choice( $opt_key, trim( $checked ) !== '', $field );
58
59 if ( empty( $hide_label ) ) {
60 $label_attributes = array(
61 'for' => $html_id . '-' . $opt_key,
62 );
63
64 if ( $read_only || $should_echo_disabled_att ) {
65 $label_attributes['class'] = 'frm-label-disabled';
66 }
67 ?>
68 <label <?php FrmAppHelper::array_to_html_params( $label_attributes, true ); ?>>
69 <?php
70 }
71
72 $checked = FrmAppHelper::check_selected( $field['value'], $field_val ) ? 'checked="checked" ' : ' ';
73 $other_opt = false;
74 $other_args = FrmFieldsHelper::prepare_other_input( compact( 'field_name', 'opt_key', 'field' ), $other_opt, $checked );
75 ?>
76 <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 ); ?>"
77 <?php
78 do_action( 'frm_field_input_html', $field );
79 echo $checked; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
80
81 if ( $should_echo_disabled_att ) {
82 echo 'disabled="disabled" ';
83 }
84 ?>/><?php
85 if ( empty( $hide_label ) ) {
86 echo ' ';
87 FrmAppHelper::kses_echo( $label, 'all' );
88 FrmFieldsHelper::after_choice_input( $field, $opt_key );
89 echo '</label>';
90 }
91
92 $other_args = array(
93 'other_opt' => $other_opt,
94 'read_only' => $read_only,
95 'checked' => $checked,
96 'name' => $other_args['name'],
97 'value' => $other_args['value'],
98 'field' => $field,
99 'html_id' => $html_id,
100 'opt_key' => $opt_key,
101 'opt_label' => $opt,
102 );
103 FrmFieldsHelper::include_other_input( $other_args );
104
105 unset( $other_opt, $other_args );
106 ?></div>
107 <?php
108 }//end foreach
109 }//end if
110