WordPress: Function Reference/wp schedule event:修订间差异

来自站长百科
跳转至: 导航、​ 搜索
无编辑摘要
无编辑摘要
 
第1行: 第1行:
== 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就会引发。请看看[[WordPress:Plugin API|插件API]]上的hooks列表。
确定WordPress actions core 在你规定的特别的时间间隔内执行hook的时间。如果预定的时间已经过去,有人访问你的站点的时候,action就会引发。请看看[[WordPress:Plugin API|插件API]]上的hooks列表。
== Usage ==


== 用法 ==
== 用法 ==
第13行: 第7行:
%%% <?php wp_schedule_event(time(), 'hourly', 'my_schedule_hook'); ?> %%%
%%% <?php wp_schedule_event(time(), 'hourly', 'my_schedule_hook'); ?> %%%


%%% <?php wp_schedule_event(time(), 'hourly', 'my_schedule_hook'); ?> %%%
== Parameters ==
== 参数 ==
== 参数 ==
{{Parameter|$timestamp|integer|The first time that you want the event to occur. This must be in a UNIX timestamp format.}}


{{Parameter|$timestamp|integer|你想要操作首次发生的时间。必须是UNIX 时间格式。}}
{{Parameter|$timestamp|integer|你想要操作首次发生的时间。必须是UNIX 时间格式。}}
{{Parameter|$recurrance|string|How often the event should reoccur. Valid values:<ul><li><tt>hourly</tt></li><li><tt>daily</tt></li></ul>}}
{{Parameter|$hook|string|The name of an action hook to execute.}}
{{Parameter|$args|array|Arguments to pass to the hook function(s).|optional}}
{{Parameter|$recurrance|string|操作应该什么时候再次发生。有效的参数值: <ul><li><tt>hourly</tt></li><li><tt>daily</tt></li></ul>}}
{{Parameter|$recurrance|string|操作应该什么时候再次发生。有效的参数值: <ul><li><tt>hourly</tt></li><li><tt>daily</tt></li></ul>}}
{{Parameter|$hook|string|将要执行的action hook的名称。}}
{{Parameter|$hook|string|将要执行的action hook的名称。}}
{{Parameter|$args|array|将要传递给hook函数的参数。|optional}}
{{Parameter|$args|array|将要传递给hook函数的参数。|optional}}


== Examples ==


== 例子 ==
== 例子 ==
=== Schedule an hourly event ===


=== 规定每隔一小时的操作 ===
=== 规定每隔一小时的操作 ===


To schedule an hourly event in a plugin, call <tt>wp_schedule_event</tt> on activation (otherwise you will end up with a lot of scheduled events!):
在插件中规定每隔一小时的操作,调用激活的<tt>wp_schedule_event</tt>(否则,你需要结束许多预定的操作!)
在插件中规定每隔一小时的操作,调用激活的<tt>wp_schedule_event</tt>(否则,你需要结束许多预定的操作!)
<pre>
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
}
</pre>


<pre>
<pre>
register_activation_hook(__FILE__, 'my_activation');
register_activation_hook(__FILE__, 'my_activation');
第69行: 第31行:
}
}
</pre>
</pre>
== Further Reading ==


== 深入阅读==
== 深入阅读==
For a comprehensive list of functions, take a look at the [http://codex.wordpress.org/Category:Functions category Functions]


关于完整的函数的列表,请看看[http://codex.wordpress.org/类别:函数类别函数]
关于完整的函数的列表,请看看[http://codex.wordpress.org/类别:函数类别函数]


Also, see [[WordPress:Function_Reference]]
也看看[[WordPress:Function_Reference|Function_Reference]]
也看看[[WordPress:Function_Reference|Function_Reference]]

2008年7月29日 (二) 15:08的最新版本

描述[ ]

确定WordPress actions core 在你规定的特别的时间间隔内执行hook的时间。如果预定的时间已经过去,有人访问你的站点的时候,action就会引发。请看看插件API上的hooks列表。

用法[ ]

%%% <?php wp_schedule_event(time(), 'hourly', 'my_schedule_hook'); ?> %%%

参数[ ]

例子[ ]

规定每隔一小时的操作[ ]

在插件中规定每隔一小时的操作,调用激活的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
}

深入阅读[ ]

关于完整的函数的列表,请看看[1]

也看看Function_Reference