Make WordPress Core

Changeset 46746


Ignore:
Timestamp:
11/18/2019 04:49:42 PM (5 years ago)
Author:
afercia
Message:

Accessibility: Add an aria-current attribute to the Media Library switch links.

The aria-current attribute is a simple, effective, way to help assistive technology users orientate themselves within a set of items.

Props mayanksonawat, afercia.
Fixes #48271.

Location:
trunk/src
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/includes/class-wp-list-table.php

    r46739 r46746  
    632632        <?php
    633633        foreach ( $this->modes as $mode => $title ) {
    634             $classes = array( 'view-' . $mode );
     634            $classes      = array( 'view-' . $mode );
     635            $aria_current = '';
     636
    635637            if ( $current_mode === $mode ) {
    636                 $classes[] = 'current';
     638                $classes[]    = 'current';
     639                $aria_current = ' aria-current="page"';
    637640            }
    638641            printf(
    639                 "<a href='%s' class='%s' id='view-switch-$mode'><span class='screen-reader-text'>%s</span></a>\n",
     642                "<a href='%s' class='%s' id='view-switch-$mode'$aria_current><span class='screen-reader-text'>%s</span></a>\n",
    640643                esc_url( add_query_arg( 'mode', $mode ) ),
    641644                implode( ' ', $classes ),
  • trunk/src/wp-includes/media-template.php

    r46489 r46746  
    319319            <span class="screen-reader-text"><?php _e( 'List View' ); ?></span>
    320320        </a>
    321         <a href="<?php echo esc_url( add_query_arg( 'mode', 'grid', $_SERVER['REQUEST_URI'] ) ); ?>" class="view-grid current">
     321        <a href="<?php echo esc_url( add_query_arg( 'mode', 'grid', $_SERVER['REQUEST_URI'] ) ); ?>" class="view-grid current" aria-current="page">
    322322            <span class="screen-reader-text"><?php _e( 'Grid View' ); ?></span>
    323323        </a>
Note: See TracChangeset for help on using the changeset viewer.