<!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->name;
</del><span class="cx">         if ( is_taxonomy_hierarchical($taxonomy) ) {
</span><del>-                $_tag = $tag;
-                while ( $_tag->parent ) {
-                        $_tag = get_term( $_tag->parent, $taxonomy );
-                        $tag_full_name = $_tag->name . ' &#8212; ' . $tag_full_name;
-                        $level++;
-                }
-                $noparents = $wp_list_table->single_row( $tag, $level, $taxonomy );
</del><ins>+                $level = count( get_ancestors( $tag->term_id, $taxonomy ) );
+                ob_start();
+                $wp_list_table->single_row( $tag, $level );
+                $noparents = ob_get_clean();
</ins><span class="cx">         }
</span><del>-        $tag->name = $tag_full_name;
-        $parents = $wp_list_table->single_row( $tag, 0, $taxonomy);
</del><span class="cx">
</span><ins>+        ob_start();
+        $wp_list_table->single_row( $tag );
+        $parents = ob_get_clean();
+
</ins><span class="cx">         $x->add( array(
</span><span class="cx">                 'what' => 'taxonomy',
</span><span class="cx">                 'supplemental' => compact('parents', 'noparents')
</span><span class="lines">@@ -580,7 +577,7 @@
</span><span class="cx">         $x->add( array(
</span><span class="cx">                 'what' => 'term',
</span><span class="cx">                 'position' => $level,
</span><del>-                'supplemental' => get_term( $tag->term_id, $taxonomy, ARRAY_A ) // Refetch as $tag has been contaminated by the full name.
</del><ins>+                'supplemental' => $tag
</ins><span class="cx">                 ) );
</span><span class="cx">         $x->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->single_row( $tag, 0, $taxonomy );
</del><ins>+                echo $wp_list_table->single_row( $tag );
</ins><span class="cx">         } else {
</span><span class="cx">                 if ( is_wp_error($updated) && $updated->get_error_message() )
</span><span class="cx">                         die( $updated->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="alternate"' : '' );
</span><span class="cx">
</span><del>-                $count = number_format_i18n( $tag->count );
-                $tax = get_taxonomy( $taxonomy );
</del><ins>+                $this->level = $level;
</ins><span class="cx">
</span><del>-                if ( 'post_tag' == $taxonomy ) {
-                        $tagsel = 'tag';
-                } elseif ( 'category' == $taxonomy ) {
-                        $tagsel = 'category_name';
-                } elseif ( ! empty( $tax->query_var ) ) {
-                        $tagsel = $tax->query_var;
-                } else {
-                        $tagsel = $taxonomy;
-                }
</del><ins>+                echo '<tr id="tag-' . $tag->term_id . '"' . $row_class . '>';
+                echo $this->single_row_columns( $tag );
+                echo '</tr>';
+        }
</ins><span class="cx">
</span><del>-                $pad = str_repeat( '&#8212; ', max( 0, $level ) );
</del><ins>+        function column_cb( $tag ) {
+                global $taxonomy, $tax;
+
+                $default_term = get_option( 'default_' . $taxonomy );
+
+                if ( current_user_can( $tax->cap->delete_terms ) && $tag->term_id != $default_term )
+                        return '<input type="checkbox" name="delete_tags[]" value="' . $tag->term_id . '" />';
+                else
+                        return '&nbsp;';
+        }
+
+        function column_name( $tag ) {
+                global $taxonomy, $tax, $post_type;
+
+                $default_term = get_option( 'default_' . $taxonomy );
+
+                $pad = str_repeat( '&#8212; ', max( 0, $this->level ) );
</ins><span class="cx">                 $name = apply_filters( 'term_name', $pad . ' ' . $tag->name, $tag );
</span><del>-                $qe_data = get_term( $tag->term_id, $taxonomy, object, 'edit' );
</del><ins>+                $qe_data = get_term( $tag->term_id, $taxonomy, OBJECT, 'edit' );
</ins><span class="cx">                 $edit_link = "edit-tags.php?action=edit&amp;taxonomy=$taxonomy&amp;post_type=$post_type&amp;tag_ID=$tag->term_id";
</span><span class="cx">
</span><del>-                $out = '';
-                $out .= '<tr id="tag-' . $tag->term_id . '"' . $row_class . '>';
</del><ins>+                $out = '<strong><a class="row-title" href="' . $edit_link . '" title="' . esc_attr( sprintf( __( 'Edit &#8220;%s&#8221;' ), $name ) ) . '">' . $name . '</a></strong><br />';
</ins><span class="cx">
</span><del>-                $default_term = get_option( 'default_' . $taxonomy );
</del><ins>+                $actions = array();
+                if ( current_user_can( $tax->cap->edit_terms ) ) {
+                        $actions['edit'] = '<a href="' . $edit_link . '">' . __( 'Edit' ) . '</a>';
+                        $actions['inline hide-if-no-js'] = '<a href="#" class="editinline">' . __( 'Quick&nbsp;Edit' ) . '</a>';
+                }
+                if ( current_user_can( $tax->cap->delete_terms ) && $tag->term_id != $default_term )
+                        $actions['delete'] = "<a class='delete-tag' href='" . wp_nonce_url( "edit-tags.php?action=delete&amp;taxonomy=$taxonomy&amp;tag_ID=$tag->term_id", 'delete-tag_' . $tag->term_id ) . "'>" . __( 'Delete' ) . "</a>";
</ins><span class="cx">
</span><del>-                list( $columns, $hidden ) = $this->get_column_headers();
</del><ins>+                $actions = apply_filters( 'tag_row_actions', $actions, $tag );
+                $actions = apply_filters( "${taxonomy}_row_actions", $actions, $tag );
</ins><span class="cx">
</span><del>-                foreach ( $columns as $column_name => $column_display_name ) {
-                        $class = "class=\"$column_name column-$column_name\"";
</del><ins>+                $out .= $this->row_actions( $actions );
+                $out .= '<div class="hidden" id="inline_' . $qe_data->term_id . '">';
+                $out .= '<div class="name">' . $qe_data->name . '</div>';
+                $out .= '<div class="slug">' . apply_filters( 'editable_slug', $qe_data->slug ) . '</div>';
+                $out .= '<div class="parent">' . $qe_data->parent . '</div></div></td>';
</ins><span class="cx">
</span><del>-                        $style = '';
-                        if ( in_array( $column_name, $hidden ) )
-                                $style = ' style="display:none;"';
</del><ins>+                return $out;
+        }
+        
+        function column_description( $tag ) {
+                return $tag->description;
+        }
</ins><span class="cx">
</span><del>-                        $attributes = "$class$style";
</del><ins>+        function column_slug( $tag ) {
+                return apply_filters( 'editable_slug', $tag->slug );
+        }
</ins><span class="cx">
</span><del>-                        switch ( $column_name ) {
-                                case 'cb':
-                                        if ( current_user_can( $tax->cap->delete_terms ) && $tag->term_id != $default_term )
-                                                $out .= '<th scope="row" class="check-column"> <input type="checkbox" name="delete_tags[]" value="' . $tag->term_id . '" /></th>';
-                                        else
-                                                $out .= '<th scope="row" class="check-column">&nbsp;</th>';
-                                        break;
-                                case 'name':
-                                        $out .= '<td ' . $attributes . '><strong><a class="row-title" href="' . $edit_link . '" title="' . esc_attr( sprintf( __( 'Edit &#8220;%s&#8221;' ), $name ) ) . '">' . $name . '</a></strong><br />';
</del><ins>+        function column_posts( $tag ) {
+                global $taxonomy, $post_type;
</ins><span class="cx">
</span><del>-                                        $actions = array();
-                                        if ( current_user_can( $tax->cap->edit_terms ) ) {
-                                                $actions['edit'] = '<a href="' . $edit_link . '">' . __( 'Edit' ) . '</a>';
-                                                $actions['inline hide-if-no-js'] = '<a href="#" class="editinline">' . __( 'Quick&nbsp;Edit' ) . '</a>';
-                                        }
-                                        if ( current_user_can( $tax->cap->delete_terms ) && $tag->term_id != $default_term )
-                                                $actions['delete'] = "<a class='delete-tag' href='" . wp_nonce_url( "edit-tags.php?action=delete&amp;taxonomy=$taxonomy&amp;tag_ID=$tag->term_id", 'delete-tag_' . $tag->term_id ) . "'>" . __( 'Delete' ) . "</a>";
</del><ins>+                $count = number_format_i18n( $tag->count );
</ins><span class="cx">
</span><del>-                                        $actions = apply_filters( 'tag_row_actions', $actions, $tag );
-                                        $actions = apply_filters( "${taxonomy}_row_actions", $actions, $tag );
-
-                                        $out .= $this->row_actions( $actions );
-                                        $out .= '<div class="hidden" id="inline_' . $qe_data->term_id . '">';
-                                        $out .= '<div class="name">' . $qe_data->name . '</div>';
-                                        $out .= '<div class="slug">' . apply_filters( 'editable_slug', $qe_data->slug ) . '</div>';
-                                        $out .= '<div class="parent">' . $qe_data->parent . '</div></div></td>';
-                                        break;
-                                case 'description':
-                                        $out .= "<td $attributes>$tag->description</td>";
-                                        break;
-                                case 'slug':
-                                        $out .= "<td $attributes>" . apply_filters( 'editable_slug', $tag->slug ) . "</td>";
-                                        break;
-                                case 'posts':
-                                        $attributes = 'class="posts column-posts num"' . $style;
-                                        $out .= "<td $attributes><a href='edit.php?$tagsel=$tag->slug&amp;post_type=$post_type'>$count</a></td>";
-                                        break;
-                                case 'links':
-                                        $attributes = 'class="links column-links num"' . $style;
-                                        $out .= "<td $attributes>$count</td>";
-                                        break;
-                                default:
-                                        $out .= "<td $attributes>";
-                                        $out .= apply_filters( "manage_${taxonomy}_custom_column", '', $column_name, $tag->term_id );
-                                        $out .= "</td>";
-                        }
</del><ins>+                if ( 'post_tag' == $taxonomy ) {
+                        $tagsel = 'tag';
+                } elseif ( 'category' == $taxonomy ) {
+                        $tagsel = 'category_name';
+                } elseif ( ! empty( $tax->query_var ) ) {
+                        $tagsel = $tax->query_var;
+                } else {
+                        $tagsel = $taxonomy;
</ins><span class="cx">                 }
</span><span class="cx">
</span><del>-                $out .= "</tr>\n";
</del><ins>+                return "<a href='edit.php?$tagsel=$tag->slug&amp;post_type=$post_type'>$count</a>";
+        }
</ins><span class="cx">
</span><del>-                return $out;
</del><ins>+        function column_links( $tag ) {
+                $count = number_format_i18n( $tag->count );
+                return $count;
</ins><span class="cx">         }
</span><span class="cx">
</span><ins>+        function column_default( $tag, $column_name ) {
+                global $taxonomy;
+        
+                return apply_filters( "manage_${taxonomy}_custom_column", '', $column_name, $tag->term_id );
+                $out .= "</td>";
+        }
+
</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>