Is there a global action for when a plugin is uninstalled?

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 that get_plugins() returns.

Leave a Comment