<!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>[17137] trunk/wp-admin/network/site-themes.php:
  Improved messaging for theme enabled/disabled on a per-site bases.</title>
</head>
<body>

<div id="msg">
<dl>
<dt>Revision</dt> <dd><a href="http://trac.wordpress.org/changeset/17137">17137</a></dd>
<dt>Author</dt> <dd>westi</dd>
<dt>Date</dt> <dd>2010-12-25 08:19:29 +0000 (Sat, 25 Dec 2010)</dd>
</dl>

<h3>Log Message</h3>
<pre>Improved messaging for theme enabled/disabled on a per-site bases. Fixes <a href="http://trac.wordpress.org/ticket/15920">#15920</a> props PeteMall</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkwpadminnetworksitethemesphp">trunk/wp-admin/network/site-themes.php</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkwpadminnetworksitethemesphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-admin/network/site-themes.php (17136 => 17137)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-admin/network/site-themes.php        2010-12-24 22:37:51 UTC (rev 17136)
+++ trunk/wp-admin/network/site-themes.php        2010-12-25 08:19:29 UTC (rev 17137)
</span><span class="lines">@@ -39,7 +39,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"> $id = isset( $_REQUEST['id'] ) ? intval( $_REQUEST['id'] ) : 0;
</span><span class="cx"> 
</span><span class="lines">@@ -62,7 +64,8 @@
</span><span class="cx">                 case 'enable':
</span><span class="cx">                         check_admin_referer( 'enable-theme_' . $_GET['theme'] );
</span><span class="cx">                         $theme = $_GET['theme'];
</span><del>-                        $update = 'enabled';
</del><ins>+                        $action = 'enabled';
+                        $n = 1;
</ins><span class="cx">                         if ( !$allowed_themes )
</span><span class="cx">                                 $allowed_themes = array( $theme =&gt; true );
</span><span class="cx">                         else
</span><span class="lines">@@ -71,7 +74,8 @@
</span><span class="cx">                 case 'disable':
</span><span class="cx">                         check_admin_referer( 'disable-theme_' . $_GET['theme'] );
</span><span class="cx">                         $theme = $_GET['theme'];
</span><del>-                        $update = 'disabled';
</del><ins>+                        $action = 'disabled';
+                        $n = 1;                        
</ins><span class="cx">                         if ( !$allowed_themes )
</span><span class="cx">                                 $allowed_themes = array();
</span><span class="cx">                         else
</span><span class="lines">@@ -80,23 +84,27 @@
</span><span class="cx">                 case 'enable-selected':
</span><span class="cx">                         check_admin_referer( 'bulk-themes' );
</span><span class="cx">                         if ( isset( $_POST['checked'] ) ) {
</span><del>-                                $update = 'enable';
</del><span class="cx">                                 $themes = (array) $_POST['checked'];
</span><ins>+                                $action = 'enabled';
+                                $n = count( $themes );
</ins><span class="cx">                                 foreach( (array) $themes as $theme )
</span><span class="cx">                                         $allowed_themes[ $theme ] = true;
</span><span class="cx">                         } else {
</span><del>-                                $update = 'error';
</del><ins>+                                $action = 'error';
+                                $n = 'none';
</ins><span class="cx">                         }
</span><span class="cx">                         break;
</span><span class="cx">                 case 'disable-selected':
</span><span class="cx">                         check_admin_referer( 'bulk-themes' );
</span><span class="cx">                         if ( isset( $_POST['checked'] ) ) {
</span><del>-                                $update = 'disable';
</del><span class="cx">                                 $themes = (array) $_POST['checked'];
</span><ins>+                                $action = 'disabled';
+                                $n = count( $themes );
</ins><span class="cx">                                 foreach( (array) $themes as $theme )
</span><span class="cx">                                         unset( $allowed_themes[ $theme ] );
</span><span class="cx">                         } else {
</span><del>-                                $update = 'error';
</del><ins>+                                $action = 'error';
+                                $n = 'none';
</ins><span class="cx">                         }
</span><span class="cx">                         break;
</span><span class="cx">         }
</span><span class="lines">@@ -104,12 +112,12 @@
</span><span class="cx">         update_option( 'allowedthemes', $allowed_themes );
</span><span class="cx">         restore_current_blog();
</span><span class="cx">         
</span><del>-        wp_redirect( add_query_arg( 'update', $update, wp_get_referer() ) );
</del><ins>+        wp_redirect( add_query_arg( $action, $n, $referer ) );
</ins><span class="cx">         exit;        
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> if ( isset( $_GET['action'] ) &amp;&amp; 'update-site' == $_GET['action'] ) {
</span><del>-        wp_redirect( wp_get_referer() );
</del><ins>+        wp_redirect( $referer );
</ins><span class="cx">         exit();
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -140,18 +148,14 @@
</span><span class="cx"> ?&gt;
</span><span class="cx"> &lt;/h3&gt;&lt;?php
</span><span class="cx"> 
</span><del>-if ( isset( $_GET['update'] ) ) {
-        switch ( $_GET['update'] ) {
-        case 'enabled':
-                echo '&lt;div id=&quot;message&quot; class=&quot;updated&quot;&gt;&lt;p&gt;' . __( 'Theme enabled.' ) . '&lt;/p&gt;&lt;/div&gt;';
-                break;
-        case 'disabled':
-                echo '&lt;div id=&quot;message&quot; class=&quot;updated&quot;&gt;&lt;p&gt;' . __( 'Theme disabled.' ) . '&lt;/p&gt;&lt;/div&gt;';
-                break;
-        case '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;';
-                break;
-        }
</del><ins>+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['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;'; 
</ins><span class="cx"> } ?&gt;
</span><span class="cx"> 
</span><span class="cx"> &lt;p&gt;&lt;?php _e( 'Network enabled themes are not shown on this screen.' ) ?&gt;&lt;/p&gt;
</span></span></pre>
</div>
</div>

</body>
</html>