Wondering if its possible to deactivate a plugin in the deactivation code of another plugin?
IE. i have a widget that i'm adding via its own plugin that won't function if the 'master' plugin isn't activated...
|
Wondering if its possible to deactivate a plugin in the deactivation code of another plugin? IE. i have a widget that i'm adding via its own plugin that won't function if the 'master' plugin isn't activated... |
|||
|
|
|
Yes, register a deactivation hook in your first plugin, and inside this hook deactivate the 2nd plugin using the |
|||
|
|
|
Note: After writing this, I submitted a trac ticket, only to be told that this one already existed. @OneTrickPony's answer didn't work forme, and after inspecting the source (specifically Let's suppose B depends on A, and A is deactivated by the user. WordPress calls This function does the following:
Now at step 4, we call Note: your deactivation callbacks are fired, even through WordPress still thinks its active next time the page loads. The solutionThe solution is to use a later hook (after the option has been updated). For this we can take advantage of the
|
||||
|
|