wp_get_current_commenter()获取当前评论的信息

目录

描述

译文

获取当前评论者的姓名、电子邮件和URL。

希望cookies内容已经被过滤。该函数的使用者可能希望重新检查返回的数组。

原文

Get current commenter's name, email, and URL.

Expects cookies content to already be sanitized. User of this function might wish to recheck the returned array for validity.

wp_get_current_commenter() 描述

用法

<?php wp_get_current_commenter() ?>

wp_get_current_commenter() 用法

返回值

(array) 

Comment author, email, url respectively.

wp_get_current_commenter() 返回值

注意

  • Return array is mapped like this:
/* ----------------------------------
 * wordpress之魂 © http://wphun.com
 * ---------------------------------- */

    Array (
        ['comment_author']       => 'Harriet Smith,
        ['comment_author_email'] => 'hsmith@,example.com',
        ['comment_author_url']   => 'http://example.com/'
    )

wp_get_current_commenter() 注意

历史

添加于 版本: 2.0.4

wp_get_current_commenter() 历史

源文件

wp_get_current_commenter() 函数的代码位于 wp-includes/comment.php.

/* ----------------------------------
 * wordpress之魂 © http://wphun.com
 * ---------------------------------- */
/**
 * Get current commenter's name, email, and URL.
 *
 * Expects cookies content to already be sanitized. User of this function might
 * wish to recheck the returned array for validity.
 *
 * @see sanitize_comment_cookies() Use to sanitize cookies
 *
 * @since 2.0.4
 *
 * @return array Comment author, email, url respectively.
 */
function wp_get_current_commenter() {
	// Cookies should already be sanitized.

	$comment_author = '';
	if ( isset($_COOKIE['comment_author_'.COOKIEHASH]) )
		$comment_author = $_COOKIE['comment_author_'.COOKIEHASH];

	$comment_author_email = '';
	if ( isset($_COOKIE['comment_author_email_'.COOKIEHASH]) )
		$comment_author_email = $_COOKIE['comment_author_email_'.COOKIEHASH];

	$comment_author_url = '';
	if ( isset($_COOKIE['comment_author_url_'.COOKIEHASH]) )
		$comment_author_url = $_COOKIE['comment_author_url_'.COOKIEHASH];

	/**
	 * Filter the current commenter's name, email, and URL.
	 *
	 * @since 3.1.0
	 *
	 * @param string $comment_author       Comment author's name.
	 * @param string $comment_author_email Comment author's email.
	 * @param string $comment_author_url   Comment author's URL.
	 */
	return apply_filters( 'wp_get_current_commenter', compact('comment_author', 'comment_author_email', 'comment_author_url') );
}

wp_get_current_commenter() 源文件

相关