get_comment_author_email_link

函式
get_comment_author_email_link ( $linktext = '', $before = '', $after = '', $comment = null )
引數
  • (string) $linktext Optional. Text to display instead of the comment author's email address. Default empty.
    Required:
    Default: (empty)
  • (string) $before Optional. Text or HTML to display before the email link. Default empty.
    Required:
    Default: (empty)
  • (string) $after Optional. 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:
    Default: null
返回值
  • (string) HTML markup for the comment author email link. By default, the email address is obfuscated via the {@see 'comment_email'} filter with antispambot().
定義位置
相關方法
comment_author_email_linkget_comment_author_emailget_comment_author_url_linkget_comment_author_linkcomment_author_email
引入
2.7.0
棄用
-

get_comment_author_email_link: 這個函式返回評論作者的電子郵件地址的HTML連結。它需要一個引數,即$comment_ID,它是你想獲取作者電子郵件連結的評論的ID。

返回HTML電子郵件連結給當前評論的作者。

應該注意保護電子郵件地址,並確保電子郵件收集者不會捕獲你的評論者的電子郵件地址。大多數人認為他們的電子郵件地址不會以原始形式出現在網站上。這樣做將使任何人,包括那些人們不希望得到的電子郵件地址,併為他們自己的手段好和壞使用。

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
function get_comment_author_email_link( $linktext = '', $before = '', $after = '', $comment = null ) {
$comment = get_comment( $comment );
/**
* Filters the comment author's email for display.
*
* Care should be taken to protect the email address and assure that email
* harvesters do not capture your commenter's email address.
*
* @since 1.2.0
* @since 4.1.0 The `$comment` parameter was added.
*
* @param string $comment_author_email The comment author's email address.
* @param WP_Comment $comment The comment object.
*/
$email = apply_filters( 'comment_email', $comment->comment_author_email, $comment );
if ( ( ! empty( $email ) ) && ( '@' !== $email ) ) {
$display = ( '' !== $linktext ) ? $linktext : $email;
$return = $before;
$return .= sprintf( '<a href="%1$s">%2$s</a>', esc_url( 'mailto:' . $email ), esc_html( $display ) );
$return .= $after;
return $return;
} else {
return '';
}
}
function get_comment_author_email_link( $linktext = '', $before = '', $after = '', $comment = null ) { $comment = get_comment( $comment ); /** * Filters the comment author's email for display. * * Care should be taken to protect the email address and assure that email * harvesters do not capture your commenter's email address. * * @since 1.2.0 * @since 4.1.0 The `$comment` parameter was added. * * @param string $comment_author_email The comment author's email address. * @param WP_Comment $comment The comment object. */ $email = apply_filters( 'comment_email', $comment->comment_author_email, $comment ); if ( ( ! empty( $email ) ) && ( '@' !== $email ) ) { $display = ( '' !== $linktext ) ? $linktext : $email; $return = $before; $return .= sprintf( '<a href="%1$s">%2$s</a>', esc_url( 'mailto:' . $email ), esc_html( $display ) ); $return .= $after; return $return; } else { return ''; } }
function get_comment_author_email_link( $linktext = '', $before = '', $after = '', $comment = null ) {
	$comment = get_comment( $comment );

	/**
	 * Filters the comment author's email for display.
	 *
	 * Care should be taken to protect the email address and assure that email
	 * harvesters do not capture your commenter's email address.
	 *
	 * @since 1.2.0
	 * @since 4.1.0 The `$comment` parameter was added.
	 *
	 * @param string     $comment_author_email The comment author's email address.
	 * @param WP_Comment $comment              The comment object.
	 */
	$email = apply_filters( 'comment_email', $comment->comment_author_email, $comment );

	if ( ( ! empty( $email ) ) && ( '@' !== $email ) ) {
		$display = ( '' !== $linktext ) ? $linktext : $email;
		$return  = $before;
		$return .= sprintf( '<a href="%1$s">%2$s</a>', esc_url( 'mailto:' . $email ), esc_html( $display ) );
		$return .= $after;
		return $return;
	} else {
		return '';
	}
}

常見問題

FAQs
檢視更多 >