WordPress 中文文档
Function Reference/wp schedule single event
From WordPress Chinese
目录 |
[编辑]
Description
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.
[编辑]
Usage
%%% <?php wp_schedule_single_event(time(), 'my_schedule_hook'); ?> %%%
[编辑]
Examples
[编辑]
Schedule an event one hour from now
function do_this_in_an_hour() {
// do something
}
add_action('my_new_event','do_this_in_an_hour');
// put this line inside a function,
// presumably in response to something the user does
// otherwise it will schedule a new event on every page visit
wp_schedule_single_event(time()+3600, 'my_new_event');
// time()+3600 = one hour from now.
[编辑]
