pre_get_scheduled_event
云策文档标注
概述
pre_get_scheduled_event 是一个 WordPress 过滤器,用于在检索预定事件时覆盖默认行为。通过返回非空值,可以短路正常流程,直接返回过滤后的值。
关键要点
- 过滤器名称:pre_get_scheduled_event
- 作用:覆盖检索预定事件的过程,返回自定义值或阻止默认检索
- 返回值:返回 false 表示事件不存在,否则应返回事件对象
- 参数:包括 $pre(默认 null)、$hook(动作钩子)、$args(参数数组)、$timestamp(时间戳)
- 相关函数:wp_get_scheduled_event() 使用此过滤器
- 引入版本:WordPress 5.1.0
代码示例
$pre = apply_filters( 'pre_get_scheduled_event', null, $hook, $args, $timestamp );
原文内容
Filter to override retrieving a scheduled event.
Description
Returning a non-null value will short-circuit the normal process, returning the filtered value instead.
Return false if the event does not exist, otherwise an event object should be returned.
Parameters
$prenull|false|object-
Value to return instead. Default null to continue retrieving the event.
$hookstring-
Action hook of the event.
$argsarray-
Array containing each separate argument to pass to the hook’s callback function.
Although not passed to a callback, these arguments are used to uniquely identify the event. $timestampint|null-
Unix timestamp (UTC) of the event. Null to retrieve next scheduled event.
Source
$pre = apply_filters( 'pre_get_scheduled_event', null, $hook, $args, $timestamp );
Changelog
| Version | Description |
|---|---|
| 5.1.0 | Introduced. |