<!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>[17130] trunk/wp-admin: MS themes fixes.</title>
</head>
<body>

<div id="msg">
<dl>
<dt>Revision</dt> <dd><a href="http://trac.wordpress.org/changeset/17130">17130</a></dd>
<dt>Author</dt> <dd>ryan</dd>
<dt>Date</dt> <dd>2010-12-24 17:41:36 +0000 (Fri, 24 Dec 2010)</dd>
</dl>

<h3>Log Message</h3>
<pre>MS themes fixes.  Fix bulk actions when no items selected. Props SergeyBiryukov, nacin. fixes <a href="http://trac.wordpress.org/ticket/15920">#15920</a></pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkwpadminincludesclasswpmsthemeslisttablephp">trunk/wp-admin/includes/class-wp-ms-themes-list-table.php</a></li>
<li><a href="#trunkwpadminnetworkthemesphp">trunk/wp-admin/network/themes.php</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkwpadminincludesclasswpmsthemeslisttablephp"></a>
<div class="modfile"><h4>Modified: trunk/wp-admin/includes/class-wp-ms-themes-list-table.php (17129 => 17130)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-admin/includes/class-wp-ms-themes-list-table.php        2010-12-24 14:19:41 UTC (rev 17129)
+++ trunk/wp-admin/includes/class-wp-ms-themes-list-table.php        2010-12-24 17:41:36 UTC (rev 17130)
</span><span class="lines">@@ -78,7 +78,7 @@
</span><span class="cx">                 $current = get_site_transient( 'update_themes' );
</span><span class="cx"> 
</span><span class="cx">                 foreach ( (array) $themes['all'] as $key =&gt; $theme ) {
</span><del>-                        $theme_key = esc_html( $theme['Stylesheet'] );
</del><ins>+                        $theme_key = $theme['Stylesheet'];
</ins><span class="cx"> 
</span><span class="cx">                         if ( isset( $allowed_themes [ $theme_key ] ) )  {
</span><span class="cx">                                 $themes['all'][$key]['enabled'] = true;
</span><span class="lines">@@ -276,7 +276,7 @@
</span><span class="cx">                         'delete' =&gt; ''
</span><span class="cx">                 );
</span><span class="cx"> 
</span><del>-                $theme_key = esc_html( $theme['Stylesheet'] );
</del><ins>+                $theme_key = $theme['Stylesheet'];
</ins><span class="cx"> 
</span><span class="cx">                 if ( empty( $theme['enabled'] ) )
</span><span class="cx">                         $actions['enable'] = '&lt;a href=&quot;' . esc_url( wp_nonce_url($url . 'action=enable&amp;amp;theme=' . $theme_key . '&amp;amp;paged=' . $page . '&amp;amp;s=' . $s, 'enable-theme_' . $theme_key) ) . '&quot; title=&quot;' . esc_attr__('Enable this theme') . '&quot; class=&quot;edit&quot;&gt;' . ( $this-&gt;is_site_themes ? __( 'Enable' ) : __( 'Network Enable' ) ) . '&lt;/a&gt;';
</span><span class="lines">@@ -285,8 +285,8 @@
</span><span class="cx"> 
</span><span class="cx">                 if ( current_user_can('edit_themes') )
</span><span class="cx">                         $actions['edit'] = '&lt;a href=&quot;' . esc_url('theme-editor.php?theme=' . $theme['Name'] ) . '&quot; title=&quot;' . esc_attr__('Open this theme in the Theme Editor') . '&quot; class=&quot;edit&quot;&gt;' . __('Edit') . '&lt;/a&gt;';
</span><del>-                        
-                if ( empty( $theme['enabled'] ) &amp;&amp; current_user_can( 'delete_themes' ) &amp;&amp; ! $this-&gt;is_site_themes )
</del><ins>+
+                if ( empty( $theme['enabled'] ) &amp;&amp; current_user_can( 'delete_themes' ) &amp;&amp; ! $this-&gt;is_site_themes &amp;&amp; $theme_key != get_option( 'stylesheet' ) &amp;&amp; $theme_key != get_option( 'template' ) )
</ins><span class="cx">                         $actions['delete'] = '&lt;a href=&quot;' . esc_url( wp_nonce_url( 'themes.php?action=delete-selected&amp;amp;checked[]=' . $theme_key . '&amp;amp;theme_status=' . $context . '&amp;amp;paged=' . $page . '&amp;amp;s=' . $s, 'bulk-themes' ) ) . '&quot; title=&quot;' . esc_attr__( 'Delete this theme' ) . '&quot; class=&quot;delete&quot;&gt;' . __( 'Delete' ) . '&lt;/a&gt;';
</span><span class="cx"> 
</span><span class="cx">                 $actions = apply_filters( 'theme_action_links', array_filter( $actions ), $theme_key, $theme, $context );
</span></span></pre></div>
<a id="trunkwpadminnetworkthemesphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-admin/network/themes.php (17129 => 17130)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-admin/network/themes.php        2010-12-24 14:19:41 UTC (rev 17129)
+++ trunk/wp-admin/network/themes.php        2010-12-24 17:41:36 UTC (rev 17130)
</span><span class="lines">@@ -28,7 +28,9 @@
</span><span class="cx"> $s = isset($_REQUEST['s']) ? $_REQUEST['s'] : '';
</span><span class="cx"> 
</span><span class="cx"> // Clean up request URI from temporary args for screen options/paging uri's to work as expected.
</span><del>-$_SERVER['REQUEST_URI'] = remove_query_arg(array('enable', 'disable', 'enable-selected', 'disable-selected'), $_SERVER['REQUEST_URI']);
</del><ins>+$temp_args = array( 'enabled', 'disabled', 'deleted', 'error', 'enabled', 'disabled', 'deleted', 'error' );
+$_SERVER['REQUEST_URI'] = remove_query_arg( $temp_args, $_SERVER['REQUEST_URI'] );
+$referer = remove_query_arg( $temp_args, wp_get_referer() );
</ins><span class="cx"> 
</span><span class="cx"> if ( $action ) {
</span><span class="cx">         $allowed_themes = get_site_option( 'allowedthemes' );        
</span><span class="lines">@@ -37,37 +39,41 @@
</span><span class="cx">                         check_admin_referer('enable-theme_' . $_GET['theme']);
</span><span class="cx">                         $allowed_themes[ $_GET['theme'] ] = true;
</span><span class="cx">                         update_site_option( 'allowedthemes', $allowed_themes );
</span><del>-                        wp_redirect( wp_get_referer() ); // @todo add_query_arg for update message
-                        exit;                        
</del><ins>+                        wp_redirect( add_query_arg( 'enabled', '1', $referer ) );
+                        exit;
</ins><span class="cx">                         break;
</span><span class="cx">                 case 'disable':
</span><span class="cx">                         check_admin_referer('disable-theme_' . $_GET['theme']);
</span><span class="cx">                         unset( $allowed_themes[ $_GET['theme'] ] );
</span><span class="cx">                         update_site_option( 'allowedthemes', $allowed_themes );
</span><del>-                        wp_redirect( wp_get_referer() ); // @todo add_query_arg for update message
</del><ins>+                        wp_redirect( add_query_arg( 'disabled', '1', $referer ) );
</ins><span class="cx">                         exit;
</span><span class="cx">                         break;
</span><span class="cx">                 case 'enable-selected':
</span><span class="cx">                         check_admin_referer('bulk-themes');
</span><span class="cx">                         $themes = isset( $_POST['checked'] ) ? (array) $_POST['checked'] : array();
</span><span class="cx">                         if ( empty($themes) ) {
</span><del>-                                wp_redirect( wp_get_referer() );
</del><ins>+                                wp_redirect( add_query_arg( 'error', 'none', $referer ) );
</ins><span class="cx">                                 exit;
</span><del>-                        }                                                
</del><ins>+                        }
</ins><span class="cx">                         foreach( (array) $themes as $theme )
</span><span class="cx">                                 $allowed_themes[ $theme ] = true;
</span><span class="cx">                         update_site_option( 'allowedthemes', $allowed_themes );
</span><ins>+                        wp_redirect( add_query_arg( 'enabled', count( $themes ), $referer ) );
+                        exit;
</ins><span class="cx">                         break;
</span><span class="cx">                 case 'disable-selected':
</span><span class="cx">                         check_admin_referer('bulk-themes');
</span><span class="cx">                         $themes = isset( $_POST['checked'] ) ? (array) $_POST['checked'] : array();
</span><span class="cx">                         if ( empty($themes) ) {
</span><del>-                                wp_redirect( wp_get_referer() );
</del><ins>+                                wp_redirect( add_query_arg( 'error', 'none', $referer ) );
</ins><span class="cx">                                 exit;
</span><del>-                        }                                                
</del><ins>+                        }
</ins><span class="cx">                         foreach( (array) $themes as $theme )
</span><span class="cx">                                 unset( $allowed_themes[ $theme ] );
</span><span class="cx">                         update_site_option( 'allowedthemes', $allowed_themes );
</span><ins>+                        wp_redirect( add_query_arg( 'disabled', count( $themes ), $referer ) );
+                        exit;
</ins><span class="cx">                         break;
</span><span class="cx">                 case 'delete-selected':
</span><span class="cx">                         if ( ! current_user_can( 'delete_themes' ) )
</span><span class="lines">@@ -75,8 +81,14 @@
</span><span class="cx">                         check_admin_referer( 'bulk-themes' );
</span><span class="cx"> 
</span><span class="cx">                         $themes = isset( $_REQUEST['checked'] ) ? (array) $_REQUEST['checked'] : array();
</span><ins>+
+                        if ( isset( $themes[ get_option( 'template' ) ] ) )
+                                unset( $themes[ get_option( 'template' ) ] );
+                        if ( isset( $themes[ get_option( 'stylesheet' ) ] ) )
+                                unset( $themes[ get_option( 'stylesheet' ) ] );
+
</ins><span class="cx">                         if ( empty( $themes ) ) {
</span><del>-                                wp_redirect( wp_get_referer() );
</del><ins>+                                wp_redirect( add_query_arg( 'error', 'none', $referer ) );
</ins><span class="cx">                                 exit;
</span><span class="cx">                         }
</span><span class="cx"> 
</span><span class="lines">@@ -93,7 +105,7 @@
</span><span class="cx">                         }
</span><span class="cx">                         
</span><span class="cx">                         if ( empty( $themes ) ) {
</span><del>-                                wp_redirect( add_query_arg( 'error', 'main', wp_get_referer() ) );
</del><ins>+                                wp_redirect( add_query_arg( 'error', 'main', $referer ) );
</ins><span class="cx">                                 exit;
</span><span class="cx">                         }
</span><span class="cx"> 
</span><span class="lines">@@ -149,7 +161,7 @@
</span><span class="cx"> 
</span><span class="cx">                         foreach ( $themes as $theme )
</span><span class="cx">                                 $delete_result = delete_theme( $theme );
</span><del>-                        wp_redirect( network_admin_url( 'themes.php?deleted=true' ) );
</del><ins>+                        wp_redirect( add_query_arg( 'deleted', count( $themes ), $referer ) );
</ins><span class="cx">                         exit;
</span><span class="cx">                         break;
</span><span class="cx">         }
</span><span class="lines">@@ -174,11 +186,6 @@
</span><span class="cx"> 
</span><span class="cx"> require_once(ABSPATH . 'wp-admin/admin-header.php');
</span><span class="cx"> 
</span><del>-if ( isset( $_GET['deleted'] ) ) : ?&gt;
-&lt;div class=&quot;updated&quot;&gt;&lt;p&gt;&lt;?php _e('Theme deleted.') ?&gt;&lt;/p&gt;&lt;/div&gt;&lt;?php
-elseif ( isset( $_GET['error'] ) &amp;&amp; 'main' == $_GET['error'] ) : ?&gt;
-&lt;div class=&quot;error&quot;&gt;&lt;p&gt;&lt;?php _e( 'You cannot delete a theme while it is active on the main site.' ); ?&gt;&lt;/p&gt;&lt;/div&gt;&lt;?php
-endif;
</del><span class="cx"> ?&gt;
</span><span class="cx"> 
</span><span class="cx"> &lt;div class=&quot;wrap&quot;&gt;
</span><span class="lines">@@ -188,6 +195,24 @@
</span><span class="cx">         printf( '&lt;span class=&quot;subtitle&quot;&gt;' . __('Search results for &amp;#8220;%s&amp;#8221;') . '&lt;/span&gt;', esc_html( $s ) ); ?&gt; 
</span><span class="cx"> &lt;/h2&gt;
</span><span class="cx"> 
</span><ins>+&lt;?php
+if ( isset( $_GET['enabled'] ) ) {
+        $_GET['enabled'] = absint( $_GET['enabled'] );
+        echo '&lt;div id=&quot;message&quot; class=&quot;updated&quot;&gt;&lt;p&gt;' . sprintf( _n( 'Theme enabled.', '%s themes enabled.', $_GET['enabled'] ), number_format_i18n( $_GET['enabled'] ) ) . '&lt;/p&gt;&lt;/div&gt;';
+} elseif ( isset( $_GET['disabled'] ) ) {
+        $_GET['disabled'] = absint( $_GET['disabled'] );
+        echo '&lt;div id=&quot;message&quot; class=&quot;updated&quot;&gt;&lt;p&gt;' . sprintf( _n( 'Theme disabled.', '%s themes disabled.', $_GET['disabled'] ), number_format_i18n( $_GET['disabled'] ) ) . '&lt;/p&gt;&lt;/div&gt;';
+} elseif ( isset( $_GET['deleted'] ) ) {
+        $_GET['disabled'] = absint( $_GET['deleted'] );
+        echo '&lt;div id=&quot;message&quot; class=&quot;updated&quot;&gt;&lt;p&gt;' . sprintf( _n( 'Theme deleted.', '%s themes deleted.', $_GET['deleted'] ), number_format_i18n( $_GET['deleted'] ) ) . '&lt;/p&gt;&lt;/div&gt;';
+} elseif ( isset( $_GET['error'] ) &amp;&amp; 'none' == $_GET['error'] ) {
+        echo '&lt;div id=&quot;message&quot; class=&quot;error&quot;&gt;&lt;p&gt;' . __( 'No theme selected.' ) . '&lt;/p&gt;&lt;/div&gt;';
+} elseif ( isset( $_GET['error'] ) &amp;&amp; 'main' == $_GET['error'] ) {
+        echo '&lt;div class=&quot;error&quot;&gt;&lt;p&gt;' . __( 'You cannot delete a theme while it is active on the main site.' ) . '&lt;/p&gt;&lt;/div&gt;';
+}
+
+?&gt;
+
</ins><span class="cx"> &lt;form method=&quot;get&quot; action=&quot;&quot;&gt;
</span><span class="cx"> &lt;?php $wp_list_table-&gt;search_box( __( 'Search Installed Themes' ), 'theme' ); ?&gt;
</span><span class="cx"> &lt;/form&gt;
</span></span></pre>
</div>
</div>

</body>
</html>