Make WordPress Core

Opened 3 years ago

Closed 23 months ago

Last modified 23 months ago

#51859 closed enhancement (fixed)

Add filter to get_the_author_link

Reported by: dshanske's profile dshanske Owned by: davidbaumwald's profile davidbaumwald
Milestone: 6.0 Priority: normal
Severity: normal Version:
Component: Formatting Keywords: has-patch has-unit-tests needs-dev-note
Focuses: Cc:

Description

In order to allow customization of the markup, including adding classes for styling, and changing the rel properties, suggest the introduction of a get_the_author_link filter to allow this to be edited.

Change History (11)

This ticket was mentioned in PR #772 on WordPress/wordpress-develop by donmhico.


3 years ago
#1

  • Keywords has-patch added

Apply filter to author's HTML link using author_html_link filter.

Example usage

{{{php
/

  • @param string $html_link The default HTML author link.
  • @param string $author_url The author's url.
  • @param string $display_name The author's display name. */

add_filter( 'author_html_link', function( $html_link, $author_url, $display_name ) {

return '<a href="https://wp.org">Mico</a>';

}, 10, 3 );
}}}

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

#2 @dshanske
2 years ago

  • Milestone changed from Awaiting Review to 6.0

#3 @davidbaumwald
2 years ago

  • Owner set to davidbaumwald
  • Status changed from new to reviewing

#4 @audrasjb
2 years ago

  • Keywords needs-refresh 2nd-opinion added

@since mentions needs to be refreshed. Also, instead of passing $author_url and $display_name specific variables, should we rather pass a full WP_User object?

#5 @davidbaumwald
2 years ago

@audrasjb That sounds fine. Could use the $authordata global. This would make all user data available to the filter callback.

One other concern I have here is potential confusion with the existing author_link filter. I think renaming this new filter to author_url_link_html would be more appropriate.

I'm working on adding some unit tests for this new filter. I'll throw up a PR for easier review.

This ticket was mentioned in PR #2439 on WordPress/wordpress-develop by dream-encode.


2 years ago
#6

  • Keywords has-unit-tests added; needs-refresh removed

#7 @davidbaumwald
2 years ago

  • Keywords assigned-for-commit added

#8 @davidbaumwald
23 months ago

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

In 53147:

Formatting: Make get_the_author_link pluggable.

Adds a new filter to alter the output of get_the_author_link. This change also adds unit tests for the new filter.

Props dshanske, donmhico, audrasjb, peterwilsoncc, SergeyBiryukov.
Fixes #51859.

dream-encode commented on PR #772:


23 months ago
#9

Thanks for the PR! This was merged into core in https://core.trac.wordpress.org/changeset/53147.

#11 @davidbaumwald
23 months ago

  • Keywords needs-dev-note added; 2nd-opinion assigned-for-commit removed

Marking this for at least a small call-out on the Misc Dev Note for the new filter.

Note: See TracTickets for help on using tickets.