Make WordPress Core


Ignore:
Timestamp:
05/23/2007 06:07:53 PM (19 years ago)
Author:
ryan
Message:

Set and get post cats to taxonomy. see #4189

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/admin-functions.php

    r5528 r5529  
    679679
    680680function get_nested_categories( $default = 0, $parent = 0 ) {
    681     global $post_ID, $link_id, $mode, $wpdb;
     681    global $post_ID, $mode, $wpdb;
    682682
    683683    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);
    689685
    690686        if ( count( $checked_categories ) == 0 ) {
     
    692688            $checked_categories[] = $default;
    693689        }
    694     } else if ( $link_id ) {
    695         $checked_categories = $wpdb->get_col( "
    696              SELECT category_id
    697              FROM $wpdb->categories, $wpdb->link2cat
    698              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, strange
    703             $checked_categories[] = $default;
    704         }
    705690    } else {
    706691        $checked_categories[] = $default;
    707692    }
    708693
    709     $cats = return_categories_list( $parent);
     694    $cats = get_categories("child_of=$parent&hide_empty=0&get=ids");
    710695    $result = array ();
    711696
    712697    if ( is_array( $cats ) ) {
    713698        foreach ( $cats as $cat) {
    714             $result[$cat]['children'] = get_nested_categories( $default, $cat);
     699            //$result[$cat]['children'] = get_nested_categories( $default, $cat);
    715700            $result[$cat]['cat_ID'] = $cat;
    716701            $result[$cat]['checked'] = in_array( $cat, $checked_categories );
     
    755740    }
    756741
    757     $categories = get_terms('link_category', 'orderby=count');
     742    $categories = get_terms('link_category', 'orderby=count&hide_empty=0');
    758743   
    759744    if ( empty($categories) )
     
    773758        $categories = get_categories( 'hide_empty=0' );
    774759
    775     $children = _get_category_hierarchy();
     760    $children = _get_term_hierarchy('category');
    776761
    777762    if ( $categories ) {
     
    960945    if ( $categories ) {
    961946        foreach ( $categories as $category ) {
    962             if ( $currentcat != $category->cat_ID && $parent == $category->category_parent) {
     947            if ( $currentcat != $category->term_id && $parent == $category->parent) {
    963948                $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 )
    967952                    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 );
    970955            }
    971956        }
Note: See TracChangeset for help on using the changeset viewer.