Introduce `get_the_author_posts_link()`, which returns the HTML link to the author page for the current post's author.

`the_author_posts_link()` has in-turn been converted into a wrapper, with most of its logic moved to the new function.

Adds tests for the new function.

Props chipbennett, zrothauser, wonderboymusic, DrewAPicture.
Fixes #30355.

Built from https://develop.svn.wordpress.org/trunk@34677


git-svn-id: http://core.svn.wordpress.org/trunk@34641 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Drew Jaynes 2015-09-29 01:49:25 +00:00
parent d5b2929dbb
commit d242d5bbfb
2 changed files with 22 additions and 13 deletions

View File

@ -223,23 +223,17 @@ function the_author_posts() {
} }
/** /**
* Display an HTML link to the author page of the author of the current post. * Retrieves an HTML link to the author page of the current post's author.
* *
* Does just echo get_author_posts_url() function, like the others do. The * Returns an HTML-formatted link using get_author_posts_url().
* reason for this, is that another function is used to help in printing the
* link to the author's posts.
* *
* @link https://codex.wordpress.org/Template_Tags/the_author_posts_link * @since 4.4.0
* @since 1.2.0
* *
* @global object $authordata The current author's DB object. * @global object $authordata The current author's DB object.
* *
* @param string $deprecated Deprecated. * @return string An HTML link to the author page.
*/ */
function the_author_posts_link($deprecated = '') { function get_the_author_posts_link() {
if ( !empty( $deprecated ) )
_deprecated_argument( __FUNCTION__, '2.1' );
global $authordata; global $authordata;
if ( ! is_object( $authordata ) ) { if ( ! is_object( $authordata ) ) {
return; return;
@ -259,7 +253,22 @@ function the_author_posts_link($deprecated = '') {
* *
* @param string $link HTML link. * @param string $link HTML link.
*/ */
echo apply_filters( 'the_author_posts_link', $link ); return apply_filters( 'the_author_posts_link', $link );
}
/**
* Displays an HTML link to the author page of the current post's author.
*
* @since 1.2.0
* @since 4.4.0 Converted into a wrapper for get_the_author_posts_link()
*
* @param string $deprecated Unused.
*/
function the_author_posts_link( $deprecated = '' ) {
if ( ! empty( $deprecated ) ) {
_deprecated_argument( __FUNCTION__, '2.1' );
}
echo get_the_author_posts_link();
} }
/** /**

View File

@ -4,7 +4,7 @@
* *
* @global string $wp_version * @global string $wp_version
*/ */
$wp_version = '4.4-alpha-34676'; $wp_version = '4.4-alpha-34677';
/** /**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema. * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.