Plugin_Upgrader::deactivate_plugin_before_upgrade( bool|WP_Error $return, array $plugin )
Deactivates a plugin before it is upgraded.
Description
Hooked to the ‘upgrader_pre_install’ filter by Plugin_Upgrader::upgrade().
Parameters
- $return
-
(bool|WP_Error) (Required) Upgrade offer return.
- $plugin
-
(array) (Required) Plugin package arguments.
Return
Source
File: wp-admin/includes/class-plugin-upgrader.php
public function deactivate_plugin_before_upgrade( $return, $plugin ) { if ( is_wp_error( $return ) ) { // Bypass. return $return; } // When in cron (background updates) don't deactivate the plugin, as we require a browser to reactivate it. if ( wp_doing_cron() ) { return $return; } $plugin = isset( $plugin['plugin'] ) ? $plugin['plugin'] : ''; if ( empty( $plugin ) ) { return new WP_Error( 'bad_request', $this->strings['bad_request'] ); } if ( is_plugin_active( $plugin ) ) { // Deactivate the plugin silently, Prevent deactivation hooks from running. deactivate_plugins( $plugin, true ); } return $return; }
Changelog
Version | Description |
---|---|
4.1.0 | Added a return value. |
2.8.0 | Introduced. |
© 2003–2021 WordPress Foundation
Licensed under the GNU GPLv2+ License.
https://developer.wordpress.org/reference/classes/plugin_upgrader/deactivate_plugin_before_upgrade