wp_get_schedule()
wp_get_schedule( string $hook, array $args = array() ) …
wp_get_schedule( string $hook, array $args = array() )
检索事件的定期计划。
Retrieve the recurrence schedule for an event.
目录锚点:#说明#参数#源码#笔记
说明(Description)
另请参见#另请参阅wp_get_schedules():以了解可用的计划。
参数(Parameters)
| 参数 | 类型 | 说明 |
|---|---|---|
| $hook | (string) | 用于标识事件的操作钩子。 |
| $args | (array) | 传递给事件的回调函数的参数。 |
源码(Source)
/**
* Retrieve Cron schedule for hook with arguments.
*
* @since 2.1.0
*
* @param string $hook Action hook to execute when cron is run.
* @param array $args Optional. Arguments to pass to the hook's callback function.
* @return string|false False, if no schedule. Schedule on success.
*/
function wp_get_schedule($hook, $args = array()) {
$crons = _get_cron_array();
$key = md5(serialize($args));
if ( empty($crons) )
return false;
foreach ( $crons as $timestamp => $cron ) {
if ( isset( $cron[$hook][$key] ) )
return $cron[$hook][$key]['schedule'];
}
return false;
}
//
// Private functions
//| 更新版本 | 源码位置 | 使用 | 被使用 |
|---|---|---|---|
| 5.1.0 | wp-includes/cron.php | 8 | 2 |
笔记(Notes)
我建议,也许应该更新这里的文档,让它在没有重复出现的情况下返回false。
类别:WordPress 函数手册、
本文收集自互联网,转载请注明来源。
如有侵权,请联系 wper_net@163.com 删除。

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