Don't set/get tags or categories for post types that do not support them. fixes #13346

git-svn-id: https://develop.svn.wordpress.org/trunk@14561 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Ryan Boren 2010-05-11 16:28:00 +00:00
parent 5d13bccc69
commit d5308265cd
1 changed files with 18 additions and 10 deletions

View File

@ -1992,13 +1992,20 @@ function wp_get_single_post($postid = 0, $mode = OBJECT) {
$post = get_post($postid, $mode);
// Set categories and tags
if($mode == OBJECT) {
$post->post_category = wp_get_post_categories($postid);
$post->tags_input = wp_get_post_tags($postid, array('fields' => 'names'));
}
else {
$post['post_category'] = wp_get_post_categories($postid);
$post['tags_input'] = wp_get_post_tags($postid, array('fields' => 'names'));
if ( $mode == OBJECT ) {
$post->post_category = array();
if ( is_object_in_taxonomy($post->post_type, 'category') )
$post->post_category = wp_get_post_categories($postid);
$post->tags_input = array();
if ( is_object_in_taxonomy($post->post_type, 'post_tag') )
$post->tags_input = wp_get_post_tags($postid, array('fields' => 'names'));
} else {
$post['post_category'] = array();
if ( is_object_in_taxonomy($post['post_type'], 'category') )
$post['post_category'] = wp_get_post_categories($postid);
$post['tags_input'] = array();
if ( is_object_in_taxonomy($post['post_type'], 'post_tag') )
$post['tags_input'] = wp_get_post_tags($postid, array('fields' => 'names'));
}
return $post;
@ -2240,9 +2247,10 @@ function wp_insert_post($postarr = array(), $wp_error = false) {
$wpdb->update( $wpdb->posts, array( 'post_name' => $data['post_name'] ), $where );
}
wp_set_post_categories( $post_ID, $post_category );
// old-style tags_input
if ( isset( $tags_input ) )
if ( is_object_in_taxonomy($post_type, 'category') )
wp_set_post_categories( $post_ID, $post_category );
if ( isset( $tags_input ) && is_object_in_taxonomy($post_type, 'post_tag') )
wp_set_post_tags( $post_ID, $tags_input );
// new-style support for all custom taxonomies