Changeset 12022 for trunk/wp-admin/includes/template.php
- Timestamp:
- 10/13/2009 10:02:42 AM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-admin/includes/template.php
r12016 r12022 488 488 * @param unknown_type $popular_cats 489 489 */ 490 function wp_category_checklist( $post_id = 0, $descendants_and_self = 0, $selected_cats = false, $popular_cats = false, $walker = null ) {490 function wp_category_checklist( $post_id = 0, $descendants_and_self = 0, $selected_cats = false, $popular_cats = false, $walker = null, $checked_ontop = true ) { 491 491 if ( empty($walker) || !is_a($walker, 'Walker') ) 492 492 $walker = new Walker_Category_Checklist; … … 516 516 } 517 517 518 // Post process $categories rather than adding an exclude to the get_terms() query to keep the query the same across all posts (for any query cache) 519 $checked_categories = array(); 520 $keys = array_keys( $categories ); 521 522 foreach( $keys as $k ) { 523 if ( in_array( $categories[$k]->term_id, $args['selected_cats'] ) ) { 524 $checked_categories[] = $categories[$k]; 525 unset( $categories[$k] ); 518 if ( $checked_ontop ) { 519 // Post process $categories rather than adding an exclude to the get_terms() query to keep the query the same across all posts (for any query cache) 520 $checked_categories = array(); 521 $keys = array_keys( $categories ); 522 523 foreach( $keys as $k ) { 524 if ( in_array( $categories[$k]->term_id, $args['selected_cats'] ) ) { 525 $checked_categories[] = $categories[$k]; 526 unset( $categories[$k] ); 527 } 526 528 } 527 } 528 529 // Put checked cats on top530 echo call_user_func_array(array(&$walker, 'walk'), array($checked_categories, 0, $args));529 530 // Put checked cats on top 531 echo call_user_func_array(array(&$walker, 'walk'), array($checked_categories, 0, $args)); 532 } 531 533 // Then the rest of them 532 534 echo call_user_func_array(array(&$walker, 'walk'), array($categories, 0, $args)); … … 546 548 function wp_popular_terms_checklist( $taxonomy, $default = 0, $number = 10, $echo = true ) { 547 549 global $post_ID; 550 548 551 if ( $post_ID ) 549 552 $checked_categories = wp_get_post_categories($post_ID); 550 553 else 551 554 $checked_categories = array(); 555 552 556 $categories = get_terms( $taxonomy, array( 'orderby' => 'count', 'order' => 'DESC', 'number' => $number, 'hierarchical' => false ) ); 553 557 … … 558 562 continue; 559 563 $id = "popular-category-$category->term_id"; 564 $checked = in_array( $category->term_id, $checked_categories ) ? 'checked="checked"' : ''; 560 565 ?> 561 566 562 567 <li id="<?php echo $id; ?>" class="popular-category"> 563 568 <label class="selectit"> 564 <input id="in-<?php echo $id; ?>" type="checkbox" value="<?php echo (int) $category->term_id; ?>" />569 <input id="in-<?php echo $id; ?>" type="checkbox" <?php echo $checked; ?> value="<?php echo (int) $category->term_id; ?>" /> 565 570 <?php echo esc_html( apply_filters( 'the_category', $category->name ) ); ?> 566 571 </label> … … 3059 3064 // Hide slug boxes by default 3060 3065 if ( empty($hidden[0]) ) { 3061 if ( 'page' == $page ) 3062 $hidden = array('pageslugdiv'); 3063 elseif ( 'post' == $page ) 3064 $hidden = array('slugdiv'); 3066 $hidden = array('slugdiv'); 3065 3067 } 3066 3068
Note: See TracChangeset
for help on using the changeset viewer.