Make WordPress Core


Ignore:
Timestamp:
05/02/2016 07:58:23 PM (9 years ago)
Author:
DrewAPicture
Message:

Comments: Adjust comment_author_email_link() and get_comment_author_email_link() to each accept a new optional fourth parameter, $comment, which enables overriding the $comment global.

Adds tests.

Props flixos90, boonebgorges, DrewAPicture.
See #36571.

File:
1 edited

Legend:

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

    r37342 r37348  
    139139 *
    140140 * @since 0.71
     141 * @since 4.6.0 The `$comment` parameter was added.
    141142 *
    142143 * @param string $linktext Optional. Text to display instead of the comment author's email address.
     
    144145 * @param string $before   Optional. Text or HTML to display before the email link. Default empty.
    145146 * @param string $after    Optional. Text or HTML to display after the email link. Default empty.
    146  */
    147 function comment_author_email_link( $linktext = '', $before = '', $after = '' ) {
    148     if ( $link = get_comment_author_email_link( $linktext, $before, $after ) )
     147 * @param int|WP_Comment $comment Optional. Comment ID or WP_Comment object. Default is the current comment.
     148 */
     149function comment_author_email_link( $linktext = '', $before = '', $after = '', $comment = null ) {
     150    if ( $link = get_comment_author_email_link( $linktext, $before, $after, $comment ) ) {
    149151        echo $link;
     152    }
    150153}
    151154
     
    160163 *
    161164 * @since 2.7.0
     165 * @since 4.6.0 The `$comment` parameter was added.
    162166 *
    163167 * @param string $linktext Optional. Text to display instead of the comment author's email address.
     
    165169 * @param string $before   Optional. Text or HTML to display before the email link. Default empty.
    166170 * @param string $after    Optional. Text or HTML to display after the email link. Default empty.
     171 * @param int|WP_Comment $comment Optional. Comment ID or WP_Comment object. Default is the current comment.
    167172 * @return string
    168173 */
    169 function get_comment_author_email_link( $linktext = '', $before = '', $after = '' ) {
    170     $comment = get_comment();
     174function get_comment_author_email_link( $linktext = '', $before = '', $after = '', $comment = null ) {
     175    $comment = get_comment( $comment );
     176
    171177    /**
    172178     * Filter the comment author's email for display.
     
    182188     */
    183189    $email = apply_filters( 'comment_email', $comment->comment_author_email, $comment );
     190
    184191    if ((!empty($email)) && ($email != '@')) {
    185192    $display = ($linktext != '') ? $linktext : $email;
Note: See TracChangeset for help on using the changeset viewer.