wp_throttle_comment_flood

函数
wp_throttle_comment_flood ( $block, $time_lastcomment, $time_newcomment )
参数
  • (bool) $block Whether plugin has already blocked comment.
    Required:
  • (int) $time_lastcomment Timestamp for last comment.
    Required:
  • (int) $time_newcomment Timestamp for new comment.
    Required:
返回值
  • (bool) Whether comment should be blocked.
定义位置
相关方法
wp_check_comment_floodcheck_comment_flood_dbwp_set_comment_cookieswp_trash_post_commentswp_update_comment_count
引入
2.1.0
弃用
-

wp_throttle_comment_flood是一个防止评论泛滥的函数,它检查由同一IP地址提交的两个连续评论之间的时间。如果两个评论之间的时间小于指定的阈值,该函数返回true,表明该评论不应该被接受。

决定一个评论是否应该因为评论泛滥而被阻止。

function wp_throttle_comment_flood( $block, $time_lastcomment, $time_newcomment ) {
	if ( $block ) { // A plugin has already blocked... we'll let that decision stand.
		return $block;
	}
	if ( ( $time_newcomment - $time_lastcomment ) < 15 ) {
		return true;
	}
	return false;
}

常见问题

FAQs
查看更多 >