← All changes
|
classes/views/frm-fields/front-end/checkbox-field.php
+13
-4
6.28
→
trunk
View file →
| @@ -7,9 +7,19 @@ | ||
| 7 | 7 | * Show the checkbox field on the front-end. |
| 8 | 8 | * Extra line breaks show as space on the front-end when |
| 9 | 9 | * the form is double filtered and not minimized. |
| 10 | 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 | + * | |
| 11 | 17 | * @phpcs:disable Generic.WhiteSpace.ScopeIndent |
| 18 | + * | |
| 19 | + * @since 6.30 Added `$hide_label`. | |
| 20 | + * | |
| 21 | + * @var bool $hide_label | |
| 12 | 22 | */ |
| 13 | 23 | |
| 14 | 24 | if ( isset( $field['post_field'] ) && $field['post_field'] === 'post_category' ) { |
| 15 | 25 | $type = $field['type']; |
| @@ -60,11 +70,9 @@ | ||
| 60 | 70 | $should_echo_disabled_att = FrmFieldsHelper::should_disable_choice( $opt_key, $checked, $field ); |
| 61 | 71 | ?> |
| 62 | 72 | <div class="<?php echo esc_attr( apply_filters( 'frm_checkbox_class', 'frm_checkbox', $field, $field_val ) ); ?>" id="<?php echo esc_attr( FrmFieldsHelper::get_checkbox_id( $field, $opt_key ) ); ?>"><?php |
| 63 | 73 | |
| 64 | - $include_label = ! isset( $shortcode_atts ) || ! isset( $shortcode_atts['label'] ) || $shortcode_atts['label']; | |
| 65 | - | |
| 66 | - if ( $include_label ) { | |
| 74 | + if ( empty( $hide_label ) ) { | |
| 67 | 75 | $label_attributes = array( |
| 68 | 76 | 'for' => $html_id . '-' . $opt_key, |
| 69 | 77 | ); |
| 70 | 78 | |
| @@ -79,8 +87,9 @@ | ||
| 79 | 87 | |
| 80 | 88 | ?><input type="checkbox" name="<?php echo esc_attr( $field_name ); ?>[<?php echo esc_attr( $other_opt ? $opt_key : '' ); ?>]" id="<?php echo esc_attr( $html_id ); ?>-<?php echo esc_attr( $opt_key ); ?>" value="<?php echo esc_attr( $field_val ); ?>"<?php |
| 81 | 89 | |
| 82 | 90 | echo $checked . ' '; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
| 91 | + | |
| 83 | 92 | do_action( 'frm_field_input_html', $field ); |
| 84 | 93 | |
| 85 | 94 | if ( $should_echo_disabled_att ) { |
| 86 | 95 | echo 'disabled="disabled" data-max-reached="1" '; |
| @@ -91,9 +100,9 @@ | ||
| 91 | 100 | } |
| 92 | 101 | |
| 93 | 102 | ?> /><?php |
| 94 | 103 | |
| 95 | - if ( $include_label ) { | |
| 104 | + if ( empty( $hide_label ) ) { | |
| 96 | 105 | echo ' '; |
| 97 | 106 | FrmAppHelper::kses_echo( $label, 'all' ); |
| 98 | 107 | FrmFieldsHelper::after_choice_input( $field, $opt_key ); |
| 99 | 108 | echo '</label>'; |