Allow edit posts page to save a empty set of terms for a custom hierarchical taxonomy. Props scribu for initial patch. See #10122

git-svn-id: http://svn.automattic.com/wordpress/trunk@14230 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
dd32 2010-04-25 07:42:51 +00:00
parent 99b439c6f7
commit e79df91561
1 changed files with 16 additions and 10 deletions

View File

@ -2229,14 +2229,20 @@ function wp_insert_post($postarr = array(), $wp_error = false) {
// old-style tags_input // old-style tags_input
if ( isset( $tags_input ) ) if ( isset( $tags_input ) )
wp_set_post_tags( $post_ID, $tags_input ); wp_set_post_tags( $post_ID, $tags_input );
// new-style support for all tag-like taxonomies // new-style support for all taxonomies
if ( !empty($tax_input) ) { $tax_names = get_object_taxonomies( get_post($post_ID) );
foreach ( $tax_input as $taxonomy => $tags ) { foreach ( (array)$tax_names as $taxonomy ) {
if ( 'category' == $taxonomy ) // Handled seperately.
continue;
$taxonomy_obj = get_taxonomy($taxonomy); $taxonomy_obj = get_taxonomy($taxonomy);
if ( current_user_can($taxonomy_obj->assign_cap) ) if ( !current_user_can($taxonomy_obj->assign_cap) )
continue;
if ( !$taxonomy_obj->show_ui )
continue;
$tags = isset($tax_input[$taxonomy]) ? $tax_input[$taxonomy] : array();
wp_set_post_terms( $post_ID, $tags, $taxonomy ); wp_set_post_terms( $post_ID, $tags, $taxonomy );
} }
}
$current_guid = get_post_field( 'guid', $post_ID ); $current_guid = get_post_field( 'guid', $post_ID );