From 2ea564da8b97b1093702ba2ad97326c1b10f7b74 Mon Sep 17 00:00:00 2001 From: Andrew Nacin Date: Mon, 29 Apr 2013 13:39:28 +0000 Subject: [PATCH] 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 --- .../includes/class-wp-terms-list-table.php | 27 ++++++++++--------- 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/wp-admin/includes/class-wp-terms-list-table.php b/wp-admin/includes/class-wp-terms-list-table.php index 59dcd3e4d5..3854a36edd 100644 --- a/wp-admin/includes/class-wp-terms-list-table.php +++ b/wp-admin/includes/class-wp-terms-list-table.php @@ -143,8 +143,18 @@ class WP_Terms_List_Table extends WP_List_Table { if ( is_taxonomy_hierarchical( $taxonomy ) && !isset( $orderby ) ) { // We'll need the full set of terms then. $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 ''; + $this->no_items(); + echo ''; + return; + } + + if ( is_taxonomy_hierarchical( $taxonomy ) && !isset( $orderby ) ) { if ( !empty( $search ) ) // Ignore children on searches. $children = array(); else @@ -155,19 +165,12 @@ class WP_Terms_List_Table extends WP_List_Table { } else { $terms = get_terms( $taxonomy, $args ); foreach ( $terms as $term ) - $this->single_row( $term, 0, $taxonomy ); + $this->single_row( $term ); $count = $number; // Only displaying a single page. } - - if ( empty( $terms ) ) { - list( $columns, $hidden ) = $this->get_column_info(); - echo ''; - $this->no_items(); - echo ''; - } } - 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; @@ -196,14 +199,14 @@ class WP_Terms_List_Table extends WP_List_Table { $num_parents = count( $my_parents ); while ( $my_parent = array_pop( $my_parents ) ) { echo "\t"; - $this->single_row( $my_parent, $level - $num_parents, $taxonomy ); + $this->single_row( $my_parent, $level - $num_parents ); $num_parents--; } } if ( $count >= $start ) { echo "\t"; - $this->single_row( $term, $level, $taxonomy ); + $this->single_row( $term, $level ); } ++$count;