X-Git-Url: https://scripts.mit.edu/gitweb/autoinstalls/wordpress.git/blobdiff_plain/8f374b7233bc2815ccc387e448d208c5434eb961..8a4706fdeb1ae30268e510df6ccf3c39b3028059:/wp-includes/category-template.php?ds=sidebyside diff --git a/wp-includes/category-template.php b/wp-includes/category-template.php index 2e23f8a3..e45734ab 100644 --- a/wp-includes/category-template.php +++ b/wp-includes/category-template.php @@ -41,7 +41,7 @@ function get_category_link( $category ) { */ function get_category_parents( $id, $link = false, $separator = '/', $nicename = false, $visited = array() ) { $chain = ''; - $parent = &get_category( $id ); + $parent = get_category( $id ); if ( is_wp_error( $parent ) ) return $parent; @@ -73,7 +73,7 @@ function get_category_parents( $id, $link = false, $separator = '/', $nicename = */ function get_the_category( $id = false ) { $categories = get_the_terms( $id, 'category' ); - if ( ! $categories ) + if ( ! $categories || is_wp_error( $categories ) ) $categories = array(); $categories = array_values( $categories ); @@ -135,7 +135,7 @@ function _usort_terms_by_ID( $a, $b ) { */ function get_the_category_by_ID( $cat_ID ) { $cat_ID = (int) $cat_ID; - $category = &get_category( $cat_ID ); + $category = get_category( $cat_ID ); if ( is_wp_error( $category ) ) return $category; return $category->name; @@ -1054,29 +1054,21 @@ function term_description( $term = 0, $taxonomy = 'post_tag' ) { * * @since 2.5.0 * - * @param int $id Post ID. + * @param mixed $post Post ID or object. * @param string $taxonomy Taxonomy name. * @return array|bool False on failure. Array of term objects on success. */ -function get_the_terms( $id, $taxonomy ) { - global $post; - - $id = (int) $id; - - if ( !$id ) { - if ( empty( $post->ID ) ) - return false; - else - $id = (int) $post->ID; - } +function get_the_terms( $post, $taxonomy ) { + if ( ! $post = get_post( $post ) ) + return false; - $terms = get_object_term_cache( $id, $taxonomy ); + $terms = get_object_term_cache( $post->ID, $taxonomy ); if ( false === $terms ) { - $terms = wp_get_object_terms( $id, $taxonomy ); - wp_cache_add($id, $terms, $taxonomy . '_relationships'); + $terms = wp_get_object_terms( $post->ID, $taxonomy ); + wp_cache_add($post->ID, $terms, $taxonomy . '_relationships'); } - $terms = apply_filters( 'get_the_terms', $terms, $id, $taxonomy ); + $terms = apply_filters( 'get_the_terms', $terms, $post->ID, $taxonomy ); if ( empty( $terms ) ) return false;