Make WordPress Core

Changeset 14580


Ignore:
Timestamp:
05/12/2010 07:12:18 PM (14 years ago)
Author:
ryan
Message:

Fix bulk editing of non-hierarchical taxonomies. Props prettyboymp. fixes #13153

File:
1 edited

Legend:

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

    r14571 r14580  
    312312
    313313        $tax_names = get_object_taxonomies( get_post($post_ID) );
    314 
    315314        if ( isset($new_cats) && in_array( 'category', $tax_names ) ) {
    316315            $cats = (array) wp_get_post_categories($post_ID);
     
    319318
    320319        foreach ( $tax_names as $tax_name ) {
    321             if( isset( $tax_input[$tax_name])  ) {
    322                 if ( is_taxonomy_hierarchical( $tax_name ) )
    323                     $terms = (array) wp_get_object_terms( $post_ID, $tax_name, array('fields' => 'ids') );
    324                 else
    325                     $terms = (array) wp_get_object_terms( $post_ID, $tax_name, array('fields' => 'names') );
    326                 $post_data['tax_input'][$tax_name] = array_merge( $terms, $tax_input[$tax_name] );
    327             }
     320            $taxonomy_obj = get_taxonomy($tax_name);
     321            if(  isset( $tax_input[$tax_name]) && current_user_can( $taxonomy_obj->assign_cap ) )
     322                $new_terms = $tax_input[$tax_name];
     323            else
     324                $new_terms = array();
     325               
     326            if ( $taxonomy_obj->hierarchical )
     327                $current_terms = (array) wp_get_object_terms( $post_ID, $tax_name, array('fields' => 'ids') );
     328            else
     329                $current_terms = (array) wp_get_object_terms( $post_ID, $tax_name, array('fields' => 'names') );
     330
     331            $post_data['tax_input'][$tax_name] = array_merge( $current_terms, $new_terms );
    328332        }
    329333
Note: See TracChangeset for help on using the changeset viewer.