From ce4a2a11dee7eb9b7cf03e9afa51c19df9db35e6 Mon Sep 17 00:00:00 2001 From: davidbaumwald Date: Mon, 11 Apr 2022 23:38:08 +0000 Subject: [PATCH] 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. Built from https://develop.svn.wordpress.org/trunk@53147 git-svn-id: http://core.svn.wordpress.org/trunk@52736 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/author-template.php | 26 ++++++++++++++++++++++---- wp-includes/version.php | 2 +- 2 files changed, 23 insertions(+), 5 deletions(-) diff --git a/wp-includes/author-template.php b/wp-includes/author-template.php index e129e6f701..3f28492377 100644 --- a/wp-includes/author-template.php +++ b/wp-includes/author-template.php @@ -224,18 +224,36 @@ function the_author_meta( $field = '', $user_id = false ) { * * @since 3.0.0 * + * @global WP_User $authordata The current author's data. + * * @return string|null An HTML link if the author's url exist in user meta, * else the result of get_the_author(). */ function get_the_author_link() { if ( get_the_author_meta( 'url' ) ) { - return sprintf( + global $authordata; + + $author_url = get_the_author_meta( 'url' ); + $author_display_name = get_the_author(); + + $link = sprintf( '%3$s', - esc_url( get_the_author_meta( 'url' ) ), + esc_url( $author_url ), /* translators: %s: Author's display name. */ - esc_attr( sprintf( __( 'Visit %s’s website' ), get_the_author() ) ), - get_the_author() + esc_attr( sprintf( __( 'Visit %s’s website' ), $author_display_name ) ), + $author_display_name ); + + /** + * Filters the author URL link HTML. + * + * @since 6.0.0 + * + * @param string $link The default rendered author HTML link. + * @param string $author_url Author's URL. + * @param WP_User $authordata Author user data. + */ + return apply_filters( 'the_author_link', $link, $author_url, $authordata ); } else { return get_the_author(); } diff --git a/wp-includes/version.php b/wp-includes/version.php index 38fef4128d..09443bf9df 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -16,7 +16,7 @@ * * @global string $wp_version */ -$wp_version = '6.0-alpha-53146'; +$wp_version = '6.0-alpha-53147'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.