Make WordPress Core

Opened 10 years ago

Last modified 12 days ago

#39844 accepted enhancement

Don't return anchor tag if link is empty in get_the_author_posts_link()

Reported by: SirkoSchindler Owned by: joedolson
Priority: normal Milestone: Future Release
Component: Themes Version: 4.7.2
Severity: normal Keywords: has-patch
Cc: Focuses: accessibility, template

Description

If get_author_posts_url() returns an empty value, currently get_the_author_posts_link() creates an anchor tag with am empty target. If shown on the page this results in a link to the current page, which is not what is expected from an author link.

https://core.trac.wordpress.org/browser/tags/4.7.2/src/wp-includes/author-template.php#L252

The attached patch changes this, so that if no link is given, just the author name is returned with no anchor tag surrounding.
This is in line with the respective code for get_comment_author_link()

https://core.trac.wordpress.org/browser/tags/4.7.2/src/wp-includes/comment-template.php#L216

Attachments (2)

author-template.php.patch​ (1.7 KB ) - added by SirkoSchindler 10 years ago.
39844.diff​ (1.4 KB ) - added by sabernhardt 5 years ago.

Download all attachments as: .zip

Change History (10)

#1 @swissspidy
10 years ago

  • Keywords has-patch added

#2 @SirkoSchindler
9 years ago

Any updates or comments on this?

#3 @swissspidy
9 years ago

  • Keywords needs-unit-tests added
  • Milestone Awaiting Review → Future Release

@sabernhardt
5 years ago

#4 @sabernhardt
5 years ago

To work on this, I removed and then changed the author's URL with the author_link hook:

add_filter( 'author_link', '__return_empty_string' );
add_filter( 'author_link', function(){ return 'http://'; } );

The patch is refreshed, but it still should have unit tests.

This ticket was mentioned in ​PR #12415 on ​WordPress/wordpress-develop by ​@sainathpoojary.


3 months ago
#5

Trac ticket: #39844

#6 @sainathpoojary
3 months ago

  • Keywords needs-unit-tests removed

#7 @joedolson
3 months ago

  • Focuses accessibility added
  • Owner set to joedolson
  • Status new → accepted

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


12 days ago

Note: See TracTickets for help on using tickets.