Changeset 3746820 for formidable/trunk/classes/views/shared/toggle.php
- Timestamp:
- 10/14/2026 04:54:36 PM (2 weeks ago)
- File:
-
- 1 edited
-
formidable/trunk/classes/views/shared/toggle.php (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
formidable/trunk/classes/views/shared/toggle.php
r3438799 r3746820 18 18 $show_labels = $args['show_labels'] ?? false; 19 19 $off_label = $args['off_label'] ?? ''; 20 $on_label = $args['on_label'] ?? 1;21 $value = $args['value'] ?? $ on_label;20 $on_label = $args['on_label'] ?? ''; 21 $value = $args['value'] ?? $args['on_label'] ?? 1; 22 22 $checked = isset( $args['checked'] ) && ( true === $args['checked'] || str_contains( $args['checked'], 'checked="checked"' ) ); 23 23 $disabled = ! empty( $args['disabled'] ); … … 25 25 $input_html = $args['input_html'] ?? array(); 26 26 $use_container = false; 27 28 $off_label_shown = $show_labels && '' !== $off_label; 29 $on_label_shown = $show_labels && '' !== $on_label; 30 31 $aria_attrs = array(); 32 33 if ( isset( $args['aria-label-attr'] ) && '' !== $args['aria-label-attr'] ) { 34 $aria_attrs['aria-label'] = $args['aria-label-attr']; 35 } elseif ( $off_label_shown || $on_label_shown ) { 36 // Use the visible labels for the accessible name when this view renders them. 37 $labelledby = array(); 38 39 if ( $off_label_shown ) { 40 $labelledby[] = $id . '_off_label'; 41 } 42 43 if ( $on_label_shown ) { 44 $labelledby[] = $id . '_on_label'; 45 } 46 $aria_attrs['aria-labelledby'] = implode( ' ', $labelledby ); 47 } else { 48 $aria_attrs['aria-labelledby'] = $id . '_label'; 49 }//end if 50 $aria_attrs['aria-checked'] = $aria_checked; 27 51 28 52 $div_params = array( … … 49 73 ?> 50 74 <label class="frm_toggle_block" <?php FrmAppHelper::array_to_html_params( $div_params, true ); ?>> 51 <?php if ( $ show_labels && $off_label) { ?>52 <span class="frm_off_label frm_toggle_opt frm-leading-none"><?php echo esc_html( $off_label ); ?></span>75 <?php if ( $off_label_shown ) { ?> 76 <span id="<?php echo esc_attr( $id ); ?>_off_label" class="frm_off_label frm_toggle_opt frm-leading-none"><?php echo esc_html( $off_label ); ?></span> 53 77 <?php } ?> 54 78 55 79 <input type="checkbox" name="<?php echo esc_attr( $name ); ?>" id="<?php echo esc_attr( $id ); ?>" value="<?php echo esc_attr( $value ); ?>" 56 80 <?php checked( $checked, true ); ?> 57 <?php if ( $ show_labels && $off_label) { ?>81 <?php if ( $off_label_shown ) { ?> 58 82 data-off="<?php echo esc_attr( $off_label ); ?>" 59 83 <?php } ?> … … 71 95 72 96 <span class="frm_toggle" tabindex="0" role="switch" 73 <?php echo ! empty( $args['aria-label-attr'] ) ? 'aria-label="' . esc_attr( $args['aria-label-attr'] ) . '"' : ''; ?> 74 aria-labelledby="<?php echo esc_attr( $id ); ?>_label" 75 aria-checked="<?php echo esc_attr( $aria_checked ); ?>" 97 <?php FrmAppHelper::array_to_html_params( $aria_attrs, true ); ?> 76 98 > 77 99 <span class="frm_toggle_slider"></span> 78 100 </span> 79 101 80 <?php // phpcs:ignore Universal.Operators.StrictComparisons ?> 81 <?php if ( $show_labels && $on_label != 1 ) { ?> 82 <span class="frm_on_label frm_toggle_opt frm-leading-none"><?php FrmAppHelper::kses_echo( $on_label, 'all' ); ?></span> 102 <?php if ( $on_label_shown ) { ?> 103 <span id="<?php echo esc_attr( $id ); ?>_on_label" class="frm_on_label frm_toggle_opt frm-leading-none"><?php FrmAppHelper::kses_echo( $on_label, 'all' ); ?></span> 83 104 <?php } ?> 84 105 </label>
Note:
See TracChangeset
for help on using the changeset viewer.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)