Make WordPress Core


Ignore:
Timestamp:
05/23/2007 07:15:10 AM (18 years ago)
Author:
ryan
Message:

Start moving link categories to taxonomy. see #4189

File:
1 edited

Legend:

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

    r5510 r5523  
    741741}
    742742
    743 function return_link_categories_list( $parent = 0 ) {
    744     global $wpdb;
    745     return $wpdb->get_col( "SELECT cat_ID FROM $wpdb->categories WHERE category_parent = $parent AND ( type & " . TAXONOMY_CATEGORY . " != 0 ) AND ( category_count = 0 OR link_count != 0 ) ORDER BY link_count DESC" );
    746 }
    747 
    748 function get_nested_link_categories( $default = 0, $parent = 0 ) {
    749     global $post_ID, $link_id, $mode, $wpdb;
     743function dropdown_link_categories( $default = 0 ) {
     744    global $link_id;
    750745
    751746    if ( $link_id ) {
    752         $checked_categories = $wpdb->get_col( "
    753              SELECT category_id
    754              FROM $wpdb->categories, $wpdb->link2cat
    755              WHERE $wpdb->link2cat.category_id = cat_ID AND $wpdb->link2cat.link_id = '$link_id'
    756              " );
     747        $checked_categories = wp_get_link_cats($link_id);
    757748
    758749        if ( count( $checked_categories ) == 0 ) {
     
    764755    }
    765756
    766     $cats = return_link_categories_list( $parent);
    767     $result = array ();
    768 
    769     if ( is_array( $cats ) ) {
    770         foreach ( $cats as $cat) {
    771             $result[$cat]['children'] = get_nested_link_categories( $default, $cat);
    772             $result[$cat]['cat_ID'] = $cat;
    773             $result[$cat]['checked'] = in_array( $cat, $checked_categories );
    774             $result[$cat]['cat_name'] = get_the_category_by_ID( $cat);
    775         }
    776     }
    777 
    778     usort( $result, 'sort_cats' );
    779 
    780     return $result;
    781 }
    782 
    783 function dropdown_link_categories( $default = 0 ) {
    784     write_nested_categories( get_nested_link_categories( $default) );
     757    $categories = get_terms('link_category', 'orderby=count');
     758   
     759    if ( empty($categories) )
     760        return;
     761
     762    foreach ( $categories as $category ) {
     763        $cat_id = $category->term_id;
     764        $name = wp_specialchars( apply_filters('the_category', $category->name));
     765        $checked = in_array( $cat_id, $checked_categories );
     766        echo '<li id="category-', $cat_id, '"><label for="in-category-', $cat_id, '" class="selectit"><input value="', $cat_id, '" type="checkbox" name="post_category[]" id="in-category-', $cat_id, '"', ($checked ? ' checked="checked"' : "" ), '/> ', $name, "</label></li>";
     767    }
    785768}
    786769
Note: See TracChangeset for help on using the changeset viewer.