Plugin Directory


Ignore:
Timestamp:
10/14/2026 04:54:36 PM (2 weeks ago)
Author:
formidableforms
Message:

Update to version 7.0 from GitHub

File:
1 edited

Legend:

Unmodified
Added
Removed
  • formidable/trunk/classes/views/shared/toggle.php

    r3438799 r3746820  
    1818$show_labels   = $args['show_labels'] ?? false;
    1919$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;
    2222$checked       = isset( $args['checked'] ) && ( true === $args['checked'] || str_contains( $args['checked'], 'checked="checked"' ) );
    2323$disabled      = ! empty( $args['disabled'] );
    … …  
    2525$input_html    = $args['input_html'] ?? array();
    2626$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
     33if ( 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;
    2751
    2852$div_params = array(
    … …  
    4973?>
    5074        <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>
    5377                <?php } ?>
    5478
    5579                <input type="checkbox" name="<?php echo esc_attr( $name ); ?>" id="<?php echo esc_attr( $id ); ?>" value="<?php echo esc_attr( $value ); ?>"
    5680                        <?php checked( $checked, true ); ?>
    57                         <?php if ( $show_labels && $off_label ) { ?>
     81                        <?php if ( $off_label_shown ) { ?>
    5882                                data-off="<?php echo esc_attr( $off_label ); ?>"
    5983                        <?php } ?>
    … …  
    7195
    7296                <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 ); ?>
    7698                >
    7799                        <span class="frm_toggle_slider"></span>
    78100                </span>
    79101
    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>
    83104                <?php } ?>
    84105        </label>
Note: See TracChangeset for help on using the changeset viewer.