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