惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

酷 壳 – CoolShell
酷 壳 – CoolShell
aimingoo的专栏
aimingoo的专栏
P
Proofpoint News Feed
宝玉的分享
宝玉的分享
MyScale Blog
MyScale Blog
The GitHub Blog
The GitHub Blog
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
月光博客
月光博客
量子位
博客园 - 司徒正美
V
V2EX
I
InfoQ
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
Vercel News
Vercel News
H
Hackread – Cybersecurity News, Data Breaches, AI and More
美团技术团队
N
Netflix TechBlog - Medium
L
LangChain Blog
IT之家
IT之家
Blog — PlanetScale
Blog — PlanetScale
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
Stack Overflow Blog
Stack Overflow Blog
A
About on SuperTechFans
Microsoft Azure Blog
Microsoft Azure Blog

N25H

Maye Nano:拒绝臃肿,回归纯粹的快速启动工具 – N25H Maye Nano Script Help – N25H 国行三星 Galaxy Watch7 其他品牌手机解锁心电图、血压等功能 – N25H 推翻重做,彻底重写WordPress主题 – N25H WordPress 模板目前采用的缓存获取方案 – N25H 相册测试1 – N25H 相册测试2 – N25H 从 Typecho 迁移到 WordPress 的后续 – N25H 在Linux Ubuntu上挂载新硬盘 (临时、永久挂载) – N25H
WordPress 通过Hook修改评论Flood判定时间 – N25H
作者: N25H · 2023-12-12 · via N25H

如果是使用wp原生评论系统直接通过钩子comment_flood_filter拦截即可

在主题function.php文件中加入以下代码:

if ( !function_exists( 'mz_comment_flood_filter' ) ){
    function mz_comment_flood_filter( $dam_it, $time_lastcomment, $time_newcomment ) {

        if( !is_admin() ) {
            if ( ( $time_newcomment - $time_lastcomment ) < MZ_COMMENT_FLOOD_TIME ) { // 间隔为10秒
                return true;
            }
            
            return false;
        }
        
    }
}
add_filter( 'comment_flood_filter', 'mz_comment_flood_filter', 10, 3 );

这个回调的大概意思是,不在后台的情况下,用当前发布的时间减去上次的时间,如果小于MZ_COMMENT_FLOOD_TIME则判定为Flood,否则什么都不做

为了方便快速控制判断时间,这里定义了一个MZ_COMMENT_FLOOD_TIME

define('MZ_COMMENT_FLOOD_TIME',     10);

ps:函数add_filter,的参数依次为:hook名,回调,优先级,参数数量


详情参考:comment_flood_filter

赞赏作者

如果觉得我的文章对你有用,请随意赞赏