Changeset 5529 for trunk/wp-admin/admin-functions.php
- Timestamp:
- 05/23/2007 06:07:53 PM (19 years ago)
- File:
-
- 1 edited
-
trunk/wp-admin/admin-functions.php (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-admin/admin-functions.php
r5528 r5529 679 679 680 680 function get_nested_categories( $default = 0, $parent = 0 ) { 681 global $post_ID, $ link_id, $mode, $wpdb;681 global $post_ID, $mode, $wpdb; 682 682 683 683 if ( $post_ID ) { 684 $checked_categories = $wpdb->get_col( " 685 SELECT category_id 686 FROM $wpdb->categories, $wpdb->post2cat 687 WHERE $wpdb->post2cat.category_id = cat_ID AND $wpdb->post2cat.post_id = '$post_ID' AND rel_type = 'category' 688 " ); 684 $checked_categories = wp_get_post_categories($post_ID); 689 685 690 686 if ( count( $checked_categories ) == 0 ) { … … 692 688 $checked_categories[] = $default; 693 689 } 694 } else if ( $link_id ) {695 $checked_categories = $wpdb->get_col( "696 SELECT category_id697 FROM $wpdb->categories, $wpdb->link2cat698 WHERE $wpdb->link2cat.category_id = cat_ID AND $wpdb->link2cat.link_id = '$link_id'699 " );700 701 if ( count( $checked_categories ) == 0 ) {702 // No selected categories, strange703 $checked_categories[] = $default;704 }705 690 } else { 706 691 $checked_categories[] = $default; 707 692 } 708 693 709 $cats = return_categories_list( $parent);694 $cats = get_categories("child_of=$parent&hide_empty=0&get=ids"); 710 695 $result = array (); 711 696 712 697 if ( is_array( $cats ) ) { 713 698 foreach ( $cats as $cat) { 714 $result[$cat]['children'] = get_nested_categories( $default, $cat);699 //$result[$cat]['children'] = get_nested_categories( $default, $cat); 715 700 $result[$cat]['cat_ID'] = $cat; 716 701 $result[$cat]['checked'] = in_array( $cat, $checked_categories ); … … 755 740 } 756 741 757 $categories = get_terms('link_category', 'orderby=count ');742 $categories = get_terms('link_category', 'orderby=count&hide_empty=0'); 758 743 759 744 if ( empty($categories) ) … … 773 758 $categories = get_categories( 'hide_empty=0' ); 774 759 775 $children = _get_ category_hierarchy();760 $children = _get_term_hierarchy('category'); 776 761 777 762 if ( $categories ) { … … 960 945 if ( $categories ) { 961 946 foreach ( $categories as $category ) { 962 if ( $currentcat != $category-> cat_ID && $parent == $category->category_parent) {947 if ( $currentcat != $category->term_id && $parent == $category->parent) { 963 948 $pad = str_repeat( '– ', $level ); 964 $category-> cat_name = wp_specialchars( $category->cat_name );965 echo "\n\t<option value='$category-> cat_ID'";966 if ( $currentparent == $category-> cat_ID)949 $category->name = wp_specialchars( $category->name ); 950 echo "\n\t<option value='$category->term_id'"; 951 if ( $currentparent == $category->term_id ) 967 952 echo " selected='selected'"; 968 echo ">$pad$category-> cat_name</option>";969 wp_dropdown_cats( $currentcat, $currentparent, $category-> cat_ID, $level +1, $categories );953 echo ">$pad$category->name</option>"; 954 wp_dropdown_cats( $currentcat, $currentparent, $category->term_id, $level +1, $categories ); 970 955 } 971 956 }
Note: See TracChangeset
for help on using the changeset viewer.