Skip to content

Commit 4452b67

Browse files
committed
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. git-svn-id: https://develop.svn.wordpress.org/trunk@59907 602fd350-edb4-49c9-b593-d223f7449a82
1 parent bc1bdb3 commit 4452b67

File tree

11 files changed

+37
-23
lines changed

11 files changed

+37
-23
lines changed

src/wp-content/themes/twentyeleven/header.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,8 @@
7878
<div id="page" class="hfeed">
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>
8485

@@ -97,7 +98,7 @@
9798
$header_image_width = HEADER_IMAGE_WIDTH;
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
/*
103104
* The header image.

src/wp-content/themes/twentyfifteen/header.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,12 @@
3333
<div class="site-branding">
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;
4444

src/wp-content/themes/twentyfourteen/header.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,17 +33,18 @@
3333
<body <?php body_class(); ?>>
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>
4142
</div>
4243
<?php endif; ?>
4344

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">
4950
<a href="#search-container" class="screen-reader-text" aria-expanded="false" aria-controls="search-container">

src/wp-content/themes/twentynineteen/template-parts/header/site-branding.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,12 @@
1313
<div class="site-logo"><?php the_custom_logo(); ?></div>
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; ?>
2324

src/wp-content/themes/twentyseventeen/template-parts/header/site-branding.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,11 @@
1515
<?php the_custom_logo(); ?>
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

2425
<?php

src/wp-content/themes/twentysixteen/header.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,11 @@
3636
<div class="site-header-main">
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;
4646

@@ -101,7 +101,7 @@
101101
$custom_header_sizes = apply_filters( 'twentysixteen_custom_header_sizes', '(max-width: 709px) 85vw, (max-width: 909px) 81vw, (max-width: 1362px) 88vw, 1200px' );
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();
107107
$attrs = array(

src/wp-content/themes/twentyten/header.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,8 @@
7171
<?php $heading_tag = ( is_home() || is_front_page() ) ? 'h1' : 'div'; ?>
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; ?>>
7778
<div id="site-description"><?php bloginfo( 'description' ); ?></div>

src/wp-content/themes/twentythirteen/header.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@
2323
<?php wp_body_open(); ?>
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>
2930
</a>

src/wp-content/themes/twentytwelve/header.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,8 @@
3636
<div id="page" class="hfeed site">
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>
4243

@@ -54,7 +55,7 @@
5455
</nav><!-- #site-navigation -->
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 -->
6061

src/wp-content/themes/twentytwenty/inc/template-tags.php

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ function twentytwenty_site_logo( $args = array(), $display = true ) {
4040
$defaults = array(
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>',
4646
'single_wrap' => '<div class="%1$s faux-heading">%2$s</div>',
@@ -63,7 +63,14 @@ function twentytwenty_site_logo( $args = array(), $display = true ) {
6363
$contents = sprintf( $args['logo'], $logo, esc_html( $site_title ) );
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
}
6976

0 commit comments

Comments
 (0)