deactivate_blog
云策文档标注
概述
deactivate_blog 是一个 WordPress 动作钩子,在网络站点被标记为删除前触发。它允许开发者在站点停用或删除前执行自定义操作。
关键要点
- 这是一个动作钩子,用于在站点被标记为删除时执行代码。
- 参数 $id 是整数类型,表示被标记站点的 ID。
- 钩子定义在 do_action( 'deactivate_blog', $id ) 中。
- 自 WordPress MU 3.0.0 版本引入。
代码示例
/**
* Example of deactivate_blog usage
*
* @param int $id Blog ID of the blog being deactivated.
*/
function wporg_deactivate_blog_example( $id ) {
if ( 5 == $id ) {
// Update some option or something
}
}
add_action( 'deactivate_blog', 'wporg_deactivate_blog_example' );
原文内容
Fires before a network site is flagged for deletion.
Parameters
$idint-
The ID of the site being flagged for deletion.
Source
do_action( 'deactivate_blog', $id );
Changelog
| Version | Description |
|---|---|
| MU (3.0.0) | Introduced. |
Skip to note 2 content
Steven Lin
Example migrated from Codex:
/** * Example of deactivate_blog usage * * @param int $id Blog ID of the blog being deactivated. */ function wporg_deactivate_blog_example( $id ) { if ( 5 == $id ) { // Update some option or something } } add_action( 'deactivate_blog', 'wporg_deactivate_blog_example' );