*/
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;
*/
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 );
*/
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;
*
* @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;