Changeset 47122 for trunk/src/wp-admin/includes/class-plugin-upgrader.php
- Timestamp:
- 01/29/2020 12:43:23 AM (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-admin/includes/class-plugin-upgrader.php
r46696 r47122 124 124 } 125 125 126 // Force refresh of plugin update information 126 // Force refresh of plugin update information. 127 127 wp_clean_plugins_cache( $parsed_args['clear_update_cache'] ); 128 128 … … 164 164 } 165 165 166 // Get the URL to the zip file 166 // Get the URL to the zip file. 167 167 $r = $current->response[ $plugin ]; 168 168 169 169 add_filter( 'upgrader_pre_install', array( $this, 'deactivate_plugin_before_upgrade' ), 10, 2 ); 170 170 add_filter( 'upgrader_clear_destination', array( $this, 'delete_old_plugin' ), 10, 4 ); 171 //'source_selection' => array($this, 'source_selection'), //there's a trac ticket to move up the directory for zip's which are made a bit differently, useful for non-.org plugins. 171 // There's a Trac ticket to move up the directory for zips which are made a bit differently, useful for non-.org plugins. 172 // 'source_selection' => array( $this, 'source_selection' ), 172 173 if ( $parsed_args['clear_update_cache'] ) { 173 174 // Clear cache so wp_update_plugins() knows about the new plugin. … … 198 199 } 199 200 200 // Force refresh of plugin update information 201 // Force refresh of plugin update information. 201 202 wp_clean_plugins_cache( $parsed_args['clear_update_cache'] ); 202 203 … … 235 236 $this->skin->header(); 236 237 237 // Connect to the Filesystem first.238 // Connect to the filesystem first. 238 239 $res = $this->fs_connect( array( WP_CONTENT_DIR, WP_PLUGIN_DIR ) ); 239 240 if ( ! $res ) { … … 248 249 * - running Multisite and there are one or more plugins specified, OR 249 250 * - a plugin with an update available is currently active. 250 * @ TODO:For multisite, maintenance mode should only kick in for individual sites if at all possible.251 * @todo For multisite, maintenance mode should only kick in for individual sites if at all possible. 251 252 */ 252 253 $maintenance = ( is_multisite() && ! empty( $plugins ) ); … … 295 296 $results[ $plugin ] = $this->result; 296 297 297 // Prevent credentials auth screen from displaying multiple times 298 // Prevent credentials auth screen from displaying multiple times. 298 299 if ( false === $result ) { 299 300 break; 300 301 } 301 } // end foreach $plugins302 } // End foreach $plugins. 302 303 303 304 $this->maintenance_mode( false ); … … 354 355 } 355 356 356 // Check th e folder contains at least 1 valid plugin.357 // Check that the folder contains at least 1 valid plugin. 357 358 $plugins_found = false; 358 359 $files = glob( $working_directory . '*.php' ); … … 391 392 } 392 393 393 $plugin = get_plugins( '/' . $this->result['destination_name'] ); //Ensure to pass with leading slash 394 // Ensure to pass with leading slash. 395 $plugin = get_plugins( '/' . $this->result['destination_name'] ); 394 396 if ( empty( $plugin ) ) { 395 397 return false; 396 398 } 397 399 398 $pluginfiles = array_keys( $plugin ); //Assume the requested plugin is the first in the list 400 // Assume the requested plugin is the first in the list. 401 $pluginfiles = array_keys( $plugin ); 399 402 400 403 return $this->result['destination_name'] . '/' . $pluginfiles[0]; … … 415 418 public function deactivate_plugin_before_upgrade( $return, $plugin ) { 416 419 417 if ( is_wp_error( $return ) ) { // Bypass.420 if ( is_wp_error( $return ) ) { // Bypass. 418 421 return $return; 419 422 } 420 423 421 // When in cron (background updates) don't deactivate the plugin, as we require a browser to reactivate it 424 // When in cron (background updates) don't deactivate the plugin, as we require a browser to reactivate it. 422 425 if ( wp_doing_cron() ) { 423 426 return $return; … … 430 433 431 434 if ( is_plugin_active( $plugin ) ) { 432 // Deactivate the plugin silently, Prevent deactivation hooks from running.435 // Deactivate the plugin silently, Prevent deactivation hooks from running. 433 436 deactivate_plugins( $plugin, true ); 434 437 } … … 457 460 458 461 if ( is_wp_error( $removed ) ) { 459 return $removed; // Pass errors through.462 return $removed; // Pass errors through. 460 463 } 461 464 … … 468 471 $this_plugin_dir = trailingslashit( dirname( $plugins_dir . $plugin ) ); 469 472 470 if ( ! $wp_filesystem->exists( $this_plugin_dir ) ) { // If it's already vanished.473 if ( ! $wp_filesystem->exists( $this_plugin_dir ) ) { // If it's already vanished. 471 474 return $removed; 472 475 } 473 476 474 477 // If plugin is in its own directory, recursively delete the directory. 475 if ( strpos( $plugin, '/' ) && $this_plugin_dir != $plugins_dir ) { //base check on if plugin includes directory separator AND that it's not the root plugin folder 478 // Base check on if plugin includes directory separator AND that it's not the root plugin folder. 479 if ( strpos( $plugin, '/' ) && $this_plugin_dir != $plugins_dir ) { 476 480 $deleted = $wp_filesystem->delete( $this_plugin_dir, true ); 477 481 } else {
Note: See TracChangeset
for help on using the changeset viewer.