Changeset 13602
- Timestamp:
- 03/06/2010 08:39:50 AM (15 years ago)
- Location:
- trunk/wp-admin
- Files:
-
- 5 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 * -
trunk/wp-admin/includes/misc.php
r13487 r13602 272 272 } 273 273 echo "<p>$message</p>\n"; 274 wp_ob_end_flush_all(); 275 flush(); 274 276 } 275 277 -
trunk/wp-admin/plugins.php
r13499 r13602 97 97 break; 98 98 case 'update-selected' : 99 if ( ! current_user_can( 'update_plugins' ) ) 100 wp_die( __( 'You do not have sufficient permissions to update plugins for this blog.' ) ); 101 99 102 100 check_admin_referer( 'bulk-manage-plugins' ); 103 101 104 102 if ( isset( $_GET['plugins'] ) ) 105 103 $plugins = explode( ',', $_GET['plugins'] ); … … 107 105 $plugins = (array) $_POST['checked']; 108 106 else 109 break; 110 111 if ( empty( $plugins ) ) 112 break; 113 114 // We'll be passing all checked plugins as long as at least one is out of date. 115 $_plugins = $plugins; 116 $current = get_site_transient( 'update_plugins' ); 117 foreach ( $_plugins as $k => $v ) { 118 if ( ! isset( $current->response[ $v ] ) ) 119 unset( $_plugins[ $k ] ); 120 } 121 unset( $current ); 122 // If all checked plugins are up to date 123 if ( empty( $_plugins ) ) 124 break; 125 126 require_once( ABSPATH . 'wp-admin/includes/class-wp-upgrader.php' ); 107 $plugins = array(); 108 109 $title = __( 'Upgrade Plugins' ); 110 $parent_file = 'plugins.php'; 111 127 112 require_once( 'admin-header.php' ); 128 129 $url = 'plugins.php?action=upgrade-selected&plugins=' . urlencode( join( ',', $plugins ) ); 130 $title = __( 'Upgrade Plugins' ); 131 $nonce = 'bulk-manage-plugins'; 132 $parent_file = 'plugins.php'; 133 134 $upgrader = new Plugin_Upgrader( new Plugin_Upgrader_Skin( compact( 'title', 'nonce', 'url' ) ) ); 135 $upgrader->bulk_upgrade( $plugins ); 136 113 114 echo '<div class="wrap">'; 115 screen_icon(); 116 echo '<h2>' . esc_html( $title ) . '</h2>'; 117 118 119 $url = 'update.php?action=update-selected&plugins=' . urlencode( join(',', $plugins) ); 120 $url = wp_nonce_url($url, 'bulk-update-plugins'); 121 122 echo "<iframe src='$url' style='width: 100%; height:100%; min-height:850px;'></iframe>"; 123 echo '</div>'; 137 124 require_once( 'admin-footer.php' ); 138 125 exit; -
trunk/wp-admin/update-core.php
r13590 r13602 352 352 } 353 353 354 function do_plugin_upgrade() {355 if ( isset( $_GET['plugins'] ) ) {356 $plugins = explode( ',', $_GET['plugins'] );357 } elseif ( isset( $_POST['checked'] ) ) {358 $plugins = (array) $_POST['checked'];359 } else {360 // Nothing to do.361 return;362 }363 364 include_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';365 $url = 'update-core.php?action=do-plugin-upgrade&plugins=' . urlencode( implode( ',', $plugins ) );366 $title = __( 'Upgrade Plugins' );367 $nonce = 'upgrade-core';368 $upgrader = new Plugin_Upgrader( new Plugin_Upgrader_Skin( compact( 'title', 'nonce', 'url' ) ) );369 $upgrader->bulk_upgrade( $plugins );370 }371 372 354 $action = isset($_GET['action']) ? $_GET['action'] : 'upgrade-core'; 373 355 … … 387 369 } elseif ( 'do-core-upgrade' == $action || 'do-core-reinstall' == $action ) { 388 370 check_admin_referer('upgrade-core'); 371 389 372 // do the (un)dismiss actions before headers, 390 373 // so that they can redirect … … 392 375 do_dismiss_core_update(); 393 376 elseif ( isset( $_POST['undismiss'] ) ) 394 do_undismiss_core_update(); 377 do_undismiss_core_update(); 378 395 379 require_once('admin-header.php'); 396 380 if ( 'do-core-reinstall' == $action ) … … 398 382 else 399 383 $reinstall = false; 384 400 385 if ( isset( $_POST['upgrade'] ) ) 401 386 do_core_upgrade($reinstall); 387 402 388 } elseif ( 'do-plugin-upgrade' == $action ) { 403 389 check_admin_referer('upgrade-core'); 390 391 if ( isset( $_GET['plugins'] ) ) { 392 $plugins = explode( ',', $_GET['plugins'] ); 393 } elseif ( isset( $_POST['checked'] ) ) { 394 $plugins = (array) $_POST['checked']; 395 } else { 396 wp_redirect('plugins.php'); 397 exit; 398 } 399 400 $url = 'update.php?action=update-selected&plugins=' . urlencode(implode(',', $plugins)); 401 $url = wp_nonce_url($url, 'bulk-update-plugins'); 402 403 $title = __('Update Plugins'); 404 404 405 require_once('admin-header.php'); 405 do_plugin_upgrade(); 406 echo '<div class="wrap">'; 407 screen_icon('plugins'); 408 echo '<h2>' . esc_html__('Update Plugins') . '</h2>'; 409 echo "<iframe src='$url' style='width: 100%; height:100%; min-height:850px;'></iframe>"; 410 echo '</div>'; 406 411 } 407 412 -
trunk/wp-admin/update.php
r13499 r13602 17 17 $action = isset($_REQUEST['action']) ? $_REQUEST['action'] : ''; 18 18 19 if ( 'upgrade-plugin' == $action ) { 19 if ( 'update-selected' == $action ) { 20 if ( ! current_user_can( 'update_plugins' ) ) 21 wp_die( __( 'You do not have sufficient permissions to update plugins for this blog.' ) ); 22 23 check_admin_referer( 'bulk-update-plugins' ); 24 25 if ( isset( $_GET['plugins'] ) ) 26 $plugins = explode( ',', stripslashes($_GET['plugins']) ); 27 elseif ( isset( $_POST['checked'] ) ) 28 $plugins = (array) $_POST['checked']; 29 else 30 $plugins = array(); 31 32 $plugins = array_map('urldecode', $plugins); 33 34 $url = 'update.php?action=update-selected&plugins=' . urlencode(implode(',', $plugins)); 35 $nonce = 'bulk-update-plugins'; 36 37 require_once( ABSPATH . 'wp-admin/includes/class-wp-upgrader.php' ); 38 wp_enqueue_script('jquery'); 39 iframe_header(); 40 41 $upgrader = new Plugin_Upgrader( new Bulk_Plugin_Upgrader_Skin( compact( 'nonce', 'url' ) ) ); 42 $upgrader->bulk_upgrade( $plugins ); 43 44 iframe_footer(); 45 exit; 46 47 } elseif ( 'upgrade-plugin' == $action ) { 20 48 if ( ! current_user_can('update_plugins') ) 21 49 wp_die(__('You do not have sufficient permissions to update plugins for this blog.'));
Note: See TracChangeset
for help on using the changeset viewer.