Make WordPress Core

Changeset 59907


Ignore:
Timestamp:
03/03/2025 06:43:08 PM (18 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.

Location:
trunk/src/wp-content/themes
Files:
11 edited

Legend:

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

    r59344 r59907  
    7979        <header id="branding">
    8080                        <hgroup>
    81                                 <h1 id="site-title"><span><a href="<?php echo esc_url( home_url( '/' ) ); ?>" rel="home"><?php bloginfo( 'name' ); ?></a></span></h1>
     81                        <?php $is_front = ! is_paged() && ( is_front_page() || ( is_home() && ( (int) get_option( 'page_for_posts' ) !== get_queried_object_id() ) ) ); ?>
     82                                <h1 id="site-title"><span><a href="<?php echo esc_url( home_url( '/' ) ); ?>" rel="home" <?php echo $is_front ? 'aria-current="page"' : ''; ?>><?php bloginfo( 'name' ); ?></a></span></h1>
    8283                                <h2 id="site-description"><?php bloginfo( 'description' ); ?></h2>
    8384                        </hgroup>
     
    9899                                }
    99100                                ?>
    100                         <a href="<?php echo esc_url( home_url( '/' ) ); ?>">
     101                        <a href="<?php echo esc_url( home_url( '/' ) ); ?>" rel="home" <?php echo $is_front ? 'aria-current="page"' : ''; ?>>
    101102                                <?php
    102103                                /*
  • trunk/src/wp-content/themes/twentyfifteen/header.php

    r59026 r59907  
    3434                                <?php
    3535                                        twentyfifteen_the_custom_logo();
    36 
     36                                        $is_front = ! is_paged() && ( is_front_page() || ( is_home() && ( (int) get_option( 'page_for_posts' ) !== get_queried_object_id() ) ) );
    3737                                if ( is_front_page() && is_home() ) :
    3838                                        ?>
    39                                                 <h1 class="site-title"><a href="<?php echo esc_url( home_url( '/' ) ); ?>" rel="home"><?php bloginfo( 'name' ); ?></a></h1>
     39                                                <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>
    4040                                        <?php else : ?>
    41                                                 <p class="site-title"><a href="<?php echo esc_url( home_url( '/' ) ); ?>" rel="home"><?php bloginfo( 'name' ); ?></a></p>
     41                                                <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>
    4242                                                <?php
    4343                                        endif;
  • trunk/src/wp-content/themes/twentyfourteen/header.php

    r59026 r59907  
    3434<?php wp_body_open(); ?>
    3535<div id="page" class="hfeed site">
     36        <?php $is_front = ! is_paged() && ( is_front_page() || ( is_home() && ( (int) get_option( 'page_for_posts' ) !== get_queried_object_id() ) ) ); ?>
    3637        <?php if ( get_header_image() ) : ?>
    3738        <div id="site-header">
    38                 <a href="<?php echo esc_url( home_url( '/' ) ); ?>" rel="home">
     39                <a href="<?php echo esc_url( home_url( '/' ) ); ?>" rel="home" <?php echo $is_front ? 'aria-current="page"' : ''; ?>>
    3940                        <?php twentyfourteen_header_image(); ?>
    4041                </a>
     
    4445        <header id="masthead" class="site-header">
    4546                <div class="header-main">
    46                         <h1 class="site-title"><a href="<?php echo esc_url( home_url( '/' ) ); ?>" rel="home"><?php bloginfo( 'name' ); ?></a></h1>
     47                        <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>
    4748
    4849                        <div class="search-toggle">
  • trunk/src/wp-content/themes/twentynineteen/template-parts/header/site-branding.php

    r46827 r59907  
    1414        <?php endif; ?>
    1515        <?php $blog_info = get_bloginfo( 'name' ); ?>
     16        <?php $is_front = ! is_paged() && ( is_front_page() || ( is_home() && ( (int) get_option( 'page_for_posts' ) !== get_queried_object_id() ) ) ); ?>
    1617        <?php if ( ! empty( $blog_info ) ) : ?>
    1718                <?php if ( is_front_page() && is_home() ) : ?>
    18                         <h1 class="site-title"><a href="<?php echo esc_url( home_url( '/' ) ); ?>" rel="home"><?php bloginfo( 'name' ); ?></a></h1>
     19                        <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>
    1920                <?php else : ?>
    20                         <p class="site-title"><a href="<?php echo esc_url( home_url( '/' ) ); ?>" rel="home"><?php bloginfo( 'name' ); ?></a></p>
     21                        <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>
    2122                <?php endif; ?>
    2223        <?php endif; ?>
  • trunk/src/wp-content/themes/twentyseventeen/template-parts/header/site-branding.php

    r55276 r59907  
    1616
    1717                <div class="site-branding-text">
     18                        <?php $is_front = ! is_paged() && ( is_front_page() || ( is_home() && ( (int) get_option( 'page_for_posts' ) !== get_queried_object_id() ) ) ); ?>
    1819                        <?php if ( is_front_page() ) : ?>
    19                                 <h1 class="site-title"><a href="<?php echo esc_url( home_url( '/' ) ); ?>" rel="home"><?php bloginfo( 'name' ); ?></a></h1>
     20                                <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>
    2021                        <?php else : ?>
    21                                 <p class="site-title"><a href="<?php echo esc_url( home_url( '/' ) ); ?>" rel="home"><?php bloginfo( 'name' ); ?></a></p>
     22                                <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>
    2223                        <?php endif; ?>
    2324
  • 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();
  • trunk/src/wp-content/themes/twentyten/header.php

    r59857 r59907  
    7272                                <<?php echo $heading_tag; ?> id="site-title">
    7373                                        <span>
    74                                                 <a href="<?php echo esc_url( home_url( '/' ) ); ?>" rel="home"><?php bloginfo( 'name' ); ?></a>
     74                                        <?php $is_front = ! is_paged() && ( is_front_page() || ( is_home() && ( (int) get_option( 'page_for_posts' ) !== get_queried_object_id() ) ) ); ?>
     75                                                <a href="<?php echo esc_url( home_url( '/' ) ); ?>" rel="home" <?php echo $is_front ? 'aria-current="page"' : ''; ?>><?php bloginfo( 'name' ); ?></a>
    7576                                        </span>
    7677                                </<?php echo $heading_tag; ?>>
  • trunk/src/wp-content/themes/twentythirteen/header.php

    r59026 r59907  
    2424        <div id="page" class="hfeed site">
    2525                <header id="masthead" class="site-header">
    26                         <a class="home-link" href="<?php echo esc_url( home_url( '/' ) ); ?>" rel="home">
     26                <?php $is_front = ! is_paged() && ( is_front_page() || ( is_home() && ( (int) get_option( 'page_for_posts' ) !== get_queried_object_id() ) ) ); ?>
     27                        <a class="home-link" href="<?php echo esc_url( home_url( '/' ) ); ?>" rel="home" <?php echo $is_front ? 'aria-current="page"' : ''; ?>>
    2728                                <h1 class="site-title"><?php bloginfo( 'name' ); ?></h1>
    2829                                <h2 class="site-description"><?php bloginfo( 'description' ); ?></h2>
  • trunk/src/wp-content/themes/twentytwelve/header.php

    r59026 r59907  
    3737        <header id="masthead" class="site-header">
    3838                <hgroup>
    39                         <h1 class="site-title"><a href="<?php echo esc_url( home_url( '/' ) ); ?>" rel="home"><?php bloginfo( 'name' ); ?></a></h1>
     39                <?php $is_front = ! is_paged() && ( is_front_page() || ( is_home() && ( (int) get_option( 'page_for_posts' ) !== get_queried_object_id() ) ) ); ?>
     40                        <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>
    4041                        <h2 class="site-description"><?php bloginfo( 'description' ); ?></h2>
    4142                </hgroup>
     
    5556
    5657                <?php if ( get_header_image() ) : ?>
    57                 <a href="<?php echo esc_url( home_url( '/' ) ); ?>"><?php twentytwelve_header_image(); ?></a>
     58                <a href="<?php echo esc_url( home_url( '/' ) ); ?>" <?php echo $is_front ? 'aria-current="page"' : ''; ?> rel="home"><?php twentytwelve_header_image(); ?></a>
    5859                <?php endif; ?>
    5960        </header><!-- #masthead -->
  • 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        }
  • trunk/src/wp-content/themes/twentytwentyone/template-parts/header/site-branding.php

    r50802 r59907  
    2929                        <h1 class="<?php echo esc_attr( $header_class ); ?>"><?php echo esc_html( $blog_info ); ?></h1>
    3030                <?php elseif ( is_front_page() && ! is_home() ) : ?>
    31                         <h1 class="<?php echo esc_attr( $header_class ); ?>"><a href="<?php echo esc_url( home_url( '/' ) ); ?>"><?php echo esc_html( $blog_info ); ?></a></h1>
     31                        <h1 class="<?php echo esc_attr( $header_class ); ?>"><a href="<?php echo esc_url( home_url( '/' ) ); ?>" rel="home"><?php echo esc_html( $blog_info ); ?></a></h1>
    3232                <?php else : ?>
    33                         <p class="<?php echo esc_attr( $header_class ); ?>"><a href="<?php echo esc_url( home_url( '/' ) ); ?>"><?php echo esc_html( $blog_info ); ?></a></p>
     33                        <p class="<?php echo esc_attr( $header_class ); ?>"><a href="<?php echo esc_url( home_url( '/' ) ); ?>" rel="home"><?php echo esc_html( $blog_info ); ?></a></p>
    3434                <?php endif; ?>
    3535        <?php endif; ?>
Note: See TracChangeset for help on using the changeset viewer.