Opened 9 years ago
Closed 9 years ago
#21122 closed defect (bug) (duplicate)
deactivate_plugins called within a deactivation callback doesn't work
Reported by: |
|
Owned by: | |
---|---|---|---|
Milestone: | Priority: | normal | |
Severity: | normal | Version: | 3.4 |
Component: | Plugins | Keywords: | |
Focuses: | Cc: |
Description
This problem occurs when you attempt to deactivate another a plug-in, when some other plug-in is deactivated. For instance, you may want to deactivate all 'dependent' plug-ins when their 'parent' plug-in is deactivated.
First deactivate_plugins
(Link to source: https://github.com/WordPress/WordPress/blob/3.4.1/wp-admin/includes/plugin.php#L580) retrieves an array of active plug-ins, and removes the plugin to be deactivated. It then triggers the plug-in's deactivation hook (inside which someone may try to deactivate a second plug-in). Once the actions have been completed, the array of active plug-ins is updated to the database - but this array does not reflect any activation / deactivation that has taken place as a result of the triggered actions.
Consequently the array is updated with only the original plug-in removed.
Importantly, the deactivation callbacks for all plug-ins are triggered, but all but the original plug-in exist as active in the database.
This is a duplicate as another ticket.
As a workaround, hook into shutdown and deactivate then.