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 WordPre...)
 
无编辑摘要
第1行: 第1行:
== Description ==
== 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.
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列表。


== Usage ==
== Usage ==
== 用法 ==
%%% <?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 ==
== 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|The first time that you want the event to occur. This must be in a UNIX timestamp format.}}
{{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|$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|$hook|string|The name of an action hook to execute.}}
{{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|$recurrance|string|操作应该什么时候再次发生。有效的参数值: <ul><li><tt>hourly</tt></li><li><tt>daily</tt></li></ul>}}
{{Parameter|$hook|string|将要执行的action hook的名称。}}
{{Parameter|$args|array|将要传递给hook函数的参数。|optional}}


== Examples ==
== Examples ==
== 例子 ==


=== Schedule an hourly event ===
=== 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!):
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>(否则,你需要结束许多预定的操作!)
<pre>
<pre>
register_activation_hook(__FILE__, 'my_activation');
register_activation_hook(__FILE__, 'my_activation');
第31行: 第56行:
</pre>
</pre>


<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>
== 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:37的版本

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