<!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>[15653] trunk/wp-admin/includes: Column headers revamp:</title>
</head>
<body>

<div id="msg">
<dl>
<dt>Revision</dt> <dd><a href="http://trac.wordpress.org/changeset/15653">15653</a></dd>
<dt>Author</dt> <dd>scribu</dd>
<dt>Date</dt> <dd>2010-09-24 13:35:06 +0000 (Fri, 24 Sep 2010)</dd>
</dl>

<h3>Log Message</h3>
<pre>Column headers revamp:
        * undeprecate get_column_headers()
        * undeprecate get_hidden_columns()
        * in WP_List_Table, rename get_column_headers() to get_column_info()
        * remove $taxonomy argument from single_row()
        * merge manage_columns_prefs() into screen_meta()
Fixes <a href="http://trac.wordpress.org/ticket/14952">#14952</a>. Fixes <a href="http://trac.wordpress.org/ticket/14776">#14776</a>.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkwpadminincludesdefaultlisttablesphp">trunk/wp-admin/includes/default-list-tables.php</a></li>
<li><a href="#trunkwpadminincludesdeprecatedphp">trunk/wp-admin/includes/deprecated.php</a></li>
<li><a href="#trunkwpadminincludeslisttablephp">trunk/wp-admin/includes/list-table.php</a></li>
<li><a href="#trunkwpadminincludestemplatephp">trunk/wp-admin/includes/template.php</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkwpadminincludesdefaultlisttablesphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-admin/includes/default-list-tables.php (15652 => 15653)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-admin/includes/default-list-tables.php        2010-09-24 12:09:44 UTC (rev 15652)
+++ trunk/wp-admin/includes/default-list-tables.php        2010-09-24 13:35:06 UTC (rev 15653)
</span><span class="lines">@@ -454,7 +454,7 @@
</span><span class="cx">                 &lt;tr id='post-&lt;?php echo $post-&gt;ID; ?&gt;' class='&lt;?php echo trim( $rowclass . ' author-' . $post_owner . ' status-' . $post-&gt;post_status ); ?&gt; iedit' valign=&quot;top&quot;&gt;
</span><span class="cx">         &lt;?php
</span><span class="cx"> 
</span><del>-                list( $columns, $hidden ) = $this-&gt;get_column_headers();
</del><ins>+                list( $columns, $hidden ) = $this-&gt;get_column_info();
</ins><span class="cx"> 
</span><span class="cx">                 foreach ( $columns as $column_name =&gt; $column_display_name ) {
</span><span class="cx">                         $class = &quot;class=\&quot;$column_name column-$column_name\&quot;&quot;;
</span><span class="lines">@@ -676,7 +676,7 @@
</span><span class="cx">                                 $flat_taxonomies[] = $taxonomy;
</span><span class="cx">                 }
</span><span class="cx"> 
</span><del>-                list( $columns, $hidden ) = $this-&gt;get_column_headers();
</del><ins>+                list( $columns, $hidden ) = $this-&gt;get_column_info();
</ins><span class="cx"> 
</span><span class="cx">                 $col_count = count( $columns ) - count( $hidden );
</span><span class="cx">                 $m = ( isset( $mode ) &amp;&amp; 'excerpt' == $mode ) ? 'excerpt' : 'list';
</span><span class="lines">@@ -1162,7 +1162,7 @@
</span><span class="cx">         &lt;tr id='post-&lt;?php echo $id; ?&gt;' class='&lt;?php echo trim( $alt . ' author-' . $post_owner . ' status-' . $post-&gt;post_status ); ?&gt;' valign=&quot;top&quot;&gt;
</span><span class="cx"> &lt;?php
</span><span class="cx"> 
</span><del>-list( $columns, $hidden ) = $this-&gt;get_column_headers();
</del><ins>+list( $columns, $hidden ) = $this-&gt;get_column_info();
</ins><span class="cx"> foreach ( $columns as $column_name =&gt; $column_display_name ) {
</span><span class="cx">         $class = &quot;class='$column_name column-$column_name'&quot;;
</span><span class="cx"> 
</span><span class="lines">@@ -1727,7 +1727,7 @@
</span><span class="cx">                 if ( ! current_user_can( $tax-&gt;cap-&gt;edit_terms ) )
</span><span class="cx">                         return;
</span><span class="cx"> 
</span><del>-                list( $columns, $hidden ) = $this-&gt;get_column_headers();
</del><ins>+                list( $columns, $hidden ) = $this-&gt;get_column_info();
</ins><span class="cx"> 
</span><span class="cx">                 $col_count = count( $columns ) - count( $hidden );
</span><span class="cx">                 ?&gt;
</span><span class="lines">@@ -1996,7 +1996,7 @@
</span><span class="cx">                 $r = &quot;&lt;tr id='user-$user_object-&gt;ID'$style&gt;&quot;;
</span><span class="cx">                 $avatar = get_avatar( $user_object-&gt;ID, 32 );
</span><span class="cx"> 
</span><del>-                list( $columns, $hidden ) = $this-&gt;get_column_headers();
</del><ins>+                list( $columns, $hidden ) = $this-&gt;get_column_info();
</ins><span class="cx"> 
</span><span class="cx">                 foreach ( $columns as $column_name =&gt; $column_display_name ) {
</span><span class="cx">                         $class = &quot;class=\&quot;$column_name column-$column_name\&quot;&quot;;
</span><span class="lines">@@ -2648,7 +2648,7 @@
</span><span class="cx">                 &lt;tr id=&quot;link-&lt;?php echo $link-&gt;link_id; ?&gt;&quot; valign=&quot;middle&quot; &lt;?php echo $style; ?&gt;&gt;
</span><span class="cx"> &lt;?php
</span><span class="cx"> 
</span><del>-                        list( $columns, $hidden ) = $this-&gt;get_column_headers();
</del><ins>+                        list( $columns, $hidden ) = $this-&gt;get_column_info();
</ins><span class="cx"> 
</span><span class="cx">                         foreach ( $columns as $column_name =&gt; $column_display_name ) {
</span><span class="cx">                                 $class = &quot;class='column-$column_name'&quot;;
</span><span class="lines">@@ -2869,7 +2869,7 @@
</span><span class="cx"> 
</span><span class="cx">                         $blogname = ( is_subdomain_install() ) ? str_replace( '.'.$current_site-&gt;domain, '', $blog['domain'] ) : $blog['path'];
</span><span class="cx"> 
</span><del>-                        list( $columns, $hidden ) = $this-&gt;get_column_headers();
</del><ins>+                        list( $columns, $hidden ) = $this-&gt;get_column_info();
</ins><span class="cx"> 
</span><span class="cx">                         foreach ( $columns as $column_name =&gt; $column_display_name ) {
</span><span class="cx">                                 switch ( $column_name ) {
</span><span class="lines">@@ -3117,7 +3117,7 @@
</span><span class="cx">                         &lt;tr class=&quot;&lt;?php echo $class; ?&gt;&quot;&gt;
</span><span class="cx">                         &lt;?php
</span><span class="cx"> 
</span><del>-                        list( $columns, $hidden ) = $this-&gt;get_column_headers();
</del><ins>+                        list( $columns, $hidden ) = $this-&gt;get_column_info();
</ins><span class="cx"> 
</span><span class="cx">                         foreach ( $columns as $column_name =&gt; $column_display_name ) :
</span><span class="cx">                                 switch ( $column_name ) {
</span></span></pre></div>
<a id="trunkwpadminincludesdeprecatedphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-admin/includes/deprecated.php (15652 => 15653)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-admin/includes/deprecated.php        2010-09-24 12:09:44 UTC (rev 15652)
+++ trunk/wp-admin/includes/deprecated.php        2010-09-24 13:35:06 UTC (rev 15653)
</span><span class="lines">@@ -370,28 +370,6 @@
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> /**
</span><del>- * Get the column headers for a screen
- *
- * @since 2.7.0
- * @deprecated 3.1.0
- * @deprecated Use WP_List_Table
- *
- * @param string|object $screen The screen you want the headers for
- * @return array Containing the headers in the format id =&gt; UI String
- */
-function get_column_headers($screen) {
-        _deprecated_function( __FUNCTION__, '3.1', 'WP_List_Table' );
-
-        global $wp_list_table;
-        if ( !is_a($wp_list_table, 'WP_List_Table') )
-                $wp_list_table = new _WP_List_Table_Compat($screen);
-
-        list( $columns ) = $wp_list_table-&gt;get_column_headers();
-
-        return $columns;
-}
-
-/**
</del><span class="cx">  * Prints column headers for a particular screen.
</span><span class="cx">  *
</span><span class="cx">  * @since 2.7.0
</span><span class="lines">@@ -408,26 +386,6 @@
</span><span class="cx">         $wp_list_table-&gt;print_column_headers($id);
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-/**
- * Gets hidden column names for a particular screen.
- *
- * @since 2.7.0
- * @deprecated 3.1.0
- * @deprecated Use WP_List_Table
- *
- * @param string $screen
- * @return array
- */
-function get_hidden_columns($screen) {
-        _deprecated_function( __FUNCTION__, '3.1', 'WP_List_Table' );
-
-        global $wp_list_table;
-        if ( !is_a($wp_list_table, 'WP_List_Table') )
-                $wp_list_table = new _WP_List_Table_Compat($screen);
-
-        return $wp_list_table-&gt;get_hidden_columns();
-}
-
</del><span class="cx"> // Helper class to be used only by deprecated functions
</span><span class="cx"> class _WP_List_Table_Compat extends WP_List_Table {
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkwpadminincludeslisttablephp"></a>
<div class="modfile"><h4>Modified: trunk/wp-admin/includes/list-table.php (15652 => 15653)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-admin/includes/list-table.php        2010-09-24 12:09:44 UTC (rev 15652)
+++ trunk/wp-admin/includes/list-table.php        2010-09-24 13:35:06 UTC (rev 15653)
</span><span class="lines">@@ -69,7 +69,10 @@
</span><span class="cx">          * @access protected
</span><span class="cx">          */
</span><span class="cx">         function WP_List_Table( $args ) {
</span><ins>+                global $_wp_column_headers;
</ins><span class="cx"> 
</span><ins>+                $_wp_column_headers = $this-&gt;get_columns();
+
</ins><span class="cx">                 $args = wp_parse_args( $args, array(
</span><span class="cx">                         'screen' =&gt; '',
</span><span class="cx">                         'plural' =&gt; '',
</span><span class="lines">@@ -82,6 +85,8 @@
</span><span class="cx">                 if ( is_string( $this-&gt;_screen ) )
</span><span class="cx">                         $this-&gt;_screen = convert_to_screen( $this-&gt;_screen );
</span><span class="cx"> 
</span><ins>+                add_filter( 'manage_' . $this-&gt;_screen-&gt;id . '_columns', array( $this, 'get_columns' ) );
+
</ins><span class="cx">                 if ( !$args['plural'] )
</span><span class="cx">                         $args['plural'] = $this-&gt;_screen-&gt;base;
</span><span class="cx"> 
</span><span class="lines">@@ -514,18 +519,6 @@
</span><span class="cx">         }
</span><span class="cx"> 
</span><span class="cx">         /**
</span><del>-         * Get a list of hidden columns.
-         *
-         * @since 3.1.0
-         * @access private
-         *
-         * @return array
-         */
-        function get_hidden_columns() {
-                return (array) get_user_option( 'manage' . $this-&gt;_screen-&gt;id. 'columnshidden' );
-        }
-
-        /**
</del><span class="cx">          * Get a list of all, hidden and sortable columns, with filter applied
</span><span class="cx">          *
</span><span class="cx">          * @since 3.1.0
</span><span class="lines">@@ -533,11 +526,11 @@
</span><span class="cx">          *
</span><span class="cx">          * @return array
</span><span class="cx">          */
</span><del>-        function get_column_headers() {
</del><ins>+        function get_column_info() {
</ins><span class="cx">                 if ( !isset( $this-&gt;_column_headers ) ) {
</span><del>-                        $columns = apply_filters( 'manage_' . $this-&gt;_screen-&gt;id . '_columns', $this-&gt;get_columns() );
</del><ins>+                        $columns = get_column_headers( $this-&gt;_screen );
+                        $hidden = get_hidden_columns( $this-&gt;_screen );
</ins><span class="cx">                         $sortable = apply_filters( 'manage_' . $this-&gt;_screen-&gt;id . '_sortable_columns', $this-&gt;get_sortable_columns() );
</span><del>-                        $hidden = $this-&gt;get_hidden_columns();
</del><span class="cx"> 
</span><span class="cx">                         $this-&gt;_column_headers = array( $columns, $hidden, $sortable );
</span><span class="cx">                 }
</span><span class="lines">@@ -556,7 +549,7 @@
</span><span class="cx">         function print_column_headers( $with_id = true ) {
</span><span class="cx">                 $screen = $this-&gt;_screen;
</span><span class="cx"> 
</span><del>-                list( $columns, $hidden, $sortable ) = $this-&gt;get_column_headers();
</del><ins>+                list( $columns, $hidden, $sortable ) = $this-&gt;get_column_info();
</ins><span class="cx"> 
</span><span class="cx">                 $current_url = ( is_ssl() ? 'https://' : 'http://' ) . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
</span><span class="cx"> 
</span><span class="lines">@@ -746,7 +739,7 @@
</span><span class="cx">          * @param $object $item The current item
</span><span class="cx">          */
</span><span class="cx">         function single_row_columns( $item ) {
</span><del>-                list( $columns, $hidden ) = $this-&gt;get_column_headers();
</del><ins>+                list( $columns, $hidden ) = $this-&gt;get_column_info();
</ins><span class="cx"> 
</span><span class="cx">                 foreach ( $columns as $column_name =&gt; $column_display_name ) {
</span><span class="cx">                         $class = &quot;class=\&quot;$column_name column-$column_name\&quot;&quot;;
</span></span></pre></div>
<a id="trunkwpadminincludestemplatephp"></a>
<div class="modfile"><h4>Modified: trunk/wp-admin/includes/template.php (15652 => 15653)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-admin/includes/template.php        2010-09-24 12:09:44 UTC (rev 15652)
+++ trunk/wp-admin/includes/template.php        2010-09-24 13:35:06 UTC (rev 15653)
</span><span class="lines">@@ -219,6 +219,42 @@
</span><span class="cx">         }
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+/**
+ * Get the column headers for a screen
+ *
+ * @since 2.7.0
+ *
+ * @param string|object $screen The screen you want the headers for
+ * @return array Containing the headers in the format id =&gt; UI String
+ */
+function get_column_headers( $screen ) {
+        if ( is_string( $screen ) )
+                $screen = convert_to_screen( $screen );
+
+        global $_wp_column_headers;
+
+        if ( !isset( $_wp_column_headers[ $screen-&gt;id ] ) ) {
+                $_wp_column_headers[ $screen-&gt;id ] = apply_filters( 'manage_' . $screen-&gt;id . '_columns', $_wp_column_headers );
+        }
+
+        return $_wp_column_headers[ $screen-&gt;id ];
+}
+
+/**
+ * Get a list of hidden columns.
+ *
+ * @since 2.7.0
+ *
+ * @param string|object $screen The screen you want the hidden columns for
+ * @return array
+ */
+function get_hidden_columns( $screen ) {
+        if ( is_string( $screen ) )
+                $screen = convert_to_screen( $screen );
+
+        return (array) get_user_option( 'manage' . $screen-&gt;id . 'columnshidden' );
+}
+
</ins><span class="cx"> // adds hidden fields with the data for use in the inline editor for posts and pages
</span><span class="cx"> /**
</span><span class="cx">  * {@internal Missing Short Description}}
</span><span class="lines">@@ -295,8 +331,8 @@
</span><span class="cx"> 
</span><span class="cx">         $wp_list_table = get_list_table('comments');
</span><span class="cx"> 
</span><del>-        $columns = $wp_list_table-&gt;get_column_headers();
-        $hidden = array_intersect( array_keys( $columns ), array_filter( $wp_list_table-&gt;get_hidden_columns() ) );
</del><ins>+        list ( $columns, $hidden ) = $wp_list_table-&gt;get_column_info();
+        $hidden = array_intersect( array_keys( $columns ), array_filter( $hidden ) );
</ins><span class="cx">         $col_count = count($columns) - count($hidden);
</span><span class="cx"> 
</span><span class="cx"> ?&gt;
</span><span class="lines">@@ -1290,36 +1326,6 @@
</span><span class="cx">  *
</span><span class="cx">  * @since unknown
</span><span class="cx">  *
</span><del>- * @param unknown_type $page
- */
-function manage_columns_prefs( $page ) {
-        global $wp_list_table;
-
-        list( $columns, $hidden ) = $wp_list_table-&gt;get_column_headers();
-
-        $special = array('_title', 'cb', 'comment', 'media', 'name', 'title', 'username');
-
-        foreach ( $columns as $column =&gt; $title ) {
-                // Can't hide these for they are special
-                if ( in_array( $column, $special ) )
-                        continue;
-                if ( empty( $title ) )
-                        continue;
-
-                if ( 'comments' == $column )
-                        $title = __( 'Comments' );
-                $id = &quot;$column-hide&quot;;
-                echo '&lt;label for=&quot;' . $id . '&quot;&gt;';
-                echo '&lt;input class=&quot;hide-column-tog&quot; name=&quot;' . $id . '&quot; type=&quot;checkbox&quot; id=&quot;' . $id . '&quot; value=&quot;' . $column . '&quot;' . (! in_array($column, $hidden) ? ' checked=&quot;checked&quot;' : '') . ' /&gt;';
-                echo &quot;$title&lt;/label&gt;\n&quot;;
-        }
-}
-
-/**
- * {@internal Missing Short Description}}
- *
- * @since unknown
- *
</del><span class="cx">  * @param unknown_type $found_action
</span><span class="cx">  */
</span><span class="cx"> function find_posts_div($found_action = '') {
</span><span class="lines">@@ -1634,8 +1640,9 @@
</span><span class="cx">         if ( is_string($screen) )
</span><span class="cx">                 $screen = convert_to_screen($screen);
</span><span class="cx"> 
</span><del>-        if ( is_a($wp_list_table, 'WP_List_Table') )
-                list( $screen_columns ) = $wp_list_table-&gt;get_column_headers();
</del><ins>+        $columns = get_column_headers( $screen );
+        $hidden = get_hidden_columns( $screen );
+
</ins><span class="cx">         $meta_screens = array('index' =&gt; 'dashboard');
</span><span class="cx"> 
</span><span class="cx">         if ( isset($meta_screens[$screen-&gt;id]) ) {
</span><span class="lines">@@ -1644,7 +1651,7 @@
</span><span class="cx">         }
</span><span class="cx"> 
</span><span class="cx">         $show_screen = false;
</span><del>-        if ( !empty($wp_meta_boxes[$screen-&gt;id]) || !empty($screen_columns) )
</del><ins>+        if ( !empty($wp_meta_boxes[$screen-&gt;id]) || !empty($columns) )
</ins><span class="cx">                 $show_screen = true;
</span><span class="cx"> 
</span><span class="cx">         $screen_options = screen_options($screen);
</span><span class="lines">@@ -1677,10 +1684,27 @@
</span><span class="cx">                         &lt;br class=&quot;clear&quot; /&gt;
</span><span class="cx">                 &lt;/div&gt;
</span><span class="cx">                 &lt;?php endif;
</span><del>-                if ( ! empty($screen_columns) ) : ?&gt;
-                &lt;h5&gt;&lt;?php echo ( isset( $screen_columns['_title'] ) ?  $screen_columns['_title'] :  _x('Show on screen', 'Columns') ) ?&gt;&lt;/h5&gt;
</del><ins>+                if ( ! empty($columns) ) : ?&gt;
+                &lt;h5&gt;&lt;?php echo ( isset( $columns['_title'] ) ?  $columns['_title'] :  _x('Show on screen', 'Columns') ) ?&gt;&lt;/h5&gt;
</ins><span class="cx">                 &lt;div class=&quot;metabox-prefs&quot;&gt;
</span><del>-                        &lt;?php manage_columns_prefs($screen); ?&gt;
</del><ins>+&lt;?php
+        $special = array('_title', 'cb', 'comment', 'media', 'name', 'title', 'username');
+
+        foreach ( $columns as $column =&gt; $title ) {
+                // Can't hide these for they are special
+                if ( in_array( $column, $special ) )
+                        continue;
+                if ( empty( $title ) )
+                        continue;
+
+                if ( 'comments' == $column )
+                        $title = __( 'Comments' );
+                $id = &quot;$column-hide&quot;;
+                echo '&lt;label for=&quot;' . $id . '&quot;&gt;';
+                echo '&lt;input class=&quot;hide-column-tog&quot; name=&quot;' . $id . '&quot; type=&quot;checkbox&quot; id=&quot;' . $id . '&quot; value=&quot;' . $column . '&quot;' . checked( !in_array($column, $hidden), true, false ) . ' /&gt;';
+                echo &quot;$title&lt;/label&gt;\n&quot;;
+        }
+?&gt;
</ins><span class="cx">                         &lt;br class=&quot;clear&quot; /&gt;
</span><span class="cx">                 &lt;/div&gt;
</span><span class="cx">         &lt;?php endif;
</span></span></pre>
</div>
</div>

</body>
</html>