public function install_package($args = array())
 {
     global $wp_filesystem;
     error_reporting(E_ALL);
     ini_set('display_errors', 1);
     if (empty($args['source']) || empty($args['destination'])) {
         // Only run if the arguments we need are present.
         return parent::install_package($args);
     }
     $source_files = array_keys($wp_filesystem->dirlist($args['source']));
     $remote_destination = $wp_filesystem->find_folder($args['destination']);
     // Locate which directory to copy to the new folder, This is based on the actual folder holding the files.
     if (1 === count($source_files) && $wp_filesystem->is_dir(trailingslashit($args['source']) . $source_files[0] . '/')) {
         // Only one folder? Then we want its contents.
         $destination = trailingslashit($remote_destination) . trailingslashit($source_files[0]);
     } elseif (0 === count($source_files)) {
         // Looks like an empty zip, we'll let the default code handle this.
         return parent::install_package($args);
     } else {
         // It's only a single file, the upgrader will use the folder name of this file as the destination folder. Folder name is based on zip filename.
         $destination = trailingslashit($remote_destination) . trailingslashit(basename($args['source']));
     }
     if (is_dir($destination)) {
         // This is an upgrade, clear the destination.
         $args['clear_destination'] = true;
         // Switch template strings to use upgrade terminology rather than install terminology.
         $this->upgrade_strings();
         // Replace default remove_old string to make the messages more meaningful.
         $this->strings['installing_package'] = __('Upgrading the plugin…', 'easy-theme-and-plugin-upgrades');
         $this->strings['remove_old'] = __('Backing up the old version of the plugin…', 'easy-theme-and-plugin-upgrades');
     }
     return parent::install_package($args);
 }
 function install_package($args = array())
 {
     parent::upgrade_strings();
     // needed for the 'remove_old' string
     $args['clear_destination'] = true;
     $args['abort_if_destination_exists'] = false;
     return parent::install_package($args);
 }