Make WordPress Core

Ticket #33064: 33064.3.diff

File 33064.3.diff, 3.3 KB (added by joedolson, 2 years ago)

Refreshed

  • src/wp-includes/class-wp-customize-control.php

     
    100100         */
    101101        public $label = '';
    102102
     103        /**
     104         * Whether the label is visible or used as screen reader text.
     105         *
     106         * @since 6.3.0
     107+        * @var bool
     108+        */
     109+       public $use_label_as_screen_reader_text  = false;
     110
    103111        /**
    104112         * Description for the control.
    105113         *
     
    488496                $input_id         = '_customize-input-' . $this->id;
    489497                $description_id   = '_customize-description-' . $this->id;
    490498                $describedby_attr = ( ! empty( $this->description ) ) ? ' aria-describedby="' . esc_attr( $description_id ) . '" ' : '';
     499                $label_class      = 'customize-control-title';
     500                if ( true === $this->use_label_as_screen_reader_text ) {
     501                        $label_class .= ' screen-reader-text';
     502                }
    491503                switch ( $this->type ) {
    492504                        case 'checkbox':
    493505                                ?>
     
    515527                                $name = '_customize-radio-' . $this->id;
    516528                                ?>
    517529                                <?php if ( ! empty( $this->label ) ) : ?>
    518                                         <span class="customize-control-title"><?php echo esc_html( $this->label ); ?></span>
     530                                        <span class="<?php echo $label_class; ?>"><?php echo esc_html( $this->label ); ?></span>
    519531                                <?php endif; ?>
    520532                                <?php if ( ! empty( $this->description ) ) : ?>
    521533                                        <span id="<?php echo esc_attr( $description_id ); ?>" class="description customize-control-description"><?php echo $this->description; ?></span>
     
    544556
    545557                                ?>
    546558                                <?php if ( ! empty( $this->label ) ) : ?>
    547                                         <label for="<?php echo esc_attr( $input_id ); ?>" class="customize-control-title"><?php echo esc_html( $this->label ); ?></label>
     559                                        <label for="<?php echo esc_attr( $input_id ); ?>" class="<?php echo $label_class; ?>"><?php echo esc_html( $this->label ); ?></label>
    548560                                <?php endif; ?>
    549561                                <?php if ( ! empty( $this->description ) ) : ?>
    550562                                        <span id="<?php echo esc_attr( $description_id ); ?>" class="description customize-control-description"><?php echo $this->description; ?></span>
     
    562574                        case 'textarea':
    563575                                ?>
    564576                                <?php if ( ! empty( $this->label ) ) : ?>
    565                                         <label for="<?php echo esc_attr( $input_id ); ?>" class="customize-control-title"><?php echo esc_html( $this->label ); ?></label>
     577                                        <label for="<?php echo esc_attr( $input_id ); ?>" class="<?php echo $label_class; ?>"><?php echo esc_html( $this->label ); ?></label>
    566578                                <?php endif; ?>
    567579                                <?php if ( ! empty( $this->description ) ) : ?>
    568580                                        <span id="<?php echo esc_attr( $description_id ); ?>" class="description customize-control-description"><?php echo $this->description; ?></span>
     
    579591                        case 'dropdown-pages':
    580592                                ?>
    581593                                <?php if ( ! empty( $this->label ) ) : ?>
    582                                         <label for="<?php echo esc_attr( $input_id ); ?>" class="customize-control-title"><?php echo esc_html( $this->label ); ?></label>
     594                                        <label for="<?php echo esc_attr( $input_id ); ?>" class="<?php echo $label_class; ?>"><?php echo esc_html( $this->label ); ?></label>
    583595                                <?php endif; ?>
    584596                                <?php if ( ! empty( $this->description ) ) : ?>
    585597                                        <span id="<?php echo esc_attr( $description_id ); ?>" class="description customize-control-description"><?php echo $this->description; ?></span>