Turns on maintenance mode before attempting to background update an active plugin.
Hooked to the ‘upgrader_pre_install’ filter by Plugin_Upgrader::upgrade().
$responsebool|WP_Errorrequired
$pluginarrayrequired
$response parameter or WP_Error.public function active_before( $response, $plugin ) {
if ( is_wp_error( $response ) ) {
return $response;
}
// Only enable maintenance mode when in cron (background update).
if ( ! wp_doing_cron() ) {
return $response;
}
$plugin = isset( $plugin['plugin'] ) ? $plugin['plugin'] : '';
// Only run if plugin is active.
if ( ! is_plugin_active( $plugin ) ) {
return $response;
}
// Change to maintenance mode. Bulk edit handles this separately.
if ( ! $this->bulk ) {
$this->maintenance_mode( true );
}
return $response;
}
| Version | Description |
|---|---|
| 5.4.0 | Introduced. |
© 2003–2024 WordPress Foundation
Licensed under the GNU GPLv2+ License.
https://developer.wordpress.org/reference/classes/plugin_upgrader/active_before