<!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->items as $key => $theme )
+                        $this->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->is_site_themes )
</span><span class="cx">                         $url = "site-themes.php?id={$this->site_id}&amp;";
</span><span class="cx">                 else
</span><span class="cx">                         $url = 'themes.php?';
</span><span class="cx">
</span><del>-                foreach ( $this->items as $key => $theme ) {
-                        // preorder
-                        $actions = array(
-                                'enable' => '',
-                                'disable' => '',
-                                'edit' => ''
-                        );
-                        
-                        $theme_key = esc_html( $theme['Stylesheet'] );
</del><ins>+                // preorder
+                $actions = array(
+                        'enable' => '',
+                        'disable' => '',
+                        'edit' => ''
+                );
</ins><span class="cx">
</span><del>-                        if ( empty( $theme['enabled'] ) )
-                                        $actions['enable'] = '<a href="' . wp_nonce_url($url . 'action=enable&amp;theme=' . $theme_key . '&amp;paged=' . $page . '&amp;s=' . $s, 'enable-theme_' . $theme_key) . '" title="' . __('Enable this theme') . '" class="edit">' . __('Enable') . '</a>';
-                        else
-                                        $actions['disable'] = '<a href="' . wp_nonce_url($url . 'action=disable&amp;theme=' . $theme_key . '&amp;paged=' . $page . '&amp;s=' . $s, 'disable-theme_' . $theme_key) . '" title="' . __('Disable this theme') . '">' . __('Disable') . '</a>';
-                        
-                        if ( current_user_can('edit_themes') )
-                                $actions['edit'] = '<a href="theme-editor.php?theme=' . $theme['Name'] . '" title="' . __('Open this theme in the Theme Editor') . '" class="edit">' . __('Edit') . '</a>';
</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( "theme_action_links_$theme_key", $actions, $theme_key, $theme, $context );
</del><ins>+                if ( empty( $theme['enabled'] ) )
+                        $actions['enable'] = '<a href="' . wp_nonce_url($url . 'action=enable&amp;theme=' . $theme_key . '&amp;paged=' . $page . '&amp;s=' . $s, 'enable-theme_' . $theme_key) . '" title="' . __('Enable this theme') . '" class="edit">' . __('Enable') . '</a>';
+                else
+                        $actions['disable'] = '<a href="' . wp_nonce_url($url . 'action=disable&amp;theme=' . $theme_key . '&amp;paged=' . $page . '&amp;s=' . $s, 'disable-theme_' . $theme_key) . '" title="' . __('Disable this theme') . '">' . __('Disable') . '</a>';
</ins><span class="cx">
</span><del>-                        $class = empty( $theme['enabled'] ) ? 'inactive' : 'active';
-                        $checkbox = "<input type='checkbox' name='checked[]' value='" . esc_attr( $theme_key ) . "' />";
</del><ins>+                if ( current_user_can('edit_themes') )
+                        $actions['edit'] = '<a href="theme-editor.php?theme=' . $theme['Name'] . '" title="' . __('Open this theme in the Theme Editor') . '" class="edit">' . __('Edit') . '</a>';
</ins><span class="cx">
</span><del>-                        $description = '<p>' . $theme['Description'] . '</p>';
-                        $theme_name = $theme['Name'];
</del><ins>+                $actions = apply_filters( 'theme_action_links', array_filter( $actions ), $theme_key, $theme, $context );
+                $actions = apply_filters( "theme_action_links_$theme_key", $actions, $theme_key, $theme, $context );
</ins><span class="cx">
</span><ins>+                $class = empty( $theme['enabled'] ) ? 'inactive' : 'active';
+                $checkbox_id = md5($theme['Name']) . "_checkbox";
+                $checkbox = "<input type='checkbox' name='checked[]' value='" . esc_attr( $theme_key ) . "' id='" . $checkbox_id . "' /><label class='screen-reader-text' for='" . $checkbox_id . "' >" . __('Select') . " " . $theme['Name'] . "</label>";
</ins><span class="cx">
</span><del>-                        $id = sanitize_title( $theme_name );
</del><ins>+                $description = '<p>' . $theme['Description'] . '</p>';
+                $theme_name = $theme['Name'];
</ins><span class="cx">
</span><del>-                        echo "
-                <tr id='$id' class='$class'>
-                        <th scope='row' class='check-column'>$checkbox</th>
-                        <td class='theme-title'><strong>$theme_name</strong></td>
-                        <td class='desc'>$description</td>
-                </tr>
-                <tr class='$class second'>
-                        <td></td>
-                        <td class='theme-title'>";
</del><ins>+                $id = sanitize_title( $theme_name );
</ins><span class="cx">
</span><del>-                        echo $this->row_actions( $actions, true );
</del><ins>+                echo "<tr id='$id' class='$class'>";
</ins><span class="cx">
</span><del>-                        echo "</td>
-                        <td class='desc'>";
-                        $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 = '<a href="' . $theme['Author URI'] . '" title="' . __( 'Visit author homepage' ) . '">' . $theme['Author'] . '</a>';
-                                $theme_meta[] = sprintf( __( 'By %s' ), $author );
</del><ins>+                list( $columns, $hidden ) = $this->get_column_info();
+
+                foreach ( $columns as $column_name => $column_display_name ) {
+                        $style = '';
+                        if ( in_array( $column_name, $hidden ) )
+                                $style = ' style="display:none;"';
+
+                        switch ( $column_name ) {
+                                case 'cb':
+                                        echo "<th scope='row' class='check-column'>$checkbox</th>";
+                                        break;
+                                case 'name':
+                                        echo "<td class='theme-title'$style><strong>$theme_name</strong>";
+                                        echo $this->row_actions( $actions, true );
+                                        echo "</td>";
+                                        break;
+                                case 'description':
+                                        echo "<td class='column-description desc'$style>
+                                                <div class='theme-description'>$description</div>
+                                                <div class='$class second theme-version-author-uri'>";
+
+                                        $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 = '<a href="' . $theme['Author URI'] . '" title="' . __( 'Visit author homepage' ) . '">' . $theme['Author'] . '</a>';
+                                                $theme_meta[] = sprintf( __( 'By %s' ), $author );
+                                        }
+                                        if ( !empty( $theme['Theme URI'] ) )
+                                                $theme_meta[] = '<a href="' . $theme['Theme URI'] . '" title="' . __( 'Visit theme homepage' ) . '">' . __( 'Visit Theme Site' ) . '</a>';
+
+                                        $theme_meta = apply_filters( 'theme_row_meta', $theme_meta, $theme_key, $theme, $status );
+                                        echo implode( ' | ', $theme_meta );
+
+                                        echo "</div></td>";
+                                        break;        
+                                        break;
+                                default:
+                                        echo "<td class='$column_name column-$column_name'$style>";
+                                        do_action( 'manage_themes_custom_column', $column_name, $theme_key, $theme );
+                                        echo "</td>";
</ins><span class="cx">                         }
</span><del>-                        if ( !empty( $theme['Theme URI'] ) )
-                                $theme_meta[] = '<a href="' . $theme['Theme URI'] . '" title="' . __( 'Visit theme homepage' ) . '">' . __( 'Visit Theme Site' ) . '</a>';
</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 "</td>
-                </tr>\n";
</del><ins>+                echo "</tr>";
</ins><span class="cx">
</span><del>-                        do_action( 'after_theme_row', $theme_key, $theme, $status );
-                        do_action( "after_theme_row_$theme_key", $theme_key, $theme, $status );
-                }
</del><ins>+                do_action( 'after_theme_row', $theme_key, $theme, $status );
+                do_action( "after_theme_row_$theme_key", $theme_key, $theme, $status );
</ins><span class="cx">         }
</span><span class="cx"> }
</span><ins>+
</ins><span class="cx"> ?>
</span></span></pre>
</div>
</div>
</body>
</html>