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

git-svn-id: http://svn.automattic.com/wordpress/trunk@14580 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
ryan 2010-05-12 19:12:18 +00:00
parent 0961da9244
commit e65ae591a0

View File

@ -311,20 +311,24 @@ function bulk_edit_posts( $post_data = null ) {
}
$tax_names = get_object_taxonomies( get_post($post_ID) );
if ( isset($new_cats) && in_array( 'category', $tax_names ) ) {
$cats = (array) wp_get_post_categories($post_ID);
$post_data['post_category'] = array_unique( array_merge($cats, $new_cats) );
}
foreach ( $tax_names as $tax_name ) {
if( isset( $tax_input[$tax_name]) ) {
if ( is_taxonomy_hierarchical( $tax_name ) )
$terms = (array) wp_get_object_terms( $post_ID, $tax_name, array('fields' => 'ids') );
else
$terms = (array) wp_get_object_terms( $post_ID, $tax_name, array('fields' => 'names') );
$post_data['tax_input'][$tax_name] = array_merge( $terms, $tax_input[$tax_name] );
}
$taxonomy_obj = get_taxonomy($tax_name);
if( isset( $tax_input[$tax_name]) && current_user_can( $taxonomy_obj->assign_cap ) )
$new_terms = $tax_input[$tax_name];
else
$new_terms = array();
if ( $taxonomy_obj->hierarchical )
$current_terms = (array) wp_get_object_terms( $post_ID, $tax_name, array('fields' => 'ids') );
else
$current_terms = (array) wp_get_object_terms( $post_ID, $tax_name, array('fields' => 'names') );
$post_data['tax_input'][$tax_name] = array_merge( $current_terms, $new_terms );
}
$post_data['ID'] = $post_ID;
@ -1606,4 +1610,4 @@ tinyMCE.init(tinyMCEPreInit.mceInit);
/* ]]> */
</script>
<?php
}
}