WordPress: Function Reference/register deactivation hook:修订间差异
来自站长百科
(新页面: The function <strong>register_deactivation_hook</strong> (introduced in WordPress 2.0) registers a plugin function to be run when the plugin is deactivated. == Usage and parameters == %...) |
无编辑摘要 |
||
第1行: | 第1行: | ||
The function <strong>register_deactivation_hook</strong> (introduced in WordPress 2.0) registers a plugin function to be run when the plugin is deactivated. | --[[User:Fludlen|Fludlen]] 2008年7月21日 (一) 16:54 (CST)The function <strong>register_deactivation_hook</strong> (introduced in WordPress 2.0) registers a plugin function to be run when the plugin is deactivated. | ||
--[[User:Fludlen|Fludlen]] 2008年7月21日 (一) 16:54 (CST)函数 <strong>register_deactivation_hook</strong>(在WordPress2.0时引进)注册插件函数在插件无效时,运行。 | |||
== Usage and parameters == | == Usage and parameters == | ||
== 用法和参数== | |||
%%% <?php register_deactivation_hook($file, $function); ?> %%% | |||
%%% <?php register_deactivation_hook($file, $function); ?> %%% | %%% <?php register_deactivation_hook($file, $function); ?> %%% | ||
; <var>$file</var> | |||
; <var>$file</var> | ; <var>$file</var> | ||
: (string) Path to the [[WordPress:Writing_a_Plugin#Plugin_Files|main plugin file]] inside the <tt>wp-content/plugins</tt> directory. A full path will work. | : (string) Path to the [[WordPress:Writing_a_Plugin#Plugin_Files|main plugin file]] inside the <tt>wp-content/plugins</tt> directory. A full path will work. | ||
: (string)<tt>wp-content/plugins</tt>目录中的[[WordPress:Writing_a_Plugin#Plugin_Files|主要插件文件]]的路径。全称路径能够运行。 | |||
; <var>$function</var> | |||
; <var>$function</var> | ; <var>$function</var> | ||
: (callback) The function to be run when the plugin is deactivated. Any of [http://us2.php.net/manual/en/language.pseudo-types.php#language.types.callback PHP's callback pseudo-types] will work. | : (callback) The function to be run when the plugin is deactivated. Any of [http://us2.php.net/manual/en/language.pseudo-types.php#language.types.callback PHP's callback pseudo-types] will work. | ||
: (callback)插件无效时,运行的函数。任何[http://us2.php.net/manual/en/language.pseudo-types.php#language.types.callback PHP's callback pseudo-types]都能够运行。 | |||
== Examples == | == Examples == | ||
== 例子 == | |||
If you have a function called <tt>myplugin_deactivate()</tt> in the [[WordPress:Writing_a_Plugin#Plugin_Files|main plugin file]] at either | If you have a function called <tt>myplugin_deactivate()</tt> in the [[WordPress:Writing_a_Plugin#Plugin_Files|main plugin file]] at either | ||
* <tt>wp-content/plugins/<var>myplugin</var>.php</tt> or | * <tt>wp-content/plugins/<var>myplugin</var>.php</tt> or | ||
* <tt>wp-content/plugins/<var>myplugin</var>/<var>myplugin</var>.php</tt> | * <tt>wp-content/plugins/<var>myplugin</var>/<var>myplugin</var>.php</tt> | ||
如果你在* <tt>wp-content/plugins/<var>myplugin</var>.php</tt>或者 | |||
* <tt>wp-content/plugins/<var>myplugin</var>/<var>myplugin</var>.php</tt>中的[[WordPress:Writing_a_Plugin#Plugin_Files|主要插件文件]]中有一个称作<tt>myplugin_deactivate()</tt>的函数 | |||
use this code: | use this code: | ||
使用这个代码: | |||
register_deactivation_hook( __FILE__, 'myplugin_deactivate' ); | register_deactivation_hook( __FILE__, 'myplugin_deactivate' ); | ||
register_deactivation_hook( __FILE__, 'myplugin_deactivate' ); | |||
This will call the <tt>myplugin_deactivate()</tt> function on deactivation of the plugin. | This will call the <tt>myplugin_deactivate()</tt> function on deactivation of the plugin. | ||
函数无效的时候,代码会调用<tt>myplugin_deactivate()</tt>函数。 |
2008年7月21日 (一) 16:54的版本
--Fludlen 2008年7月21日 (一) 16:54 (CST)The function register_deactivation_hook (introduced in WordPress 2.0) registers a plugin function to be run when the plugin is deactivated.
--Fludlen 2008年7月21日 (一) 16:54 (CST)函数 register_deactivation_hook(在WordPress2.0时引进)注册插件函数在插件无效时,运行。
Usage and parameters
用法和参数
%%% <?php register_deactivation_hook($file, $function); ?> %%%
%%% <?php register_deactivation_hook($file, $function); ?> %%%
- $file
- $file
- (string) Path to the main plugin file inside the wp-content/plugins directory. A full path will work.
- (string)wp-content/plugins目录中的主要插件文件的路径。全称路径能够运行。
- $function
- $function
- (callback) The function to be run when the plugin is deactivated. Any of PHP's callback pseudo-types will work.
- (callback)插件无效时,运行的函数。任何PHP's callback pseudo-types都能够运行。
Examples
例子
If you have a function called myplugin_deactivate() in the main plugin file at either
- wp-content/plugins/myplugin.php or
- wp-content/plugins/myplugin/myplugin.php
如果你在* wp-content/plugins/myplugin.php或者
- wp-content/plugins/myplugin/myplugin.php中的主要插件文件中有一个称作myplugin_deactivate()的函数
use this code: 使用这个代码:
register_deactivation_hook( __FILE__, 'myplugin_deactivate' );
register_deactivation_hook( __FILE__, 'myplugin_deactivate' );
This will call the myplugin_deactivate() function on deactivation of the plugin.
函数无效的时候,代码会调用myplugin_deactivate()函数。