Warning: Trying to access array offset on false in /www/wwwroot/www.wpdongli.com/wp-content/themes/WPdongli/functions/wp.php on line 216
schedule_event - 在计划任务事件之前修改事件 - WordPress钩子 - WordPress动力
当前浏览:首页 / WordPress钩子 / schedule_event

apply_filters( 'schedule_event', stdClass|false $event )

在计划任务事件之前修改事件


Warning: Undefined array key -1 in /www/wwwroot/www.wpdongli.com/wp-content/themes/WPdongli/functions/reference-cat.php on line 185

Warning: Undefined array key 2 in /www/wwwroot/www.wpdongli.com/wp-content/themes/WPdongli/functions/reference-cat.php on line 186

Warning: Undefined variable $searchand in /www/wwwroot/www.wpdongli.com/wp-content/themes/WPdongli/functions/wp.php on line 154

Warning: Undefined array key "bbe9567d371d1aba967be1bf0437422b" in /www/wwwroot/www.wpdongli.com/wp-content/themes/WPdongli/functions/wp.php on line 223

Warning: Undefined variable $searchand in /www/wwwroot/www.wpdongli.com/wp-content/themes/WPdongli/functions/wp.php on line 154

Warning: Undefined array key "44151d67412eeece127830f624d350c0" in /www/wwwroot/www.wpdongli.com/wp-content/themes/WPdongli/functions/wp.php on line 223

event

schedule 计划任务


参数

$eventstdClass|false
包含事件数据的对象,或布尔值false以防止事件被调度。

  • hook string
    事件运行时要执行的动作钩子。
  • timestamp int
    下次运行事件的时间戳(UTC)。
  • schedule string|false
    事件随后应重复发生的频率。
  • args array
    数组,包含传递给钩子回调函数的每个单独参数。
  • interval int
    计划的间隔时间(秒)。仅适用于定期事件。

更多信息

  • 当一个新事件添加到cron计划任务时,将应用钩子。钩子传递一个参数:正在调度的$event。
  • 在WordPress 3.21中,core会安排以下重复事件:wp_version_check、wp_update_plugins、wp_update_themes、wp_schedule_delete和(仅适用于多站点安装的主站点)wp_update_network_counts。
  • 在WordPress 3.21中,core按需安排以下单个事件:publish_future_post、do_pings、importer_scheduled_cleanup。


源码

查看源码 官方文档


更新日志

版本描述
3.1.0开始引入

使用示例

  • 示例1

    从Codex迁移的示例:

    消除对插件的所有检查

    add_filter( 'schedule_event', 'filter_cron_events', '10', 1);
    
    function filter_cron_events($event) {
        switch ($event->hook) {
            case 'wp_version_check':
            case 'wp_update_plugins':
            case 'wp_update_themes':
            case 'wp_update_themes':
                $event = false;
            break;
        }
        return $event;
    }