Make WordPress Core


Ignore:
Timestamp:
03/03/2025 06:43:08 PM (3 months ago)
Author:
joedolson
Message:

Bundled Themes: Add aria-current="page" on header links.

Mark links that point to the current URL in bundled theme headers with aria-current="page" to inform screen reader users that this link is the current page.

Changes to Twenty Ten through Twenty Twenty add aria-current and rel="home" where appropriate, Twenty Twenty One only adds rel="home".

Props bschneidewind, joedolson, hiabhaykulkarni, sabernhardt.
Fixes #62895.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-content/themes/twentysixteen/header.php

    r59026 r59907  
    3737                <div class="site-branding">
    3838                    <?php twentysixteen_the_custom_logo(); ?>
    39 
     39                    <?php $is_front = ! is_paged() && ( is_front_page() || ( is_home() && ( (int) get_option( 'page_for_posts' ) !== get_queried_object_id() ) ) ); ?>
    4040                    <?php if ( is_front_page() && is_home() ) : ?>
    41                         <h1 class="site-title"><a href="<?php echo esc_url( home_url( '/' ) ); ?>" rel="home"><?php bloginfo( 'name' ); ?></a></h1>
     41                        <h1 class="site-title"><a href="<?php echo esc_url( home_url( '/' ) ); ?>" rel="home" <?php echo $is_front ? 'aria-current="page"' : ''; ?>><?php bloginfo( 'name' ); ?></a></h1>
    4242                    <?php else : ?>
    43                         <p class="site-title"><a href="<?php echo esc_url( home_url( '/' ) ); ?>" rel="home"><?php bloginfo( 'name' ); ?></a></p>
     43                        <p class="site-title"><a href="<?php echo esc_url( home_url( '/' ) ); ?>" rel="home" <?php echo $is_front ? 'aria-current="page"' : ''; ?>><?php bloginfo( 'name' ); ?></a></p>
    4444                        <?php
    4545                    endif;
     
    102102                ?>
    103103                <div class="header-image">
    104                     <a href="<?php echo esc_url( home_url( '/' ) ); ?>" rel="home">
     104                    <a href="<?php echo esc_url( home_url( '/' ) ); ?>" rel="home" <?php echo $is_front ? 'aria-current="page"' : ''; ?>>
    105105                        <?php
    106106                        $custom_header = get_custom_header();
Note: See TracChangeset for help on using the changeset viewer.