Don't bail from get_the_terms() if the post type is not registed for the taxonomy. This can break back compat when add_post_type_support( 'page', 'post-formats' ) is called but register_taxonomy_for_object_type( 'postr_-format', 'page' ) is not.

Props SergeyBiryukov
fixes #22473


git-svn-id: https://develop.svn.wordpress.org/trunk@22722 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Ryan Boren 2012-11-20 18:31:06 +00:00
parent 7194aa3b9c
commit e158d36f6e
2 changed files with 8 additions and 7 deletions

View File

@ -1062,9 +1062,6 @@ function get_the_terms( $post, $taxonomy ) {
if ( ! $post = get_post( $post ) )
return false;
if ( ! is_object_in_taxonomy( $post->post_type, $taxonomy ) )
return false;
$terms = get_object_term_cache( $post->ID, $taxonomy );
if ( false === $terms ) {
$terms = wp_get_object_terms( $post->ID, $taxonomy );

View File

@ -615,16 +615,20 @@ final class WP_Post {
}
if ( 'post_category' == $key ) {
if ( is_object_in_taxonomy( $this->post_type, 'category' ) )
$terms = get_the_terms( $this, 'category' );
if ( ! $terms )
if ( empty( $terms ) )
return array();
return wp_list_pluck( $terms, 'term_id' );
}
if ( 'tags_input' == $key ) {
if ( is_object_in_taxonomy( $this->post_type, 'post_tag' ) )
$terms = get_the_terms( $this, 'post_tag' );
if ( ! $terms )
if ( empty( $terms ) )
return array();
return wp_list_pluck( $terms, 'name' );