<!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>[15632] trunk/wp-admin: WP_Terms_Table cleanup:</title>
</head>
<body>

<div id="msg">
<dl>
<dt>Revision</dt> <dd><a href="http://trac.wordpress.org/changeset/15632">15632</a></dd>
<dt>Author</dt> <dd>scribu</dd>
<dt>Date</dt> <dd>2010-09-18 19:30:53 +0000 (Sat, 18 Sep 2010)</dd>
</dl>

<h3>Log Message</h3>
<pre>WP_Terms_Table cleanup:
        * use column_*() methods
        * remove $taxonomy argument from single_row()
        * don't calculate tag full name in admin-ajax.php
See <a href="http://trac.wordpress.org/ticket/14579">#14579</a></pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkwpadminadminajaxphp">trunk/wp-admin/admin-ajax.php</a></li>
<li><a href="#trunkwpadminincludesdefaultlisttablesphp">trunk/wp-admin/includes/default-list-tables.php</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkwpadminadminajaxphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-admin/admin-ajax.php (15631 => 15632)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-admin/admin-ajax.php        2010-09-18 19:20:16 UTC (rev 15631)
+++ trunk/wp-admin/admin-ajax.php        2010-09-18 19:30:53 UTC (rev 15632)
</span><span class="lines">@@ -559,20 +559,17 @@
</span><span class="cx">         $wp_list_table = get_list_table('terms');
</span><span class="cx"> 
</span><span class="cx">         $level = 0;
</span><del>-        $tag_full_name = false;
-        $tag_full_name = $tag-&gt;name;
</del><span class="cx">         if ( is_taxonomy_hierarchical($taxonomy) ) {
</span><del>-                $_tag = $tag;
-                while ( $_tag-&gt;parent  ) {
-                        $_tag = get_term( $_tag-&gt;parent, $taxonomy );
-                        $tag_full_name = $_tag-&gt;name . ' &amp;#8212; ' . $tag_full_name;
-                        $level++;
-                }
-                $noparents = $wp_list_table-&gt;single_row( $tag, $level, $taxonomy );
</del><ins>+                $level = count( get_ancestors( $tag-&gt;term_id, $taxonomy ) );
+                ob_start();
+                $wp_list_table-&gt;single_row( $tag, $level );
+                $noparents = ob_get_clean();
</ins><span class="cx">         }
</span><del>-        $tag-&gt;name = $tag_full_name;
-        $parents = $wp_list_table-&gt;single_row( $tag, 0, $taxonomy);
</del><span class="cx"> 
</span><ins>+        ob_start();
+        $wp_list_table-&gt;single_row( $tag );
+        $parents = ob_get_clean();
+
</ins><span class="cx">         $x-&gt;add( array(
</span><span class="cx">                 'what' =&gt; 'taxonomy',
</span><span class="cx">                 'supplemental' =&gt; compact('parents', 'noparents')
</span><span class="lines">@@ -580,7 +577,7 @@
</span><span class="cx">         $x-&gt;add( array(
</span><span class="cx">                 'what' =&gt; 'term',
</span><span class="cx">                 'position' =&gt; $level,
</span><del>-                'supplemental' =&gt; get_term( $tag-&gt;term_id, $taxonomy, ARRAY_A ) // Refetch as $tag has been contaminated by the full name.
</del><ins>+                'supplemental' =&gt; $tag
</ins><span class="cx">                 ) );
</span><span class="cx">         $x-&gt;send();
</span><span class="cx">         break;
</span><span class="lines">@@ -1227,7 +1224,7 @@
</span><span class="cx">                         die( __('Item not updated.') );
</span><span class="cx">                 }
</span><span class="cx"> 
</span><del>-                echo $wp_list_table-&gt;single_row( $tag, 0, $taxonomy );
</del><ins>+                echo $wp_list_table-&gt;single_row( $tag );
</ins><span class="cx">         } else {
</span><span class="cx">                 if ( is_wp_error($updated) &amp;&amp; $updated-&gt;get_error_message() )
</span><span class="cx">                         die( $updated-&gt;get_error_message() );
</span></span></pre></div>
<a id="trunkwpadminincludesdefaultlisttablesphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-admin/includes/default-list-tables.php (15631 => 15632)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-admin/includes/default-list-tables.php        2010-09-18 19:20:16 UTC (rev 15631)
+++ trunk/wp-admin/includes/default-list-tables.php        2010-09-18 19:30:53 UTC (rev 15632)
</span><span class="lines">@@ -1597,98 +1597,98 @@
</span><span class="cx">                 return $output;
</span><span class="cx">         }
</span><span class="cx"> 
</span><del>-        function single_row( $tag, $level, $taxonomy = 'post_tag' ) {
-                global $post_type, $current_screen;
</del><ins>+        function single_row( $tag, $level = 0 ) {
</ins><span class="cx">                 static $row_class = '';
</span><span class="cx">                 $row_class = ( $row_class == '' ? ' class=&quot;alternate&quot;' : '' );
</span><span class="cx"> 
</span><del>-                $count = number_format_i18n( $tag-&gt;count );
-                $tax = get_taxonomy( $taxonomy );
</del><ins>+                $this-&gt;level = $level;
</ins><span class="cx"> 
</span><del>-                if ( 'post_tag' == $taxonomy ) {
-                        $tagsel = 'tag';
-                } elseif ( 'category' == $taxonomy ) {
-                        $tagsel = 'category_name';
-                } elseif ( ! empty( $tax-&gt;query_var ) ) {
-                        $tagsel = $tax-&gt;query_var;
-                } else {
-                        $tagsel = $taxonomy;
-                }
</del><ins>+                echo '&lt;tr id=&quot;tag-' . $tag-&gt;term_id . '&quot;' . $row_class . '&gt;';
+                echo $this-&gt;single_row_columns( $tag );
+                echo '&lt;/tr&gt;';
+        }
</ins><span class="cx"> 
</span><del>-                $pad = str_repeat( '&amp;#8212; ', max( 0, $level ) );
</del><ins>+        function column_cb( $tag ) {
+                global $taxonomy, $tax;
+
+                $default_term = get_option( 'default_' . $taxonomy );
+
+                if ( current_user_can( $tax-&gt;cap-&gt;delete_terms ) &amp;&amp; $tag-&gt;term_id != $default_term )
+                        return '&lt;input type=&quot;checkbox&quot; name=&quot;delete_tags[]&quot; value=&quot;' . $tag-&gt;term_id . '&quot; /&gt;';
+                else
+                        return '&amp;nbsp;';
+        }
+
+        function column_name( $tag ) {
+                global $taxonomy, $tax, $post_type;
+
+                $default_term = get_option( 'default_' . $taxonomy );
+
+                $pad = str_repeat( '&amp;#8212; ', max( 0, $this-&gt;level ) );
</ins><span class="cx">                 $name = apply_filters( 'term_name', $pad . ' ' . $tag-&gt;name, $tag );
</span><del>-                $qe_data = get_term( $tag-&gt;term_id, $taxonomy, object, 'edit' );
</del><ins>+                $qe_data = get_term( $tag-&gt;term_id, $taxonomy, OBJECT, 'edit' );
</ins><span class="cx">                 $edit_link = &quot;edit-tags.php?action=edit&amp;amp;taxonomy=$taxonomy&amp;amp;post_type=$post_type&amp;amp;tag_ID=$tag-&gt;term_id&quot;;
</span><span class="cx"> 
</span><del>-                $out = '';
-                $out .= '&lt;tr id=&quot;tag-' . $tag-&gt;term_id . '&quot;' . $row_class . '&gt;';
</del><ins>+                $out = '&lt;strong&gt;&lt;a class=&quot;row-title&quot; href=&quot;' . $edit_link . '&quot; title=&quot;' . esc_attr( sprintf( __( 'Edit &amp;#8220;%s&amp;#8221;' ), $name ) ) . '&quot;&gt;' . $name . '&lt;/a&gt;&lt;/strong&gt;&lt;br /&gt;';
</ins><span class="cx"> 
</span><del>-                $default_term = get_option( 'default_' . $taxonomy );
</del><ins>+                $actions = array();
+                if ( current_user_can( $tax-&gt;cap-&gt;edit_terms ) ) {
+                        $actions['edit'] = '&lt;a href=&quot;' . $edit_link . '&quot;&gt;' . __( 'Edit' ) . '&lt;/a&gt;';
+                        $actions['inline hide-if-no-js'] = '&lt;a href=&quot;#&quot; class=&quot;editinline&quot;&gt;' . __( 'Quick&amp;nbsp;Edit' ) . '&lt;/a&gt;';
+                }
+                if ( current_user_can( $tax-&gt;cap-&gt;delete_terms ) &amp;&amp; $tag-&gt;term_id != $default_term )
+                        $actions['delete'] = &quot;&lt;a class='delete-tag' href='&quot; . wp_nonce_url( &quot;edit-tags.php?action=delete&amp;amp;taxonomy=$taxonomy&amp;amp;tag_ID=$tag-&gt;term_id&quot;, 'delete-tag_' . $tag-&gt;term_id ) . &quot;'&gt;&quot; . __( 'Delete' ) . &quot;&lt;/a&gt;&quot;;
</ins><span class="cx"> 
</span><del>-                list( $columns, $hidden ) = $this-&gt;get_column_headers();
</del><ins>+                $actions = apply_filters( 'tag_row_actions', $actions, $tag );
+                $actions = apply_filters( &quot;${taxonomy}_row_actions&quot;, $actions, $tag );
</ins><span class="cx"> 
</span><del>-                foreach ( $columns as $column_name =&gt; $column_display_name ) {
-                        $class = &quot;class=\&quot;$column_name column-$column_name\&quot;&quot;;
</del><ins>+                $out .= $this-&gt;row_actions( $actions );
+                $out .= '&lt;div class=&quot;hidden&quot; id=&quot;inline_' . $qe_data-&gt;term_id . '&quot;&gt;';
+                $out .= '&lt;div class=&quot;name&quot;&gt;' . $qe_data-&gt;name . '&lt;/div&gt;';
+                $out .= '&lt;div class=&quot;slug&quot;&gt;' . apply_filters( 'editable_slug', $qe_data-&gt;slug ) . '&lt;/div&gt;';
+                $out .= '&lt;div class=&quot;parent&quot;&gt;' . $qe_data-&gt;parent . '&lt;/div&gt;&lt;/div&gt;&lt;/td&gt;';
</ins><span class="cx"> 
</span><del>-                        $style = '';
-                        if ( in_array( $column_name, $hidden ) )
-                                $style = ' style=&quot;display:none;&quot;';
</del><ins>+                return $out;
+        }
+        
+        function column_description( $tag ) {
+                return $tag-&gt;description;
+        }
</ins><span class="cx"> 
</span><del>-                        $attributes = &quot;$class$style&quot;;
</del><ins>+        function column_slug( $tag ) {
+                return apply_filters( 'editable_slug', $tag-&gt;slug );
+        }
</ins><span class="cx"> 
</span><del>-                        switch ( $column_name ) {
-                                case 'cb':
-                                        if ( current_user_can( $tax-&gt;cap-&gt;delete_terms ) &amp;&amp; $tag-&gt;term_id != $default_term )
-                                                $out .= '&lt;th scope=&quot;row&quot; class=&quot;check-column&quot;&gt; &lt;input type=&quot;checkbox&quot; name=&quot;delete_tags[]&quot; value=&quot;' . $tag-&gt;term_id . '&quot; /&gt;&lt;/th&gt;';
-                                        else
-                                                $out .= '&lt;th scope=&quot;row&quot; class=&quot;check-column&quot;&gt;&amp;nbsp;&lt;/th&gt;';
-                                        break;
-                                case 'name':
-                                        $out .= '&lt;td ' . $attributes . '&gt;&lt;strong&gt;&lt;a class=&quot;row-title&quot; href=&quot;' . $edit_link . '&quot; title=&quot;' . esc_attr( sprintf( __( 'Edit &amp;#8220;%s&amp;#8221;' ), $name ) ) . '&quot;&gt;' . $name . '&lt;/a&gt;&lt;/strong&gt;&lt;br /&gt;';
</del><ins>+        function column_posts( $tag ) {
+                global $taxonomy, $post_type;
</ins><span class="cx"> 
</span><del>-                                        $actions = array();
-                                        if ( current_user_can( $tax-&gt;cap-&gt;edit_terms ) ) {
-                                                $actions['edit'] = '&lt;a href=&quot;' . $edit_link . '&quot;&gt;' . __( 'Edit' ) . '&lt;/a&gt;';
-                                                $actions['inline hide-if-no-js'] = '&lt;a href=&quot;#&quot; class=&quot;editinline&quot;&gt;' . __( 'Quick&amp;nbsp;Edit' ) . '&lt;/a&gt;';
-                                        }
-                                        if ( current_user_can( $tax-&gt;cap-&gt;delete_terms ) &amp;&amp; $tag-&gt;term_id != $default_term )
-                                                $actions['delete'] = &quot;&lt;a class='delete-tag' href='&quot; . wp_nonce_url( &quot;edit-tags.php?action=delete&amp;amp;taxonomy=$taxonomy&amp;amp;tag_ID=$tag-&gt;term_id&quot;, 'delete-tag_' . $tag-&gt;term_id ) . &quot;'&gt;&quot; . __( 'Delete' ) . &quot;&lt;/a&gt;&quot;;
</del><ins>+                $count = number_format_i18n( $tag-&gt;count );
</ins><span class="cx"> 
</span><del>-                                        $actions = apply_filters( 'tag_row_actions', $actions, $tag );
-                                        $actions = apply_filters( &quot;${taxonomy}_row_actions&quot;, $actions, $tag );
-
-                                        $out .= $this-&gt;row_actions( $actions );
-                                        $out .= '&lt;div class=&quot;hidden&quot; id=&quot;inline_' . $qe_data-&gt;term_id . '&quot;&gt;';
-                                        $out .= '&lt;div class=&quot;name&quot;&gt;' . $qe_data-&gt;name . '&lt;/div&gt;';
-                                        $out .= '&lt;div class=&quot;slug&quot;&gt;' . apply_filters( 'editable_slug', $qe_data-&gt;slug ) . '&lt;/div&gt;';
-                                        $out .= '&lt;div class=&quot;parent&quot;&gt;' . $qe_data-&gt;parent . '&lt;/div&gt;&lt;/div&gt;&lt;/td&gt;';
-                                        break;
-                                case 'description':
-                                        $out .= &quot;&lt;td $attributes&gt;$tag-&gt;description&lt;/td&gt;&quot;;
-                                        break;
-                                case 'slug':
-                                        $out .= &quot;&lt;td $attributes&gt;&quot; . apply_filters( 'editable_slug', $tag-&gt;slug ) . &quot;&lt;/td&gt;&quot;;
-                                        break;
-                                case 'posts':
-                                        $attributes = 'class=&quot;posts column-posts num&quot;' . $style;
-                                        $out .= &quot;&lt;td $attributes&gt;&lt;a href='edit.php?$tagsel=$tag-&gt;slug&amp;amp;post_type=$post_type'&gt;$count&lt;/a&gt;&lt;/td&gt;&quot;;
-                                        break;
-                                case 'links':
-                                        $attributes = 'class=&quot;links column-links num&quot;' . $style;
-                                        $out .= &quot;&lt;td $attributes&gt;$count&lt;/td&gt;&quot;;
-                                        break;
-                                default:
-                                        $out .= &quot;&lt;td $attributes&gt;&quot;;
-                                        $out .= apply_filters( &quot;manage_${taxonomy}_custom_column&quot;, '', $column_name, $tag-&gt;term_id );
-                                        $out .= &quot;&lt;/td&gt;&quot;;
-                        }
</del><ins>+                if ( 'post_tag' == $taxonomy ) {
+                        $tagsel = 'tag';
+                } elseif ( 'category' == $taxonomy ) {
+                        $tagsel = 'category_name';
+                } elseif ( ! empty( $tax-&gt;query_var ) ) {
+                        $tagsel = $tax-&gt;query_var;
+                } else {
+                        $tagsel = $taxonomy;
</ins><span class="cx">                 }
</span><span class="cx"> 
</span><del>-                $out .= &quot;&lt;/tr&gt;\n&quot;;
</del><ins>+                return &quot;&lt;a href='edit.php?$tagsel=$tag-&gt;slug&amp;amp;post_type=$post_type'&gt;$count&lt;/a&gt;&quot;;
+        }
</ins><span class="cx"> 
</span><del>-                return $out;
</del><ins>+        function column_links( $tag ) {
+                $count = number_format_i18n( $tag-&gt;count );
+                return $count;
</ins><span class="cx">         }
</span><span class="cx"> 
</span><ins>+        function column_default( $tag, $column_name ) {
+                global $taxonomy;
+        
+                return apply_filters( &quot;manage_${taxonomy}_custom_column&quot;, '', $column_name, $tag-&gt;term_id );
+                $out .= &quot;&lt;/td&gt;&quot;;
+        }
+
</ins><span class="cx">         /**
</span><span class="cx">          * Outputs the hidden row displayed when inline editing
</span><span class="cx">          *
</span></span></pre>
</div>
</div>

</body>
</html>