]> scripts.mit.edu Git - autoinstalls/wordpress.git/blobdiff - wp-includes/category-template.php
WordPress 3.5.1-scripts
[autoinstalls/wordpress.git] / wp-includes / category-template.php
index 2e23f8a3feabb751dad6caa78cc8347b97df16e8..e45734abbbaf334f9bf4110af88325df3f09a333 100644 (file)
@@ -41,7 +41,7 @@ function get_category_link( $category ) {
  */
 function get_category_parents( $id, $link = false, $separator = '/', $nicename = false, $visited = array() ) {
        $chain = '';
  */
 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;
 
        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' );
  */
 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 );
                $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;
  */
 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;
        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
  *
  *
  * @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.
  */
  * @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 ) {
        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;
 
        if ( empty( $terms ) )
                return false;