WordPress.org

Make WordPress Core

Changeset 12509


Ignore:
Timestamp:
12/23/09 14:25:09 (4 years ago)
Author:
ryan
Message:

Add hierarchical taxonomy handling to wp_set_post_terms(). Props prettyboymp. see #10122

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-includes/post.php

    r12415 r12509  
    20632063 
    20642064    $tags = is_array($tags) ? $tags : explode( ',', trim($tags, " \n\t\r\0\x0B,") ); 
     2065 
     2066    // Hierarchical taxonomies must always pass IDs rather than names so that children with the same 
     2067    // names but different parents aren't confused. 
     2068    $taxonomy_obj = get_taxonomy( $taxonomy ); 
     2069    if ( $taxonomy_obj->hierarchical ) { 
     2070        $tags = array_map( 'intval', $tags ); 
     2071        $tags = array_unique( $tags ); 
     2072    } 
     2073 
    20652074    wp_set_object_terms($post_id, $tags, $taxonomy, $append); 
    20662075} 
Note: See TracChangeset for help on using the changeset viewer.