Changeset 25806 for trunk/src/wp-admin/includes/class-wp-upgrader.php
- Timestamp:
- 10/16/2013 04:14:29 AM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-admin/includes/class-wp-upgrader.php
r25801 r25806 308 308 extract($options); 309 309 310 //Connect to the Filesystem first.311 $res = $this->fs_connect( array(WP_CONTENT_DIR, $destination) );312 if ( ! $res ) //Mainly for non-connected filesystem.313 return false;314 315 310 if ( ! $is_multi ) // call $this->header separately if running multiple times 316 311 $this->skin->header(); 312 313 // Connect to the Filesystem first. 314 $res = $this->fs_connect( array(WP_CONTENT_DIR, $destination) ); 315 // Mainly for non-connected filesystem. 316 if ( ! $res ) { 317 if ( ! $is_multi ) 318 $this->skin->footer(); 319 return false; 320 } 317 321 318 322 $this->skin->before(); … … 369 373 $this->skin->after(); 370 374 371 if ( ! $is_multi ) 375 if ( ! $is_multi ) { 376 do_action( 'upgrader_process_complete', $this, $hook_extra ); 372 377 $this->skin->footer(); 378 } 373 379 374 380 return $result; … … 443 449 'clear_destination' => false, // Do not overwrite files. 444 450 'clear_working' => true, 445 'hook_extra' => array() 451 'hook_extra' => array( 452 'type' => 'plugin', 453 'action' => 'install', 454 ) 446 455 ) ); 447 456 … … 453 462 // Force refresh of plugin update information 454 463 wp_clean_plugins_cache( $parsed_args['clear_update_cache'] ); 455 456 do_action( 'upgrader_process_complete', $this, array( 'action' => 'install', 'type' => 'plugin' ), $package );457 464 458 465 return true; … … 491 498 'clear_working' => true, 492 499 'hook_extra' => array( 493 'plugin' => $plugin 500 'plugin' => $plugin, 501 'type' => 'plugin', 502 'action' => 'update', 494 503 ), 495 504 ) ); … … 504 513 // Force refresh of plugin update information 505 514 wp_clean_plugins_cache( $parsed_args['clear_update_cache'] ); 506 507 do_action( 'upgrader_process_complete', $this, array( 'action' => 'update', 'type' => 'plugin' ), $plugin );508 515 509 516 return true; … … 588 595 $this->maintenance_mode(false); 589 596 597 do_action( 'upgrader_process_complete', $this, array( 598 'action' => 'update', 599 'type' => 'plugin', 600 'bulk' => true, 601 'plugins' => $plugins, 602 ) ); 603 590 604 $this->skin->bulk_footer(); 591 605 … … 597 611 // Force refresh of plugin update information 598 612 wp_clean_plugins_cache( $parsed_args['clear_update_cache'] ); 599 600 do_action( 'upgrader_process_complete', $this, array( 'action' => 'update', 'type' => 'plugin', 'bulk' => true ), $plugins );601 613 602 614 return $results; … … 815 827 'destination' => get_theme_root(), 816 828 'clear_destination' => false, //Do not overwrite files. 817 'clear_working' => true 829 'clear_working' => true, 830 'hook_extra' => array( 831 'type' => 'theme', 832 'action' => 'install', 833 ), 818 834 ) ); 819 835 … … 826 842 // Refresh the Theme Update information 827 843 wp_clean_themes_cache( $parsed_args['clear_update_cache'] ); 828 829 do_action( 'upgrader_process_complete', $this, array( 'action' => 'install', 'type' => 'theme' ), $package );830 844 831 845 return true; … … 864 878 'clear_working' => true, 865 879 'hook_extra' => array( 866 'theme' => $theme 880 'theme' => $theme, 881 'type' => 'theme', 882 'action' => 'update', 867 883 ), 868 884 ) ); … … 876 892 877 893 wp_clean_themes_cache( $parsed_args['clear_update_cache'] ); 878 879 do_action( 'upgrader_process_complete', $this, array( 'action' => 'update', 'type' => 'theme' ), $theme );880 894 881 895 return true; … … 960 974 $this->maintenance_mode(false); 961 975 976 do_action( 'upgrader_process_complete', $this, array( 977 'action' => 'update', 978 'type' => 'plugin', 979 'bulk' => true, 980 'themes' => $themes, 981 ) ); 982 962 983 $this->skin->bulk_footer(); 963 984 … … 971 992 // Refresh the Theme Update information 972 993 wp_clean_themes_cache( $parsed_args['clear_update_cache'] ); 973 974 do_action( 'upgrader_process_complete', $this, array( 'action' => 'update', 'type' => 'theme', 'bulk' => true ), $themes );975 994 976 995 return $results; … … 1074 1093 } 1075 1094 1076 add_action( 'upgrader_process_complete', array( 'Language_Pack_Upgrader', 'async_upgrade' ), 20 , 3);1095 add_action( 'upgrader_process_complete', array( 'Language_Pack_Upgrader', 'async_upgrade' ), 20 ); 1077 1096 class Language_Pack_Upgrader extends WP_Upgrader { 1078 1097 … … 1080 1099 var $bulk = true; 1081 1100 1082 static function async_upgrade( $upgrader , $context, $package ) {1101 static function async_upgrade( $upgrader = false ) { 1083 1102 // Avoid recursion. 1084 if ( $upgrader instanceof Language_Pack_Upgrader )1103 if ( $upgrader && $upgrader instanceof Language_Pack_Upgrader ) 1085 1104 return; 1086 1105 1087 $lp_upgrader = new Language_Pack_Upgrader( new Headerless_Upgrader_Skin() ); 1106 // Nothing to do? 1107 $language_updates = wp_get_translation_updates(); 1108 if ( ! $language_updates ) 1109 return; 1110 1111 $skin = new Language_Pack_Upgrader_Skin( array( 1112 'skip_header_footer' => true, 1113 ) ); 1114 1115 $lp_upgrader = new Language_Pack_Upgrader( $skin ); 1088 1116 $lp_upgrader->upgrade(); 1089 1117 } … … 1099 1127 } 1100 1128 1101 function upgrade( $update = false ) {1129 function upgrade( $update = false, $args = array() ) { 1102 1130 if ( $update ) 1103 1131 $update = array( $update ); 1104 $results = $this->bulk_upgrade( $update );1132 $results = $this->bulk_upgrade( $update, $args ); 1105 1133 return $results[0]; 1106 1134 } 1107 1135 1108 function bulk_upgrade( $language_updates = array() ) {1136 function bulk_upgrade( $language_updates = array(), $args = array() ) { 1109 1137 global $wp_filesystem; 1138 1139 $defaults = array( 1140 'clear_update_cache' => true, 1141 ); 1142 $parsed_args = wp_parse_args( $args, $defaults ); 1110 1143 1111 1144 $this->init(); … … 1115 1148 $language_updates = wp_get_translation_updates(); 1116 1149 1117 if ( empty( $language_updates ) ) 1150 if ( empty( $language_updates ) ) { 1151 $this->skin->header(); 1152 $this->skin->before(); 1153 $this->skin->set_result( true ); 1154 $this->skin->feedback( 'up_to_date' ); 1155 $this->skin->after(); 1156 $this->skin->bulk_footer(); 1157 $this->skin->footer(); 1118 1158 return true; 1159 } 1119 1160 1120 1161 if ( 'upgrader_process_complete' == current_filter() ) … … 1145 1186 1146 1187 foreach ( $language_updates as $language_update ) { 1188 1189 $this->skin->language_update = $language_update; 1147 1190 1148 1191 $destination = WP_LANG_DIR; … … 1176 1219 } 1177 1220 1221 $this->skin->bulk_footer(); 1222 1223 $this->skin->footer(); 1224 1178 1225 // Clean up our hooks, in case something else does an upgrade on this connection. 1179 1226 remove_filter( 'upgrader_source_selection', array( &$this, 'check_package' ), 10, 2 ); 1227 1228 if ( $parsed_args['clear_update_cache'] ) { 1229 wp_clean_themes_cache( true ); 1230 wp_clean_plugins_cache( true ); 1231 delete_site_transient( 'update_core' ); 1232 } 1180 1233 1181 1234 return $results; … … 1205 1258 1206 1259 return $source; 1260 } 1261 1262 function get_name_for_update( $update ) { 1263 switch ( $update->type ) { 1264 case 'core': 1265 return 'WordPress'; // Not translated 1266 break; 1267 case 'theme': 1268 $theme = wp_get_theme( $update->slug ); 1269 if ( $theme->exists() ) 1270 return $theme->Get( 'Name' ); 1271 break; 1272 case 'plugin': 1273 $plugin_data = get_plugins( '/' . $update->slug ); 1274 $plugin_data = array_shift( $plugin_data ); 1275 if ( $plugin_data ) 1276 return $plugin_data['Name']; 1277 break; 1278 } 1279 return ''; 1207 1280 } 1208 1281 … … 1322 1395 } 1323 1396 1324 do_action( 'upgrader_process_complete', $this, array( 'action' => 'update', 'type' => 'core' ), $result );1325 1397 return $result; 1326 1398 } … … 1629 1701 break; 1630 1702 case 'language': 1631 if ( 'theme' == $item->type ) { 1632 $theme = wp_get_theme( $item->slug ); 1633 $skin->feedback( sprintf( 1634 __( 'Updating the %1$s translation for the %2$s theme' ), 1635 $item->language, 1636 $theme->Get( 'Name' ) 1637 ) ); 1638 $item_name = sprintf( 1639 __( '%1$s translation for the %2$s theme' ), 1640 $item->language, 1641 $theme->Get( 'Name' ) 1642 ); 1643 } elseif ( 'plugin' == $item->type ) { 1644 $plugin_data = get_plugins( '/' . $item->slug ); 1645 $plugin_data = array_shift( $plugin_data ); 1646 $skin->feedback( sprintf( 1647 __( 'Updating the %1$s translation for the %2$s plugin' ), 1648 $item->language, 1649 $plugin_data['Name'] 1650 ) ); 1651 $item_name = sprintf( 1652 __( '%1$s translation for the %2$s plugin' ), 1653 $item->language, 1654 $plugin_data['Name'] 1655 ); 1656 } else { 1657 $skin->feedback( sprintf( 1658 __( 'Updating %s translation' ), 1659 $item->language 1660 ) ); 1661 $item_name = sprintf( 1662 __( '%s translation' ), 1663 $item->language 1664 ); 1665 } 1666 1703 $name = $upgrader->get_name_for_update( $item ); 1704 $skin->feedback( sprintf( __( 'Updating translations for %1$s (%2$s)…' ), $name, $item->language ) ); 1667 1705 break; 1668 1706 } … … 1712 1750 1713 1751 // Don't automatically run these thins, as we'll handle it ourselves 1714 remove_action( 'upgrader_process_complete', array( 'Language_Pack_Upgrader', 'async_upgrade' ), 20 , 3);1752 remove_action( 'upgrader_process_complete', array( 'Language_Pack_Upgrader', 'async_upgrade' ), 20 ); 1715 1753 remove_action( 'upgrader_process_complete', 'wp_version_check' ); 1716 1754 remove_action( 'upgrader_process_complete', 'wp_update_plugins' );
Note: See TracChangeset
for help on using the changeset viewer.