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.
定義位置
相關方法
get_comment_author_linkcomment_author_url_linkget_comment_author_urlget_comment_author_email_linkcomment_author_link
引入
1.5.0
棄用
-

get_comment_author_url_link: 這個函式返回評論作者的網站的HTML連結。它需要一個引數,即$comment_ID,這是你想檢索作者網站連結的評論的ID。

檢索當前評論的作者的URL的HTML連結。

$linktext引數只在評論作者的URL不存在時使用。如果URL確實存在,那麼將使用該URL,$linktext將被忽略。

將HTML連結封裝在$before和$after之間。所以它將以$before、link、最後$after的順序出現。

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
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<a href='$url' rel='external'>$display</a>$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 );
}
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<a href='$url' rel='external'>$display</a>$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 ); }
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<a href='$url' rel='external'>$display</a>$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 );
}

常見問題

FAQs
檢視更多 >