Changes from branches/3.1/wp-admin/includes/class-wp-upgrader.php at r17503 to trunk/wp-admin/includes/class-wp-upgrader.php at r18227
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-admin/includes/class-wp-upgrader.php
r17503 r18227 26 26 var $result = array(); 27 27 28 function WP_Upgrader($skin = null) {29 return $this->__construct($skin);30 }31 28 function __construct($skin = null) { 32 29 if ( null == $skin ) … … 212 209 } 213 210 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) ) 218 216 $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 ); 233 230 } 234 231 } … … 303 300 } 304 301 302 $delete_package = ($download != $package); // Do not delete a "local" file 303 305 304 //Unzip's the file into a temporary directory 306 $working_dir = $this->unpack_package( $download );305 $working_dir = $this->unpack_package( $download, $delete_package ); 307 306 if ( is_wp_error($working_dir) ) { 308 307 $this->skin->error($working_dir); … … 582 581 583 582 // 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 sep erator AND that its not the root plugin folder583 if ( strpos($plugin, '/') && $this_plugin_dir != $plugins_dir ) //base check on if plugin includes directory separator AND that its not the root plugin folder 585 584 $deleted = $wp_filesystem->delete($this_plugin_dir, true); 586 585 else … … 590 589 return new WP_Error('remove_old_failed', $this->strings['remove_old_failed']); 591 590 592 return $removed;591 return true; 593 592 } 594 593 } … … 869 868 870 869 function upgrade($current) { 871 global $wp_filesystem ;870 global $wp_filesystem, $wp_version; 872 871 873 872 $this->init(); … … 887 886 $wp_dir = trailingslashit($wp_filesystem->abspath()); 888 887 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 ); 890 903 if ( is_wp_error($download) ) 891 904 return $download; … … 924 937 var $result = false; 925 938 926 function WP_Upgrader_Skin($args = array()) {927 return $this->__construct($args);928 }929 939 function __construct($args = array()) { 930 940 $defaults = array( 'url' => '', 'nonce' => '', 'title' => '', 'context' => false ); … … 1013 1023 var $plugin_network_active = false; 1014 1024 1015 function Plugin_Upgrader_Skin($args = array()) {1016 return $this->__construct($args);1017 }1018 1019 1025 function __construct($args = array()) { 1020 1026 $defaults = array( 'url' => '', 'plugin' => '', 'nonce' => '', 'title' => __('Update Plugin') ); … … 1069 1075 var $error = false; 1070 1076 1071 function Bulk_Upgrader_Skin($args = array()) {1072 return $this->__construct($args);1073 }1074 1075 1077 function __construct($args = array()) { 1076 1078 $defaults = array( 'url' => '', 'nonce' => '' ); … … 1177 1179 class Bulk_Plugin_Upgrader_Skin extends Bulk_Upgrader_Skin { 1178 1180 var $plugin_info = array(); // Plugin_Upgrader::bulk() will fill this in. 1179 function Plugin_Upgrader_Skin($args = array()) { 1181 1182 function __construct($args = array()) { 1180 1183 parent::__construct($args); 1181 1184 } … … 1208 1211 class Bulk_Theme_Upgrader_Skin extends Bulk_Upgrader_Skin { 1209 1212 var $theme_info = array(); // Theme_Upgrader::bulk() will fill this in. 1210 function Theme_Upgrader_Skin($args = array()) { 1213 1214 function __construct($args = array()) { 1211 1215 parent::__construct($args); 1212 1216 } … … 1250 1254 var $type; 1251 1255 1252 function Plugin_Installer_Skin($args = array()) {1253 return $this->__construct($args);1254 }1255 1256 1256 function __construct($args = array()) { 1257 1257 $defaults = array( 'type' => 'web', 'url' => '', 'plugin' => '', 'nonce' => '', 'title' => '' ); … … 1318 1318 var $type; 1319 1319 1320 function Theme_Installer_Skin($args = array()) {1321 return $this->__construct($args);1322 }1323 1324 1320 function __construct($args = array()) { 1325 1321 $defaults = array( 'type' => 'web', 'url' => '', 'theme' => '', 'nonce' => '', 'title' => '' ); … … 1383 1379 class Theme_Upgrader_Skin extends WP_Upgrader_Skin { 1384 1380 var $theme = ''; 1385 1386 function Theme_Upgrader_Skin($args = array()) {1387 return $this->__construct($args);1388 }1389 1381 1390 1382 function __construct($args = array()) { … … 1439 1431 var $filename; 1440 1432 1441 function File_Upload_Upgrader($form, $urlholder) {1442 return $this->__construct($form, $urlholder);1443 }1444 1433 function __construct($form, $urlholder) { 1445 1434 if ( ! ( ( $uploads = wp_upload_dir() ) && false === $uploads['error'] ) )
Note: See TracChangeset
for help on using the changeset viewer.