WordPress:Function Reference/wp schedule event
Description
描述
Schedules a hook which will be executed by the WordPress actions core on a specific interval, specified by you. The action will trigger when someone visits your WordPress site, if the scheduled time has passed. See the WordPress:Plugin API for a list of hooks.
确定WordPress actions core 在你规定的特别的时间间隔内执行hook的时间。如果预定的时间已经过去,有人访问你的站点的时候,action就会引发。请看看插件API上的hooks列表。
Usage
用法
%%% <?php wp_schedule_event(time(), 'hourly', 'my_schedule_hook'); ?> %%%
%%% <?php wp_schedule_event(time(), 'hourly', 'my_schedule_hook'); ?> %%%
Parameters
参数
Examples
例子
Schedule an hourly event
规定每隔一小时的操作
To schedule an hourly event in a plugin, call wp_schedule_event on activation (otherwise you will end up with a lot of scheduled events!): 在插件中规定每隔一小时的操作,调用激活的wp_schedule_event(否则,你需要结束许多预定的操作!)
register_activation_hook(__FILE__, 'my_activation'); add_action('my_hourly_event', 'do_this_hourly'); function my_activation() { wp_schedule_event(time(), 'hourly', 'my_hourly_event'); } function do_this_hourly() { // do something every hour }
register_activation_hook(__FILE__, 'my_activation'); add_action('my_hourly_event', 'do_this_hourly'); function my_activation() { wp_schedule_event(time(), 'hourly', 'my_hourly_event'); } function do_this_hourly() { // do something every hour }
Further Reading
深入阅读
For a comprehensive list of functions, take a look at the category Functions
关于完整的函数的列表,请看看[1]
Also, see WordPress:Function_Reference 也看看Function_Reference