WordPress.org

Make WordPress Core

Changeset 13219


Ignore:
Timestamp:
02/19/10 10:45:29 (4 years ago)
Author:
dd32
Message:

Make better use of $wp_query->get_queried_object() instead of duplicating its functionality. See [13143]

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-includes/general-template.php

    r13202 r13219  
    674674function single_cat_title($prefix = '', $display = true ) { 
    675675    global $wp_query; 
    676     $cat = $wp_query->queried_object; 
    677  
    678     if ( is_tag() ) { 
     676 
     677    if ( is_tag() ) 
    679678        return single_tag_title($prefix, $display); 
    680     } elseif ( !empty($cat->name) ) { 
    681         $cat = $cat->name; 
    682     } else { 
    683         $cat = intval( get_query_var('cat') ); 
    684         if ( !empty($cat) ) 
    685             $cat = get_the_category_by_ID($cat); 
    686     } 
    687     $my_cat_name = apply_filters('single_cat_title', $cat); 
     679 
     680    if ( !is_category() ) 
     681        return; 
     682 
     683    $cat = $wp_query->get_queried_object(); 
     684    $my_cat_name = apply_filters('single_cat_title', $cat->name); 
    688685    if ( !empty($my_cat_name) ) { 
    689686        if ( $display ) 
     
    712709 */ 
    713710function single_tag_title($prefix = '', $display = true ) { 
     711    global $wp_query; 
    714712    if ( !is_tag() ) 
    715713        return; 
    716714 
    717     global $wp_query; 
    718     $tag = $wp_query->queried_object; 
    719  
    720     if ( !empty($tag->name) ) { 
    721         $tag = sanitize_term($tag, 'post_tag', 'display'); 
    722     } else { 
    723         $tag_id = intval( get_query_var('tag_id') ); 
    724         if ( !empty($tag_id) ) { 
    725             $tag = &get_term($tag_id, 'post_tag', OBJECT, 'display'); 
    726             if ( is_wp_error( $tag ) ) 
    727                 return false; 
    728         } 
    729     } 
     715    $tag = $wp_query->get_queried_object();; 
     716     
     717    if ( ! $tag ) 
     718        return; 
    730719 
    731720    $my_tag_name = apply_filters('single_tag_title', $tag->name); 
Note: See TracChangeset for help on using the changeset viewer.