wp_next_scheduled
云策文档标注
概述
wp_next_scheduled 是一个 WordPress 过滤器钩子,用于修改指定钩子的下一个计划事件的时间戳。它允许开发者在事件执行前调整其计划时间。
关键要点
- 过滤器名称:wp_next_scheduled
- 主要用途:过滤下一个计划事件的时间戳,适用于自定义 cron 事件管理
- 参数:包括时间戳、事件对象、钩子名称和参数数组,支持动态调整事件执行时间
- 引入版本:WordPress 6.8.0,是较新的功能
代码示例
apply_filters( 'wp_next_scheduled', $next_event->timestamp, $next_event, $hook, $args );注意事项
此过滤器仅影响通过 wp_schedule_event() 或类似函数安排的事件;确保正确处理时间戳以避免计划冲突。
原文内容
Filters the timestamp of the next scheduled event for the given hook.
Parameters
$timestampint-
Unix timestamp (UTC) for when to next run the event.
$next_eventobject-
An object containing an event’s data.
hookstringAction hook of the event.timestampintUnix timestamp (UTC) for when to next run the event.schedulestringHow often the event should subsequently recur.argsarrayArray containing each separate argument to pass to the hook callback function.intervalintOptional. The interval time in seconds for the schedule. Only present for recurring events.
$argsarray-
Array containing each separate argument to pass to the hook callback function.
Source
return apply_filters( 'wp_next_scheduled', $next_event->timestamp, $next_event, $hook, $args );
Changelog
| Version | Description |
|---|---|
| 6.8.0 | Introduced. |