<!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>[16361] trunk/wp-admin/includes/class-wp-ms-themes-list-table.php:
  Rework WP_MS_Themes_List_Table column display.</title>
</head>
<body>

<div id="msg">
<dl>
<dt>Revision</dt> <dd><a href="http://trac.wordpress.org/changeset/16361">16361</a></dd>
<dt>Author</dt> <dd>scribu</dd>
<dt>Date</dt> <dd>2010-11-13 23:47:14 +0000 (Sat, 13 Nov 2010)</dd>
</dl>

<h3>Log Message</h3>
<pre>Rework WP_MS_Themes_List_Table column display. Props ocean90. See <a href="http://trac.wordpress.org/ticket/15318">#15318</a></pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkwpadminincludesclasswpmsthemeslisttablephp">trunk/wp-admin/includes/class-wp-ms-themes-list-table.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 (16360 => 16361)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-admin/includes/class-wp-ms-themes-list-table.php        2010-11-13 23:32:18 UTC (rev 16360)
+++ trunk/wp-admin/includes/class-wp-ms-themes-list-table.php        2010-11-13 23:47:14 UTC (rev 16361)
</span><span class="lines">@@ -250,79 +250,102 @@
</span><span class="cx">         }
</span><span class="cx"> 
</span><span class="cx">         function display_rows() {
</span><ins>+                foreach ( $this-&gt;items as $key =&gt; $theme )
+                        $this-&gt;single_row( $key, $theme );
+        }
+
+        function single_row( $key, $theme ) {
</ins><span class="cx">                 global $status, $page, $s;
</span><span class="cx"> 
</span><span class="cx">                 $context = $status;
</span><del>-                
</del><ins>+
</ins><span class="cx">                 if ( $this-&gt;is_site_themes )
</span><span class="cx">                         $url = &quot;site-themes.php?id={$this-&gt;site_id}&amp;amp;&quot;;
</span><span class="cx">                 else
</span><span class="cx">                         $url = 'themes.php?';
</span><span class="cx"> 
</span><del>-                foreach ( $this-&gt;items as $key =&gt; $theme ) {
-                        // preorder
-                        $actions = array(
-                                'enable' =&gt; '',
-                                'disable' =&gt; '',
-                                'edit' =&gt; ''
-                        );
-                        
-                        $theme_key = esc_html( $theme['Stylesheet'] );
</del><ins>+                // preorder
+                $actions = array(
+                        'enable' =&gt; '',
+                        'disable' =&gt; '',
+                        'edit' =&gt; ''
+                );
</ins><span class="cx"> 
</span><del>-                        if ( empty( $theme['enabled'] ) )
-                                        $actions['enable'] = '&lt;a href=&quot;' . 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;' . __('Enable this theme') . '&quot; class=&quot;edit&quot;&gt;' . __('Enable') . '&lt;/a&gt;';
-                        else
-                                        $actions['disable'] = '&lt;a href=&quot;' . wp_nonce_url($url . 'action=disable&amp;amp;theme=' . $theme_key . '&amp;amp;paged=' . $page . '&amp;amp;s=' . $s, 'disable-theme_' . $theme_key) . '&quot; title=&quot;' . __('Disable this theme') . '&quot;&gt;' . __('Disable') . '&lt;/a&gt;';
-                        
-                        if ( current_user_can('edit_themes') )
-                                $actions['edit'] = '&lt;a href=&quot;theme-editor.php?theme=' . $theme['Name'] . '&quot; title=&quot;' . __('Open this theme in the Theme Editor') . '&quot; class=&quot;edit&quot;&gt;' . __('Edit') . '&lt;/a&gt;';
</del><ins>+                $theme_key = esc_html( $theme['Stylesheet'] );
</ins><span class="cx"> 
</span><del>-                        $actions = apply_filters( 'theme_action_links', array_filter( $actions ), $theme_key, $theme, $context );
-                        $actions = apply_filters( &quot;theme_action_links_$theme_key&quot;, $actions, $theme_key, $theme, $context );
</del><ins>+                if ( empty( $theme['enabled'] ) )
+                        $actions['enable'] = '&lt;a href=&quot;' . 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;' . __('Enable this theme') . '&quot; class=&quot;edit&quot;&gt;' . __('Enable') . '&lt;/a&gt;';
+                else
+                        $actions['disable'] = '&lt;a href=&quot;' . wp_nonce_url($url . 'action=disable&amp;amp;theme=' . $theme_key . '&amp;amp;paged=' . $page . '&amp;amp;s=' . $s, 'disable-theme_' . $theme_key) . '&quot; title=&quot;' . __('Disable this theme') . '&quot;&gt;' . __('Disable') . '&lt;/a&gt;';
</ins><span class="cx"> 
</span><del>-                        $class = empty( $theme['enabled'] ) ? 'inactive' : 'active';
-                        $checkbox = &quot;&lt;input type='checkbox' name='checked[]' value='&quot; . esc_attr( $theme_key ) . &quot;' /&gt;&quot;;
</del><ins>+                if ( current_user_can('edit_themes') )
+                        $actions['edit'] = '&lt;a href=&quot;theme-editor.php?theme=' . $theme['Name'] . '&quot; title=&quot;' . __('Open this theme in the Theme Editor') . '&quot; class=&quot;edit&quot;&gt;' . __('Edit') . '&lt;/a&gt;';
</ins><span class="cx"> 
</span><del>-                        $description = '&lt;p&gt;' . $theme['Description'] . '&lt;/p&gt;';
-                        $theme_name = $theme['Name'];
</del><ins>+                $actions = apply_filters( 'theme_action_links', array_filter( $actions ), $theme_key, $theme, $context );
+                $actions = apply_filters( &quot;theme_action_links_$theme_key&quot;, $actions, $theme_key, $theme, $context );
</ins><span class="cx"> 
</span><ins>+                $class = empty( $theme['enabled'] ) ? 'inactive' : 'active';
+                $checkbox_id = md5($theme['Name']) . &quot;_checkbox&quot;;
+                $checkbox = &quot;&lt;input type='checkbox' name='checked[]' value='&quot; . esc_attr( $theme_key ) . &quot;' id='&quot; . $checkbox_id . &quot;' /&gt;&lt;label class='screen-reader-text' for='&quot; . $checkbox_id . &quot;' &gt;&quot; . __('Select') . &quot; &quot; . $theme['Name'] . &quot;&lt;/label&gt;&quot;;
</ins><span class="cx"> 
</span><del>-                        $id = sanitize_title( $theme_name );
</del><ins>+                $description = '&lt;p&gt;' . $theme['Description'] . '&lt;/p&gt;';
+                $theme_name = $theme['Name'];
</ins><span class="cx"> 
</span><del>-                        echo &quot;
-                &lt;tr id='$id' class='$class'&gt;
-                        &lt;th scope='row' class='check-column'&gt;$checkbox&lt;/th&gt;
-                        &lt;td class='theme-title'&gt;&lt;strong&gt;$theme_name&lt;/strong&gt;&lt;/td&gt;
-                        &lt;td class='desc'&gt;$description&lt;/td&gt;
-                &lt;/tr&gt;
-                &lt;tr class='$class second'&gt;
-                        &lt;td&gt;&lt;/td&gt;
-                        &lt;td class='theme-title'&gt;&quot;;
</del><ins>+                $id = sanitize_title( $theme_name );
</ins><span class="cx"> 
</span><del>-                        echo $this-&gt;row_actions( $actions, true );
</del><ins>+                echo &quot;&lt;tr id='$id' class='$class'&gt;&quot;;
</ins><span class="cx"> 
</span><del>-                        echo &quot;&lt;/td&gt;
-                        &lt;td class='desc'&gt;&quot;;
-                        $theme_meta = array();
-                        if ( !empty( $theme['Version'] ) )
-                                $theme_meta[] = sprintf( __( 'Version %s' ), $theme['Version'] );
-                        if ( !empty( $theme['Author'] ) ) {
-                                $author = $theme['Author'];
-                                if ( !empty( $theme['Author URI'] ) )
-                                        $author = '&lt;a href=&quot;' . $theme['Author URI'] . '&quot; title=&quot;' . __( 'Visit author homepage' ) . '&quot;&gt;' . $theme['Author'] . '&lt;/a&gt;';
-                                $theme_meta[] = sprintf( __( 'By %s' ), $author );
</del><ins>+                list( $columns, $hidden ) = $this-&gt;get_column_info();
+
+                foreach ( $columns as $column_name =&gt; $column_display_name ) {
+                        $style = '';
+                        if ( in_array( $column_name, $hidden ) )
+                                $style = ' style=&quot;display:none;&quot;';
+
+                        switch ( $column_name ) {
+                                case 'cb':
+                                        echo &quot;&lt;th scope='row' class='check-column'&gt;$checkbox&lt;/th&gt;&quot;;
+                                        break;
+                                case 'name':
+                                        echo &quot;&lt;td class='theme-title'$style&gt;&lt;strong&gt;$theme_name&lt;/strong&gt;&quot;;
+                                        echo $this-&gt;row_actions( $actions, true );
+                                        echo &quot;&lt;/td&gt;&quot;;
+                                        break;
+                                case 'description':
+                                        echo &quot;&lt;td class='column-description desc'$style&gt;
+                                                &lt;div class='theme-description'&gt;$description&lt;/div&gt;
+                                                &lt;div class='$class second theme-version-author-uri'&gt;&quot;;
+
+                                        $theme_meta = array();
+                                        if ( !empty( $theme['Version'] ) )
+                                                $theme_meta[] = sprintf( __( 'Version %s' ), $theme['Version'] );
+                                        if ( !empty( $theme['Author'] ) ) {
+                                                $author = $theme['Author'];
+                                                if ( !empty( $theme['Author URI'] ) )
+                                                        $author = '&lt;a href=&quot;' . $theme['Author URI'] . '&quot; title=&quot;' . __( 'Visit author homepage' ) . '&quot;&gt;' . $theme['Author'] . '&lt;/a&gt;';
+                                                $theme_meta[] = sprintf( __( 'By %s' ), $author );
+                                        }
+                                        if ( !empty( $theme['Theme URI'] ) )
+                                                $theme_meta[] = '&lt;a href=&quot;' . $theme['Theme URI'] . '&quot; title=&quot;' . __( 'Visit theme homepage' ) . '&quot;&gt;' . __( 'Visit Theme Site' ) . '&lt;/a&gt;';
+
+                                        $theme_meta = apply_filters( 'theme_row_meta', $theme_meta, $theme_key, $theme, $status );
+                                        echo implode( ' | ', $theme_meta );
+
+                                        echo &quot;&lt;/div&gt;&lt;/td&gt;&quot;;
+                                        break;        
+                                        break;
+                                default:
+                                        echo &quot;&lt;td class='$column_name column-$column_name'$style&gt;&quot;;
+                                        do_action( 'manage_themes_custom_column', $column_name, $theme_key, $theme );
+                                        echo &quot;&lt;/td&gt;&quot;;
</ins><span class="cx">                         }
</span><del>-                        if ( !empty( $theme['Theme URI'] ) )
-                                $theme_meta[] = '&lt;a href=&quot;' . $theme['Theme URI'] . '&quot; title=&quot;' . __( 'Visit theme homepage' ) . '&quot;&gt;' . __( 'Visit Theme Site' ) . '&lt;/a&gt;';
</del><ins>+                }
</ins><span class="cx"> 
</span><del>-                        $theme_meta = apply_filters( 'theme_row_meta', $theme_meta, $theme_key, $theme, $status );
-                        echo implode( ' | ', $theme_meta );
-                        echo &quot;&lt;/td&gt;
-                &lt;/tr&gt;\n&quot;;
</del><ins>+                echo &quot;&lt;/tr&gt;&quot;;
</ins><span class="cx"> 
</span><del>-                        do_action( 'after_theme_row', $theme_key, $theme, $status );
-                        do_action( &quot;after_theme_row_$theme_key&quot;, $theme_key, $theme, $status );
-                }
</del><ins>+                do_action( 'after_theme_row', $theme_key, $theme, $status );
+                do_action( &quot;after_theme_row_$theme_key&quot;, $theme_key, $theme, $status );
</ins><span class="cx">         }
</span><span class="cx"> }
</span><ins>+
</ins><span class="cx"> ?&gt;
</span></span></pre>
</div>
</div>

</body>
</html>