Make WordPress Core


Ignore:
Timestamp:
01/29/2020 12:43:23 AM (6 years ago)
Author:
SergeyBiryukov
Message:

Docs: Improve inline comments per the documentation standards.

Includes minor code layout fixes for better readability.

See #48303.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/includes/class-plugin-upgrader.php

    r46696 r47122  
    124124                }
    125125
    126                 // Force refresh of plugin update information
     126                // Force refresh of plugin update information.
    127127                wp_clean_plugins_cache( $parsed_args['clear_update_cache'] );
    128128
     
    164164                }
    165165
    166                 // Get the URL to the zip file
     166                // Get the URL to the zip file.
    167167                $r = $current->response[ $plugin ];
    168168
    169169                add_filter( 'upgrader_pre_install', array( $this, 'deactivate_plugin_before_upgrade' ), 10, 2 );
    170170                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' ),
    172173                if ( $parsed_args['clear_update_cache'] ) {
    173174                        // Clear cache so wp_update_plugins() knows about the new plugin.
     
    198199                }
    199200
    200                 // Force refresh of plugin update information
     201                // Force refresh of plugin update information.
    201202                wp_clean_plugins_cache( $parsed_args['clear_update_cache'] );
    202203
     
    235236                $this->skin->header();
    236237
    237                 // Connect to the Filesystem first.
     238                // Connect to the filesystem first.
    238239                $res = $this->fs_connect( array( WP_CONTENT_DIR, WP_PLUGIN_DIR ) );
    239240                if ( ! $res ) {
     
    248249                 * - running Multisite and there are one or more plugins specified, OR
    249250                 * - 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.
    251252                 */
    252253                $maintenance = ( is_multisite() && ! empty( $plugins ) );
     
    295296                        $results[ $plugin ] = $this->result;
    296297
    297                         // Prevent credentials auth screen from displaying multiple times
     298                        // Prevent credentials auth screen from displaying multiple times.
    298299                        if ( false === $result ) {
    299300                                break;
    300301                        }
    301                 } //end foreach $plugins
     302                } // End foreach $plugins.
    302303
    303304                $this->maintenance_mode( false );
     
    354355                }
    355356
    356                 // Check the folder contains at least 1 valid plugin.
     357                // Check that the folder contains at least 1 valid plugin.
    357358                $plugins_found = false;
    358359                $files         = glob( $working_directory . '*.php' );
     
    391392                }
    392393
    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'] );
    394396                if ( empty( $plugin ) ) {
    395397                        return false;
    396398                }
    397399
    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 );
    399402
    400403                return $this->result['destination_name'] . '/' . $pluginfiles[0];
     
    415418        public function deactivate_plugin_before_upgrade( $return, $plugin ) {
    416419
    417                 if ( is_wp_error( $return ) ) { //Bypass.
     420                if ( is_wp_error( $return ) ) { // Bypass.
    418421                        return $return;
    419422                }
    420423
    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.
    422425                if ( wp_doing_cron() ) {
    423426                        return $return;
     
    430433
    431434                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.
    433436                        deactivate_plugins( $plugin, true );
    434437                }
     
    457460
    458461                if ( is_wp_error( $removed ) ) {
    459                         return $removed; //Pass errors through.
     462                        return $removed; // Pass errors through.
    460463                }
    461464
     
    468471                $this_plugin_dir = trailingslashit( dirname( $plugins_dir . $plugin ) );
    469472
    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.
    471474                        return $removed;
    472475                }
    473476
    474477                // 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 ) {
    476480                        $deleted = $wp_filesystem->delete( $this_plugin_dir, true );
    477481                } else {
Note: See TracChangeset for help on using the changeset viewer.