mirror of
https://github.com/WordPress/WordPress.git
synced 2024-12-23 01:27:36 +01:00
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:
parent
e02de569a6
commit
8ec77ea445
@ -293,8 +293,13 @@ function comment_author_IP( $comment_ID = 0 ) {
|
|||||||
*/
|
*/
|
||||||
function get_comment_author_url( $comment_ID = 0 ) {
|
function get_comment_author_url( $comment_ID = 0 ) {
|
||||||
$comment = get_comment( $comment_ID );
|
$comment = get_comment( $comment_ID );
|
||||||
$url = ('http://' == $comment->comment_author_url) ? '' : $comment->comment_author_url;
|
$url = '';
|
||||||
$url = esc_url( $url, array('http', 'https') );
|
$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.
|
* 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 int $comment_ID The comment ID.
|
||||||
* @param WP_Comment $comment The comment object.
|
* @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.
|
* in the order of $before, link, and finally $after.
|
||||||
*
|
*
|
||||||
* @since 1.5.0
|
* @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
|
* @param string $linktext Optional. The text to display instead of the comment
|
||||||
* author's email address. Default empty.
|
* author's email address. Default empty.
|
||||||
* @param string $before Optional. The text or HTML to display before the email link.
|
* @param string $before Optional. The text or HTML to display before the email link.
|
||||||
* Default empty.
|
* Default empty.
|
||||||
* @param string $after Optional. The text or HTML to display after the email link.
|
* @param string $after Optional. The text or HTML to display after the email link.
|
||||||
* Default empty.
|
* 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.
|
* @return string The HTML link between the $before and $after parameters.
|
||||||
*/
|
*/
|
||||||
function get_comment_author_url_link( $linktext = '', $before = '', $after = '' ) {
|
function get_comment_author_url_link( $linktext = '', $before = '', $after = '', $comment = 0 ) {
|
||||||
$url = get_comment_author_url();
|
$url = get_comment_author_url( $comment );
|
||||||
$display = ($linktext != '') ? $linktext : $url;
|
$display = ($linktext != '') ? $linktext : $url;
|
||||||
$display = str_replace( 'http://www.', '', $display );
|
$display = str_replace( 'http://www.', '', $display );
|
||||||
$display = str_replace( 'http://', '', $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.
|
* Displays the HTML link of the url of the author of the current comment.
|
||||||
*
|
*
|
||||||
* @since 0.71
|
* @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
|
* @param string $linktext Optional. Text to display instead of the comment author's
|
||||||
* email address. Default empty.
|
* email address. Default empty.
|
||||||
* @param string $before Optional. Text or HTML to display before the email link.
|
* @param string $before Optional. Text or HTML to display before the email link.
|
||||||
* Default empty.
|
* Default empty.
|
||||||
* @param string $after Optional. Text or HTML to display after the email link.
|
* @param string $after Optional. Text or HTML to display after the email link.
|
||||||
* Default empty.
|
* 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 = '' ) {
|
function comment_author_url_link( $linktext = '', $before = '', $after = '', $comment = 0 ) {
|
||||||
echo get_comment_author_url_link( $linktext, $before, $after );
|
echo get_comment_author_url_link( $linktext, $before, $after, $comment );
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
*
|
*
|
||||||
* @global string $wp_version
|
* @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.
|
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
||||||
|
Loading…
Reference in New Issue
Block a user