Make WordPress Core

Changeset 34677


Ignore:
Timestamp:
09/29/2015 01:48:47 AM (9 years ago)
Author:
DrewAPicture
Message:

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.

Location:
trunk
Files:
1 added
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/author-template.php

    r32594 r34677  
    224224
    225225/**
    226  * Display an HTML link to the author page of the author of the current post.
    227  *
    228  * Does just echo get_author_posts_url() function, like the others do. The
    229  * reason for this, is that another function is used to help in printing the
    230  * link to the author's posts.
    231  *
    232  * @link https://codex.wordpress.org/Template_Tags/the_author_posts_link
    233  * @since 1.2.0
     226 * Retrieves an HTML link to the author page of the current post's author.
     227 *
     228 * Returns an HTML-formatted link using get_author_posts_url().
     229 *
     230 * @since 4.4.0
    234231 *
    235232 * @global object $authordata The current author's DB object.
    236233 *
    237  * @param string $deprecated Deprecated.
    238  */
    239 function the_author_posts_link($deprecated = '') {
    240     if ( !empty( $deprecated ) )
    241         _deprecated_argument( __FUNCTION__, '2.1' );
    242 
     234 * @return string An HTML link to the author page.
     235 */
     236function get_the_author_posts_link() {
    243237    global $authordata;
    244238    if ( ! is_object( $authordata ) ) {
     
    260254     * @param string $link HTML link.
    261255     */
    262     echo apply_filters( 'the_author_posts_link', $link );
     256    return apply_filters( 'the_author_posts_link', $link );
     257}
     258
     259/**
     260 * Displays an HTML link to the author page of the current post's author.
     261 *
     262 * @since 1.2.0
     263 * @since 4.4.0 Converted into a wrapper for get_the_author_posts_link()
     264 *
     265 * @param string $deprecated Unused.
     266 */
     267function the_author_posts_link( $deprecated = '' ) {
     268    if ( ! empty( $deprecated ) ) {
     269        _deprecated_argument( __FUNCTION__, '2.1' );
     270    }
     271    echo get_the_author_posts_link();
    263272}
    264273
Note: See TracChangeset for help on using the changeset viewer.