Changeset 25806
- Timestamp:
- 10/16/2013 04:14:29 AM (11 years ago)
- Location:
- trunk/src/wp-admin
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-admin/css/wp-admin.css
r25771 r25806 6637 6637 } 6638 6638 6639 /* Upgrader styles, Specific to Language Packs */ 6640 .lp-show-latest p { 6641 display: none; 6642 } 6643 .lp-show-latest p:last-child, 6644 .lp-show-latest .lp-error p { 6645 display: block; 6646 } 6639 6647 6640 6648 /* - Only used once or twice in all of WP - deprecate for global style -
trunk/src/wp-admin/includes/class-wp-upgrader-skins.php
r25775 r25806 530 530 531 531 /** 532 * Translation Upgrader Skin for WordPress Translation Upgrades. 533 * 534 * @package WordPress 535 * @subpackage Upgrader 536 * @since 3.7.0 537 */ 538 class Language_Pack_Upgrader_Skin extends WP_Upgrader_Skin { 539 var $language_update = null; 540 var $done_header = false; 541 var $display_footer_actions = true; 542 543 function __construct( $args = array() ) { 544 $defaults = array( 'url' => '', 'nonce' => '', 'title' => __( 'Update Translations' ), 'skip_header_footer' => false ); 545 $args = wp_parse_args( $args, $defaults ); 546 if ( $args['skip_header_footer'] ) { 547 $this->done_header = true; 548 $this->display_footer_actions = false; 549 } 550 parent::__construct( $args ); 551 } 552 553 function before() { 554 $name = $this->upgrader->get_name_for_update( $this->language_update ); 555 556 echo '<div class="update-messages lp-show-latest">'; 557 558 printf( '<h4>' . __( 'Updating translations for %1$s (%2$s)…' ) . '</h4>', $name, $this->language_update->language ); 559 } 560 561 function error( $error ) { 562 echo '<div class="lp-error">'; 563 parent::error( $error ); 564 echo '</div>'; 565 } 566 567 function after() { 568 echo '</div>'; 569 } 570 571 function bulk_footer() { 572 $update_actions = array(); 573 $update_actions['updates_page'] = '<a href="' . self_admin_url( 'update-core.php' ) . '" title="' . esc_attr__( 'Go to WordPress Updates page' ) . '" target="_parent">' . __( 'Return to WordPress Updates' ) . '</a>'; 574 $update_actions = apply_filters( 'update_translations_complete_actions', $update_actions ); 575 576 if ( $update_actions && $this->display_footer_actions ) 577 $this->feedback( implode( ' | ', $update_actions ) ); 578 579 parent::footer(); 580 } 581 } 582 583 /** 532 584 * Upgrader Skin for Automatic WordPress Upgrades 533 585 * -
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' ); -
trunk/src/wp-admin/includes/file.php
r25799 r25806 892 892 if ( !$context ) 893 893 $context = WP_CONTENT_DIR; 894 895 // If the directory doesn't exist (wp-content/languages) then use the parent directory as we'll create it. 896 if ( WP_LANG_DIR == $context && ! is_dir( $context ) ) 897 $context = dirname( $context ); 898 894 899 $context = trailingslashit($context); 895 900 $temp_file_name = $context . 'temp-write-test-' . time(); … … 1022 1027 </script> 1023 1028 <form action="<?php echo esc_url( $form_post ) ?>" method="post"> 1024 <div class="wrap"> 1025 <?php screen_icon(); ?> 1026 <h2><?php _e('Connection Information') ?></h2> 1029 <div> 1030 <h3><?php _e('Connection Information') ?></h3> 1027 1031 <p><?php 1028 1032 $label_user = __('Username'); -
trunk/src/wp-admin/includes/update-core.php
r25805 r25806 890 890 $wp_filesystem->delete($maintenance_file); 891 891 892 // Has to be in here, rather than the Upgrader as the filter below will override and kill the process before themes get updated on major updates 893 do_action( 'upgrader_process_complete', null, array( 'action' => 'update', 'type' => 'core' ) ); 894 892 895 // If we made it this far: 893 896 do_action( '_core_updated_successfully', $wp_version ); -
trunk/src/wp-admin/update-core.php
r25784 r25806 325 325 } 326 326 327 function list_translation_updates() { 328 $updates = wp_get_translation_updates(); 329 if ( ! $updates ) { 330 if ( 'en_US' != get_locale() ) { 331 echo '<h3>' . __( 'Translations' ) . '</h3>'; 332 echo '<p>' . __( 'Your translations are all up to date.' ) . '</p>'; 333 } 334 return; 335 } 336 337 $form_action = 'update-core.php?action=do-translation-upgrade'; 338 ?> 339 <h3><?php _e( 'Translations' ); ?></h3> 340 <form method="post" action="<?php echo esc_url( $form_action ); ?>" name="upgrade-themes" class="upgrade"> 341 <p><?php _e( 'Some of your translations are out of date.' ); ?></p> 342 <?php wp_nonce_field('upgrade-translations'); ?> 343 <p><input class="button" type="submit" value="<?php esc_attr_e( 'Update Translations' ); ?>" name="upgrade" /></p> 344 </form> 345 <?php 346 } 347 327 348 /** 328 349 * Upgrade WordPress core display. … … 342 363 $url = 'update-core.php?action=do-core-upgrade'; 343 364 $url = wp_nonce_url($url, 'upgrade-core'); 344 if ( false === ($credentials = request_filesystem_credentials($url, '', false, ABSPATH)) )345 return;346 365 347 366 $version = isset( $_POST['version'] )? $_POST['version'] : false; … … 351 370 return; 352 371 353 if ( ! WP_Filesystem($credentials, ABSPATH) ) {354 request_filesystem_credentials($url, '', true, ABSPATH); //Failed to connect, Error and request again355 return;356 }357 372 ?> 358 373 <div class="wrap"> … … 360 375 <h2><?php _e('Update WordPress'); ?></h2> 361 376 <?php 377 378 if ( false === ( $credentials = request_filesystem_credentials( $url, '', false, ABSPATH ) ) ) { 379 echo '</div>'; 380 return; 381 } 382 383 if ( ! WP_Filesystem( $credentials, ABSPATH ) ) { 384 // Failed to connect, Error and request again 385 request_filesystem_credentials( $url, '', true, ABSPATH ); 386 echo '</div>'; 387 return; 388 } 389 362 390 if ( $wp_filesystem->errors->get_error_code() ) { 363 391 foreach ( $wp_filesystem->errors->get_error_messages() as $message ) … … 478 506 echo '</p>'; 479 507 480 if ( current_user_can( 'update_core' ) )508 if ( $core = current_user_can( 'update_core' ) ) 481 509 core_upgrade_preamble(); 482 if ( current_user_can( 'update_plugins' ) )510 if ( $plugins = current_user_can( 'update_plugins' ) ) 483 511 list_plugin_updates(); 484 if ( current_user_can( 'update_themes' ) )512 if ( $themes = current_user_can( 'update_themes' ) ) 485 513 list_theme_updates(); 514 if ( $core || $plugins || $themes ) 515 list_translation_updates(); 516 unset( $core, $plugins, $themes ); 486 517 do_action('core_upgrade_preamble'); 487 518 echo '</div>'; … … 571 602 include(ABSPATH . 'wp-admin/admin-footer.php'); 572 603 604 } elseif ( 'do-translation-upgrade' == $action ) { 605 606 if ( ! current_user_can( 'update_core' ) && ! current_user_can( 'update_plugins' ) && ! current_user_can( 'update_themes' ) ) 607 wp_die( __( 'You do not have sufficient permissions to update this site.' ) ); 608 609 check_admin_referer( 'upgrade-translations' ); 610 611 require_once( ABSPATH . 'wp-admin/admin-header.php' ); 612 include_once( ABSPATH . 'wp-admin/includes/class-wp-upgrader.php' ); 613 614 $url = 'update-core.php?action=do-translation-upgrade'; 615 $nonce = 'upgrade-translations'; 616 $title = __( 'Update Translations' ); 617 $context = WP_LANG_DIR; 618 619 $upgrader = new Language_Pack_Upgrader( new Language_Pack_Upgrader_Skin( compact( 'url', 'nonce', 'title', 'context' ) ) ); 620 $result = $upgrader->bulk_upgrade(); 621 622 require_once( ABSPATH . 'wp-admin/admin-footer.php' ); 623 573 624 } else { 574 625 do_action('update-core-custom_' . $action);
Note: See TracChangeset
for help on using the changeset viewer.