Ticket #7136: category_paging.diff
| File category_paging.diff, 3.7 kB (added by ryan, 6 months ago) |
|---|
-
wp-admin/includes/template.php
old new 4 4 // Big Mess 5 5 // 6 6 7 // Dandy new recursive multiple category stuff.8 function cat_rows( $parent = 0, $level = 0, $categories= 0 ) {9 if ( !$categories) {7 // Ugly recursive category stuff. 8 function cat_rows( $parent = 0, $level = 0, &$categories = 0, $page = 1, $per_page = 20, &$count = 0 ) { 9 if ( empty($categories) ) { 10 10 $args = array('hide_empty' => 0); 11 if ( !empty($_GET['s']) ) 11 if ( !empty($_GET['s']) ) { 12 12 $args['search'] = $_GET['s']; 13 $parent = -1; 14 } 13 15 $categories = get_categories( $args ); 14 16 } 15 17 18 if ( !$categories ) 19 return false; 20 16 21 $children = _get_term_hierarchy('category'); 17 22 18 if ( $categories ) { 19 ob_start(); 20 foreach ( $categories as $category ) { 21 if ( $category->parent == $parent) { 22 echo "\t" . _cat_row( $category, $level ); 23 if ( isset($children[$category->term_id]) ) 24 cat_rows( $category->term_id, $level +1, $categories ); 23 $start = ($page - 1) * $per_page; 24 $end = $start + $per_page; 25 $i = -1; 26 ob_start(); 27 foreach ( $categories as $category ) { 28 if ( $count >= $end ) 29 break; 30 31 $i++; 32 33 if ( ($category->parent != $parent) && ( -1 != $parent) ) 34 continue; 35 36 // If the page starts in a subtree, print the parents. 37 if ( $count == $start && $category->parent > 0 ) { 38 $my_parents = array(); 39 $my_parent = $category->parent; 40 while ( $my_parent) { 41 $my_parent = get_category($my_parent); 42 $my_parents[] = $my_parent; 43 if ( !$my_parent->parent ) 44 break; 45 $my_parent = $my_parent->parent; 25 46 } 47 $num_parents = count($my_parents); 48 while( $my_parent = array_pop($my_parents) ) { 49 echo "\t" . _cat_row( $my_parent, $level - $num_parents ); 50 $num_parents--; 51 } 26 52 } 27 $output = ob_get_contents();28 ob_end_clean();29 53 30 $output = apply_filters('cat_rows', $output); 54 if ( $count >= $start ) 55 echo "\t" . _cat_row( $category, $level ); 31 56 32 echo $output; 33 } else { 34 return false; 57 unset($categories[$i]); // Prune the working set 58 $count++; 59 60 if ( isset($children[$category->term_id]) ) 61 cat_rows( $category->term_id, $level + 1, $categories, $page, $per_page, $count ); 62 35 63 } 64 65 $output = ob_get_contents(); 66 ob_end_clean(); 67 68 $output = apply_filters('cat_rows', $output); 69 70 echo $output; 36 71 } 37 72 38 73 function _cat_row( $category, $level, $name_override = false ) { -
wp-admin/categories.php
old new 135 135 136 136 <div class="tablenav"> 137 137 138 <?php 139 $pagenum = absint( $_GET['pagenum'] ); 140 if ( empty($pagenum) ) 141 $pagenum = 1; 142 if( !$catsperpage || $catsperpage < 0 ) 143 $catsperpage = 20; 144 145 $page_links = paginate_links( array( 146 'base' => add_query_arg( 'pagenum', '%#%' ), 147 'format' => '', 148 'total' => ceil(wp_count_terms('category') / $catsperpage), 149 'current' => $pagenum 150 )); 151 152 if ( $page_links ) 153 echo "<div class='tablenav-pages'>$page_links</div>"; 154 ?> 155 138 156 <div class="alignleft"> 139 157 <input type="submit" value="<?php _e('Delete'); ?>" name="deleteit" class="button-secondary delete" /> 140 158 <?php wp_nonce_field('bulk-categories'); ?> … … 156 174 </thead> 157 175 <tbody id="the-list" class="list:cat"> 158 176 <?php 159 cat_rows(); 177 $categories = array(); 178 cat_rows(0, 0, $categories, $pagenum, $catsperpage); 160 179 ?> 161 180 </tbody> 162 181 </table> 163 182 </form> 164 183 165 184 <div class="tablenav"> 185 186 <?php 187 if ( $page_links ) 188 echo "<div class='tablenav-pages'>$page_links</div>"; 189 ?> 166 190 <br class="clear" /> 167 191 </div> 168 192 <br class="clear" />
