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

推荐订阅源

OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
G
Google Developers Blog
雷峰网
雷峰网
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
人人都是产品经理
人人都是产品经理
U
Unit 42
B
Blog RSS Feed
博客园 - 【当耐特】
T
Tailwind CSS Blog
V
V2EX
S
SegmentFault 最新的问题
美团技术团队
Apple Machine Learning Research
Apple Machine Learning Research
Y
Y Combinator Blog
M
MIT News - Artificial intelligence
量子位
aimingoo的专栏
aimingoo的专栏
Stack Overflow Blog
Stack Overflow Blog
Engineering at Meta
Engineering at Meta
GbyAI
GbyAI
P
Proofpoint News Feed
D
DataBreaches.Net
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
A
About on SuperTechFans

Hi, I Am I

[I Am I 年度简报] — 不知终日梦为鱼 初探 ESP32-CAM QQ 聊天记录 MHT 文件转 HTML [I Am I 年度简报] - 草木本无意,荣枯自有时。 Hexo 中实现 Live Photos 支持 写在当下 NKCTF 2024 1z_F0r3ns1c5 Writeup 春秋杯冬季赛 2023 Writeup [I Am I 年度简报] - 2023 某内网渗透内部赛 Writeup 强网拟态 2023 Writeup Github Actions 自动化部署 Hexo 浅析CobaltStrike流量解密 陇剑杯 2023 Writeup CTF线下赛AWDP总结 ISCC 2023 Writeup ISCC 2023 实战题 Writeup CISCN 2023 Writeup 福建闽盾杯网络空间安全大赛 2023 Writeup 天一永安杯宁波市网络安全大赛 2023 Writeup 贵阳大数据及网络安全精英对抗赛 2023 Writeup 红明谷杯 2023 Writeup Confetti 带来有仪式感的鼓励 记一次 JS 逆向密码加密 [I Am I 年度简报] – 2022 PHP 读取 Excel 文件内容并写入数据库 从0开始的 MoeCTF 开发之路 观安杯 2022 Writeup 利用微信服务号实现早安自动化 Cloudflare批量拉黑IP脚本
WordPress 评论夜间自动改为必须审核
2018-02-10 · via Hi, I Am I

从龙大佬那搬来的 因为白天都醒着,而且手机有提醒,所以对于恶意评论可以做到秒删 但是晚上就不可以了 所以这个就必要使用了

  /**
   * Wordpress控制评论状态的钩子:pre_comment_approved - 龙笑天下
   * https://www.ilxtx.com/wordpress-filter-pre-comment-approved.html
   * 实用方法:新增评论规则 -- 晚上23:30-9:00的评论全部设为待审核
   */
  function lxtx_limit_comment_to_pending($approved, $commentdata){
      date_default_timezone_set('Asia/Shanghai'); //设置为东八区上海时间
      $time = time();
      $t1 = date("Y-m-d",$time).' 09:00:00';
      $t2 = date("Y-m-d",$time).' 23:30:00';    
      $short_t1 = strtotime($t1);
      $short_t2 = strtotime($t2);
      if( ($time>$short_t2 || $time<$short_t1) && !current_user_can('manage_options') ){
          $approved = 0;
      }
      return $approved;
  }
  add_action('pre_comment_approved', 'lxtx_limit_comment_to_pending', 10, 2);