钩子文档

wp_doing_cron

💡 云策文档标注

概述

wp_doing_cron 是一个 WordPress 过滤器,用于判断当前请求是否为 WordPress 的 cron 请求。它基于 DOING_CRON 常量的定义状态来过滤布尔值。

关键要点

  • wp_doing_cron 是一个过滤器钩子,允许开发者修改当前请求是否为 cron 请求的判断逻辑。
  • 参数 $wp_doing_cron 是一个布尔值,表示当前请求是否为 WordPress cron 请求。
  • 源代码使用 apply_filters 调用,默认基于 DOING_CRON 常量的定义和值来返回布尔结果。
  • 相关函数 wp_doing_cron() 位于 wp-includes/load.php 中,用于确定当前请求是否为 cron 请求。
  • 该过滤器在 WordPress 4.8.0 版本中引入。

📄 原文内容

Filters whether the current request is a WordPress cron request.

Parameters

$wp_doing_cronbool
Whether the current request is a WordPress cron request.

Source

return apply_filters( 'wp_doing_cron', defined( 'DOING_CRON' ) && DOING_CRON );

Changelog

Version Description
4.8.0 Introduced.