Changeset 8078
- Timestamp:
- 06/13/2008 11:22:29 PM (18 years ago)
- Location:
- trunk/wp-admin
- Files:
-
- 2 edited
-
categories.php (modified) (3 diffs)
-
includes/template.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-admin/categories.php
r7883 r8078 135 135 136 136 <div class="tablenav"> 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 ?> 137 155 138 156 <div class="alignleft"> … … 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> … … 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> -
trunk/wp-admin/includes/template.php
r7956 r8078 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 11 if ( !empty($_GET['s']) ) … … 14 14 } 15 15 16 if ( !$categories ) 17 return false; 18 16 19 $children = _get_term_hierarchy('category'); 17 20 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 ); 21 $start = ($page - 1) * $per_page; 22 $end = $start + $per_page; 23 $i = -1; 24 ob_start(); 25 foreach ( $categories as $category ) { 26 if ( $count >= $end ) 27 break; 28 29 $i++; 30 31 if ( $category->parent != $parent ) 32 continue; 33 34 // If the page starts in a subtree, print the parents. 35 if ( $count == $start && $category->parent > 0 ) { 36 $my_parents = array(); 37 $my_parent = $category->parent; 38 while ( $my_parent) { 39 $my_parent = get_category($my_parent); 40 $my_parents[] = $my_parent; 41 if ( !$my_parent->parent ) 42 break; 43 $my_parent = $my_parent->parent; 25 44 } 26 } 27 $output = ob_get_contents(); 28 ob_end_clean(); 29 30 $output = apply_filters('cat_rows', $output); 31 32 echo $output; 33 } else { 34 return false; 35 } 45 $num_parents = count($my_parents); 46 while( $my_parent = array_pop($my_parents) ) { 47 echo "\t" . _cat_row( $my_parent, $level - $num_parents ); 48 $num_parents--; 49 } 50 } 51 52 if ( $count >= $start ) 53 echo "\t" . _cat_row( $category, $level ); 54 55 unset($categories[$i]); // Prune the working set 56 $count++; 57 58 if ( isset($children[$category->term_id]) ) 59 cat_rows( $category->term_id, $level + 1, $categories, $page, $per_page, $count ); 60 61 } 62 63 $output = ob_get_contents(); 64 ob_end_clean(); 65 66 $output = apply_filters('cat_rows', $output); 67 68 echo $output; 36 69 } 37 70
Note: See TracChangeset
for help on using the changeset viewer.