From 8ec77ea445a62b6e1a231edeaebdef70e085e723 Mon Sep 17 00:00:00 2001 From: Scott Taylor Date: Fri, 22 Apr 2016 22:45:27 +0000 Subject: [PATCH] Comments: add a `$comment` parameter to `get_comment_author_url_link()`. Add unit tests (none exist). Props flixos90, wonderboymusic. Fixes #36573. Built from https://develop.svn.wordpress.org/trunk@37305 git-svn-id: http://core.svn.wordpress.org/trunk@37271 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/comment-template.php | 49 +++++++++++++++++++------------- wp-includes/version.php | 2 +- 2 files changed, 31 insertions(+), 20 deletions(-) diff --git a/wp-includes/comment-template.php b/wp-includes/comment-template.php index 09969c81da..92ba74fb55 100644 --- a/wp-includes/comment-template.php +++ b/wp-includes/comment-template.php @@ -293,8 +293,13 @@ function comment_author_IP( $comment_ID = 0 ) { */ function get_comment_author_url( $comment_ID = 0 ) { $comment = get_comment( $comment_ID ); - $url = ('http://' == $comment->comment_author_url) ? '' : $comment->comment_author_url; - $url = esc_url( $url, array('http', 'https') ); + $url = ''; + $id = 0; + if ( ! empty( $comment ) ) { + $author_url = ( 'http://' == $comment->comment_author_url ) ? '' : $comment->comment_author_url; + $url = esc_url( $author_url, array( 'http', 'https' ) ); + $id = $comment->ID; + } /** * Filter the comment author's URL. @@ -306,7 +311,7 @@ function get_comment_author_url( $comment_ID = 0 ) { * @param int $comment_ID The comment ID. * @param WP_Comment $comment The comment object. */ - return apply_filters( 'get_comment_author_url', $url, $comment->comment_ID, $comment ); + return apply_filters( 'get_comment_author_url', $url, $id, $comment ); } /** @@ -345,17 +350,20 @@ function comment_author_url( $comment_ID = 0 ) { * in the order of $before, link, and finally $after. * * @since 1.5.0 + * @since 4.6.0 The `$comment` parameter was added. * - * @param string $linktext Optional. The text to display instead of the comment - * author's email address. Default empty. - * @param string $before Optional. The text or HTML to display before the email link. - * Default empty. - * @param string $after Optional. The text or HTML to display after the email link. - * Default empty. + * @param string $linktext Optional. The text to display instead of the comment + * author's email address. Default empty. + * @param string $before Optional. The text or HTML to display before the email link. + * Default empty. + * @param string $after Optional. The text or HTML to display after the email link. + * Default empty. + * @param int|WP_Comment $comment Optional. Comment ID or WP_Comment object. + * Default is the current comment. * @return string The HTML link between the $before and $after parameters. */ -function get_comment_author_url_link( $linktext = '', $before = '', $after = '' ) { - $url = get_comment_author_url(); +function get_comment_author_url_link( $linktext = '', $before = '', $after = '', $comment = 0 ) { + $url = get_comment_author_url( $comment ); $display = ($linktext != '') ? $linktext : $url; $display = str_replace( 'http://www.', '', $display ); $display = str_replace( 'http://', '', $display ); @@ -380,16 +388,19 @@ function get_comment_author_url_link( $linktext = '', $before = '', $after = '' * Displays the HTML link of the url of the author of the current comment. * * @since 0.71 + * @since 4.6.0 The `$comment` parameter was added. * - * @param string $linktext Optional. Text to display instead of the comment author's - * email address. Default empty. - * @param string $before Optional. Text or HTML to display before the email link. - * Default empty. - * @param string $after Optional. Text or HTML to display after the email link. - * Default empty. + * @param string $linktext Optional. Text to display instead of the comment author's + * email address. Default empty. + * @param string $before Optional. Text or HTML to display before the email link. + * Default empty. + * @param string $after Optional. Text or HTML to display after the email link. + * Default empty. + * @param int|WP_Comment $comment Optional. Comment ID or WP_Comment object. + * Default is the current comment. */ -function comment_author_url_link( $linktext = '', $before = '', $after = '' ) { - echo get_comment_author_url_link( $linktext, $before, $after ); +function comment_author_url_link( $linktext = '', $before = '', $after = '', $comment = 0 ) { + echo get_comment_author_url_link( $linktext, $before, $after, $comment ); } /** diff --git a/wp-includes/version.php b/wp-includes/version.php index 27a570ac35..5408de6fda 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -4,7 +4,7 @@ * * @global string $wp_version */ -$wp_version = '4.6-alpha-37304'; +$wp_version = '4.6-alpha-37305'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.