sanitize_comment_cookies()HTTP请求读取cookies后执行此动作函数

目录

描述

译文

审查发送给用户的cookies

若已经为用户生成cookies,可以进行其他操作。cookies被发送到其他地方之后,可以使用该函数。

原文

Sanitizes the cookies sent to the user already.

Will only do anything if the cookies have already been created for the user. Mostly used after cookies had been sent to use elsewhere.

sanitize_comment_cookies() 描述

用法

<?php sanitize_comment_cookies() ?>

sanitize_comment_cookies() 用法

参数

返回值

(void) 

This function does not return a value.

sanitize_comment_cookies() 返回值

注意

  • 使用到: apply_filters() with 'pre_comment_author_name' on 'comment_author' cookie
  • 使用到: apply_filters() with 'pre_comment_author_email' on 'comment_author_email' cookie
  • 使用到: apply_filters() with 'pre_comment_author_url' on 'comment_author_url' cookie

sanitize_comment_cookies() 注意

历史

添加于 版本: 2.0.4

sanitize_comment_cookies() 历史

源文件

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

/* ----------------------------------
 * wordpress之魂 © http://wphun.com
 * ---------------------------------- */
/**
 * Sanitizes the cookies sent to the user already.
 *
 * Will only do anything if the cookies have already been created for the user.
 * Mostly used after cookies had been sent to use elsewhere.
 *
 * @since 2.0.4
 */
function sanitize_comment_cookies() {
	if ( isset( $_COOKIE['comment_author_' . COOKIEHASH] ) ) {
		/**
		 * Filter the comment author's name cookie before it is set.
		 *
		 * When this filter hook is evaluated in wp_filter_comment(),
		 * the comment author's name string is passed.
		 *
		 * @since 1.5.0
		 *
		 * @param string $author_cookie The comment author name cookie.
		 */
		$comment_author = apply_filters( 'pre_comment_author_name', $_COOKIE['comment_author_' . COOKIEHASH] );
		$comment_author = wp_unslash($comment_author);
		$comment_author = esc_attr($comment_author);
		$_COOKIE['comment_author_' . COOKIEHASH] = $comment_author;
	}

	if ( isset( $_COOKIE['comment_author_email_' . COOKIEHASH] ) ) {
		/**
		 * Filter the comment author's email cookie before it is set.
		 *
		 * When this filter hook is evaluated in wp_filter_comment(),
		 * the comment author's email string is passed.
		 *
		 * @since 1.5.0
		 *
		 * @param string $author_email_cookie The comment author email cookie.
		 */
		$comment_author_email = apply_filters( 'pre_comment_author_email', $_COOKIE['comment_author_email_' . COOKIEHASH] );
		$comment_author_email = wp_unslash($comment_author_email);
		$comment_author_email = esc_attr($comment_author_email);
		$_COOKIE['comment_author_email_'.COOKIEHASH] = $comment_author_email;
	}

	if ( isset( $_COOKIE['comment_author_url_' . COOKIEHASH] ) ) {
		/**
		 * Filter the comment author's URL cookie before it is set.
		 *
		 * When this filter hook is evaluated in wp_filter_comment(),
		 * the comment author's URL string is passed.
		 *
		 * @since 1.5.0
		 *
		 * @param string $author_url_cookie The comment author URL cookie.
		 */
		$comment_author_url = apply_filters( 'pre_comment_author_url', $_COOKIE['comment_author_url_' . COOKIEHASH] );
		$comment_author_url = wp_unslash($comment_author_url);
		$_COOKIE['comment_author_url_'.COOKIEHASH] = $comment_author_url;
	}
}

sanitize_comment_cookies() 源文件