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: http://core.svn.wordpress.org/trunk@22722 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
d6c85b1373
commit
a2edda4b6a
|
@ -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 );
|
||||
|
|
|
@ -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' );
|
||||
|
|
Loading…
Reference in New Issue