WordPress.org

Make WordPress Core

Ticket #47106: 47106.diff

File 47106.diff, 5.7 KB (added by audrasjb, 18 months ago)

adds aria-current attribute to Admin nav tabs

  • src/wp-admin/about.php

    diff --git a/src/wp-admin/about.php b/src/wp-admin/about.php
    index e11424c..a29c56e 100644
    a b include( ABSPATH . 'wp-admin/admin-header.php' ); 
    3434                </div>
    3535
    3636                <nav class="nav-tab-wrapper wp-clearfix" aria-label="<?php esc_attr_e( 'Secondary menu' ); ?>">
    37                         <a href="about.php" class="nav-tab nav-tab-active"><?php _e( 'What&#8217;s New' ); ?></a>
     37                        <a href="about.php" class="nav-tab nav-tab-active" aria-current="page"><?php _e( 'What&#8217;s New' ); ?></a>
    3838                        <a href="credits.php" class="nav-tab"><?php _e( 'Credits' ); ?></a>
    3939                        <a href="freedoms.php" class="nav-tab"><?php _e( 'Freedoms' ); ?></a>
    4040                        <a href="freedoms.php?privacy-notice" class="nav-tab"><?php _e( 'Privacy' ); ?></a>
  • src/wp-admin/credits.php

    diff --git a/src/wp-admin/credits.php b/src/wp-admin/credits.php
    index e9bd916..19befcf 100644
    a b include( ABSPATH . 'wp-admin/admin-header.php' ); 
    2626
    2727<nav class="nav-tab-wrapper wp-clearfix" aria-label="<?php esc_attr_e( 'Secondary menu' ); ?>">
    2828        <a href="about.php" class="nav-tab"><?php _e( 'What&#8217;s New' ); ?></a>
    29         <a href="credits.php" class="nav-tab nav-tab-active"><?php _e( 'Credits' ); ?></a>
     29        <a href="credits.php" class="nav-tab nav-tab-active" aria-current="page"><?php _e( 'Credits' ); ?></a>
    3030        <a href="freedoms.php" class="nav-tab"><?php _e( 'Freedoms' ); ?></a>
    3131        <a href="freedoms.php?privacy-notice" class="nav-tab"><?php _e( 'Privacy' ); ?></a>
    3232</nav>
  • src/wp-admin/freedoms.php

    diff --git a/src/wp-admin/freedoms.php b/src/wp-admin/freedoms.php
    index fb99a87..ff6749b 100644
    a b $is_privacy_notice = isset( $_GET['privacy-notice'] ); 
    2020if ( $is_privacy_notice ) {
    2121        $freedoms_class = '';
    2222        $privacy_class  = ' nav-tab-active';
     23        $freedoms_aria_current = '';
     24        $privacy_aria_current = ' aria-current="page"';
    2325} else {
    2426        $freedoms_class = ' nav-tab-active';
    2527        $privacy_class  = '';
     28        $freedoms_aria_current = ' aria-current="page"';
     29        $privacy_aria_current = '';
    2630}
    2731
    2832?>
    if ( $is_privacy_notice ) { 
    3741<nav class="nav-tab-wrapper wp-clearfix" aria-label="<?php esc_attr_e( 'Secondary menu' ); ?>">
    3842        <a href="about.php" class="nav-tab"><?php _e( 'What&#8217;s New' ); ?></a>
    3943        <a href="credits.php" class="nav-tab"><?php _e( 'Credits' ); ?></a>
    40         <a href="freedoms.php" class="nav-tab<?php echo $freedoms_class; ?>"><?php _e( 'Freedoms' ); ?></a>
    41         <a href="freedoms.php?privacy-notice" class="nav-tab<?php echo $privacy_class; ?>"><?php _e( 'Privacy' ); ?></a>
     44        <a href="freedoms.php" class="nav-tab<?php echo $freedoms_class; ?>"<?php echo $freedoms_aria_current; ?>><?php _e( 'Freedoms' ); ?></a>
     45        <a href="freedoms.php?privacy-notice" class="nav-tab<?php echo $privacy_class; ?>"<?php echo $privacy_aria_current; ?>><?php _e( 'Privacy' ); ?></a>
    4246</nav>
    4347
    4448<?php if ( $is_privacy_notice ) : ?>
  • src/wp-admin/includes/ms.php

    diff --git a/src/wp-admin/includes/ms.php b/src/wp-admin/includes/ms.php
    index f8e3fc0..01420d4 100644
    a b function network_edit_site_nav( $args = array() ) { 
    11181118                // Link classes
    11191119                $classes = array( 'nav-tab' );
    11201120
     1121                // Aria-current attribute
     1122                $aria_current = '';
     1123
    11211124                // Selected is set by the parent OR assumed by the $pagenow global
    11221125                if ( $r['selected'] === $link_id || $link['url'] === $GLOBALS['pagenow'] ) {
    11231126                        $classes[] = 'nav-tab-active';
     1127                        $aria_current = ' aria-current="page"';
    11241128                }
    11251129
    11261130                // Escape each class
    function network_edit_site_nav( $args = array() ) { 
    11301134                $url = add_query_arg( array( 'id' => $r['blog_id'] ), network_admin_url( $link['url'] ) );
    11311135
    11321136                // Add link to nav links
    1133                 $screen_links[ $link_id ] = '<a href="' . esc_url( $url ) . '" id="' . esc_attr( $link_id ) . '" class="' . $esc_classes . '">' . esc_html( $link['label'] ) . '</a>';
     1137                $screen_links[ $link_id ] = '<a href="' . esc_url( $url ) . '" id="' . esc_attr( $link_id ) . '" class="' . $esc_classes . '"' . $aria_current . '>' . esc_html( $link['label'] ) . '</a>';
    11341138        }
    11351139
    11361140        // All done!
  • src/wp-admin/nav-menus.php

    diff --git a/src/wp-admin/nav-menus.php b/src/wp-admin/nav-menus.php
    index 2409ff3..3f89957 100644
    a b require_once( ABSPATH . 'wp-admin/admin-header.php' ); 
    620620        endif;
    621621
    622622        $nav_tab_active_class = '';
     623        $aria_current = '';
    623624        if ( ! isset( $_GET['action'] ) || isset( $_GET['action'] ) && 'locations' != $_GET['action'] ) {
    624625                $nav_tab_active_class = ' nav-tab-active';
     626                $aria_current = ' aria-current="page"';
    625627        }
    626628        ?>
    627629
    628630        <hr class="wp-header-end">
    629631
    630632        <nav class="nav-tab-wrapper wp-clearfix" aria-label="<?php esc_attr_e( 'Secondary menu' ); ?>">
    631                 <a href="<?php echo admin_url( 'nav-menus.php' ); ?>" class="nav-tab<?php echo $nav_tab_active_class; ?>"><?php esc_html_e( 'Edit Menus' ); ?></a>
     633                <a href="<?php echo admin_url( 'nav-menus.php' ); ?>" class="nav-tab<?php echo $nav_tab_active_class; ?>"<?php echo $aria_current; ?>><?php esc_html_e( 'Edit Menus' ); ?></a>
    632634                <?php
    633635                if ( $num_locations && $menu_count ) {
    634636                        $active_tab_class = '';
    635637                        if ( $locations_screen ) {
    636638                                $active_tab_class = ' nav-tab-active';
     639                                $aria_current = ' aria-current="page"';
    637640                        }
    638641                        ?>
    639                         <a href="<?php echo esc_url( add_query_arg( array( 'action' => 'locations' ), admin_url( 'nav-menus.php' ) ) ); ?>" class="nav-tab<?php echo $active_tab_class; ?>"><?php esc_html_e( 'Manage Locations' ); ?></a>
     642                        <a href="<?php echo esc_url( add_query_arg( array( 'action' => 'locations' ), admin_url( 'nav-menus.php' ) ) ); ?>" class="nav-tab<?php echo $active_tab_class; ?>"<?php echo $aria_current; ?>><?php esc_html_e( 'Manage Locations' ); ?></a>
    640643                        <?php
    641644                }
    642645                ?>