Make WordPress Core


Ignore:
Timestamp:
03/26/2007 07:28:29 AM (19 years ago)
Author:
matt
Message:

A backend interface for tagging.

File:
1 edited

Legend:

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

    r5089 r5110  
    648648function return_categories_list( $parent = 0 ) {
    649649    global $wpdb;
    650     return $wpdb->get_col( "SELECT cat_ID FROM $wpdb->categories WHERE category_parent = $parent AND ( link_count = 0 OR category_count != 0 OR ( link_count = 0 AND category_count = 0 ) ) ORDER BY category_count DESC" );
     650    return $wpdb->get_col( "SELECT cat_ID FROM $wpdb->categories WHERE category_parent = $parent AND ( ( link_count = 0 AND tag_count = 0 ) OR category_count != 0 OR ( link_count = 0 AND category_count = 0 AND tag_count = 0 ) ) ORDER BY category_count DESC" );
    651651}
    652652
     
    658658}
    659659
     660function get_tags_to_edit( $post_id ) {
     661    global $wpdb;
     662
     663    $post_id = (int) $post_id;
     664    if ( !$post_id )
     665        return false;
     666
     667    $tags = $wpdb->get_results( "
     668             SELECT category_id, cat_name
     669             FROM $wpdb->categories, $wpdb->post2cat
     670             WHERE $wpdb->post2cat.category_id = cat_ID AND $wpdb->post2cat.post_id = '$post_id' AND rel_type = 'tag'
     671             " );
     672    if ( !$tags )
     673        return false;
     674
     675    foreach ( $tags as $tag )
     676        $tag_names[] = $tag->cat_name;
     677    $tags_to_edit = join( ', ', $tag_names );
     678    $tags_to_edit = attribute_escape( $tags_to_edit );
     679    $tags_to_edit = apply_filters( 'tags_to_edit', $tags_to_edit );
     680    return $tags_to_edit;
     681}
     682
    660683function get_nested_categories( $default = 0, $parent = 0 ) {
    661684    global $post_ID, $link_id, $mode, $wpdb;
     
    665688             SELECT category_id
    666689             FROM $wpdb->categories, $wpdb->post2cat
    667              WHERE $wpdb->post2cat.category_id = cat_ID AND $wpdb->post2cat.post_id = '$post_ID'
     690             WHERE $wpdb->post2cat.category_id = cat_ID AND $wpdb->post2cat.post_id = '$post_ID' AND rel_type = 'category'
    668691             " );
    669692
     
    722745function return_link_categories_list( $parent = 0 ) {
    723746    global $wpdb;
    724     return $wpdb->get_col( "SELECT cat_ID FROM $wpdb->categories WHERE category_parent = $parent AND ( category_count = 0  OR link_count != 0 OR ( link_count = 0 AND category_count = 0 ) ) ORDER BY link_count DESC" );
     747    return $wpdb->get_col( "SELECT cat_ID FROM $wpdb->categories WHERE category_parent = $parent AND ( ( category_count = 0 AND tag_count = 0 ) OR link_count != 0 OR ( link_count = 0 AND category_count = 0 AND tag_count = 0 ) ) ORDER BY link_count DESC" );
    725748}
    726749
Note: See TracChangeset for help on using the changeset viewer.