WordPress.org

Make WordPress Core

Ticket #22287: class-wp-upgrader.php.diff

File class-wp-upgrader.php.diff, 1.0 KB (added by joehoyle, 6 years ago)
  • wp-admin/includes/class-wp-upgrader.php

    diff --git wp-admin/includes/class-wp-upgrader.php wp-admin/includes/class-wp-upgrader.php
    index ef8fb5f..94afe34 100644
    class Plugin_Upgrader extends WP_Upgrader { 
    580580                if ( empty($plugin) )
    581581                        return false;
    582582
    583                 $pluginfiles = array_keys($plugin); //Assume the requested plugin is the first in the list
     583                $pluginfiles = array_keys($plugin);
     584
     585                usort( $pluginfiles, array( $this, '_plugin_info_sort_comparison' ) );
    584586
    585587                return $this->result['destination_name'] . '/' . $pluginfiles[0];
    586588        }
    587589
     590        /**
     591         * Internal function for comparing paths to sort plugin files in no directory to the top.
     592         *
     593         * @param  string $plugin_file_a
     594         * @param  string $plugin_file_b
     595         * @return int
     596         */
     597        function _plugin_info_sort_comparison( $plugin_file_a, $plugin_file_b ) {
     598                return strstr( $plugin_file_a, '/' ) ? 1 : -1;
     599        }
     600
    588601        //Hooked to pre_install
    589602        function deactivate_plugin_before_upgrade($return, $plugin) {
    590603