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/twentytwenty/inc/template-tags.php

    r56548 r59907  
    4141        'logo'        => '%1$s<span class="screen-reader-text">%2$s</span>',
    4242        'logo_class'  => 'site-logo',
    43         'title'       => '<a href="%1$s">%2$s</a>',
     43        'title'       => '<a href="%1$s" rel="home">%2$s</a>',
    4444        'title_class' => 'site-title',
    4545        'home_wrap'   => '<h1 class="%1$s">%2$s</h1>',
     
    6464        $classname = $args['logo_class'];
    6565    } else {
    66         $contents  = sprintf( $args['title'], esc_url( get_home_url( null, '/' ) ), esc_html( $site_title ) );
     66        $contents = sprintf( $args['title'], esc_url( get_home_url( null, '/' ) ), esc_html( $site_title ) );
     67        if (
     68            ( is_front_page() || is_home() && ( (int) get_option( 'page_for_posts' ) !== get_queried_object_id() ) )
     69            && ! is_paged()
     70            && $args['title'] === $defaults['title']
     71        ) {
     72            $contents = str_replace( ' rel=', ' aria-current="page" rel=', $contents );
     73        }
    6774        $classname = $args['title_class'];
    6875    }
Note: See TracChangeset for help on using the changeset viewer.