wp_schedule_single_event()计划某个钩子(hook)的使用时间

目录

描述

译文

计划某个钩子(hook)的使用时间,用户指定时间后,WordPress动作(action)函数执行一次该钩子。预定时间过去后,如果有人访问用户的WordPress网站,动作函数会停止运行。

原文

Schedules a hook which will be executed once by the WordPress actions core at a time which you specify. The action will fire off when someone visits your WordPress site, if the schedule time has passed.

wp_schedule_single_event() 描述

用法

 <?php wp_schedule_single_event$timestamp$hook$args ); ?> 

Note that scheduling an event to occur before 10 minutes after an existing event of the same name will be ignored, unless you pass unique values for $args to each scheduled event. See wp_next_scheduled() for more information.

This behavior is subject to change, as the original intention of the code was to prevent scheduling two identical events within ten minutes of each other, not preventing scheduling of identical events until ten minutes after the next scheduled occurrence.

Attempts to schedule an event after an event of the same name and $args will also be ignored.

wp_schedule_single_event() 用法

参数

$timestamp

(integer) (必填) The time you want the event to occur. This must be in a UNIX timestamp format. WP cron uses UTC/GMT time, not local time. Use time(), which is always GMT in WordPress. (current_time( 'timestamp' ) is local time in WordPress.)

默认值: None

$hook

(string) (必填) The name of an action hook to execute.

默认值: None

$args

(array) (可选) Arguments to pass to the hook function(s)

默认值: array()

wp_schedule_single_event() 参数

示例

Schedule an event one hour from now

Schedule an event one hour from now with arguments

wp_schedule_single_event() 示例

注意

历史

添加于 版本: 2.1.0

wp_schedule_single_event() 历史

源文件

wp_schedule_single_event() 函数的代码位于 wp-includes/cron.php

wp_schedule_single_event() 源文件

相关