Changeset 13602 for trunk/wp-admin/includes/class-wp-upgrader.php
- Timestamp:
- 03/06/2010 08:39:50 AM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-admin/includes/class-wp-upgrader.php
r13089 r13602 298 298 if ( is_wp_error($download) ) { 299 299 $this->skin->error($download); 300 $this->skin->after(); 300 301 return $download; 301 302 } … … 305 306 if ( is_wp_error($working_dir) ) { 306 307 $this->skin->error($working_dir); 308 $this->skin->after(); 307 309 return $working_dir; 308 310 } … … 410 412 $current = get_site_transient( 'update_plugins' ); 411 413 if ( !isset( $current->response[ $plugin ] ) ) { 414 $this->skin->before(); 412 415 $this->skin->set_result(false); 413 416 $this->skin->error('up_to_date'); … … 467 470 $results = array(); 468 471 469 $ all= count($plugins);470 $ i = 1;472 $this->plugin_count = count($plugins); 473 $this->plugin_current = 0; 471 474 foreach ( $plugins as $plugin ) { 472 473 $this->show_before = sprintf( '<h4>' . __('Updating plugin %1$d of %2$d…') . '</h4>', $i, $all ); 474 $i++; 475 $this->plugin_current++; 476 $this->skin->plugin_info = get_plugin_data( WP_PLUGIN_DIR . '/' . $plugin, false, true); 475 477 476 478 if ( !isset( $current->response[ $plugin ] ) ) { 477 479 $this->skin->set_result(false); 480 $this->skin->before(); 478 481 $this->skin->error('up_to_date'); 479 482 $this->skin->after(); … … 503 506 if ( false === $result ) 504 507 break; 505 } 508 } //end foreach $plugins 506 509 $this->maintenance_mode(false); 507 510 $this->skin->footer(); … … 646 649 $current = get_site_transient( 'update_themes' ); 647 650 if ( !isset( $current->response[ $theme ] ) ) { 651 $this->skin->before(); 648 652 $this->skin->set_result(false); 649 653 $this->skin->error('up_to_date'); … … 911 915 912 916 function after() { 913 if ( $this->upgrader->bulk )914 return;915 916 917 $this->plugin = $this->upgrader->plugin_info(); 917 918 if ( !empty($this->plugin) && !is_wp_error($this->result) && $this->plugin_active ){ … … 943 944 944 945 /** 946 * Plugin Upgrader Skin for WordPress Plugin Upgrades. 947 * 948 * @package WordPress 949 * @subpackage Upgrader 950 * @since 3.0 951 */ 952 class Bulk_Plugin_Upgrader_Skin extends WP_Upgrader_Skin { 953 var $in_loop = false; 954 var $error = false; 955 956 function Plugin_Upgrader_Skin($args = array()) { 957 return $this->__construct($args); 958 } 959 960 function __construct($args = array()) { 961 $defaults = array( 'url' => '', 'nonce' => '' ); 962 $args = wp_parse_args($args, $defaults); 963 964 parent::__construct($args); 965 } 966 967 function feedback($string) { 968 if ( isset( $this->upgrader->strings[$string] ) ) 969 $string = $this->upgrader->strings[$string]; 970 971 if ( strpos($string, '%') !== false ) { 972 $args = func_get_args(); 973 $args = array_splice($args, 1); 974 if ( !empty($args) ) 975 $string = vsprintf($string, $args); 976 } 977 if ( empty($string) ) 978 return; 979 if ( $this->in_loop ) 980 echo "$string<br />\n"; 981 else 982 echo "<p>$string</p>\n"; 983 } 984 985 function header() { 986 // Nothing, This will be displayed within a iframe. 987 } 988 989 function footer() { 990 // Nothing, This will be displayed within a iframe. 991 } 992 function error($error) { 993 if ( is_string($error) && isset( $this->upgrader->strings[$error] ) ) 994 $this->error = $this->upgrader->strings[$error]; 995 996 if ( is_wp_error($error) && $error->get_error_code() ) { 997 foreach ( $error->get_error_messages() as $emessage ) { 998 if ( $error->get_error_data() ) 999 $messages[] = $emessage . ' ' . $error->get_error_data(); 1000 else 1001 $messages[] = $emessage; 1002 } 1003 $this->error = implode(', ', $messages); 1004 } 1005 } 1006 1007 function before() { 1008 $this->in_loop = true; 1009 printf( '<h4>' . __('Updating Plugin %1$s (%2$d/%3$d)') . '</h4>', $this->plugin_info['Title'], $this->upgrader->plugin_current, $this->upgrader->plugin_count); 1010 echo '<div class="update-messages" style="display:none" id="progress-' . esc_attr($this->upgrader->plugin_current) . '"><p>'; 1011 $this->flush_output(); 1012 } 1013 1014 function after() { 1015 echo '</p></div>'; 1016 if ( $this->error || ! $this->result ) { 1017 if ( $this->error ) 1018 echo '<div class="error"><p>' . sprintf(__('An error occured while updating %1$s: <strong>%2$s</strong>.'), $this->plugin_info['Title'], $this->error) . '</p></div>'; 1019 else 1020 echo '<div class="error"><p>' . sprintf(__('The update of %1$s failed.'), $this->plugin_info['Title']) . '</p></div>'; 1021 echo '<script type="text/javascript">jQuery(\'#progress-' . esc_js($this->upgrader->plugin_current) . '\').show();</script>'; 1022 } 1023 if ( !empty($this->result) && !is_wp_error($this->result) ) { 1024 echo '<div class="updated"><p>' . sprintf(__('%1$s updated successfully. <a onclick="%2$s" href="#">See Details</a>.'), $this->plugin_info['Title'], 'jQuery(\'#progress-' . esc_js($this->upgrader->plugin_current) . '\').toggle(); return false;') . '</p></div>'; 1025 } 1026 $this->reset(); 1027 $this->flush_output(); 1028 } 1029 1030 function reset() { 1031 $this->in_loop = false; 1032 $this->error = false; 1033 } 1034 1035 function flush_output() { 1036 wp_ob_end_flush_all(); 1037 flush(); 1038 } 1039 1040 } 1041 1042 /** 945 1043 * Plugin Installer Skin for WordPress Plugin Installer. 946 1044 *
Note: See TracChangeset
for help on using the changeset viewer.