Make WordPress Core


Ignore:
Timestamp:
12/18/2008 07:12:26 PM (16 years ago)
Author:
ryan
Message:

Allow muliple tag-like taxonomies in the post editor. see #6387

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/includes/taxonomy.php

    r9481 r10222  
    195195 * @return unknown
    196196 */
    197 function get_tags_to_edit( $post_id ) {
     197function get_tags_to_edit( $post_id, $taxonomy = 'post_tag' ) {
     198    return get_terms_to_edit( $post_id, $taxonomy);
     199}
     200
     201/**
     202 * {@internal Missing Short Description}}
     203 *
     204 * @since unknown
     205 *
     206 * @param unknown_type $post_id
     207 * @return unknown
     208 */
     209function get_terms_to_edit( $post_id, $taxonomy = 'post_tag' ) {
    198210    $post_id = (int) $post_id;
    199211    if ( !$post_id )
    200212        return false;
    201213
    202     $tags = wp_get_post_tags($post_id);
     214    $tags = wp_get_post_terms($post_id, $taxonomy, array());
    203215
    204216    if ( !$tags )
    205217        return false;
    206218
     219    if ( is_wp_error($tags) )
     220        return $tags;
     221   
    207222    foreach ( $tags as $tag )
    208223        $tag_names[] = $tag->name;
    209224    $tags_to_edit = join( ',', $tag_names );
    210225    $tags_to_edit = attribute_escape( $tags_to_edit );
    211     $tags_to_edit = apply_filters( 'tags_to_edit', $tags_to_edit );
     226    $tags_to_edit = apply_filters( 'terms_to_edit', $tags_to_edit, $taxonomy );
     227
    212228    return $tags_to_edit;
    213229}
     
    234250 */
    235251function wp_create_tag($tag_name) {
    236     if ( $id = tag_exists($tag_name) )
     252    return wp_create_term( $tag_name, 'post_tag');
     253}
     254
     255/**
     256 * {@internal Missing Short Description}}
     257 *
     258 * @since unknown
     259 *
     260 * @param unknown_type $tag_name
     261 * @return unknown
     262 */
     263function wp_create_term($tag_name, $taxonomy = 'post_tag') {
     264    if ( $id = is_term($tag_name, $taxonomy) )
    237265        return $id;
    238266
    239     return wp_insert_term($tag_name, 'post_tag');
    240 }
    241 
    242 ?>
     267    return wp_insert_term($tag_name, $taxonomy);
     268}
Note: See TracChangeset for help on using the changeset viewer.