Ticket #54181: 54181.3.diff
File 54181.3.diff, 4.6 KB (added by , 3 years ago) |
---|
-
src/wp-admin/includes/class-wp-terms-list-table.php
77 77 /** 78 78 */ 79 79 public function prepare_items() { 80 $ta gs_per_page = $this->get_items_per_page( 'edit_' . $this->screen->taxonomy . '_per_page' );80 $taxonomy = $this->screen->taxonomy; 81 81 82 if ( 'post_tag' === $this->screen->taxonomy ) { 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. 85 87 * … … 98 100 * @param int $tags_per_page Number of tags to be displayed. Default 20. 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. 104 106 * … … 112 114 $search = ! empty( $_REQUEST['s'] ) ? trim( wp_unslash( $_REQUEST['s'] ) ) : ''; 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 120 124 if ( ! empty( $_REQUEST['orderby'] ) ) { … … 125 129 $args['order'] = trim( wp_unslash( $_REQUEST['order'] ) ); 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; 129 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 ); 144 130 145 $this->set_pagination_args( 131 146 array( 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 ) 137 152 ), … … 141 156 } 142 157 143 158 /** 144 * @return bool145 159 */ 146 public function has_items() {147 // @todo Populate $this->items in prepare_items().148 return true;149 }150 151 /**152 */153 160 public function no_items() { 154 161 echo get_taxonomy( $this->screen->taxonomy )->labels->not_found; 155 162 } … … 216 223 public function display_rows_or_placeholder() { 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 ); 226 $number = $this->callback_args['number']; 227 $offset = $this->callback_args['offset']; 229 228 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;237 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(); 252 235 echo '</td></tr>'; … … 253 236 return; 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 { 260 243 $children = _get_term_hierarchy( $taxonomy ); … … 264 247 * Some funky recursion to get the job done (paging & parents mainly) is contained within. 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 } 272 255 }