Make WordPress Core


Ignore:
Timestamp:
09/28/2025 11:38:57 PM (9 months ago)
Author:
joedolson
Message:

A11y: Ensure icons are not spoken by screen readers.

For all CSS generated icons across core, either add aria-hidden="true" to the HTML wrapper or set the generated content alternative to an empty string in the CSS using the alternative text specification for CSS generated content.

Props afercia, joedolson, cheffheid, jhabdas.
Fixes #40428.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/media-template.php

    r60786 r60806  
    198198        <div id="wp-media-modal" tabindex="0" class="<?php echo $class; ?>" role="dialog" aria-labelledby="media-frame-title">
    199199            <# if ( data.hasCloseButton ) { #>
    200                 <button type="button" class="media-modal-close"><span class="media-modal-icon"><span class="screen-reader-text">
     200                <button type="button" class="media-modal-close"><span class="media-modal-icon" aria-hidden="true"></span><span class="screen-reader-text">
    201201                    <?php
    202202                    /* translators: Hidden accessibility text. */
    203203                    _e( 'Close dialog' );
    204204                    ?>
    205                 </span></span></button>
     205                </span></button>
    206206            <# } #>
    207207            <div class="media-modal-content" role="document"></div>
     
    366366            <button class="left dashicons"<# if ( ! data.hasPrevious ) { #> disabled<# } #>><span class="screen-reader-text"><?php /* translators: Hidden accessibility text. */ _e( 'Edit previous media item' ); ?></span></button>
    367367            <button class="right dashicons"<# if ( ! data.hasNext ) { #> disabled<# } #>><span class="screen-reader-text"><?php /* translators: Hidden accessibility text. */ _e( 'Edit next media item' ); ?></span></button>
    368             <button type="button" class="media-modal-close"><span class="media-modal-icon"><span class="screen-reader-text"><?php _e( 'Close dialog' ); ?></span></span></button>
     368            <button type="button" class="media-modal-close"><span class="media-modal-icon" aria-hidden="true"></span><span class="screen-reader-text"><?php _e( 'Close dialog' ); ?></span></button>
    369369        </div>
    370370        <div class="media-frame-title"></div>
     
    622622            </div>
    623623            <# if ( data.buttons.close ) { #>
    624                 <button type="button" class="button-link attachment-close media-modal-icon"><span class="screen-reader-text">
     624                <button type="button" class="button-link attachment-close"><span class="media-modal-icon" aria-hidden="true"></span><span class="screen-reader-text">
    625625                    <?php
    626626                    /* translators: Hidden accessibility text. */
     
    631631        </div>
    632632        <# if ( data.buttons.check ) { #>
    633             <button type="button" class="check" tabindex="-1"><span class="media-modal-icon"></span><span class="screen-reader-text">
     633            <button type="button" class="check" tabindex="-1"><span class="media-modal-icon" aria-hidden="true"></span><span class="screen-reader-text">
    634634                <?php
    635635                /* translators: Hidden accessibility text. */
Note: See TracChangeset for help on using the changeset viewer.