Make WordPress Core

Opened 3 years ago

Last modified 3 months ago

#16433 accepted enhancement

Extend function to optionally include commenter name in comment_reply_link

Reported by: Elpie Owned by: merty
Milestone: Future Release Priority: low
Severity: normal Version: 3.0.4
Component: Comments Keywords: has-patch
Focuses: accessibility Cc:


Screen readers recognize links and make them searchable. Unique names facilitate that search. Links need to have unique names that are descriptive and make sense when read out of context. WordPress allows users to set the text they want to display on the comment_reply_link but then this text is repeated for every comment on a post.

WCAG Checkpoint 13.1 says: Clearly identify the target of each link. [Priority 2]

For improved accessibility it is far better to have the comment_reply_link include the commenter name. "Reply to Tom Thumb" and ideally, include a title on the link that includes both the commenter name and comment number. Users should have the option to filter for their custom text and to include (or not include) the commenter name.

At the moment, anyone who wants to present an accessible front-end cannot use threaded comments unless they are prepared to generate masses of the same, generic, unhelpful link.

Attachments (3)

16433.diff (527 bytes) - added by andrewryno 3 years ago.
16433.patch (1.2 KB) - added by merty 3 years ago.
16433.2.diff (1.2 KB) - added by merty 17 months ago.
This should be the proper way to do it

Download all attachments as: .zip

Change History (16)

comment:1 Elpie3 years ago

Somewhat related to #10569.

comment:2 scribu3 years ago

  • Cc scribu added

andrewryno3 years ago

comment:3 andrewryno3 years ago

Possible fix. Just gives the user a %s option in 'reply_text' which will add the persons username. Not sure if someone wants to change this to allow different tags (username, first name, last name, nickname, etc.).

comment:4 markjaquith3 years ago

  • Milestone changed from Awaiting Review to Future Release
  • Priority changed from normal to low
  • Type changed from defect (bug) to enhancement

Like that idea, andrewryno.

I had to use this nonsense to do it!

function txfx_reply_to_comment_link( $link, $args, $comment ) {
	if ( !empty( $comment->comment_type ) )
		return '';
	$link = str_replace( '>' . $args['reply_text'] . '<', '>' . esc_html( 'Reply to ' . $comment->comment_author ) . ' &rarr;<', $link );
	return $link;

add_filter( 'comment_reply_link', 'txfx_reply_to_comment_link', 10, 3 );

comment:5 Elpie3 years ago

Thanks andrewryno. This will make a significant difference to frontend accessibility for the average user. Accessibility out of the box is far preferable to having to add custom functions on a theme by theme basis. Cheers.

This is a trivial change - any chance it can get into 3.1?

comment:6 markjaquith3 years ago

No chance for 3.1. But 3.2 dev should start soon.

merty3 years ago

comment:7 merty3 years ago

  • Owner set to merty
  • Status changed from new to accepted

Applied a patch to the current repository. The patch can be found in the attachments section.

Version 1, edited 3 years ago by merty (previous) (next) (diff)

comment:8 Elpie3 years ago

Is there any chance of this getting into 3.2 or has it missed the boat again?

comment:9 Elpie3 years ago

  • Cc Elpie added

comment:10 merty3 years ago

  • Cc merty92@… added

comment:11 SergeyBiryukov3 years ago

  • Keywords has-patch added

merty17 months ago

This should be the proper way to do it

comment:12 scottsweb7 months ago

  • Cc scottsweb added

Due to the useless / repetitive nature of title attributes when used in screen readers (discussed in #24766), it may not be best to proceed with adding a title attribute for this ticket.

If this was within wp-admin we could alter the actual anchor text to include both the commenter name and comment number, then wrap that new text within <span class="screen-reader-text">. For the front end though it would require themes support the screen-reader-text class along with http://codex.wordpress.org/CSS#WordPress_Generated_Classes which we cannot guarantee at the moment.

comment:13 nacin3 months ago

  • Component changed from Accessibility to Comments
  • Focuses accessibility added
Note: See TracTickets for help on using tickets.