I need to do something anytime any plugin is uninstalled. There’s a hook for when MY plugin is uninstalled but I don’t see an uninstall equivalent of deactivated_plugin
. Does uninstalling a plugin fire the deactivation action?
1 Answer
No, deactivated_plugin
won’t fire during a plugin’s uninstallation process. But there are indeed two hooks that fire when a plugin is uninstalled:
pre_uninstall_plugin
, which is called right before a plugin is uninstalled. It acts globally, targeting any plugin.uninstall_{$file}
, which fires after a specific plugin is uninstalled. Its scope it’s limited to a unique plugin with basename{$file}
. If you want to access the basenames of the whole plugins list, you can check the keys in the array thatget_plugins()
returns.