| | 447 | * Turn on maintenance mode before attempting to background update an active plugin. |
| | 448 | * |
| | 449 | * Hooked to the {@see 'upgrader_pre_install'} filter by Plugin_Upgrader::upgrade(). |
| | 450 | * |
| | 451 | * @since 5.4.0 |
| | 452 | * |
| | 453 | * @param bool|WP_Error $return |
| | 454 | * @param array $plugin |
| | 455 | * @return bool|WP_Error |
| | 456 | */ |
| | 457 | public function active_before( $return, $plugin ) { |
| | 458 | if ( is_wp_error( $return ) ) { |
| | 459 | return $return; |
| | 460 | } |
| | 461 | |
| | 462 | // Only enable maintenance mode when in cron (background update). |
| | 463 | if ( ! wp_doing_cron() ) { |
| | 464 | return $return; |
| | 465 | } |
| | 466 | |
| | 467 | $plugin = isset( $plugin['plugin'] ) ? $plugin['plugin'] : ''; |
| | 468 | |
| | 469 | if ( ! is_plugin_active( $plugin ) ) { // If not active. |
| | 470 | return $return; |
| | 471 | } |
| | 472 | |
| | 473 | // Bulk edit handles maintenance mode separately. |
| | 474 | if ( ! $this->bulk ) { |
| | 475 | $this->maintenance_mode( true ); |
| | 476 | } |
| | 477 | |
| | 478 | return $return; |
| | 479 | } |
| | 480 | |
| | 481 | /** |
| | 482 | * Turn off maintenance mode after upgrading an active plugin. |
| | 483 | * |
| | 484 | * Hooked to the {@see 'upgrader_post_install'} filter by Plugin_Upgrader::upgrade(). |
| | 485 | * |
| | 486 | * @since 5.4.0 |
| | 487 | * |
| | 488 | * @param bool|WP_Error $return |
| | 489 | * @param array $plugin |
| | 490 | * @return bool|WP_Error |
| | 491 | */ |
| | 492 | public function active_after( $return, $plugin ) { |
| | 493 | if ( is_wp_error( $return ) ) { |
| | 494 | return $return; |
| | 495 | } |
| | 496 | |
| | 497 | // Only enable maintenance mode when in cron (background update). |
| | 498 | if ( ! wp_doing_cron() ) { |
| | 499 | return $return; |
| | 500 | } |
| | 501 | |
| | 502 | $plugin = isset( $plugin['plugin'] ) ? $plugin['plugin'] : ''; |
| | 503 | |
| | 504 | if ( ! is_plugin_active( $plugin ) ) { // If not active. |
| | 505 | return $return; |
| | 506 | } |
| | 507 | |
| | 508 | // Bulk edit handles maintenance mode separately. |
| | 509 | if ( ! $this->bulk ) { |
| | 510 | $this->maintenance_mode( false ); |
| | 511 | } |
| | 512 | |
| | 513 | return $return; |
| | 514 | } |
| | 515 | |
| | 516 | /** |