| 1 | commit f5ea77aaef460b2a28b75e6446b58020b58805c2 |
|---|
| 2 | Author: scribu <mail@scribu.net> |
|---|
| 3 | Date: Sat Sep 22 19:48:51 2012 +0300 |
|---|
| 4 | |
|---|
| 5 | use get_the_terms() in WP_Post->__get() |
|---|
| 6 | |
|---|
| 7 | diff --git wp-includes/category-template.php wp-includes/category-template.php |
|---|
| 8 | index c4ba37d..fea6979 100644 |
|---|
| 9 | --- wp-includes/category-template.php |
|---|
| 10 | +++ wp-includes/category-template.php |
|---|
| 11 | @@ -1062,6 +1062,9 @@ function get_the_terms( $post, $taxonomy ) { |
|---|
| 12 | if ( ! $post = get_post( $post ) ) |
|---|
| 13 | return false; |
|---|
| 14 | |
|---|
| 15 | + if ( !is_object_in_taxonomy( $post->post_type, $taxonomy ) ) |
|---|
| 16 | + return false; |
|---|
| 17 | + |
|---|
| 18 | $terms = get_object_term_cache( $post->ID, $taxonomy ); |
|---|
| 19 | if ( false === $terms ) { |
|---|
| 20 | $terms = wp_get_object_terms( $post->ID, $taxonomy ); |
|---|
| 21 | diff --git wp-includes/post.php wp-includes/post.php |
|---|
| 22 | index cac125e..a49d2cf 100644 |
|---|
| 23 | --- wp-includes/post.php |
|---|
| 24 | +++ wp-includes/post.php |
|---|
| 25 | @@ -495,17 +495,19 @@ final class WP_Post { |
|---|
| 26 | } |
|---|
| 27 | |
|---|
| 28 | if ( 'post_category' == $key ) { |
|---|
| 29 | - if ( is_object_in_taxonomy( $this->post_type, 'category' ) ) |
|---|
| 30 | - return wp_get_post_categories( $this->ID ); |
|---|
| 31 | - else |
|---|
| 32 | + $terms = get_the_terms( $this, 'category' ); |
|---|
| 33 | + if ( !$terms ) |
|---|
| 34 | return array(); |
|---|
| 35 | + |
|---|
| 36 | + return wp_list_pluck( $terms, 'term_id' ); |
|---|
| 37 | } |
|---|
| 38 | |
|---|
| 39 | if ( 'tags_input' == $key ) { |
|---|
| 40 | - if ( is_object_in_taxonomy( $this->post_type, 'post_tag' ) ) |
|---|
| 41 | - return wp_get_post_tags( $this->ID, array( 'fields' => 'names' ) ); |
|---|
| 42 | - else |
|---|
| 43 | + $terms = get_the_terms( $this, 'post_tag' ); |
|---|
| 44 | + if ( !$terms ) |
|---|
| 45 | return array(); |
|---|
| 46 | + |
|---|
| 47 | + return wp_list_pluck( $terms, 'name' ); |
|---|
| 48 | } |
|---|
| 49 | |
|---|
| 50 | // Rest of the values need filtering |
|---|