admin管理员组

文章数量:1122846

Is there an action hook when a new plugin is installed?

I want to hook into the moment when a new plugin was put into the /wp-content/plugins folder. So really just adding the plugin (either via upload or via installation through the admin interface to pick plugins for installation).

Please note I am not referring to the activation of a plugin (activated_plugin does that trick).

Is there an action hook when a new plugin is installed?

I want to hook into the moment when a new plugin was put into the /wp-content/plugins folder. So really just adding the plugin (either via upload or via installation through the admin interface to pick plugins for installation).

Please note I am not referring to the activation of a plugin (activated_plugin does that trick).

Share Improve this question edited Jan 10, 2022 at 23:01 hbit asked Jan 10, 2022 at 22:30 hbithbit 2301 silver badge11 bronze badges 7
  • There's no hook for that that I know of. hookr.io is pretty useful for browsing all of the hooks at once. – admcfajn Commented Jan 10, 2022 at 22:57
  • 1 you would need to check for this on every single request and then fire a hook yourself to catch when someone drops a plugin in that folder via FTP or other means, which could be costly. You'd also need to maintain a list. What's the reason for wanting to do this? What are you trying to do that requires it? – Tom J Nowell Commented Jan 11, 2022 at 0:44
  • Is it your plugin that you can code? – brothman01 Commented Jan 11, 2022 at 18:39
  • There is a need for a server-side script, nothing to do with WordPress. – Max Yudin Commented Jan 11, 2022 at 21:38
  • @TomJNowell Adding folders via FTP is out of scope. I am only concerned what WordPress offers via the admin UI. So the package upload and "online install" from the WP.org repo. I had hoped I can get an info for that cases. – hbit Commented Jan 11, 2022 at 22:24
 |  Show 2 more comments

1 Answer 1

Reset to default 0

I think it's a bit tricky but using https://developer.wordpress.org/reference/hooks/plugin_loaded/ to know if the plugin has just been activated.

I think check if a plugin is added to get_option('active_plugins');

And doing your stuff when you detect something new

本文标签: ActionHook when a new plugin is added