Make WordPress Core


Ignore:
File:
1 edited

Legend:

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

    r17503 r18227  
    2626    var $result = array();
    2727
    28     function WP_Upgrader($skin = null) {
    29         return $this->__construct($skin);
    30     }
    3128    function __construct($skin = null) {
    3229        if ( null == $skin )
     
    212209        }
    213210
    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');
     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) )
    218216                $removed = $wp_filesystem->delete($remote_destination, true);
    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                 }
     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 );
    233230            }
    234231        }
     
    303300        }
    304301
     302        $delete_package = ($download != $package); // Do not delete a "local" file
     303
    305304        //Unzip's the file into a temporary directory
    306         $working_dir = $this->unpack_package( $download );
     305        $working_dir = $this->unpack_package( $download, $delete_package );
    307306        if ( is_wp_error($working_dir) ) {
    308307            $this->skin->error($working_dir);
     
    582581
    583582        // If plugin is in its own directory, recursively delete the directory.
    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
     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
    585584            $deleted = $wp_filesystem->delete($this_plugin_dir, true);
    586585        else
     
    590589            return new WP_Error('remove_old_failed', $this->strings['remove_old_failed']);
    591590
    592         return $removed;
     591        return true;
    593592    }
    594593}
     
    869868
    870869    function upgrade($current) {
    871         global $wp_filesystem;
     870        global $wp_filesystem, $wp_version;
    872871
    873872        $this->init();
     
    887886        $wp_dir = trailingslashit($wp_filesystem->abspath());
    888887
    889         $download = $this->download_package( $current->package );
     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 );
    890903        if ( is_wp_error($download) )
    891904            return $download;
     
    924937    var $result = false;
    925938
    926     function WP_Upgrader_Skin($args = array()) {
    927         return $this->__construct($args);
    928     }
    929939    function __construct($args = array()) {
    930940        $defaults = array( 'url' => '', 'nonce' => '', 'title' => '', 'context' => false );
     
    10131023    var $plugin_network_active = false;
    10141024
    1015     function Plugin_Upgrader_Skin($args = array()) {
    1016         return $this->__construct($args);
    1017     }
    1018 
    10191025    function __construct($args = array()) {
    10201026        $defaults = array( 'url' => '', 'plugin' => '', 'nonce' => '', 'title' => __('Update Plugin') );
     
    10691075    var $error = false;
    10701076
    1071     function Bulk_Upgrader_Skin($args = array()) {
    1072         return $this->__construct($args);
    1073     }
    1074 
    10751077    function __construct($args = array()) {
    10761078        $defaults = array( 'url' => '', 'nonce' => '' );
     
    11771179class Bulk_Plugin_Upgrader_Skin extends Bulk_Upgrader_Skin {
    11781180    var $plugin_info = array(); // Plugin_Upgrader::bulk() will fill this in.
    1179     function Plugin_Upgrader_Skin($args = array()) {
     1181
     1182    function __construct($args = array()) {
    11801183        parent::__construct($args);
    11811184    }
     
    12081211class Bulk_Theme_Upgrader_Skin extends Bulk_Upgrader_Skin {
    12091212    var $theme_info = array(); // Theme_Upgrader::bulk() will fill this in.
    1210     function Theme_Upgrader_Skin($args = array()) {
     1213
     1214    function __construct($args = array()) {
    12111215        parent::__construct($args);
    12121216    }
     
    12501254    var $type;
    12511255
    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 
    13241320    function __construct($args = array()) {
    13251321        $defaults = array( 'type' => 'web', 'url' => '', 'theme' => '', 'nonce' => '', 'title' => '' );
     
    13831379class Theme_Upgrader_Skin extends WP_Upgrader_Skin {
    13841380    var $theme = '';
    1385 
    1386     function Theme_Upgrader_Skin($args = array()) {
    1387         return $this->__construct($args);
    1388     }
    13891381
    13901382    function __construct($args = array()) {
     
    14391431    var $filename;
    14401432
    1441     function File_Upload_Upgrader($form, $urlholder) {
    1442         return $this->__construct($form, $urlholder);
    1443     }
    14441433    function __construct($form, $urlholder) {
    14451434        if ( ! ( ( $uploads = wp_upload_dir() ) && false === $uploads['error'] ) )
Note: See TracChangeset for help on using the changeset viewer.