钩子文档

deactivated_plugin

💡 云策文档标注

概述

deactivated_plugin 是一个 WordPress 动作钩子,在插件被停用后触发。它主要用于检测其他插件的停用事件,但静默停用(如更新期间)时不会触发。

关键要点

  • 触发时机:插件停用后立即执行,可用于监控插件状态变化。
  • 参数:$plugin(插件文件相对于 plugins 目录的路径)和 $network_deactivating(布尔值,表示是否在网络范围内停用,仅适用于多站点)。
  • 注意事项:静默停用(如更新)不会触发此钩子,且钩子在 active_plugins 选项更新前运行。

代码示例

do_action( 'deactivated_plugin', $plugin, $network_deactivating );

📄 原文内容

Fires after a plugin is deactivated.

Description

If a plugin is silently deactivated (such as during an update), this hook does not fire.

Parameters

$pluginstring
Path to the plugin file relative to the plugins directory.
$network_deactivatingbool
Whether the plugin is deactivated for all sites in the network or just the current site. Multisite only. Default false.

More Information

This hook is run immediately after any plugin is deactivated, and may be used to detect the deactivation of other plugins.

Source

do_action( 'deactivated_plugin', $plugin, $network_deactivating );

Changelog

Version Description
2.9.0 Introduced.

User Contributed Notes