Make WordPress Core

Ticket #10122: wp_insert_post.diff

File wp_insert_post.diff, 1016 bytes (added by scribu, 15 years ago)

allow clearing all terms

  • wp-includes/post.php

     
    22292229        // old-style tags_input
    22302230        if ( isset( $tags_input ) )
    22312231                wp_set_post_tags( $post_ID, $tags_input );
    2232         // new-style support for all tag-like taxonomies
     2232        // new-style support for all taxonomies
    22332233        if ( !empty($tax_input) ) {
    2234                 foreach ( $tax_input as $taxonomy => $tags ) {
    2235                         $taxonomy_obj = get_taxonomy($taxonomy);
    2236                         if ( current_user_can($taxonomy_obj->assign_cap) )
    2237                                 wp_set_post_terms( $post_ID, $tags, $taxonomy );
     2234                $tax_names = get_object_taxonomies( get_post($post_ID) );
     2235
     2236                foreach ( $tax_names as $tax_name ) {
     2237                        $tax_obj = get_taxonomy($tax_name);
     2238                        if ( !current_user_can($tax_obj->assign_cap) )
     2239                                continue;
     2240
     2241                        if ( isset($tax_input[$tax_name]) )
     2242                                $term = $tax_input[$tax_name];
     2243                        else
     2244                                $term = array();
     2245
     2246                        wp_set_post_terms( $post_ID, $term, $tax_name );
    22382247                }
    22392248        }
    22402249