Terms list table:

* Don't call single_row() with an undeclared and unused $taxonomy argument.
 * Don't define optional parameters before required parameters in the _rows() method. Make them required.
 * Move empty( $terms ) check above other operations. This function was improperly returning an else case until [24123].

props rlerdorf.
see #24210.



git-svn-id: http://core.svn.wordpress.org/trunk@24127 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Andrew Nacin 2013-04-29 13:39:28 +00:00
parent 92b4636e17
commit 2ea564da8b
1 changed files with 15 additions and 12 deletions

View File

@ -143,8 +143,18 @@ class WP_Terms_List_Table extends WP_List_Table {
if ( is_taxonomy_hierarchical( $taxonomy ) && !isset( $orderby ) ) { if ( is_taxonomy_hierarchical( $taxonomy ) && !isset( $orderby ) ) {
// We'll need the full set of terms then. // We'll need the full set of terms then.
$args['number'] = $args['offset'] = 0; $args['number'] = $args['offset'] = 0;
}
$terms = get_terms( $taxonomy, $args );
$terms = get_terms( $taxonomy, $args ); if ( empty( $terms ) ) {
list( $columns, $hidden ) = $this->get_column_info();
echo '<tr class="no-items"><td class="colspanchange" colspan="' . $this->get_column_count() . '">';
$this->no_items();
echo '</td></tr>';
return;
}
if ( is_taxonomy_hierarchical( $taxonomy ) && !isset( $orderby ) ) {
if ( !empty( $search ) ) // Ignore children on searches. if ( !empty( $search ) ) // Ignore children on searches.
$children = array(); $children = array();
else else
@ -155,19 +165,12 @@ class WP_Terms_List_Table extends WP_List_Table {
} else { } else {
$terms = get_terms( $taxonomy, $args ); $terms = get_terms( $taxonomy, $args );
foreach ( $terms as $term ) foreach ( $terms as $term )
$this->single_row( $term, 0, $taxonomy ); $this->single_row( $term );
$count = $number; // Only displaying a single page. $count = $number; // Only displaying a single page.
} }
if ( empty( $terms ) ) {
list( $columns, $hidden ) = $this->get_column_info();
echo '<tr class="no-items"><td class="colspanchange" colspan="' . $this->get_column_count() . '">';
$this->no_items();
echo '</td></tr>';
}
} }
function _rows( $taxonomy, $terms, &$children, $start = 0, $per_page = 20, &$count, $parent = 0, $level = 0 ) { function _rows( $taxonomy, $terms, &$children, $start, $per_page, &$count, $parent = 0, $level = 0 ) {
$end = $start + $per_page; $end = $start + $per_page;
@ -196,14 +199,14 @@ class WP_Terms_List_Table extends WP_List_Table {
$num_parents = count( $my_parents ); $num_parents = count( $my_parents );
while ( $my_parent = array_pop( $my_parents ) ) { while ( $my_parent = array_pop( $my_parents ) ) {
echo "\t"; echo "\t";
$this->single_row( $my_parent, $level - $num_parents, $taxonomy ); $this->single_row( $my_parent, $level - $num_parents );
$num_parents--; $num_parents--;
} }
} }
if ( $count >= $start ) { if ( $count >= $start ) {
echo "\t"; echo "\t";
$this->single_row( $term, $level, $taxonomy ); $this->single_row( $term, $level );
} }
++$count; ++$count;