<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" /><style type="text/css"><!--
#msg dl { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fc0 solid; padding: 6px; }
#msg ul, pre { overflow: auto; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<title>[13602] trunk/wp-admin: First scrape at new UI for Bulk plugin upgrades.</title>
</head>
<body>

<div id="msg">
<dl>
<dt>Revision</dt> <dd><a href="http://trac.wordpress.org/changeset/13602">13602</a></dd>
<dt>Author</dt> <dd>dd32</dd>
<dt>Date</dt> <dd>2010-03-06 08:39:50 +0000 (Sat, 06 Mar 2010)</dd>
</dl>

<h3>Log Message</h3>
<pre>First scrape at new UI for Bulk plugin upgrades. See <a href="http://trac.wordpress.org/ticket/11232">#11232</a></pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkwpadminincludesclasswpupgraderphp">trunk/wp-admin/includes/class-wp-upgrader.php</a></li>
<li><a href="#trunkwpadminincludesmiscphp">trunk/wp-admin/includes/misc.php</a></li>
<li><a href="#trunkwpadminpluginsphp">trunk/wp-admin/plugins.php</a></li>
<li><a href="#trunkwpadminupdatecorephp">trunk/wp-admin/update-core.php</a></li>
<li><a href="#trunkwpadminupdatephp">trunk/wp-admin/update.php</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkwpadminincludesclasswpupgraderphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-admin/includes/class-wp-upgrader.php (13601 => 13602)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-admin/includes/class-wp-upgrader.php        2010-03-06 08:02:26 UTC (rev 13601)
+++ trunk/wp-admin/includes/class-wp-upgrader.php        2010-03-06 08:39:50 UTC (rev 13602)
</span><span class="lines">@@ -297,6 +297,7 @@
</span><span class="cx">                 $download = $this-&gt;download_package( $package );
</span><span class="cx">                 if ( is_wp_error($download) ) {
</span><span class="cx">                         $this-&gt;skin-&gt;error($download);
</span><ins>+                        $this-&gt;skin-&gt;after();
</ins><span class="cx">                         return $download;
</span><span class="cx">                 }
</span><span class="cx"> 
</span><span class="lines">@@ -304,6 +305,7 @@
</span><span class="cx">                 $working_dir = $this-&gt;unpack_package( $download );
</span><span class="cx">                 if ( is_wp_error($working_dir) ) {
</span><span class="cx">                         $this-&gt;skin-&gt;error($working_dir);
</span><ins>+                        $this-&gt;skin-&gt;after();
</ins><span class="cx">                         return $working_dir;
</span><span class="cx">                 }
</span><span class="cx"> 
</span><span class="lines">@@ -409,6 +411,7 @@
</span><span class="cx"> 
</span><span class="cx">                 $current = get_site_transient( 'update_plugins' );
</span><span class="cx">                 if ( !isset( $current-&gt;response[ $plugin ] ) ) {
</span><ins>+                        $this-&gt;skin-&gt;before();
</ins><span class="cx">                         $this-&gt;skin-&gt;set_result(false);
</span><span class="cx">                         $this-&gt;skin-&gt;error('up_to_date');
</span><span class="cx">                         $this-&gt;skin-&gt;after();
</span><span class="lines">@@ -466,15 +469,15 @@
</span><span class="cx"> 
</span><span class="cx">                 $results = array();
</span><span class="cx"> 
</span><del>-                $all = count($plugins);
-                $i = 1;
</del><ins>+                $this-&gt;plugin_count = count($plugins);
+                $this-&gt;plugin_current = 0;
</ins><span class="cx">                 foreach ( $plugins as $plugin ) {
</span><ins>+                        $this-&gt;plugin_current++;
+                        $this-&gt;skin-&gt;plugin_info = get_plugin_data( WP_PLUGIN_DIR . '/' . $plugin, false, true);
</ins><span class="cx"> 
</span><del>-                        $this-&gt;show_before = sprintf( '&lt;h4&gt;' . __('Updating plugin %1$d of %2$d&amp;#8230;') . '&lt;/h4&gt;', $i, $all );
-                        $i++;
-
</del><span class="cx">                         if ( !isset( $current-&gt;response[ $plugin ] ) ) {
</span><span class="cx">                                 $this-&gt;skin-&gt;set_result(false);
</span><ins>+                                $this-&gt;skin-&gt;before();
</ins><span class="cx">                                 $this-&gt;skin-&gt;error('up_to_date');
</span><span class="cx">                                 $this-&gt;skin-&gt;after();
</span><span class="cx">                                 $results[$plugin] = false;
</span><span class="lines">@@ -502,7 +505,7 @@
</span><span class="cx">                         // Prevent credentials auth screen from displaying multiple times
</span><span class="cx">                         if ( false === $result )
</span><span class="cx">                                 break;
</span><del>-                }
</del><ins>+                } //end foreach $plugins
</ins><span class="cx">                 $this-&gt;maintenance_mode(false);
</span><span class="cx">                 $this-&gt;skin-&gt;footer();
</span><span class="cx"> 
</span><span class="lines">@@ -645,6 +648,7 @@
</span><span class="cx">                 // Is an update available?
</span><span class="cx">                 $current = get_site_transient( 'update_themes' );
</span><span class="cx">                 if ( !isset( $current-&gt;response[ $theme ] ) ) {
</span><ins>+                        $this-&gt;skin-&gt;before();
</ins><span class="cx">                         $this-&gt;skin-&gt;set_result(false);
</span><span class="cx">                         $this-&gt;skin-&gt;error('up_to_date');
</span><span class="cx">                         $this-&gt;skin-&gt;after();
</span><span class="lines">@@ -910,9 +914,6 @@
</span><span class="cx">         }
</span><span class="cx"> 
</span><span class="cx">         function after() {
</span><del>-                if ( $this-&gt;upgrader-&gt;bulk )
-                        return;
-
</del><span class="cx">                 $this-&gt;plugin = $this-&gt;upgrader-&gt;plugin_info();
</span><span class="cx">                 if ( !empty($this-&gt;plugin) &amp;&amp; !is_wp_error($this-&gt;result) &amp;&amp; $this-&gt;plugin_active ){
</span><span class="cx">                         show_message(__('Reactivating the plugin&amp;#8230;'));
</span><span class="lines">@@ -942,6 +943,103 @@
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> /**
</span><ins>+ * Plugin Upgrader Skin for WordPress Plugin Upgrades.
+ *
+ * @package WordPress
+ * @subpackage Upgrader
+ * @since 3.0
+ */
+class Bulk_Plugin_Upgrader_Skin extends WP_Upgrader_Skin {
+        var $in_loop = false;
+        var $error = false;
+
+        function Plugin_Upgrader_Skin($args = array()) {
+                return $this-&gt;__construct($args);
+        }
+
+        function __construct($args = array()) {
+                $defaults = array( 'url' =&gt; '', 'nonce' =&gt; '' );
+                $args = wp_parse_args($args, $defaults);
+
+                parent::__construct($args);
+        }
+        
+        function feedback($string) {
+                if ( isset( $this-&gt;upgrader-&gt;strings[$string] ) )
+                        $string = $this-&gt;upgrader-&gt;strings[$string];
+
+                if ( strpos($string, '%') !== false ) {
+                        $args = func_get_args();
+                        $args = array_splice($args, 1);
+                        if ( !empty($args) )
+                                $string = vsprintf($string, $args);
+                }
+                if ( empty($string) )
+                        return;
+                if ( $this-&gt;in_loop )
+                        echo &quot;$string&lt;br /&gt;\n&quot;;
+                else
+                        echo &quot;&lt;p&gt;$string&lt;/p&gt;\n&quot;;
+        }
+
+        function header() {
+                // Nothing, This will be displayed within a iframe.
+        }
+
+        function footer() {
+                // Nothing, This will be displayed within a iframe.
+        }
+        function error($error) {
+                if ( is_string($error) &amp;&amp; isset( $this-&gt;upgrader-&gt;strings[$error] ) )
+                        $this-&gt;error = $this-&gt;upgrader-&gt;strings[$error];
+                
+                if ( is_wp_error($error) &amp;&amp; $error-&gt;get_error_code() ) {
+                        foreach ( $error-&gt;get_error_messages() as $emessage ) {
+                                if ( $error-&gt;get_error_data() )
+                                        $messages[] = $emessage . ' ' . $error-&gt;get_error_data();
+                                else
+                                        $messages[] = $emessage;
+                        }
+                        $this-&gt;error = implode(', ', $messages);
+                }
+        }
+
+        function before() {
+                $this-&gt;in_loop = true;
+                printf( '&lt;h4&gt;' . __('Updating Plugin %1$s (%2$d/%3$d)') . '&lt;/h4&gt;',  $this-&gt;plugin_info['Title'], $this-&gt;upgrader-&gt;plugin_current, $this-&gt;upgrader-&gt;plugin_count);
+                echo '&lt;div class=&quot;update-messages&quot; style=&quot;display:none&quot; id=&quot;progress-' . esc_attr($this-&gt;upgrader-&gt;plugin_current) . '&quot;&gt;&lt;p&gt;';
+                $this-&gt;flush_output();
+        }
+
+        function after() {
+                echo '&lt;/p&gt;&lt;/div&gt;';
+                if ( $this-&gt;error || ! $this-&gt;result ) {
+                        if ( $this-&gt;error )
+                                echo '&lt;div class=&quot;error&quot;&gt;&lt;p&gt;' . sprintf(__('An error occured while updating %1$s: &lt;strong&gt;%2$s&lt;/strong&gt;.'), $this-&gt;plugin_info['Title'], $this-&gt;error) . '&lt;/p&gt;&lt;/div&gt;';
+                        else
+                                echo '&lt;div class=&quot;error&quot;&gt;&lt;p&gt;' . sprintf(__('The update of %1$s failed.'), $this-&gt;plugin_info['Title']) . '&lt;/p&gt;&lt;/div&gt;';
+                        echo '&lt;script type=&quot;text/javascript&quot;&gt;jQuery(\'#progress-' . esc_js($this-&gt;upgrader-&gt;plugin_current) . '\').show();&lt;/script&gt;';
+                }
+                if ( !empty($this-&gt;result) &amp;&amp; !is_wp_error($this-&gt;result) ) {
+                        echo '&lt;div class=&quot;updated&quot;&gt;&lt;p&gt;' . sprintf(__('%1$s updated successfully. &lt;a onclick=&quot;%2$s&quot; href=&quot;#&quot;&gt;See Details&lt;/a&gt;.'), $this-&gt;plugin_info['Title'], 'jQuery(\'#progress-' . esc_js($this-&gt;upgrader-&gt;plugin_current) . '\').toggle(); return false;') . '&lt;/p&gt;&lt;/div&gt;';
+                }
+                $this-&gt;reset();
+                $this-&gt;flush_output();
+        }
+
+        function reset() {
+                $this-&gt;in_loop = false;
+                $this-&gt;error = false;
+        }
+
+        function flush_output() {
+                wp_ob_end_flush_all();
+                flush();
+        }
+
+}
+
+/**
</ins><span class="cx">  * Plugin Installer Skin for WordPress Plugin Installer.
</span><span class="cx">  *
</span><span class="cx">  * @TODO More Detailed docs, for methods as well.
</span></span></pre></div>
<a id="trunkwpadminincludesmiscphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-admin/includes/misc.php (13601 => 13602)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-admin/includes/misc.php        2010-03-06 08:02:26 UTC (rev 13601)
+++ trunk/wp-admin/includes/misc.php        2010-03-06 08:39:50 UTC (rev 13602)
</span><span class="lines">@@ -271,6 +271,8 @@
</span><span class="cx">                         $message = $message-&gt;get_error_message();
</span><span class="cx">         }
</span><span class="cx">         echo &quot;&lt;p&gt;$message&lt;/p&gt;\n&quot;;
</span><ins>+        wp_ob_end_flush_all();
+        flush();
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> function wp_doc_link_parse( $content ) {
</span></span></pre></div>
<a id="trunkwpadminpluginsphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-admin/plugins.php (13601 => 13602)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-admin/plugins.php        2010-03-06 08:02:26 UTC (rev 13601)
+++ trunk/wp-admin/plugins.php        2010-03-06 08:39:50 UTC (rev 13602)
</span><span class="lines">@@ -96,44 +96,31 @@
</span><span class="cx">                         exit;
</span><span class="cx">                         break;
</span><span class="cx">                 case 'update-selected' :
</span><del>-                        if ( ! current_user_can( 'update_plugins' ) )
-                                wp_die( __( 'You do not have sufficient permissions to update plugins for this blog.' ) );
-
</del><ins>+                
</ins><span class="cx">                         check_admin_referer( 'bulk-manage-plugins' );
</span><del>-
</del><ins>+                        
</ins><span class="cx">                         if ( isset( $_GET['plugins'] ) )
</span><span class="cx">                                 $plugins = explode( ',', $_GET['plugins'] );
</span><span class="cx">                         elseif ( isset( $_POST['checked'] ) )
</span><span class="cx">                                 $plugins = (array) $_POST['checked'];
</span><span class="cx">                         else
</span><del>-                                break;
</del><ins>+                                $plugins = array();
+                        
+                        $title = __( 'Upgrade Plugins' );
+                        $parent_file = 'plugins.php';
</ins><span class="cx"> 
</span><del>-                        if ( empty( $plugins ) )
-                                break;
-
-                        // We'll be passing all checked plugins as long as at least one is out of date.
-                        $_plugins = $plugins;
-                        $current = get_site_transient( 'update_plugins' );
-                        foreach ( $_plugins as $k =&gt; $v ) {
-                                if ( ! isset( $current-&gt;response[ $v ] ) )
-                                        unset( $_plugins[ $k ] );
-                        }
-                        unset( $current );
-                        // If all checked plugins are up to date
-                        if ( empty( $_plugins ) )
-                                break;
-
-                        require_once( ABSPATH . 'wp-admin/includes/class-wp-upgrader.php' );
</del><span class="cx">                         require_once( 'admin-header.php' );
</span><ins>+                        
+                        echo '&lt;div class=&quot;wrap&quot;&gt;';
+                        screen_icon();
+                        echo '&lt;h2&gt;' . esc_html( $title ) . '&lt;/h2&gt;';
</ins><span class="cx"> 
</span><del>-                        $url = 'plugins.php?action=upgrade-selected&amp;amp;plugins=' . urlencode( join( ',', $plugins ) );
-                        $title = __( 'Upgrade Plugins' );
-                        $nonce = 'bulk-manage-plugins';
-                        $parent_file = 'plugins.php';
</del><span class="cx"> 
</span><del>-                        $upgrader = new Plugin_Upgrader( new Plugin_Upgrader_Skin( compact( 'title', 'nonce', 'url' ) ) );
-                        $upgrader-&gt;bulk_upgrade( $plugins );
</del><ins>+                        $url = 'update.php?action=update-selected&amp;amp;plugins=' . urlencode( join(',', $plugins) );
+                        $url = wp_nonce_url($url, 'bulk-update-plugins');
</ins><span class="cx"> 
</span><ins>+                        echo &quot;&lt;iframe src='$url' style='width: 100%; height:100%; min-height:850px;'&gt;&lt;/iframe&gt;&quot;;
+                        echo '&lt;/div&gt;';
</ins><span class="cx">                         require_once( 'admin-footer.php' );
</span><span class="cx">                         exit;
</span><span class="cx">                         break;
</span></span></pre></div>
<a id="trunkwpadminupdatecorephp"></a>
<div class="modfile"><h4>Modified: trunk/wp-admin/update-core.php (13601 => 13602)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-admin/update-core.php        2010-03-06 08:02:26 UTC (rev 13601)
+++ trunk/wp-admin/update-core.php        2010-03-06 08:39:50 UTC (rev 13602)
</span><span class="lines">@@ -351,24 +351,6 @@
</span><span class="cx">         return '';
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-function do_plugin_upgrade() {
-        if ( isset( $_GET['plugins'] ) ) {
-                $plugins = explode( ',', $_GET['plugins'] );
-        } elseif ( isset( $_POST['checked'] ) ) {
-                $plugins = (array) $_POST['checked'];
-        } else {
-                // Nothing to do.
-                return;
-        }
-
-        include_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
-        $url = 'update-core.php?action=do-plugin-upgrade&amp;amp;plugins=' . urlencode( implode( ',', $plugins ) );
-        $title = __( 'Upgrade Plugins' );
-        $nonce = 'upgrade-core';
-        $upgrader = new Plugin_Upgrader( new Plugin_Upgrader_Skin( compact( 'title', 'nonce', 'url' ) ) );
-        $upgrader-&gt;bulk_upgrade( $plugins );
-}
-
</del><span class="cx"> $action = isset($_GET['action']) ? $_GET['action'] : 'upgrade-core';
</span><span class="cx"> 
</span><span class="cx"> $upgrade_error = false;
</span><span class="lines">@@ -386,23 +368,46 @@
</span><span class="cx">         core_upgrade_preamble();
</span><span class="cx"> } elseif ( 'do-core-upgrade' == $action || 'do-core-reinstall' == $action ) {
</span><span class="cx">         check_admin_referer('upgrade-core');
</span><ins>+
</ins><span class="cx">         // do the (un)dismiss actions before headers,
</span><span class="cx">         // so that they can redirect
</span><span class="cx">         if ( isset( $_POST['dismiss'] ) )
</span><span class="cx">                 do_dismiss_core_update();
</span><span class="cx">         elseif ( isset( $_POST['undismiss'] ) )
</span><del>-        do_undismiss_core_update();
</del><ins>+                do_undismiss_core_update();
+
</ins><span class="cx">         require_once('admin-header.php');
</span><span class="cx">         if ( 'do-core-reinstall' == $action )
</span><span class="cx">                 $reinstall = true;
</span><span class="cx">         else
</span><span class="cx">                 $reinstall = false;
</span><ins>+
</ins><span class="cx">         if ( isset( $_POST['upgrade'] ) )
</span><span class="cx">                 do_core_upgrade($reinstall);
</span><ins>+
</ins><span class="cx"> } elseif ( 'do-plugin-upgrade' == $action ) {
</span><span class="cx">         check_admin_referer('upgrade-core');
</span><ins>+
+        if ( isset( $_GET['plugins'] ) ) {
+                $plugins = explode( ',', $_GET['plugins'] );
+        } elseif ( isset( $_POST['checked'] ) ) {
+                $plugins = (array) $_POST['checked'];
+        } else {
+                wp_redirect('plugins.php');
+                exit;
+        }
+
+        $url = 'update.php?action=update-selected&amp;plugins=' . urlencode(implode(',', $plugins));
+        $url = wp_nonce_url($url, 'bulk-update-plugins');
+
+        $title = __('Update Plugins');
+
</ins><span class="cx">         require_once('admin-header.php');
</span><del>-        do_plugin_upgrade();
</del><ins>+        echo '&lt;div class=&quot;wrap&quot;&gt;';
+        screen_icon('plugins');
+        echo '&lt;h2&gt;' . esc_html__('Update Plugins') . '&lt;/h2&gt;';
+        echo &quot;&lt;iframe src='$url' style='width: 100%; height:100%; min-height:850px;'&gt;&lt;/iframe&gt;&quot;;
+        echo '&lt;/div&gt;';
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> include('admin-footer.php');
</span></span></pre></div>
<a id="trunkwpadminupdatephp"></a>
<div class="modfile"><h4>Modified: trunk/wp-admin/update.php (13601 => 13602)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-admin/update.php        2010-03-06 08:02:26 UTC (rev 13601)
+++ trunk/wp-admin/update.php        2010-03-06 08:39:50 UTC (rev 13602)
</span><span class="lines">@@ -16,7 +16,35 @@
</span><span class="cx">         $theme = isset($_REQUEST['theme']) ? urldecode($_REQUEST['theme']) : '';
</span><span class="cx">         $action = isset($_REQUEST['action']) ? $_REQUEST['action'] : '';
</span><span class="cx"> 
</span><del>-        if ( 'upgrade-plugin' == $action ) {
</del><ins>+        if ( 'update-selected' == $action ) {
+                if ( ! current_user_can( 'update_plugins' ) )
+                        wp_die( __( 'You do not have sufficient permissions to update plugins for this blog.' ) );
+
+                check_admin_referer( 'bulk-update-plugins' );
+
+                if ( isset( $_GET['plugins'] ) )
+                        $plugins = explode( ',', stripslashes($_GET['plugins']) );
+                elseif ( isset( $_POST['checked'] ) )
+                        $plugins = (array) $_POST['checked'];
+                else
+                        $plugins = array();
+
+                $plugins = array_map('urldecode', $plugins);
+
+                $url = 'update.php?action=update-selected&amp;amp;plugins=' . urlencode(implode(',', $plugins));
+                $nonce = 'bulk-update-plugins';
+
+                require_once( ABSPATH . 'wp-admin/includes/class-wp-upgrader.php' );
+                wp_enqueue_script('jquery');
+                iframe_header();
+
+                $upgrader = new Plugin_Upgrader( new Bulk_Plugin_Upgrader_Skin( compact( 'nonce', 'url' ) ) );
+                $upgrader-&gt;bulk_upgrade( $plugins );
+
+                iframe_footer();
+                exit;
+                        
+        } elseif ( 'upgrade-plugin' == $action ) {
</ins><span class="cx">                 if ( ! current_user_can('update_plugins') )
</span><span class="cx">                         wp_die(__('You do not have sufficient permissions to update plugins for this blog.'));
</span><span class="cx"> 
</span></span></pre>
</div>
</div>

</body>
</html>