get_comment_author_url_link

函数


get_comment_author_url_link ( $linktext = '', $before = '', $after = '', $comment = 0 )
参数
  • (string)
    $linktext
    Optional. The text to display instead of the comment author’s email address. Default empty.
    Required:
    Default: (empty)
  • (string)
    $before
    Optional. The text or HTML to display before the email link. Default empty.
    Required:
    Default: (empty)
  • (string)
    $after
    Optional. The text or HTML to display after the email link. Default empty.
    Required:
    Default: (empty)
  • (int|WP_Comment)
    $comment
    Optional. Comment ID or WP_Comment object. Default is the current comment.
    Required:
返回值
  • (string) The HTML link between the $before and $after parameters.
定义位置
  • wp-includes/comment-template.php
    , line 379
引入
1.5.0
弃用

检索当前评论的作者的URL的HTML链接。

$linktext参数只在评论作者的URL不存在时使用。如果URL确实存在,那么将使用该URL,$linktext将被忽略。

将HTML链接封装在$before和$after之间。所以它将以$before、link、最后$after的顺序出现。

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 );

	if ( '/' === substr( $display, -1 ) ) {
		$display = substr( $display, 0, -1 );
	}

	$return = "$before$display$after";

	/**
	 * Filters the comment author's returned URL link.
	 *
	 * @since 1.5.0
	 *
	 * @param string $return The HTML-formatted comment author URL link.
	 */
	return apply_filters( 'get_comment_author_url_link', $return );
}