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
This commit is contained in:
Scott Taylor 2016-04-22 22:45:27 +00:00
parent e02de569a6
commit 8ec77ea445
2 changed files with 31 additions and 20 deletions

View File

@ -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 );
}
/**

View File

@ -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.