From e158d36f6ea6982984a7e1df5769f703e67c3a43 Mon Sep 17 00:00:00 2001 From: Ryan Boren Date: Tue, 20 Nov 2012 18:31:06 +0000 Subject: [PATCH] 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 --- wp-includes/category-template.php | 3 --- wp-includes/post.php | 12 ++++++++---- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/wp-includes/category-template.php b/wp-includes/category-template.php index 8cf66c53bc..e45734abbb 100644 --- a/wp-includes/category-template.php +++ b/wp-includes/category-template.php @@ -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 ); diff --git a/wp-includes/post.php b/wp-includes/post.php index 1cc76b9af9..3eaa5620d4 100644 --- a/wp-includes/post.php +++ b/wp-includes/post.php @@ -615,16 +615,20 @@ final class WP_Post { } if ( 'post_category' == $key ) { - $terms = get_the_terms( $this, 'category' ); - if ( ! $terms ) + if ( is_object_in_taxonomy( $this->post_type, 'category' ) ) + $terms = get_the_terms( $this, 'category' ); + + if ( empty( $terms ) ) return array(); return wp_list_pluck( $terms, 'term_id' ); } if ( 'tags_input' == $key ) { - $terms = get_the_terms( $this, 'post_tag' ); - if ( ! $terms ) + if ( is_object_in_taxonomy( $this->post_type, 'post_tag' ) ) + $terms = get_the_terms( $this, 'post_tag' ); + + if ( empty( $terms ) ) return array(); return wp_list_pluck( $terms, 'name' );