Changeset 51896
- Timestamp:
- 10/08/2021 12:36:18 AM (3 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-admin/includes/class-wp-terms-list-table.php
r51737 r51896 78 78 */ 79 79 public function prepare_items() { 80 $tags_per_page = $this->get_items_per_page( 'edit_' . $this->screen->taxonomy . '_per_page' ); 81 82 if ( 'post_tag' === $this->screen->taxonomy ) { 80 $taxonomy = $this->screen->taxonomy; 81 82 $tags_per_page = $this->get_items_per_page( "edit_{$taxonomy}_per_page" ); 83 84 if ( 'post_tag' === $taxonomy ) { 83 85 /** 84 86 * Filters the number of terms displayed per page for the Tags list table. … … 99 101 */ 100 102 $tags_per_page = apply_filters_deprecated( 'tagsperpage', array( $tags_per_page ), '2.8.0', 'edit_tags_per_page' ); 101 } elseif ( 'category' === $t his->screen->taxonomy ) {103 } elseif ( 'category' === $taxonomy ) { 102 104 /** 103 105 * Filters the number of terms displayed per page for the Categories list table. … … 113 115 114 116 $args = array( 115 'search' => $search, 116 'page' => $this->get_pagenum(), 117 'number' => $tags_per_page, 117 'taxonomy' => $taxonomy, 118 'search' => $search, 119 'page' => $this->get_pagenum(), 120 'number' => $tags_per_page, 121 'hide_empty' => 0, 118 122 ); 119 123 … … 126 130 } 127 131 132 $args['offset'] = ( $args['page'] - 1 ) * $args['number']; 133 134 // Save the values because 'number' and 'offset' can be subsequently overridden. 128 135 $this->callback_args = $args; 136 137 if ( is_taxonomy_hierarchical( $taxonomy ) && ! isset( $args['orderby'] ) ) { 138 // We'll need the full set of terms then. 139 $args['number'] = 0; 140 $args['offset'] = $args['number']; 141 } 142 143 $this->items = get_terms( $args ); 129 144 130 145 $this->set_pagination_args( … … 132 147 'total_items' => wp_count_terms( 133 148 array( 134 'taxonomy' => $t his->screen->taxonomy,149 'taxonomy' => $taxonomy, 135 150 'search' => $search, 136 151 ) … … 139 154 ) 140 155 ); 141 }142 143 /**144 * @return bool145 */146 public function has_items() {147 // @todo Populate $this->items in prepare_items().148 return true;149 156 } 150 157 … … 217 224 $taxonomy = $this->screen->taxonomy; 218 225 219 $args = wp_parse_args( 220 $this->callback_args, 221 array( 222 'taxonomy' => $taxonomy, 223 'page' => 1, 224 'number' => 20, 225 'search' => '', 226 'hide_empty' => 0, 227 ) 228 ); 229 230 $page = $args['page']; 231 232 // Set variable because $args['number'] can be subsequently overridden. 233 $number = $args['number']; 234 235 $offset = ( $page - 1 ) * $number; 236 $args['offset'] = $offset; 226 $number = $this->callback_args['number']; 227 $offset = $this->callback_args['offset']; 237 228 238 229 // Convert it to table rows. 239 230 $count = 0; 240 231 241 if ( is_taxonomy_hierarchical( $taxonomy ) && ! isset( $args['orderby'] ) ) { 242 // We'll need the full set of terms then. 243 $args['number'] = 0; 244 $args['offset'] = $args['number']; 245 } 246 247 $terms = get_terms( $args ); 248 249 if ( empty( $terms ) || ! is_array( $terms ) ) { 232 if ( empty( $this->items ) || ! is_array( $this->items ) ) { 250 233 echo '<tr class="no-items"><td class="colspanchange" colspan="' . $this->get_column_count() . '">'; 251 234 $this->no_items(); … … 254 237 } 255 238 256 if ( is_taxonomy_hierarchical( $taxonomy ) && ! isset( $ args['orderby'] ) ) {257 if ( ! empty( $ args['search'] ) ) {// Ignore children on searches.239 if ( is_taxonomy_hierarchical( $taxonomy ) && ! isset( $this->callback_args['orderby'] ) ) { 240 if ( ! empty( $this->callback_args['search'] ) ) {// Ignore children on searches. 258 241 $children = array(); 259 242 } else { … … 265 248 * Skip it for non-hierarchical taxonomies for performance sake. 266 249 */ 267 $this->_rows( $taxonomy, $t erms, $children, $offset, $number, $count );250 $this->_rows( $taxonomy, $this->items, $children, $offset, $number, $count ); 268 251 } else { 269 foreach ( $t erms as $term ) {252 foreach ( $this->items as $term ) { 270 253 $this->single_row( $term ); 271 254 }
Note: See TracChangeset
for help on using the changeset viewer.