Make WordPress Core


Ignore:
Timestamp:
07/06/2006 04:27:45 AM (20 years ago)
Author:
matt
Message:

Some renames

File:
1 edited

Legend:

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

    r3985 r3999  
    637637function dropdown_categories($default = 0) {
    638638        write_nested_categories(get_nested_categories($default));
     639}
     640
     641function return_link_categories_list($parent = 0) {
     642        global $wpdb;
     643        return $wpdb->get_col("SELECT cat_ID FROM $wpdb->categories WHERE category_parent = $parent AND link_count > 0");
     644}
     645
     646function get_nested_link_categories( $default = 0, $parent = 0 ) {
     647        global $post_ID, $link_id, $mode, $wpdb;
     648
     649        if ($link_id) {
     650                $checked_categories = $wpdb->get_col("
     651                     SELECT category_id
     652                     FROM $wpdb->categories, $wpdb->link2cat
     653                     WHERE $wpdb->link2cat.category_id = cat_ID AND $wpdb->link2cat.link_id = '$link_id'
     654                     ");
     655
     656                if (count($checked_categories) == 0) {
     657                        // No selected categories, strange
     658                        $checked_categories[] = $default;
     659                }       
     660        } else {
     661                $checked_categories[] = $default;
     662        }
     663
     664        $cats = return_link_categories_list($parent);
     665        $result = array ();
     666
     667        if (is_array($cats)) {
     668                foreach ($cats as $cat) {
     669                        $result[$cat]['children'] = get_nested_link_categories($default, $cat);
     670                        $result[$cat]['cat_ID'] = $cat;
     671                        $result[$cat]['checked'] = in_array($cat, $checked_categories);
     672                        $result[$cat]['cat_name'] = get_the_category_by_ID($cat);
     673                }
     674        }
     675
     676        usort($result, 'sort_cats');
     677
     678        return $result;
     679}
     680
     681function dropdown_link_categories($default = 0) {
     682        write_nested_categories(get_nested_link_categories($default));
    639683}
    640684
    … …  
    770814                return false;
    771815        }
    772 }
    773 
    774 function return_link_categories_list($parent = 0) {
    775         global $wpdb;
    776         return $wpdb->get_col("SELECT cat_ID FROM $wpdb->categories WHERE category_parent = $parent ORDER BY link_count DESC");
    777816}
    778817
Note: See TracChangeset for help on using the changeset viewer.