commit f5ea77aaef460b2a28b75e6446b58020b58805c2
Author: scribu <mail@scribu.net>
Date: Sat Sep 22 19:48:51 2012 +0300
use get_the_terms() in WP_Post->__get()
diff --git wp-includes/category-template.php wp-includes/category-template.php
index c4ba37d..fea6979 100644
|
|
function get_the_terms( $post, $taxonomy ) { |
1062 | 1062 | if ( ! $post = get_post( $post ) ) |
1063 | 1063 | return false; |
1064 | 1064 | |
| 1065 | if ( !is_object_in_taxonomy( $post->post_type, $taxonomy ) ) |
| 1066 | return false; |
| 1067 | |
1065 | 1068 | $terms = get_object_term_cache( $post->ID, $taxonomy ); |
1066 | 1069 | if ( false === $terms ) { |
1067 | 1070 | $terms = wp_get_object_terms( $post->ID, $taxonomy ); |
diff --git wp-includes/post.php wp-includes/post.php
index cac125e..a49d2cf 100644
|
|
final class WP_Post { |
495 | 495 | } |
496 | 496 | |
497 | 497 | if ( 'post_category' == $key ) { |
498 | | if ( is_object_in_taxonomy( $this->post_type, 'category' ) ) |
499 | | return wp_get_post_categories( $this->ID ); |
500 | | else |
| 498 | $terms = get_the_terms( $this, 'category' ); |
| 499 | if ( !$terms ) |
501 | 500 | return array(); |
| 501 | |
| 502 | return wp_list_pluck( $terms, 'term_id' ); |
502 | 503 | } |
503 | 504 | |
504 | 505 | if ( 'tags_input' == $key ) { |
505 | | if ( is_object_in_taxonomy( $this->post_type, 'post_tag' ) ) |
506 | | return wp_get_post_tags( $this->ID, array( 'fields' => 'names' ) ); |
507 | | else |
| 506 | $terms = get_the_terms( $this, 'post_tag' ); |
| 507 | if ( !$terms ) |
508 | 508 | return array(); |
| 509 | |
| 510 | return wp_list_pluck( $terms, 'name' ); |
509 | 511 | } |
510 | 512 | |
511 | 513 | // Rest of the values need filtering |