WordPress: Function Reference/wp schedule single event:修订间差异
来自站长百科
(新页面: == 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...) |
无编辑摘要 |
||
第1行: | 第1行: | ||
== Description == | == 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. | 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. | ||
确定hook的时间,hook会在你规定的时间由WordPress actions core执行。如果规定的时间过去了,有人访问你的WordPress站点,action就会停止。 | |||
== Usage == | == Usage == | ||
== 用法 == | |||
%%% <?php wp_schedule_single_event(time(), 'my_schedule_hook'); ?> %%% | |||
%%% <?php wp_schedule_single_event(time(), 'my_schedule_hook'); ?> %%% | %%% <?php wp_schedule_single_event(time(), 'my_schedule_hook'); ?> %%% | ||
== Examples == | == Examples == | ||
== 例子 == | |||
=== Schedule an event one hour from now === | === Schedule an event one hour from now === | ||
=== 确定一个小时后的日程 === | |||
<pre> | <pre> | ||
第24行: | 第36行: | ||
// time()+3600 = one hour from now. | // time()+3600 = one hour from now. | ||
</pre> | |||
<pre> | |||
function do_this_in_an_hour() { | |||
// 执行操作 | |||
} | |||
add_action('my_new_event','do_this_in_an_hour'); | |||
// 将这一行嵌入函数内部, | |||
//响应用户执行的某个操作 | |||
//否则,访问一个网页,就会确定新的操作安排wp_schedule_single_event(time()+3600, 'my_new_event'); | |||
// time()+3600 = 一个小时后。 | |||
</pre> | </pre> | ||
== Parameters == | == Parameters == | ||
== 参数 == | |||
{{Parameter|$timestamp|integer|The time you want the event to occur. This must be in a UNIX timestamp format.}} | {{Parameter|$timestamp|integer|The time you want the event to occur. This must be in a UNIX timestamp format.}} | ||
{{Parameter|$timestamp|integer|你希望执行操作的时间。必须是时间标记格式。}} | |||
{{Parameter|$hook|string|The name of an action hook to execute.}} | {{Parameter|$hook|string|The name of an action hook to execute.}} | ||
{{Parameter|$hook|string|将要执行的action hook的名称。}} | |||
{{Parameter|$args|array|Arguments to pass to the hook function(s)|optional}} | {{Parameter|$args|array|Arguments to pass to the hook function(s)|optional}} | ||
{{Parameter|$args|array|将要传递给hook函数的参数|optional}} | |||
== Further Reading == | == Further Reading == | ||
== 深入阅读 == | |||
For a comprehensive list of functions, take a look at the [http://codex.wordpress.org/Category:Functions category Functions] | For a comprehensive list of functions, take a look at the [http://codex.wordpress.org/Category:Functions category Functions] | ||
关于完整的函数的列表,请看看[http://codex.wordpress.org/类别:函数类别函数] | |||
Also, see [[WordPress:Function_Reference]] | Also, see [[WordPress:Function_Reference]] | ||
也看看[[WordPress:Function_Reference|Function_Reference]] |
2008年7月22日 (二) 14:10的版本
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.
确定hook的时间,hook会在你规定的时间由WordPress actions core执行。如果规定的时间过去了,有人访问你的WordPress站点,action就会停止。
Usage
用法
%%% <?php wp_schedule_single_event(time(), 'my_schedule_hook'); ?> %%%
%%% <?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.
function do_this_in_an_hour() { // 执行操作 } add_action('my_new_event','do_this_in_an_hour'); // 将这一行嵌入函数内部, //响应用户执行的某个操作 //否则,访问一个网页,就会确定新的操作安排wp_schedule_single_event(time()+3600, 'my_new_event'); // time()+3600 = 一个小时后。
Parameters
参数
Further Reading
深入阅读
For a comprehensive list of functions, take a look at the category Functions
关于完整的函数的列表,请看看[1]
Also, see WordPress:Function_Reference