Make WordPress Core

Opened 14 months ago

Closed 13 days ago

Last modified 13 days ago

#62835 closed defect (bug) (fixed)

Remove title attributes from author link functions

Reported by: sabernhardt's profile sabernhardt Owned by: joedolson's profile joedolson
Milestone: 7.0 Priority: normal
Severity: normal Version:
Component: Users Keywords: title-attribute has-patch has-unit-tests needs-dev-note commit
Focuses: accessibility Cc:

Description

Related: #24766 and #26559

#26559 retained some title attributes because the "Posts by author" and "Visit author's website" tooltips still had a small additional value for anyone who could access them. (The important information was already in the visible link text.)

Discussion on #24766 started to reconsider either removing the title attributes or changing them.

@audrasjb:

Shouldn't we just replace the title attribute with aria-label?

@joedolson:

This should also consider a text order change. For screen reader users, the unique information should go first: 'website: author', 'posts: author'; but for voice command, the visible information should go first: 'author: website', 'author: posts'.

@alh0319 suggested removing the attributes in a spreadsheet, and @adnanlimdi had made a patch like that.

More than 70 themes in the directory use at least two of the three functions. The output might require some distinction between the author's website link (get_the_author_link()) and the author's post archives page (get_the_author_posts_link() and wp_list_authors()).

Alternatively, functions could add a parameter that defaults to the current title but allows removing it.

Change History (25)

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


14 months ago
#1

  • Keywords has-patch has-unit-tests added

Option 1: Remove title attributes, and update unit tests.

Props adnanlimdi

Trac 62835

#2 @joedolson
14 months ago

I still think that we need to be able to differentiate between the two different links; otherwise we're making an existing accessibility issue worse, by having links to two different resources with the same text.

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


14 months ago
#3

Option 2:

  • Removes 'Posts by %s' title attributes from get_the_author_posts_link(), the_author_posts_link() and wp_list_authors().
  • Creates a new $use_title_attr parameter for website links in get_the_author_link() and the_author_link().

By default, this would keep a distinction between links from get_the_author_link() functions and the post archive links, if they are on the same page.

Like option 1, it would also remove Core's 'Posts by %s' string, which at least 18 plugins and one recently unlisted theme have used.

Trac 62835

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


14 months ago
#4

Option 3:
Creates a new $use_title_attr argument for each of the author link functions.

By default, this should not change the output of these functions.

Trac 62835

@sabernhardt commented on PR #8183:


14 months ago
#5

The function the_author_posts_link() deprecated an `$idmode` parameter. If that parameter needs to remain deprecated and unused, I could undo the changes to that function in this PR. Then anyone who wants to remove the title attribute would use
echo get_the_author_posts_link( false );

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


13 months ago

#7 @joedolson
13 months ago

  • Milestone changed from Awaiting Review to 6.8
  • Owner set to joedolson
  • Status changed from new to accepted

#8 @audrasjb
13 months ago

Personally, I'd go with Option 2 (PR 8182). Option 3 (PR 8183) looks way overkill to me :)

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


12 months ago

@sabernhardt commented on PR #8156:


12 months ago
#10

Option 1 would not distinguish between similar links, so I'm closing the first PR.

#11 follow-up: @joedolson
12 months ago

I think option 2 makes the most sense, as well. I'm not thrilled about still using the title attribute to differentiate between these, since it's such a low priority marker. While it *technically* provides a difference between the links, it'll only be perceivable to a small percentage of users.

But adding an aria-label would mean that the difference is perceivable to all screen reader users, but to no one else, and would cause some problems for voice command.

Given that the best option right now is for authors to not use the_author_link(), so that they can customize the link text, I feel like allowing authors to set the existing title attribute as the link text would be a good fallback.

#12 in reply to: ↑ 11 @sabernhardt
12 months ago

  • Keywords needs-dev-note added
  • Milestone changed from 6.8 to 6.9

I feel like allowing authors to set the existing title attribute as the link text would be a good fallback.

I have not yet checked whether this is already possible with PR 8182 (likely using a filter). However, I do not recommend committing these changes late in the beta stage.

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


9 months ago

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


5 months ago

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


4 months ago

#16 @joedolson
4 months ago

  • Milestone changed from 6.9 to 7.0

Given that PR 8182 doesn't appear to meet the visible text needs, this isn't quite ready and we ran out of time. Going to move this to 7.0. It really should be doable.

This ticket was mentioned in Slack in #core by audrasjb. View the logs.


4 weeks ago

#18 @audrasjb
4 weeks ago

  • Keywords changes-requested added

As per today's bug scrub:
This ticket was reviewed during cycle 6.8 but we ran out of time to address the changes suggested in comment:12. The ticket was moved to 6.9 then to 7.0.

Let's still give it 10 days and punt it to Future Release before 7.0 beta 1.

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


2 weeks ago
#19

Extends option 2, with new parameters for the_author_posts_link filter:

  • Removes 'Posts by %s' title attributes from get_the_author_posts_link(), the_author_posts_link() and wp_list_authors().
  • Retains Core's 'Posts by %s' string for potential use in the the_author_posts_link hook.
  • Creates a new $use_title_attr parameter for website links in get_the_author_link() and the_author_link().

By default, this would keep a distinction between links from get_the_author_link() functions and the post archive links, if they are on the same page.

Trac 62835

Use of AI Tools: none

@sabernhardt commented on PR #11042:


2 weeks ago
#20

I was able to replace the author display name with the 'Posts by author' text in the author posts link function. I activated the Hemingway theme to find the output on single posts.

function wptrac_author_posts_link( $link, $author = '', $title = '' ) {
	if ( '' !== $title && '' !== $author ) {
		$link = str_replace(
			'>' . $author . '</a>',
			'>' . esc_html( $title ) . '</a>', 
			$link
		);
	}

	return $link;
}
add_filter( 'the_author_posts_link', 'wptrac_author_posts_link', 10, 3 );

I did not add a comparable change in the author list function because that would be verbose.

#21 @sabernhardt
2 weeks ago

  • Keywords changes-requested removed

#22 @joedolson
13 days ago

  • Keywords commit added

Tested:

  • default: the_author_posts_link(); returns author name with no title attribute
  • default: the_author_link(); returns author name with title attribute
  • the_author_link( false ) returns the author name with no title attribute
  • filter works as expected, allowing you to easily replace the name with the title attribute or make other changes.

Confirmed; marking for commit.

#23 @joedolson
13 days ago

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

In 61745:

Users: A11y: Improve title attributes in author link functions.

Remove the title attribute from the_author_posts_link() and related functions, retaining text for use in the_author_posts_link filter, and add parameter to disable title attributes in the_author_link().

Default behavior will still differentiate the two links, but adds the option to remove all title attributes.

Props sabernhardt, alh0319, adnanlimdi, audrasjb, joedolson.
Fixes #62835. See #26559.

@sabernhardt commented on PR #8182:


13 days ago
#25

Replaced by #11042, which was committed in r61745

Note: See TracTickets for help on using tickets.