Make WordPress Core

Ticket #32774: 32774.diff

File 32774.diff, 19.5 KB (added by dd32, 10 years ago)
  • src/wp-admin/includes/class-ftp.php

    class ftp_base { 
    138138                $this->SendMSG("Staring FTP client class".($this->_port_available?"":" without PORT mode support"));
    139139                $this->_connected=FALSE;
    140140                $this->_ready=FALSE;
    141141                $this->_can_restore=FALSE;
    142142                $this->_code=0;
    143143                $this->_message="";
    144144                $this->_ftp_buff_size=4096;
    145145                $this->_curtype=NULL;
    146146                $this->SetUmask(0022);
    147147                $this->SetType(FTP_AUTOASCII);
    148148                $this->SetTimeout(30);
    149149                $this->Passive(!$this->_port_available);
    150150                $this->_login="anonymous";
    151151                $this->_password="anon@ftp.com";
    152152                $this->_features=array();
    153             $this->OS_local=FTP_OS_Unix;
     153                $this->OS_local=FTP_OS_Unix;
    154154                $this->OS_remote=FTP_OS_Unix;
    155155                $this->features=array();
    156156                if(strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') $this->OS_local=FTP_OS_Windows;
    157157                elseif(strtoupper(substr(PHP_OS, 0, 3)) === 'MAC') $this->OS_local=FTP_OS_Mac;
    158158        }
    159159
    160160// <!-- --------------------------------------------------------------------------------------- -->
    161161// <!--       Public functions                                                                  -->
    162162// <!-- --------------------------------------------------------------------------------------- -->
    163163
    164164        function parselisting($line) {
    165165                $is_windows = ($this->OS_remote == FTP_OS_Windows);
    166                 if ($is_windows && preg_match("/([0-9]{2})-([0-9]{2})-([0-9]{2}) +([0-9]{2}):([0-9]{2})(AM|PM) +([0-9]+|<DIR>) +(.+)/",$line,$lucifer)) {
     166                if ( $is_windows && preg_match('/([0-9]{2})-([0-9]{2})-([0-9]{2}) +([0-9]{2}):([0-9]{2})(AM|PM) +([0-9]+|<DIR>) +(.+)/', $line, $lucifer) ) {
    167167                        $b = array();
    168                         if ($lucifer[3]<70) { $lucifer[3]+=2000; } else { $lucifer[3]+=1900; } // 4digit year fix
    169                         $b['isdir'] = ($lucifer[7]=="<DIR>");
     168                        if ( $lucifer[3] < 70 )
     169                                $lucifer[3] +=2000;
     170                        else
     171                                $lucifer[3] += 1900; // 4digit year fix
     172                        $b['isdir'] = ( $lucifer[7] == '<DIR>');
    170173                        if ( $b['isdir'] )
    171174                                $b['type'] = 'd';
    172175                        else
    173176                                $b['type'] = 'f';
    174                         $b['size'] = $lucifer[7];
    175                         $b['month'] = $lucifer[1];
    176                         $b['day'] = $lucifer[2];
    177                         $b['year'] = $lucifer[3];
    178                         $b['hour'] = $lucifer[4];
    179                         $b['minute'] = $lucifer[5];
    180                         $b['time'] = @mktime($lucifer[4]+(strcasecmp($lucifer[6],"PM")==0?12:0),$lucifer[5],0,$lucifer[1],$lucifer[2],$lucifer[3]);
    181                         $b['am/pm'] = $lucifer[6];
     177                        $b['size'] = $b['isdir'] ? false : (int) $lucifer[7];
     178                        $b['time'] = @mktime($lucifer[4] + ($lucifer[6] === "PM" ? 12 : 0), $lucifer[5], 0, $lucifer[1], $lucifer[2], $lucifer[3]);
    182179                        $b['name'] = $lucifer[8];
    183                 } else if (!$is_windows && $lucifer=preg_split("/[ ]/",$line,9,PREG_SPLIT_NO_EMPTY)) {
    184                         //echo $line."\n";
    185                         $lcount=count($lucifer);
    186                         if ($lcount<8) return '';
     180                        // Unknown on Windows:
     181                        $b['perms'] = $b['islink'] = $b['owner'] = $b['group'] = false;
     182                } elseif ( !$is_windows && $lucifer = preg_split('/[ ]/', $line, 9, PREG_SPLIT_NO_EMPTY)) {
     183                        $lcount = count($lucifer);
     184                        if ( $lcount < 8 )
     185                                return '';
    187186                        $b = array();
    188                         $b['isdir'] = $lucifer[0]{0} === "d";
    189                         $b['islink'] = $lucifer[0]{0} === "l";
     187                        $b['isdir'] = $lucifer[0]{0} === 'd';
     188                        $b['islink'] = $lucifer[0]{0} === 'l';
    190189                        if ( $b['isdir'] )
    191190                                $b['type'] = 'd';
    192191                        elseif ( $b['islink'] )
    193192                                $b['type'] = 'l';
    194193                        else
    195194                                $b['type'] = 'f';
    196195                        $b['perms'] = $lucifer[0];
    197                         $b['number'] = $lucifer[1];
    198196                        $b['owner'] = $lucifer[2];
    199197                        $b['group'] = $lucifer[3];
    200                         $b['size'] = $lucifer[4];
    201                         if ($lcount==8) {
    202                                 sscanf($lucifer[5],"%d-%d-%d",$b['year'],$b['month'],$b['day']);
    203                                 sscanf($lucifer[6],"%d:%d",$b['hour'],$b['minute']);
    204                                 $b['time'] = @mktime($b['hour'],$b['minute'],0,$b['month'],$b['day'],$b['year']);
     198                        $b['size'] = $b['isdir'] && ! $b['islink'] ? (int)$lucifer[4] : false;
     199                        if ( $lcount == 8 ) {
     200                                sscanf($lucifer[5], '%d-%d-%d', $b['year'], $b['month'], $b['day']);
     201                                sscanf($lucifer[6], '%d:%d', $b['hour'], $b['minute']);
     202                                $b['time'] = @mktime($b['hour'], $b['minute'], 0, $b['month'], $b['day'], $b['year']);
    205203                                $b['name'] = $lucifer[7];
    206204                        } else {
    207205                                $b['month'] = $lucifer[5];
    208206                                $b['day'] = $lucifer[6];
    209                                 if (preg_match("/([0-9]{2}):([0-9]{2})/",$lucifer[7],$l2)) {
     207                                if ( preg_match('/([0-9]{2}):([0-9]{2})/', $lucifer[7], $l2) ) {
    210208                                        $b['year'] = date("Y");
    211209                                        $b['hour'] = $l2[1];
    212210                                        $b['minute'] = $l2[2];
    213211                                } else {
    214212                                        $b['year'] = $lucifer[7];
    215213                                        $b['hour'] = 0;
    216214                                        $b['minute'] = 0;
    217215                                }
    218                                 $b['time'] = strtotime(sprintf("%d %s %d %02d:%02d",$b['day'],$b['month'],$b['year'],$b['hour'],$b['minute']));
     216                                $b['time'] = strtotime( sprintf('%d %s %d %02d:%02d', $b['day'], $b['month'], $b['year'], $b['hour'], $b['minute']) );
    219217                                $b['name'] = $lucifer[8];
    220218                        }
     219                        unset( $b['year'], $b['month'], $b['day'], $b['hour'], $b['minute'] );
    221220                }
     221                unset( $b['isdir'], $b['islink'] );
    222222
    223223                return $b;
    224224        }
    225225
    226226        function SendMSG($message = "", $crlf=true) {
    227227                if ($this->Verbose) {
    228228                        echo $message.($crlf?CRLF:"");
    229229                        flush();
    230230                }
    231231                return TRUE;
    232232        }
    233233
    234234        function SetType($mode=FTP_AUTOASCII) {
    235235                if(!in_array($mode, $this->AuthorizedTransferMode)) {
    236236                        $this->SendMSG("Wrong type");
  • src/wp-admin/includes/class-wp-filesystem-base.php

    class WP_Filesystem_Base { 
    749749         * @since 2.5.0
    750750         * @abstract
    751751         *
    752752         * @param string $path           Path to directory or file.
    753753         * @param bool   $include_hidden Optional. Whether to include details of hidden ("." prefixed) files.
    754754         *                               Default true.
    755755         * @param bool   $recursive      Optional. Whether to recursively include file details in nested directories.
    756756         *                               Default false.
    757757         * @return array|bool {
    758758         *     Array of files. False if unable to list directory contents.
    759759         *
    760760         *     @type string $name        Name of the file/directory.
    761761         *     @type string $perms       *nix representation of permissions.
    762762         *     @type int    $permsn      Octal representation of permissions.
    763763         *     @type string $owner       Owner name or ID.
     764         *     @type string $group       Group name or ID.
    764765         *     @type int    $size        Size of file in bytes.
    765          *     @type int    $lastmodunix Last modified unix timestamp.
    766          *     @type mixed  $lastmod     Last modified month (3 letter) and day (without leading 0).
    767          *     @type int    $time        Last modified time.
     766         *     @type int    $time        Last modified unix timestamp.
    768767         *     @type string $type        Type of resource. 'f' for file, 'd' for directory.
    769768         *     @type mixed  $files       If a directory and $recursive is true, contains another array of files.
    770769         * }
    771770         */
    772771        public function dirlist( $path, $include_hidden = true, $recursive = false ) {
    773772                return false;
    774773        }
    775774
    776775} // WP_Filesystem_Base
  • src/wp-admin/includes/class-wp-filesystem-direct.php

    class WP_Filesystem_Direct extends WP_Fi 
    300300         * @param string $file
    301301         * @return bool
    302302         */
    303303        public function is_file($file) {
    304304                return @is_file($file);
    305305        }
    306306        /**
    307307         * @param string $path
    308308         * @return bool
    309309         */
    310310        public function is_dir($path) {
    311311                return @is_dir($path);
    312312        }
    313313
    314314        /**
     315         * @param string $path
     316         * @return bool
     317         */
     318        private function is_link( $path ) {
     319                // Internal use only
     320                return @is_link( $path );
     321        }
     322
     323        /**
    315324         * @param string $file
    316325         * @return bool
    317326         */
    318327        public function is_readable($file) {
    319328                return @is_readable($file);
    320329        }
    321330
    322331        /**
    323332         * @param string $file
    324333         * @return bool
    325334         */
    326335        public function is_writable($file) {
    327336                return @is_writable($file);
    328337        }
    329338
    class WP_Filesystem_Direct extends WP_Fi 
    424433                $ret = array();
    425434
    426435                while (false !== ($entry = $dir->read()) ) {
    427436                        $struc = array();
    428437                        $struc['name'] = $entry;
    429438
    430439                        if ( '.' == $struc['name'] || '..' == $struc['name'] )
    431440                                continue;
    432441
    433442                        if ( ! $include_hidden && '.' == $struc['name'][0] )
    434443                                continue;
    435444
    436445                        if ( $limit_file && $struc['name'] != $limit_file)
    437446                                continue;
    438447
     448                        if ( $this->is_link( $path . '/' . $entry ) ) {
     449                                $struc['type']  = 'l';
     450                        } elseif ( $this->is_dir( $path . '/' . $entry) ) {
     451                                $struc['type']  = 'd';
     452                        } else {
     453                                $struc['type']  = 'f';
     454                        }
     455
    439456                        $struc['perms']         = $this->gethchmod($path.'/'.$entry);
    440457                        $struc['permsn']        = $this->getnumchmodfromh($struc['perms']);
    441                         $struc['number']        = false;
    442458                        $struc['owner']         = $this->owner($path.'/'.$entry);
    443                         $struc['group']         = $this->group($path.'/'.$entry);
    444                         $struc['size']          = $this->size($path.'/'.$entry);
    445                         $struc['lastmodunix']= $this->mtime($path.'/'.$entry);
    446                         $struc['lastmod']   = date('M j',$struc['lastmodunix']);
    447                         $struc['time']          = date('h:i:s',$struc['lastmodunix']);
    448                         $struc['type']          = $this->is_dir($path.'/'.$entry) ? 'd' : 'f';
     459                        $struc['group']         = $this->group($path.'/'.$entry);                       
     460                        $struc['size']          = $struc['type'] == 'f' ? $this->size( $path . '/' . $entry) : false;
     461                        $struc['time']          = $this->mtime($path.'/'.$entry);
     462
     463                        if ( 'u' === $struc['perms']{0} ) {
     464                                $struc['perms'][0] = ( 'f' === $struc['type'] ? '-' : $struc['type'] );
     465                        }
    449466
    450467                        if ( 'd' == $struc['type'] ) {
    451468                                if ( $recursive )
    452469                                        $struc['files'] = $this->dirlist($path . '/' . $struc['name'], $include_hidden, $recursive);
    453470                                else
    454471                                        $struc['files'] = array();
    455472                        }
    456473
    457474                        $ret[ $struc['name'] ] = $struc;
    458475                }
    459476                $dir->close();
    460477                unset($dir);
    461478                return $ret;
    462479        }
    463480}
  • src/wp-admin/includes/class-wp-filesystem-ftpext.php

    class WP_Filesystem_FTPext extends WP_Fi 
    390390                static $is_windows = null;
    391391                if ( is_null($is_windows) )
    392392                        $is_windows = stripos( ftp_systype($this->link), 'win') !== false;
    393393
    394394                if ( $is_windows && preg_match('/([0-9]{2})-([0-9]{2})-([0-9]{2}) +([0-9]{2}):([0-9]{2})(AM|PM) +([0-9]+|<DIR>) +(.+)/', $line, $lucifer) ) {
    395395                        $b = array();
    396396                        if ( $lucifer[3] < 70 )
    397397                                $lucifer[3] +=2000;
    398398                        else
    399399                                $lucifer[3] += 1900; // 4digit year fix
    400400                        $b['isdir'] = ( $lucifer[7] == '<DIR>');
    401401                        if ( $b['isdir'] )
    402402                                $b['type'] = 'd';
    403403                        else
    404404                                $b['type'] = 'f';
    405                         $b['size'] = $lucifer[7];
    406                         $b['month'] = $lucifer[1];
    407                         $b['day'] = $lucifer[2];
    408                         $b['year'] = $lucifer[3];
    409                         $b['hour'] = $lucifer[4];
    410                         $b['minute'] = $lucifer[5];
    411                         $b['time'] = @mktime($lucifer[4] + (strcasecmp($lucifer[6], "PM") == 0 ? 12 : 0), $lucifer[5], 0, $lucifer[1], $lucifer[2], $lucifer[3]);
    412                         $b['am/pm'] = $lucifer[6];
     405                        $b['size'] = $b['isdir'] ? false : (int) $lucifer[7];
     406                        $b['time'] = @mktime($lucifer[4] + ($lucifer[6] === "PM" ? 12 : 0), $lucifer[5], 0, $lucifer[1], $lucifer[2], $lucifer[3]);
    413407                        $b['name'] = $lucifer[8];
     408                        // Unknown on Windows:
     409                        $b['perms'] = $b['permsn'] = $b['owner'] = $b['group'] = false;
    414410                } elseif ( !$is_windows && $lucifer = preg_split('/[ ]/', $line, 9, PREG_SPLIT_NO_EMPTY)) {
    415                         //echo $line."\n";
    416411                        $lcount = count($lucifer);
    417412                        if ( $lcount < 8 )
    418413                                return '';
    419414                        $b = array();
    420415                        $b['isdir'] = $lucifer[0]{0} === 'd';
    421416                        $b['islink'] = $lucifer[0]{0} === 'l';
    422417                        if ( $b['isdir'] )
    423418                                $b['type'] = 'd';
    424419                        elseif ( $b['islink'] )
    425420                                $b['type'] = 'l';
    426421                        else
    427422                                $b['type'] = 'f';
    428423                        $b['perms'] = $lucifer[0];
    429424                        $b['permsn'] = $this->getnumchmodfromh( $b['perms'] );
    430                         $b['number'] = $lucifer[1];
    431425                        $b['owner'] = $lucifer[2];
    432426                        $b['group'] = $lucifer[3];
    433                         $b['size'] = $lucifer[4];
     427                        $b['size'] = ! $b['isdir'] && ! $b['islink'] ? (int)$lucifer[4] : false;
    434428                        if ( $lcount == 8 ) {
    435429                                sscanf($lucifer[5], '%d-%d-%d', $b['year'], $b['month'], $b['day']);
    436430                                sscanf($lucifer[6], '%d:%d', $b['hour'], $b['minute']);
    437431                                $b['time'] = @mktime($b['hour'], $b['minute'], 0, $b['month'], $b['day'], $b['year']);
    438432                                $b['name'] = $lucifer[7];
    439433                        } else {
    440434                                $b['month'] = $lucifer[5];
    441435                                $b['day'] = $lucifer[6];
    442436                                if ( preg_match('/([0-9]{2}):([0-9]{2})/', $lucifer[7], $l2) ) {
    443437                                        $b['year'] = date("Y");
    444438                                        $b['hour'] = $l2[1];
    445439                                        $b['minute'] = $l2[2];
    446440                                } else {
    447441                                        $b['year'] = $lucifer[7];
    448442                                        $b['hour'] = 0;
    449443                                        $b['minute'] = 0;
    450444                                }
    451445                                $b['time'] = strtotime( sprintf('%d %s %d %02d:%02d', $b['day'], $b['month'], $b['year'], $b['hour'], $b['minute']) );
    452446                                $b['name'] = $lucifer[8];
    453447                        }
     448                        unset( $b['year'], $b['month'], $b['day'], $b['hour'], $b['minute'] );
    454449                }
     450                unset( $b['isdir'], $b['islink'] );
    455451
    456452                // Replace symlinks formatted as "source -> target" with just the source name
    457                 if ( $b['islink'] )
     453                if ( 'l' === $b['type'] ) {
    458454                        $b['name'] = preg_replace( '/(\s*->\s*.*)$/', '', $b['name'] );
     455                }
    459456
    460457                return $b;
    461458        }
    462459
    463460        /**
    464461         * @param string $path
    465462         * @param bool $include_hidden
    466463         * @param bool $recursive
    467464         * @return bool|array
    468465         */
    469466        public function dirlist($path = '.', $include_hidden = true, $recursive = false) {
    470467                if ( $this->is_file($path) ) {
    471468                        $limit_file = basename($path);
    472469                        $path = dirname($path) . '/';
    473470                } else {
  • src/wp-admin/includes/class-wp-filesystem-ftpsockets.php

    class WP_Filesystem_ftpsockets extends W 
    434434
    435435                        if ( ! $include_hidden && '.' == $struc['name'][0] )
    436436                                continue;
    437437
    438438                        if ( $limit_file && $struc['name'] != $limit_file )
    439439                                continue;
    440440
    441441                        if ( 'd' == $struc['type'] ) {
    442442                                if ( $recursive )
    443443                                        $struc['files'] = $this->dirlist($path . '/' . $struc['name'], $include_hidden, $recursive);
    444444                                else
    445445                                        $struc['files'] = array();
    446446                        }
    447447
    448448                        // Replace symlinks formatted as "source -> target" with just the source name
    449                         if ( $struc['islink'] )
     449                        if ( 'l' === $struc['type'] ) {
    450450                                $struc['name'] = preg_replace( '/(\s*->\s*.*)$/', '', $struc['name'] );
     451                        }
    451452
    452453                        // Add the Octal representation of the file permissions
    453                         $struc['permsn'] = $this->getnumchmodfromh( $struc['perms'] );
     454                        $struc['permsn'] = $struc['perms'] ? $this->getnumchmodfromh( $struc['perms'] ) : false
    454455
    455456                        $ret[ $struc['name'] ] = $struc;
    456457                }
    457458
    458459                reset_mbstring_encoding();
    459460
    460461                return $ret;
    461462        }
    462463
    463464        /**
    464465         * @access public
    465466         */
    466467        public function __destruct() {
    467468                $this->ftp->quit();
    468469        }
  • src/wp-admin/includes/class-wp-filesystem-ssh2.php

    class WP_Filesystem_SSH2 extends WP_File 
    359359         * @return bool
    360360         */
    361361        public function is_file($file) {
    362362                $file = ltrim($file, '/');
    363363                return is_file('ssh2.sftp://' . $this->sftp_link . '/' . $file);
    364364        }
    365365        /**
    366366         * @param string $path
    367367         * @return bool
    368368         */
    369369        public function is_dir($path) {
    370370                $path = ltrim($path, '/');
    371371                return is_dir('ssh2.sftp://' . $this->sftp_link . '/' . $path);
    372372        }
    373373        /**
     374         * @param string $path
     375         * @return bool
     376         */
     377        private function is_link( $path ) {
     378                // Internal use only
     379                return @is_link('ssh2.sftp://' . $this->sftp_link . '/' . $path);
     380        }
     381        /**
    374382         * @param string $file
    375383         * @return bool
    376384         */
    377385        public function is_readable($file) {
    378386                $file = ltrim($file, '/');
    379387                return is_readable('ssh2.sftp://' . $this->sftp_link . '/' . $file);
    380388        }
    381389        /**
    382390         * @param string $file
    383391         * @return bool
    384392         */
    385393        public function is_writable($file) {
    386394                $file = ltrim($file, '/');
    387395                return is_writable('ssh2.sftp://' . $this->sftp_link . '/' . $file);
    388396        }
    class WP_Filesystem_SSH2 extends WP_File 
    470478
    471479                if ( ! $this->is_dir($path) )
    472480                        return false;
    473481
    474482                $ret = array();
    475483                $dir = @dir('ssh2.sftp://' . $this->sftp_link .'/' . ltrim($path, '/') );
    476484
    477485                if ( ! $dir )
    478486                        return false;
    479487
    480488                while (false !== ($entry = $dir->read()) ) {
    481489                        $struc = array();
    482490                        $struc['name'] = $entry;
    483491
    484492                        if ( '.' == $struc['name'] || '..' == $struc['name'] )
    485                                 continue; //Do not care about these folders.
     493                                continue;
    486494
    487495                        if ( ! $include_hidden && '.' == $struc['name'][0] )
    488496                                continue;
    489497
    490498                        if ( $limit_file && $struc['name'] != $limit_file )
    491499                                continue;
    492500
     501                        if ( $this->is_link( $path . '/' . $entry ) ) {
     502                                $struc['type']  = 'l';
     503                        } elseif ( $this->is_dir( $path . '/' . $entry) ) {
     504                                $struc['type']  = 'd';
     505                        } else {
     506                                $struc['type']  = 'f';
     507                        }
     508
    493509                        $struc['perms']         = $this->gethchmod($path.'/'.$entry);
    494510                        $struc['permsn']        = $this->getnumchmodfromh($struc['perms']);
    495                         $struc['number']        = false;
    496511                        $struc['owner']         = $this->owner($path.'/'.$entry);
    497512                        $struc['group']         = $this->group($path.'/'.$entry);
    498                         $struc['size']          = $this->size($path.'/'.$entry);
    499                         $struc['lastmodunix']= $this->mtime($path.'/'.$entry);
    500                         $struc['lastmod']   = date('M j',$struc['lastmodunix']);
    501                         $struc['time']          = date('h:i:s',$struc['lastmodunix']);
    502                         $struc['type']          = $this->is_dir($path.'/'.$entry) ? 'd' : 'f';
     513                        $struc['size']          = $struc['type'] == 'f' ? $this->size($path . '/' . $entry) : false;
     514                        $struc['time']          = $this->mtime($path.'/'.$entry);
     515
     516                        if ( 'u' === $struc['perms']{0} ) {
     517                                $struc['perms'][0] = ( 'f' === $struc['type'] ? '-' : $struc['type'] );
     518                        }
    503519
    504520                        if ( 'd' == $struc['type'] ) {
    505521                                if ( $recursive )
    506522                                        $struc['files'] = $this->dirlist($path . '/' . $struc['name'], $include_hidden, $recursive);
    507523                                else
    508524                                        $struc['files'] = array();
    509525                        }
    510526
    511527                        $ret[ $struc['name'] ] = $struc;
    512528                }
    513529                $dir->close();
    514530                unset($dir);
    515531                return $ret;
    516532        }
    517533}
  • src/wp-admin/includes/class-wp-upgrader.php

    class WP_Upgrader { 
    252252         * @param string $package        Full path to the package file.
    253253         * @param bool   $delete_package Optional. Whether to delete the package file after attempting
    254254         *                               to unpack it. Default true.
    255255         * @return string|WP_Error The path to the unpacked contents, or a {@see WP_Error} on failure.
    256256         */
    257257        public function unpack_package( $package, $delete_package = true ) {
    258258                global $wp_filesystem;
    259259
    260260                $this->skin->feedback('unpack_package');
    261261
    262262                $upgrade_folder = $wp_filesystem->wp_content_dir() . 'upgrade/';
    263263
    264264                //Clean up contents of upgrade directory beforehand.
    265265                $upgrade_files = $wp_filesystem->dirlist($upgrade_folder);
    266266                if ( !empty($upgrade_files) ) {
    267                         foreach ( $upgrade_files as $file )
    268                                 $wp_filesystem->delete($upgrade_folder . $file['name'], true);
     267                        foreach ( $upgrade_files as $file ) {
     268                                $wp_filesystem->delete( $upgrade_folder . $file['name'], true, $file['type'] );
     269                        }
    269270                }
    270271
    271272                // We need a working directory - Strip off any .tmp or .zip suffixes
    272273                $working_dir = $upgrade_folder . basename( basename( $package, '.tmp' ), '.zip' );
    273274
    274275                // Clean up working directory
    275276                if ( $wp_filesystem->is_dir($working_dir) )
    276277                        $wp_filesystem->delete($working_dir, true);
    277278
    278279                // Unzip package to working directory
    279280                $result = unzip_file( $package, $working_dir );
    280281
    281282                // Once extracted, delete the package if required.
    282283                if ( $delete_package )
    283284                        unlink($package);