Make WordPress Core


Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/3.1/wp-admin/includes/class-wp-upgrader.php

    r18227 r17503  
    2626    var $result = array();
    2727
     28    function WP_Upgrader($skin = null) {
     29        return $this->__construct($skin);
     30    }
    2831    function __construct($skin = null) {
    2932        if ( null == $skin )
     
    209212        }
    210213
    211         if ( $clear_destination ) {
    212             //We're going to clear the destination if theres something there
    213             $this->skin->feedback('remove_old');
    214             $removed = true;
    215             if ( $wp_filesystem->exists($remote_destination) )
     214        if ( $wp_filesystem->exists($remote_destination) ) {
     215            if ( $clear_destination ) {
     216                //We're going to clear the destination if theres something there
     217                $this->skin->feedback('remove_old');
    216218                $removed = $wp_filesystem->delete($remote_destination, true);
    217             $removed = apply_filters('upgrader_clear_destination', $removed, $local_destination, $remote_destination, $hook_extra);
    218 
    219             if ( is_wp_error($removed) )
    220                 return $removed;
    221             else if ( ! $removed )
    222                 return new WP_Error('remove_old_failed', $this->strings['remove_old_failed']);
    223         } elseif ( $wp_filesystem->exists($remote_destination) ) {
    224             //If we're not clearing the destination folder and something exists there allready, Bail.
    225             //But first check to see if there are actually any files in the folder.
    226             $_files = $wp_filesystem->dirlist($remote_destination);
    227             if ( ! empty($_files) ) {
    228                 $wp_filesystem->delete($remote_source, true); //Clear out the source files.
    229                 return new WP_Error('folder_exists', $this->strings['folder_exists'], $remote_destination );
     219                $removed = apply_filters('upgrader_clear_destination', $removed, $local_destination, $remote_destination, $hook_extra);
     220
     221                if ( is_wp_error($removed) )
     222                    return $removed;
     223                else if ( ! $removed )
     224                    return new WP_Error('remove_old_failed', $this->strings['remove_old_failed']);
     225            } else {
     226                //If we're not clearing the destination folder and something exists there allready, Bail.
     227                //But first check to see if there are actually any files in the folder.
     228                $_files = $wp_filesystem->dirlist($remote_destination);
     229                if ( ! empty($_files) ) {
     230                    $wp_filesystem->delete($remote_source, true); //Clear out the source files.
     231                    return new WP_Error('folder_exists', $this->strings['folder_exists'], $remote_destination );
     232                }
    230233            }
    231234        }
     
    300303        }
    301304
    302         $delete_package = ($download != $package); // Do not delete a "local" file
    303 
    304305        //Unzip's the file into a temporary directory
    305         $working_dir = $this->unpack_package( $download, $delete_package );
     306        $working_dir = $this->unpack_package( $download );
    306307        if ( is_wp_error($working_dir) ) {
    307308            $this->skin->error($working_dir);
     
    581582
    582583        // If plugin is in its own directory, recursively delete the directory.
    583         if ( strpos($plugin, '/') && $this_plugin_dir != $plugins_dir ) //base check on if plugin includes directory separator AND that its not the root plugin folder
     584        if ( strpos($plugin, '/') && $this_plugin_dir != $plugins_dir ) //base check on if plugin includes directory seperator AND that its not the root plugin folder
    584585            $deleted = $wp_filesystem->delete($this_plugin_dir, true);
    585586        else
     
    589590            return new WP_Error('remove_old_failed', $this->strings['remove_old_failed']);
    590591
    591         return true;
     592        return $removed;
    592593    }
    593594}
     
    868869
    869870    function upgrade($current) {
    870         global $wp_filesystem, $wp_version;
     871        global $wp_filesystem;
    871872
    872873        $this->init();
     
    886887        $wp_dir = trailingslashit($wp_filesystem->abspath());
    887888
    888         // If partial update is returned from the API, use that, unless we're doing a reinstall.
    889         // If we cross the new_bundled version number, then use the new_bundled zip.
    890         // Don't though if the constant is set to skip bundled items.
    891         // If the API returns a no_content zip, go with it. Finally, default to the full zip.
    892         if ( $current->packages->partial && 'reinstall' != $current->response && $wp_version == $current->partial_version )
    893             $to_download = 'partial';
    894         elseif ( $current->packages->new_bundled && version_compare( $wp_version, $current->new_bundled, '<' )
    895             && ( ! defined( 'CORE_UPGRADE_SKIP_NEW_BUNDLED' ) || ! CORE_UPGRADE_SKIP_NEW_BUNDLED ) )
    896             $to_download = 'new_bundled';
    897         elseif ( $current->packages->no_content )
    898             $to_download = 'no_content';
    899         else
    900             $to_download = 'full';
    901 
    902         $download = $this->download_package( $current->packages->$to_download );
     889        $download = $this->download_package( $current->package );
    903890        if ( is_wp_error($download) )
    904891            return $download;
     
    937924    var $result = false;
    938925
     926    function WP_Upgrader_Skin($args = array()) {
     927        return $this->__construct($args);
     928    }
    939929    function __construct($args = array()) {
    940930        $defaults = array( 'url' => '', 'nonce' => '', 'title' => '', 'context' => false );
     
    10231013    var $plugin_network_active = false;
    10241014
     1015    function Plugin_Upgrader_Skin($args = array()) {
     1016        return $this->__construct($args);
     1017    }
     1018
    10251019    function __construct($args = array()) {
    10261020        $defaults = array( 'url' => '', 'plugin' => '', 'nonce' => '', 'title' => __('Update Plugin') );
     
    10751069    var $error = false;
    10761070
     1071    function Bulk_Upgrader_Skin($args = array()) {
     1072        return $this->__construct($args);
     1073    }
     1074
    10771075    function __construct($args = array()) {
    10781076        $defaults = array( 'url' => '', 'nonce' => '' );
     
    11791177class Bulk_Plugin_Upgrader_Skin extends Bulk_Upgrader_Skin {
    11801178    var $plugin_info = array(); // Plugin_Upgrader::bulk() will fill this in.
    1181 
    1182     function __construct($args = array()) {
     1179    function Plugin_Upgrader_Skin($args = array()) {
    11831180        parent::__construct($args);
    11841181    }
     
    12111208class Bulk_Theme_Upgrader_Skin extends Bulk_Upgrader_Skin {
    12121209    var $theme_info = array(); // Theme_Upgrader::bulk() will fill this in.
    1213 
    1214     function __construct($args = array()) {
     1210    function Theme_Upgrader_Skin($args = array()) {
    12151211        parent::__construct($args);
    12161212    }
     
    12541250    var $type;
    12551251
     1252    function Plugin_Installer_Skin($args = array()) {
     1253        return $this->__construct($args);
     1254    }
     1255
    12561256    function __construct($args = array()) {
    12571257        $defaults = array( 'type' => 'web', 'url' => '', 'plugin' => '', 'nonce' => '', 'title' => '' );
     
    13181318    var $type;
    13191319
     1320    function Theme_Installer_Skin($args = array()) {
     1321        return $this->__construct($args);
     1322    }
     1323
    13201324    function __construct($args = array()) {
    13211325        $defaults = array( 'type' => 'web', 'url' => '', 'theme' => '', 'nonce' => '', 'title' => '' );
     
    13791383class Theme_Upgrader_Skin extends WP_Upgrader_Skin {
    13801384    var $theme = '';
     1385
     1386    function Theme_Upgrader_Skin($args = array()) {
     1387        return $this->__construct($args);
     1388    }
    13811389
    13821390    function __construct($args = array()) {
     
    14311439    var $filename;
    14321440
     1441    function File_Upload_Upgrader($form, $urlholder) {
     1442        return $this->__construct($form, $urlholder);
     1443    }
    14331444    function __construct($form, $urlholder) {
    14341445        if ( ! ( ( $uploads = wp_upload_dir() ) && false === $uploads['error'] ) )
Note: See TracChangeset for help on using the changeset viewer.