Changeset 13686
- Timestamp:
- 03/13/2010 03:59:40 AM (15 years ago)
- Location:
- trunk/wp-admin
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-admin/includes/class-wp-upgrader.php
r13602 r13686 470 470 $results = array(); 471 471 472 $this-> plugin_count = count($plugins);473 $this-> plugin_current = 0;472 $this->update_count = count($plugins); 473 $this->update_current = 0; 474 474 foreach ( $plugins as $plugin ) { 475 $this-> plugin_current++;475 $this->update_current++; 476 476 $this->skin->plugin_info = get_plugin_data( WP_PLUGIN_DIR . '/' . $plugin, false, true); 477 477 … … 683 683 } 684 684 685 function bulk_upgrade($themes) { 686 687 $this->init(); 688 $this->bulk = true; 689 $this->upgrade_strings(); 690 691 $current = get_site_transient( 'update_themes' ); 692 693 add_filter('upgrader_pre_install', array(&$this, 'current_before'), 10, 2); 694 add_filter('upgrader_post_install', array(&$this, 'current_after'), 10, 2); 695 add_filter('upgrader_clear_destination', array(&$this, 'delete_old_theme'), 10, 4); 696 697 $this->skin->header(); 698 699 // Connect to the Filesystem first. 700 $res = $this->fs_connect( array(WP_CONTENT_DIR) ); 701 if ( ! $res ) { 702 $this->skin->footer(); 703 return false; 704 } 705 706 $this->maintenance_mode(true); 707 708 $results = array(); 709 710 $this->update_count = count($themes); 711 $this->update_current = 0; 712 foreach ( $themes as $theme ) { 713 $this->update_current++; 714 715 if ( !isset( $current->response[ $theme ] ) ) { 716 $this->skin->set_result(false); 717 $this->skin->before(); 718 $this->skin->error('up_to_date'); 719 $this->skin->after(); 720 $results[$theme] = false; 721 continue; 722 } 723 724 $this->skin->theme_info = $this->theme_info($theme); 725 726 // Get the URL to the zip file 727 $r = $current->response[ $theme ]; 728 729 $options = array( 730 'package' => $r['package'], 731 'destination' => WP_CONTENT_DIR . '/themes', 732 'clear_destination' => true, 733 'clear_working' => true, 734 'hook_extra' => array( 735 'theme' => $theme 736 ) 737 ); 738 739 $result = $this->run($options); 740 741 $results[$theme] = $this->result; 742 743 // Prevent credentials auth screen from displaying multiple times 744 if ( false === $result ) 745 break; 746 } //end foreach $plugins 747 $this->maintenance_mode(false); 748 $this->skin->footer(); 749 750 // Cleanup our hooks, incase something else does a upgrade on this connection. 751 remove_filter('upgrader_pre_install', array(&$this, 'current_before'), 10, 2); 752 remove_filter('upgrader_post_install', array(&$this, 'current_after'), 10, 2); 753 remove_filter('upgrader_clear_destination', array(&$this, 'delete_old_theme'), 10, 4); 754 755 // Force refresh of theme update information 756 delete_site_transient('update_themes'); 757 758 return $results; 759 } 760 685 761 function current_before($return, $theme) { 686 762 … … 693 769 return $return; 694 770 //Change to maintainence mode now. 695 $this->maintenance_mode(true); 771 if ( ! $this->bulk ) 772 $this->maintenance_mode(true); 696 773 697 774 return $return; … … 715 792 716 793 //Time to remove maintainence mode 717 $this->maintenance_mode(false); 794 if ( ! $this->bulk ) 795 $this->maintenance_mode(false); 718 796 return $return; 719 797 } … … 734 812 } 735 813 736 function theme_info() { 737 if ( empty($this->result['destination_name']) ) 738 return false; 739 return get_theme_data(WP_CONTENT_DIR . '/themes/' . $this->result['destination_name'] . '/style.css'); 814 function theme_info($theme = null) { 815 816 if ( empty($theme) ) { 817 if ( !empty($this->result['destination_name']) ) 818 $theme = $this->result['destination_name']; 819 else 820 return false; 821 } 822 return get_theme_data(WP_CONTENT_DIR . '/themes/' . $theme . '/style.css'); 740 823 } 741 824 … … 827 910 if ( is_object($upgrader) ) 828 911 $this->upgrader =& $upgrader; 829 } 912 $this->add_strings(); 913 } 914 915 function add_strings() { 916 } 917 830 918 function set_result($result) { 831 919 $this->result = $result; … … 950 1038 * @since 3.0 951 1039 */ 952 class Bulk_ Plugin_Upgrader_Skin extends WP_Upgrader_Skin {1040 class Bulk_Upgrader_Skin extends WP_Upgrader_Skin { 953 1041 var $in_loop = false; 954 1042 var $error = false; 955 1043 956 function Plugin_Upgrader_Skin($args = array()) {1044 function Bulk_Upgrader_Skin($args = array()) { 957 1045 return $this->__construct($args); 958 1046 } … … 964 1052 parent::__construct($args); 965 1053 } 966 1054 1055 function add_strings() { 1056 $this->upgrader->strings['skin_update_failed_error'] = __('An error occured while updating %1$s: <strong>%2$s</strong>.'); 1057 $this->upgrader->strings['skin_update_failed'] = __('The update of %1$s failed.'); 1058 $this->upgrader->strings['skin_update_successful'] = __('%1$s updated successfully. <a onclick="%2$s" href="#">See Details</a>.'); 1059 } 1060 967 1061 function feedback($string) { 968 1062 if ( isset( $this->upgrader->strings[$string] ) ) … … 1005 1099 } 1006 1100 1007 function before( ) {1101 function before($title = '') { 1008 1102 $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>';1103 printf( '<h4>' . $this->upgrader->strings['skin_before_update_header'] . '</h4>', $title, $this->upgrader->update_current, $this->upgrader->update_count); 1104 echo '<div class="update-messages" style="display:none" id="progress-' . esc_attr($this->upgrader->update_current) . '"><p>'; 1011 1105 $this->flush_output(); 1012 1106 } 1013 1107 1014 function after( ) {1108 function after($title = '') { 1015 1109 echo '</p></div>'; 1016 1110 if ( $this->error || ! $this->result ) { 1017 1111 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>';1112 echo '<div class="error"><p>' . sprintf($this->upgrader->strings['skin_update_failed'], $title, $this->error) . '</p></div>'; 1019 1113 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>'; 1114 echo '<div class="error"><p>' . sprintf($this->upgrader->strings['skin_update_failed'], $title) . '</p></div>'; 1115 1116 echo '<script type="text/javascript">jQuery(\'#progress-' . esc_js($this->upgrader->update_current) . '\').show();</script>'; 1022 1117 } 1023 1118 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>';1119 echo '<div class="updated"><p>' . sprintf($this->upgrader->strings['skin_update_successful'], $title, 'jQuery(\'#progress-' . esc_js($this->upgrader->update_current) . '\').toggle(); return false;') . '</p></div>'; 1025 1120 } 1026 1121 $this->reset(); … … 1037 1132 flush(); 1038 1133 } 1039 1134 } 1135 1136 class Bulk_Plugin_Upgrader_Skin extends Bulk_Upgrader_Skin { 1137 var $plugin_info = array(); // Plugin_Upgrader::bulk() will fill this in. 1138 function Plugin_Upgrader_Skin($args = array()) { 1139 parent::__construct($args); 1140 } 1141 1142 function add_strings() { 1143 parent::add_strings(); 1144 $this->upgrader->strings['skin_before_update_header'] = __('Updating Plugin %1$s (%2$d/%3$d)'); 1145 } 1146 1147 function before() { 1148 parent::before($this->plugin_info['Title']); 1149 } 1150 1151 function after() { 1152 parent::after($this->plugin_info['Title']); 1153 } 1154 } 1155 1156 class Bulk_Theme_Upgrader_Skin extends Bulk_Upgrader_Skin { 1157 var $theme_info = array(); // Theme_Upgrader::bulk() will fill this in. 1158 function Theme_Upgrader_Skin($args = array()) { 1159 parent::__construct($args); 1160 } 1161 1162 function add_strings() { 1163 parent::add_strings(); 1164 $this->upgrader->strings['skin_before_update_header'] = __('Updating Theme %1$s (%2$d/%3$d)'); 1165 } 1166 1167 function before() { 1168 parent::before($this->theme_info['Name']); 1169 } 1170 1171 function after() { 1172 parent::after($this->theme_info['Name']); 1173 } 1040 1174 } 1041 1175 -
trunk/wp-admin/update-core.php
r13604 r13686 442 442 screen_icon('themes'); 443 443 echo '<h2>' . esc_html__('Update Themes') . '</h2>'; 444 echo "<p>@TODO: Sorry, This part of the functionality hasnt been written yet.</p>";445 444 echo "<iframe src='$url' style='width: 100%; height:100%; min-height:850px;'></iframe>"; 446 445 echo '</div>'; -
trunk/wp-admin/update.php
r13602 r13686 43 43 44 44 iframe_footer(); 45 exit;46 45 47 46 } elseif ( 'upgrade-plugin' == $action ) { … … 164 163 165 164 include('admin-footer.php'); 166 165 } elseif ( 'update-selected-themes' == $action ) { 166 if ( ! current_user_can( 'update_themes' ) ) 167 wp_die( __( 'You do not have sufficient permissions to update themes for this blog.' ) ); 168 169 check_admin_referer( 'bulk-update-themes' ); 170 171 if ( isset( $_GET['themes'] ) ) 172 $themes = explode( ',', stripslashes($_GET['themes']) ); 173 elseif ( isset( $_POST['checked'] ) ) 174 $themes = (array) $_POST['checked']; 175 else 176 $themes = array(); 177 178 $themes = array_map('urldecode', $themes); 179 180 $url = 'update.php?action=update-selected-themes&themess=' . urlencode(implode(',', $themes)); 181 $nonce = 'bulk-update-themes'; 182 183 require_once( ABSPATH . 'wp-admin/includes/class-wp-upgrader.php' ); 184 wp_enqueue_script('jquery'); 185 iframe_header(); 186 187 $upgrader = new Theme_Upgrader( new Bulk_Theme_Upgrader_Skin( compact( 'nonce', 'url' ) ) ); 188 $upgrader->bulk_upgrade( $themes ); 189 190 iframe_footer(); 167 191 } elseif ( 'install-theme' == $action ) { 168 192
Note: See TracChangeset
for help on using the changeset viewer.