Changeset 47275 for trunk/src/wp-admin/includes/class-plugin-upgrader.php
- Timestamp:
- 02/11/2020 08:12:52 PM (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-admin/includes/class-plugin-upgrader.php
r47122 r47275 168 168 169 169 add_filter( 'upgrader_pre_install', array( $this, 'deactivate_plugin_before_upgrade' ), 10, 2 ); 170 add_filter( 'upgrader_pre_install', array( $this, 'active_before' ), 10, 2 ); 170 171 add_filter( 'upgrader_clear_destination', array( $this, 'delete_old_plugin' ), 10, 4 ); 172 add_filter( 'upgrader_post_install', array( $this, 'active_after' ), 10, 2 ); 171 173 // There's a Trac ticket to move up the directory for zips which are made a bit differently, useful for non-.org plugins. 172 174 // 'source_selection' => array( $this, 'source_selection' ), … … 193 195 remove_action( 'upgrader_process_complete', 'wp_clean_plugins_cache', 9 ); 194 196 remove_filter( 'upgrader_pre_install', array( $this, 'deactivate_plugin_before_upgrade' ) ); 197 remove_filter( 'upgrader_pre_install', array( $this, 'active_before' ) ); 195 198 remove_filter( 'upgrader_clear_destination', array( $this, 'delete_old_plugin' ) ); 199 remove_filter( 'upgrader_post_install', array( $this, 'active_after' ) ); 196 200 197 201 if ( ! $this->result || is_wp_error( $this->result ) ) { … … 441 445 442 446 /** 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 disable 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 /** 443 517 * Delete the old plugin during an upgrade. 444 518 *
Note: See TracChangeset
for help on using the changeset viewer.