Make WordPress Core


Ignore:
Timestamp:
05/11/2010 04:28:00 PM (17 years ago)
Author:
ryan
Message:

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

File:
1 edited

Legend:

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

    r14528 r14561  
    19931993
    19941994        // Set categories and tags
    1995         if($mode == OBJECT) {
    1996                 $post->post_category = wp_get_post_categories($postid);
    1997                 $post->tags_input = wp_get_post_tags($postid, array('fields' => 'names'));
    1998         }
    1999         else {
    2000                 $post['post_category'] = wp_get_post_categories($postid);
    2001                 $post['tags_input'] = wp_get_post_tags($postid, array('fields' => 'names'));
     1995        if ( $mode == OBJECT ) {
     1996                $post->post_category = array();
     1997                if ( is_object_in_taxonomy($post->post_type, 'category') )
     1998                        $post->post_category = wp_get_post_categories($postid);
     1999                $post->tags_input = array();
     2000                if ( is_object_in_taxonomy($post->post_type, 'post_tag') )
     2001                        $post->tags_input = wp_get_post_tags($postid, array('fields' => 'names'));
     2002        } else {
     2003                $post['post_category'] = array();
     2004                if ( is_object_in_taxonomy($post['post_type'], 'category') )
     2005                        $post['post_category'] = wp_get_post_categories($postid);
     2006                $post['tags_input'] = array();
     2007                if ( is_object_in_taxonomy($post['post_type'], 'post_tag') )
     2008                        $post['tags_input'] = wp_get_post_tags($postid, array('fields' => 'names'));
    20022009        }
    20032010
    … …  
    22412248        }
    22422249
    2243         wp_set_post_categories( $post_ID, $post_category );
    2244         // old-style tags_input
    2245         if ( isset( $tags_input ) )
     2250        if ( is_object_in_taxonomy($post_type, 'category') )
     2251                wp_set_post_categories( $post_ID, $post_category );
     2252
     2253        if ( isset( $tags_input ) && is_object_in_taxonomy($post_type, 'post_tag') )
    22462254                wp_set_post_tags( $post_ID, $tags_input );
    22472255
Note: See TracChangeset for help on using the changeset viewer.