Make WordPress Core

Opened 7 weeks ago

Closed 3 weeks ago

#62895 closed defect (bug) (fixed)

Bundled Themes: Accessibility additions to the site title link

Reported by: bschneidewind's profile bschneidewind Owned by: joedolson's profile joedolson
Milestone: 6.8 Priority: normal
Severity: normal Version:
Component: Bundled Theme Keywords: has-patch commit
Focuses: accessibility Cc:

Description (last modified by joedolson)

In most bundled themes, the aria-current and rel="home" attributes are missing on the site logo.

Can be seen at: https://wp-themes.com/twentytwenty/

Change History (10)

This ticket was mentioned in PR #8237 on WordPress/wordpress-develop by @bschneidewind.


7 weeks ago
#1

  • Keywords has-patch added

In Twenty Twenty theme, adds the aria-current="page" (when applicable) and rel="home" to the site logo.

Trac ticket: https://core.trac.wordpress.org/ticket/62895

#2 @hiabhaykulkarni
7 weeks ago

Test Report:

Patch Tested: https://github.com/WordPress/wordpress-develop/pull/8237

I have tested the above PR, and the header logo includes the rel="home" and aria-current="page" attributes.

Environment:

OS: macOS 15.2 (24C101)
Browser: Microsoft Edge Version 132.0.2957.127 (Official build) (arm64)
Screenshot: https://share.cleanshot.com/yyspBNJP95d7p2J5vHwS

#3 @sabernhardt
7 weeks ago

  • Keywords changes-requested added

I think you mean the site title (text) link; the site logo gets its link from get_custom_logo().

The PR replaces the title argument with two new arguments. The title argument should remain usable, but you could add rel="home" to the default:

		'title'       => '<a href="%1$s" rel="home">%2$s</a>',

Then you could add the aria-current attribute

  1. if it matches the conditions in get_custom_logo() (see #62879 for any updates) and
  2. if the title argument matches the default value.
    		$contents  = sprintf( $args['title'], esc_url( get_home_url( null, '/' ) ), esc_html( $site_title ) );
    		if (
    			( is_front_page() || is_home() && ( (int) get_option( 'page_for_posts' ) !== get_queried_object_id() ) )
    			&& ! is_paged()
    			&& $args['title'] === $defaults['title']
    		) {
    			$contents = str_replace( ' rel=', ' aria-current="page" rel=', $contents );
    		}
    		$classname = $args['title_class'];
    

I purposely did not use the condition argument because it can be customized, and even its default value does not include ! is_paged(). The condition determines whether the wrapping element is a heading, but aria-current would be more exclusive.

#4 @bschneidewind
7 weeks ago

  • Keywords changes-requested removed
  • Summary changed from Twenty Twenty: site logo link missing aria-current and rel=home to Twenty Twenty: site title link missing aria-current and rel=home attributes

Thank you @sabernhardt ~ just took care of those updates!

#5 @bschneidewind
7 weeks ago

  • Summary changed from Twenty Twenty: site title link missing aria-current and rel=home attributes to Bundled Themes: Accessibility additions to the site title link

Updated the scope to include all bundled themes:
TwentyTen
TwentyEleven
TwentyTwelve
TwentyThirteen
TwentyFourteen
TwentyFifteen
TwentySixteen
TwentySeventeen
TwentyNineteen
TwentyTwenty
TwentyTwentyOne

This ticket was mentioned in Slack in #accessibility by joedolson. View the logs.


6 weeks ago

#7 @joedolson
6 weeks ago

  • Description modified (diff)
  • Milestone changed from Awaiting Review to 6.8
  • Owner set to joedolson
  • Status changed from new to accepted

#8 @joedolson
3 weeks ago

  • Keywords commit added

I've reviewed the PR and added support for the rel and aria-current attributes on linked header images where appropriate, and made a couple minor fixes. Marking for commit.

#9 @joedolson
3 weeks ago

Removed the logic for aria-current from Twenty Twenty One. The intent on Twenty Twenty One is that there shouldn't be a link when the front page is shown, and any changes there should be about handling edge cases that can show a link rather than marking it as current.

#10 @joedolson
3 weeks ago

  • Resolution set to fixed
  • Status changed from accepted to closed

In 59907:

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.

Note: See TracTickets for help on using tickets.