WordPress过滤评论数据函数:wp_filter_comment

WordPress函数wp_filter_comment()过滤和净化评论数据。

wp_filter_comment( array $commentdata ): array

函数参数

$commentdata

数据类型:array (必须)

包含有关评论的信息。参考:WordPress在数据库插入评论函数:wp_insert_comment

函数返回值

wp_filter_comment()函数返回过滤处理后的评论信息。

函数使用示例

$commentdata = array(
	'comment_author' => '背字根',
	'comment_author_email' => 'beizigen@qq.com',
	'comment_author_url' => 'https://www.beizigen.com/',
	'comment_content' => '这是一条评论',
	'comment_parent' => 0,
	'user_id' => 0,
	'comment_author_IP' => '127.0.0.1',
	'comment_agent' => 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/89.0.4389.82 Safari/537.36',
	'comment_date' => current_time('mysql'),
	'comment_date_gmt' => current_time('mysql', 1),
	'comment_approved' => 1,
);

$commentdata = wp_filter_comment( $commentdata );
wp_insert_comment( $commentdata );

扩展阅读

wp_filter_comment()函数位于:wp-includes/comment.php

相关函数:

原创文章,作者:,如若转载,请注明出处:https://ce.771633.xyz/4439.html

Like (0)
Previous 2025年10月25日
Next 2025年10月25日

相关推荐

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注