Make WordPress Core

Changeset 37305


Ignore:
Timestamp:
04/22/2016 10:44:33 PM (8 years ago)
Author:
wonderboymusic
Message:

Comments: add a $comment parameter to get_comment_author_url_link().

Add unit tests (none exist).

Props flixos90, wonderboymusic.
Fixes #36573.

Location:
trunk
Files:
1 added
1 edited

Legend:

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

    r37208 r37305  
    294294function get_comment_author_url( $comment_ID = 0 ) {
    295295    $comment = get_comment( $comment_ID );
    296     $url = ('http://' == $comment->comment_author_url) ? '' : $comment->comment_author_url;
    297     $url = esc_url( $url, array('http', 'https') );
     296    $url = '';
     297    $id = 0;
     298    if ( ! empty( $comment ) ) {
     299        $author_url = ( 'http://' == $comment->comment_author_url ) ? '' : $comment->comment_author_url;
     300        $url = esc_url( $author_url, array( 'http', 'https' ) );
     301        $id = $comment->ID;
     302    }
    298303
    299304    /**
     
    307312     * @param WP_Comment $comment    The comment object.
    308313     */
    309     return apply_filters( 'get_comment_author_url', $url, $comment->comment_ID, $comment );
     314    return apply_filters( 'get_comment_author_url', $url, $id, $comment );
    310315}
    311316
     
    346351 *
    347352 * @since 1.5.0
    348  *
    349  * @param string $linktext Optional. The text to display instead of the comment
    350  *                         author's email address. Default empty.
    351  * @param string $before   Optional. The text or HTML to display before the email link.
    352  *                         Default empty.
    353  * @param string $after    Optional. The text or HTML to display after the email link.
    354  *                         Default empty.
     353 * @since 4.6.0 The `$comment` parameter was added.
     354 *
     355 * @param string         $linktext Optional. The text to display instead of the comment
     356 *                                 author's email address. Default empty.
     357 * @param string         $before   Optional. The text or HTML to display before the email link.
     358 *                                 Default empty.
     359 * @param string         $after    Optional. The text or HTML to display after the email link.
     360 *                                 Default empty.
     361 * @param int|WP_Comment $comment  Optional. Comment ID or WP_Comment object.
     362 *                                 Default is the current comment.
    355363 * @return string The HTML link between the $before and $after parameters.
    356364 */
    357 function get_comment_author_url_link( $linktext = '', $before = '', $after = '' ) {
    358     $url = get_comment_author_url();
     365function get_comment_author_url_link( $linktext = '', $before = '', $after = '', $comment = 0 ) {
     366    $url = get_comment_author_url( $comment );
    359367    $display = ($linktext != '') ? $linktext : $url;
    360368    $display = str_replace( 'http://www.', '', $display );
     
    381389 *
    382390 * @since 0.71
    383  *
    384  * @param string $linktext Optional. Text to display instead of the comment author's
    385  *                         email address. Default empty.
    386  * @param string $before   Optional. Text or HTML to display before the email link.
    387  *                         Default empty.
    388  * @param string $after    Optional. Text or HTML to display after the email link.
    389  *                         Default empty.
    390  */
    391 function comment_author_url_link( $linktext = '', $before = '', $after = '' ) {
    392     echo get_comment_author_url_link( $linktext, $before, $after );
     391 * @since 4.6.0 The `$comment` parameter was added.
     392 *
     393 * @param string         $linktext Optional. Text to display instead of the comment author's
     394 *                                 email address. Default empty.
     395 * @param string         $before   Optional. Text or HTML to display before the email link.
     396 *                                 Default empty.
     397 * @param string         $after    Optional. Text or HTML to display after the email link.
     398 *                                 Default empty.
     399 * @param int|WP_Comment $comment  Optional. Comment ID or WP_Comment object.
     400 *                                 Default is the current comment.
     401 */
     402function comment_author_url_link( $linktext = '', $before = '', $after = '', $comment = 0 ) {
     403    echo get_comment_author_url_link( $linktext, $before, $after, $comment );
    393404}
    394405
Note: See TracChangeset for help on using the changeset viewer.