Changeset 12798 for trunk/wp-admin/includes/template.php
- Timestamp:
- 01/22/2010 07:30:05 PM (16 years ago)
- File:
-
- 1 edited
-
trunk/wp-admin/includes/template.php (modified) (9 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-admin/includes/template.php
r12797 r12798 466 466 function start_el(&$output, $category, $depth, $args) { 467 467 extract($args); 468 if ( empty($taxonomy) ) 469 $taxonomy = 'category'; 470 471 if ( $taxonomy == 'category' ) 472 $name = 'post_category'; 473 else 474 $name = 'tax_input['.$taxonomy.']'; 468 475 469 476 $class = in_array( $category->term_id, $popular_cats ) ? ' class="popular-category"' : ''; 470 $output .= "\n<li id=' category-$category->term_id'$class>" . '<label class="selectit"><input value="' . $category->term_id . '" type="checkbox" name="post_category[]" id="in-category-' . $category->term_id . '"' . (in_array( $category->term_id, $selected_cats ) ? ' checked="checked"' : "" ) . '/> ' . esc_html( apply_filters('the_category', $category->name )) . '</label>';477 $output .= "\n<li id='{$taxonomy}-{$category->term_id}'$class>" . '<label class="selectit"><input value="' . $category->term_id . '" type="checkbox" name="'.$name.'[]" id="in-'.$taxonomy.'-' . $category->term_id . '"' . (in_array( $category->term_id, $selected_cats ) ? ' checked="checked"' : "" ) . '/> ' . esc_html( apply_filters('the_category', $category->name )) . '</label>'; 471 478 } 472 479 … … 487 494 */ 488 495 function wp_category_checklist( $post_id = 0, $descendants_and_self = 0, $selected_cats = false, $popular_cats = false, $walker = null, $checked_ontop = true ) { 496 wp_terms_checklist($post_id, 497 array( 498 'taxonomy' => 'category', 499 'descendants_and_self' => $descendants_and_self, 500 'selected_cats' => $selected_cats, 501 'popular_cats' => $popular_cats, 502 'walker' => $walker, 503 'checked_ontop' => $checked_ontop 504 )); 505 } 506 507 /** 508 * Taxonomy independent version of wp_category_checklist 509 * 510 * @param int $post_id 511 * @param array $args 512 */ 513 function wp_terms_checklist($post_id = 0, $args = array()) { 514 $defaults = array( 515 'descendants_and_self' => 0, 516 'selected_cats' => false, 517 'popular_cats' => false, 518 'walker' => null, 519 'taxonomy' => 'category', 520 'checked_ontop' => true 521 ); 522 extract( wp_parse_args($args, $defaults), EXTR_SKIP ); 523 489 524 if ( empty($walker) || !is_a($walker, 'Walker') ) 490 525 $walker = new Walker_Category_Checklist; … … 492 527 $descendants_and_self = (int) $descendants_and_self; 493 528 494 $args = array( );529 $args = array('taxonomy' => $taxonomy); 495 530 496 531 if ( is_array( $selected_cats ) ) 497 532 $args['selected_cats'] = $selected_cats; 498 533 elseif ( $post_id ) 499 $args['selected_cats'] = wp_get_ post_categories($post_id);534 $args['selected_cats'] = wp_get_object_terms($post_id, $taxonomy, array_merge($args, array('fields' => 'ids'))); 500 535 else 501 536 $args['selected_cats'] = array(); … … 504 539 $args['popular_cats'] = $popular_cats; 505 540 else 506 $args['popular_cats'] = get_terms( 'category', array( 'fields' => 'ids', 'orderby' => 'count', 'order' => 'DESC', 'number' => 10, 'hierarchical' => false ) );541 $args['popular_cats'] = get_terms( $taxonomy, array( 'fields' => 'ids', 'orderby' => 'count', 'order' => 'DESC', 'number' => 10, 'hierarchical' => false ) ); 507 542 508 543 if ( $descendants_and_self ) { 509 $categories = get_categories(array('child_of' => $descendants_and_self, 'hierarchical' => 0, 'hide_empty' => 0));510 $self = get_ category( $descendants_and_self);544 $categories = (array) get_terms($taxonomy, array( 'child_of' => $descendants_and_self, 'hierarchical' => 0, 'hide_empty' => 0 ) ); 545 $self = get_term( $descendants_and_self, $taxonomy ); 511 546 array_unshift( $categories, $self ); 512 547 } else { 513 $categories = get_categories(array('get' => 'all'));548 $categories = (array) get_terms($taxonomy, array('get' => 'all')); 514 549 } 515 550 … … 548 583 549 584 if ( $post_ID ) 550 $checked_categories = wp_get_ post_categories($post_ID);585 $checked_categories = wp_get_object_terms($post_ID, 'category', array('fields'=>'ids')); 551 586 else 552 587 $checked_categories = array(); … … 559 594 if ( !$echo ) // hack for AJAX use 560 595 continue; 561 $id = "popular- category-$category->term_id";596 $id = "popular-$taxonomy-$category->term_id"; 562 597 $checked = in_array( $category->term_id, $checked_categories ) ? 'checked="checked"' : ''; 563 598 ?> … … 3835 3870 * 3836 3871 * @uses $current_screen 3837 * 3872 * 3838 3873 * @param string $id Screen id, optional. 3839 3874 */ … … 3852 3887 $current_screen = array('id' => $id, 'base' => $id); 3853 3888 } 3854 3889 3855 3890 $current_screen = (object) $current_screen; 3856 3891 3857 3892 if ( 'edit' == $current_screen->id ) { 3858 3893 if ( empty($typenow) ) … … 3868 3903 $typenow = ''; 3869 3904 } 3870 3905 3871 3906 $current_screen = apply_filters('current_screen', $current_screen); 3872 3907 }
Note: See TracChangeset
for help on using the changeset viewer.