wp_filter_comment()

wp_filter_comment( array $commentdata ) 过滤和清理注释数据。 Filt…

wp_filter_comment( array $commentdata )

过滤和清理注释数据。
Filters and sanitizes comment data.

目录锚点:#说明#参数#源码


说明(Description)

完成后,将注释数据“筛选”字段设置为true。这可以检查是否应该过滤注释,以及避免对同一注释进行多次过滤。


参数(Parameters)

参数 类型 说明
$commentdata (array) 包含有关注释的信息。

源码(Source)

/**
 * Filters and sanitizes comment data.
 *
 * 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.
 *
 * @since 2.0.0
 *
 * @param array $commentdata Contains information on the comment.
 * @return array Parsed comment information.
 */
function wp_filter_comment($commentdata) {
	if ( isset( $commentdata['user_ID'] ) ) {
		/**
		 * Filter 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'] );
	}

	/**
	 * Filter the comment author's browser user agent before it is set.
	 *
	 * @since 1.5.0
	 *
	 * @param int $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'] );
	/**
	 * Filter the comment content before it is set.
	 *
	 * @since 1.5.0
	 *
	 * @param int $comment_content The comment content.
	 */
	$commentdata['comment_content'] = apply_filters( 'pre_comment_content', $commentdata['comment_content'] );
	/**
	 * Filter the comment author's IP before it is set.
	 *
	 * @since 1.5.0
	 *
	 * @param int $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;
}
更新版本 源码位置 使用 被使用
2.0.0 wp-includes/comment.php 20 9
类别:WordPress 函数手册

本文收集自互联网,转载请注明来源。
如有侵权,请联系 wper_net@163.com 删除。

评论 (0)COMMENT

登录 账号发表你的看法,还没有账号?立即免费 注册