检索指向当前注释的作者的URL的HTML链接。
原型
get_comment_author_link( int|WP_Comment $comment_ID )
描述
get_comment_author_url()和get_comment_author()都依赖于get_comment(),如果$ comment_ID参数为空,它将回退到全局注释变量。
参数
$comment_ID
(int|WP_Comment)
(Optional)
WP_Comment或要获取作者链接的注释的ID。默认当前评论。
返回值
(string)
作者URL的评论作者姓名或HTML链接。
源文件
路径:wp-includes/comment-template.php
<?php
...
function get_comment_author_link( $comment_ID = 0 ) {
$comment = get_comment( $comment_ID );
$url = get_comment_author_url( $comment );
$author = get_comment_author( $comment );
if ( empty( $url ) || 'http://' == $url )
$return = $author;
else
$return = "<a href='$url' rel='external nofollow' class='url'>$author</a>";
/**
* Filters the comment author's link for display.
*
* @since 1.5.0
* @since 4.1.0 The `$author` and `$comment_ID` parameters were added.
*
* @param string $return The HTML-formatted comment author link.
* Empty for an invalid URL.
* @param string $author The comment author's username.
* @param int $comment_ID The comment ID.
*/
return apply_filters( 'get_comment_author_link', $return, $author, $comment->comment_ID );
}
...
?>
其他
英文文档:https://developer.wordpress.org/reference/functions/get_comment_author_link/