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

git-svn-id: http://svn.automattic.com/wordpress/trunk@14561 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
ryan 2010-05-11 16:28:00 +00:00
parent 02058305b5
commit c7f520240c

View File

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