WordPress 中文文档
Function Reference/register deactivation hook
出自WordPress Chinese 中文文档
目录 |
Description
The function register_deactivation_hook (introduced in WordPress 2.0) registers a plugin function to be run when the plugin is deactivated.
Usage
%%% ?php register_deactivation_hook($file, $function); ? %%%
Parameters
- tt$file/tt
- (string) (required) Path to the main plugin file inside the ttwp-content/plugins/tt directory. A full path will work.
- Default: Nonenoinclude
div class=template-description style=padding: 0 1.5em; border: 1px solid #eeeeee; background-color: #f9f9f9
Notes
This template is for standardizing how parameters look in the Function Reference and in Template Tags. Here is an example of this template being called: prenowiki已侦测回归模板: Template:Parameter/nowiki/pre 已侦测回归模板: Template:Parameter
The usage of this template is below: prenowiki已侦测回归模板: Template:Parameter/nowiki/pre Let's take a closer look at the parameters..
- name
- The name of the parameter.
- datatype
- The datatype that should be given for this parameter when called.
- string
- integer
- boolean
- mixed
- description
- A short description of the parameter.
- importance
- Set this parameter to optional if the parameter is optional. Otherwise, do not declare this parameter—it defaults to required.
- required
- optional
- default
- If this parameter is optional, ttdefault/tt is the value that will be used if the parameter is not declared.
wordpress.org.cn /div /noinclude
- tt$function/tt
- (callback) (required) The function to be run when the plugin is deactivated. Any of PHP's callback pseudo-types will work.
- Default: Nonenoinclude
div class=template-description style=padding: 0 1.5em; border: 1px solid #eeeeee; background-color: #f9f9f9
Notes
This template is for standardizing how parameters look in the Function Reference and in Template Tags. Here is an example of this template being called: prenowiki已侦测回归模板: Template:Parameter/nowiki/pre 已侦测回归模板: Template:Parameter
The usage of this template is below: prenowiki已侦测回归模板: Template:Parameter/nowiki/pre Let's take a closer look at the parameters..
- name
- The name of the parameter.
- datatype
- The datatype that should be given for this parameter when called.
- string
- integer
- boolean
- mixed
- description
- A short description of the parameter.
- importance
- Set this parameter to optional if the parameter is optional. Otherwise, do not declare this parameter—it defaults to required.
- required
- optional
- default
- If this parameter is optional, ttdefault/tt is the value that will be used if the parameter is not declared.
wordpress.org.cn /div /noinclude
Examples
If you have a function called ttmyplugin_deactivate()/tt in the main plugin file at either
- ttwp-content/plugins/varmyplugin/var.php/tt or
- ttwp-content/plugins/varmyplugin/var/varmyplugin/var.php/tt
use this code:
register_deactivation_hook( __FILE__, 'myplugin_deactivate' );
This will call the ttmyplugin_deactivate()/tt function on deactivation of the plugin.
Related
- See also register_activation_hook
includeonlydiv style=clear:both; background-color:#F7F7F7; border:1px solid #CCCCCC; color:#000000; padding:7px; margin:0.5em auto 0.5em auto; vertical-align:middle;See also index of Function Reference and index of Template Tags./div/includeonlynoinclude
Description
This Template is used by Codex:Template Messages.
Usage
pre 已侦测回归模板: Template:Message /pre
Result
已侦测回归模板: Template:Message
/noinclude

