wp_unschedule_event()
wp_unschedule_event( int $timestamp, string $hook, arra…
wp_unschedule_event( int $timestamp, string $hook, array $args = array() )
取消预先安排的活动。
Unschedule a previously scheduled event.
取消预先安排的活动。
Unschedule a previously scheduled event.
目录锚点:#说明#参数#源码#笔记
说明(Description)
需要$timestamp和$hook参数,以便识别事件。
参数(Parameters)
| 参数 | 类型 | 说明 |
|---|---|---|
| $timestamp | (int) | 事件的Unix时间戳(UTC)。 |
| $hook | (string) | 事件的动作钩子。 |
| $args | (array) | 数组,包含要传递给钩子的回调函数的每个独立参数。虽然没有传递给回调,但这些参数用于唯一标识事件,因此它们应该与最初调度事件时使用的参数相同。 |
源码(Source)
/**
* Unschedule a previously scheduled cron job.
*
* The $timestamp and $hook parameters are required, so that the event can be
* identified.
*
* @since 2.1.0
*
* @param int $timestamp Timestamp for when to run the event.
* @param string $hook Action hook, the execution of which will be unscheduled.
* @param array $args Arguments to pass to the hook's callback function.
* Although not passed to a callback function, these arguments are used
* to uniquely identify the scheduled event, so they should be the same
* as those used when originally scheduling the event.
*/
function wp_unschedule_event( $timestamp, $hook, $args = array() ) {
$crons = _get_cron_array();
$key = md5(serialize($args));
unset( $crons[$timestamp][$hook][$key] );
if ( empty($crons[$timestamp][$hook]) )
unset( $crons[$timestamp][$hook] );
if ( empty($crons[$timestamp]) )
unset( $crons[$timestamp] );
_set_cron_array( $crons );
}| 更新版本 | 源码位置 | 使用 | 被使用 |
|---|---|---|---|
| 5.1.0 | wp-includes/cron.php | 12 | 11 |
笔记(Notes)
例子
类别:WordPress 函数手册、
本文收集自互联网,转载请注明来源。
如有侵权,请联系 wper_net@163.com 删除。

还没有任何评论,赶紧来占个楼吧!