返回介绍

wp_filter_comment()

发布于 2017-09-11 11:56:49 字数 3957 浏览 905 评论 0 收藏 0

wp_filter_comment( array $commentdata )

Filters and sanitizes comment data.


description

Sets the comment data ‘filtered’ field to true when finished. This can be checked as to whether the comment should be filtered and to keep from filtering the same comment more than once.


参数

$commentdata

(array) (Required) Contains information on the comment.


返回值

(array) Parsed comment information.


源代码

File: wp-includes/comment.php

function wp_filter_comment($commentdata) {
	if ( isset( $commentdata['user_ID'] ) ) {
		/**
		 * Filters the comment author's user id before it is set.
		 *
		 * The first time this filter is evaluated, 'user_ID' is checked
		 * (for back-compat), followed by the standard 'user_id' value.
		 *
		 * @since 1.5.0
		 *
		 * @param int $user_ID The comment author's user ID.
		 */
		$commentdata['user_id'] = apply_filters( 'pre_user_id', $commentdata['user_ID'] );
	} elseif ( isset( $commentdata['user_id'] ) ) {
		/** This filter is documented in wp-includes/comment.php */
		$commentdata['user_id'] = apply_filters( 'pre_user_id', $commentdata['user_id'] );
	}

	/**
	 * Filters the comment author's browser user agent before it is set.
	 *
	 * @since 1.5.0
	 *
	 * @param string $comment_agent The comment author's browser user agent.
	 */
	$commentdata['comment_agent'] = apply_filters( 'pre_comment_user_agent', ( isset( $commentdata['comment_agent'] ) ? $commentdata['comment_agent'] : '' ) );
	/** This filter is documented in wp-includes/comment.php */
	$commentdata['comment_author'] = apply_filters( 'pre_comment_author_name', $commentdata['comment_author'] );
	/**
	 * Filters the comment content before it is set.
	 *
	 * @since 1.5.0
	 *
	 * @param string $comment_content The comment content.
	 */
	$commentdata['comment_content'] = apply_filters( 'pre_comment_content', $commentdata['comment_content'] );
	/**
	 * Filters the comment author's IP before it is set.
	 *
	 * @since 1.5.0
	 *
	 * @param string $comment_author_ip The comment author's IP.
	 */
	$commentdata['comment_author_IP'] = apply_filters( 'pre_comment_user_ip', $commentdata['comment_author_IP'] );
	/** This filter is documented in wp-includes/comment.php */
	$commentdata['comment_author_url'] = apply_filters( 'pre_comment_author_url', $commentdata['comment_author_url'] );
	/** This filter is documented in wp-includes/comment.php */
	$commentdata['comment_author_email'] = apply_filters( 'pre_comment_author_email', $commentdata['comment_author_email'] );
	$commentdata['filtered'] = true;
	return $commentdata;
}

更新日志

Versiondescription
2.0.0Introduced.

相关函数

Uses

  • wp-includes/plugin.php: apply_filters()
  • wp-includes/comment.php: pre_comment_user_ip
  • wp-includes/comment.php: pre_user_id
  • wp-includes/comment.php: pre_comment_user_agent
  • wp-includes/comment.php: pre_comment_content
  • wp-includes/comment.php: pre_comment_author_name
  • wp-includes/comment.php: pre_comment_author_url
  • wp-includes/comment.php: pre_comment_author_email
  • Show 3 more uses Hide more uses

Used By

  • wp-includes/rest-api/endpoints/class-wp-rest-comments-controller.php: WP_REST_Comments_Controller::create_item()
  • wp-includes/comment.php: wp_new_comment()
  • wp-includes/comment.php: wp_update_comment()

User Contributed Notes

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文