Plugin_Upgrader::deactivate_plugin_before_upgrade()
最后更新于:2021-11-25 20:38:17
Plugin_Upgrader::deactivate_plugin_before_upgrade( bool|GC_Error$return, array$plugin)Deactivates a plugin before it is upgraded.
参数
- $return
-
(bool|GC_Error) (Required) Upgrade offer return.
- $plugin
-
(array) (Required) Plugin package arguments.
响应
(bool|GC_Error) The passed in $return param or GC_Error.
源文件
文件: gc-admin/includes/class-plugin-upgrader.php
public function deactivate_plugin_before_upgrade( $return, $plugin ) {
if ( is_gc_error( $return ) ) { // Bypass.
return $return;
}
// When in cron (background updates) don't deactivate the plugin, as we require a browser to reactivate it.
if ( gc_doing_cron() ) {
return $return;
}
$plugin = isset( $plugin['plugin'] ) ? $plugin['plugin'] : '';
if ( empty( $plugin ) ) {
return new GC_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;
}