Make WordPress Core

Changeset 16115


Ignore:
Timestamp:
10/31/2010 11:23:10 AM (16 years ago)
Author:
scribu
Message:

Use get_queried_object() in more get_*_template() functions. Fixes #15263

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-includes/theme.php

    r16114 r16115  
    801801 */
    802802function get_author_template() {
    803         $author_id = absint( get_query_var( 'author' ) );
    804         $author = get_user_by( 'id', $author_id );
    805         $author = $author->user_nicename;
     803        $author = get_queried_object();
    806804
    807805        $templates = array();
    808806
    809         if ( $author )
    810                 $templates[] = "author-{$author}.php";
    811         if ( $author_id )
    812                 $templates[] = "author-{$author_id}.php";
     807        $templates[] = "author-{$author->user_nicename}.php";
     808        $templates[] = "author-{$author->ID}.php";
    813809        $templates[] = 'author.php';
    814810
    … …  
    829825 */
    830826function get_category_template() {
    831         $cat_ID = absint( get_query_var('cat') );
    832         $category = get_category( $cat_ID );
     827        $category = get_queried_object();
    833828
    834829        $templates = array();
    835830
    836         if ( !is_wp_error( $category ) )
    837                 $templates[] = "category-{$category->slug}.php";
    838 
    839         $templates[] = "category-$cat_ID.php";
     831        $templates[] = "category-{$category->slug}.php";
     832        $templates[] = "category-{$category->term_id}.php";
    840833        $templates[] = "category.php";
    841834
    … …  
    857850function get_tag_template() {
    858851        $tag = get_queried_object();
    859         $tag_name = $tag->slug;
    860         $tag_id = $tag->term_id;
    861852
    862853        $templates = array();
    863854
    864         if ( $tag_name )
    865                 $templates[] = "tag-$tag_name.php";
    866         if ( $tag_id )
    867                 $templates[] = "tag-$tag_id.php";
     855        $templates[] = "tag-{$tag->slug}.php";
     856        $templates[] = "tag-{$tag->term_id}.php";
    868857        $templates[] = "tag.php";
    869858
    … …  
    889878 */
    890879function get_taxonomy_template() {
    891         $taxonomy = get_query_var('taxonomy');
    892         $term = get_query_var('term');
     880        $term = get_queried_object();
     881        $taxonomy = $term->taxonomy;
    893882
    894883        $templates = array();
    895         if ( $taxonomy && $term )
    896                 $templates[] = "taxonomy-$taxonomy-$term.php";
    897         if ( $taxonomy )
    898                 $templates[] = "taxonomy-$taxonomy.php";
    899 
     884
     885        $templates[] = "taxonomy-$taxonomy-{$term->slug}.php";
     886        $templates[] = "taxonomy-$taxonomy.php";
    900887        $templates[] = "taxonomy.php";
    901888
    … …  
    10161003function get_single_template() {
    10171004        $object = get_queried_object();
    1018         $templates = array('single-' . $object->post_type . '.php', 'single.php');
     1005
     1006        $templates = array();
     1007
     1008        $templates[] = "single-{$object->post_type}.php";
     1009        $templates[] = "single.php";
    10191010
    10201011        return get_query_template( 'single', $templates );
Note: See TracChangeset for help on using the changeset viewer.