<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" /><style type="text/css"><!--
#msg dl { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fc0 solid; padding: 6px; }
#msg ul, pre { overflow: auto; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<title>[16115] trunk/wp-includes/theme.php: Use get_queried_object()
  in more get_*_template() functions.</title>
</head>
<body>

<div id="msg">
<dl>
<dt>Revision</dt> <dd><a href="http://trac.wordpress.org/changeset/16115">16115</a></dd>
<dt>Author</dt> <dd>scribu</dd>
<dt>Date</dt> <dd>2010-10-31 11:23:10 +0000 (Sun, 31 Oct 2010)</dd>
</dl>

<h3>Log Message</h3>
<pre>Use get_queried_object() in more get_*_template() functions. Fixes <a href="http://trac.wordpress.org/ticket/15263">#15263</a></pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkwpincludesthemephp">trunk/wp-includes/theme.php</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkwpincludesthemephp"></a>
<div class="modfile"><h4>Modified: trunk/wp-includes/theme.php (16114 => 16115)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-includes/theme.php        2010-10-31 11:02:17 UTC (rev 16114)
+++ trunk/wp-includes/theme.php        2010-10-31 11:23:10 UTC (rev 16115)
</span><span class="lines">@@ -800,16 +800,12 @@
</span><span class="cx">  * @return string
</span><span class="cx">  */
</span><span class="cx"> function get_author_template() {
</span><del>-        $author_id = absint( get_query_var( 'author' ) );
-        $author = get_user_by( 'id', $author_id );
-        $author = $author-&gt;user_nicename;
</del><ins>+        $author = get_queried_object();
</ins><span class="cx"> 
</span><span class="cx">         $templates = array();
</span><span class="cx"> 
</span><del>-        if ( $author )
-                $templates[] = &quot;author-{$author}.php&quot;;
-        if ( $author_id )
-                $templates[] = &quot;author-{$author_id}.php&quot;;
</del><ins>+        $templates[] = &quot;author-{$author-&gt;user_nicename}.php&quot;;
+        $templates[] = &quot;author-{$author-&gt;ID}.php&quot;;
</ins><span class="cx">         $templates[] = 'author.php';
</span><span class="cx"> 
</span><span class="cx">         return get_query_template( 'author', $templates );
</span><span class="lines">@@ -828,15 +824,12 @@
</span><span class="cx">  * @return string
</span><span class="cx">  */
</span><span class="cx"> function get_category_template() {
</span><del>-        $cat_ID = absint( get_query_var('cat') );
-        $category = get_category( $cat_ID );
</del><ins>+        $category = get_queried_object();
</ins><span class="cx"> 
</span><span class="cx">         $templates = array();
</span><span class="cx"> 
</span><del>-        if ( !is_wp_error( $category ) )
-                $templates[] = &quot;category-{$category-&gt;slug}.php&quot;;
-
-        $templates[] = &quot;category-$cat_ID.php&quot;;
</del><ins>+        $templates[] = &quot;category-{$category-&gt;slug}.php&quot;;
+        $templates[] = &quot;category-{$category-&gt;term_id}.php&quot;;
</ins><span class="cx">         $templates[] = &quot;category.php&quot;;
</span><span class="cx"> 
</span><span class="cx">         return get_query_template( 'category', $templates );
</span><span class="lines">@@ -856,15 +849,11 @@
</span><span class="cx">  */
</span><span class="cx"> function get_tag_template() {
</span><span class="cx">         $tag = get_queried_object();
</span><del>-        $tag_name = $tag-&gt;slug;
-        $tag_id = $tag-&gt;term_id;
</del><span class="cx"> 
</span><span class="cx">         $templates = array();
</span><span class="cx"> 
</span><del>-        if ( $tag_name )
-                $templates[] = &quot;tag-$tag_name.php&quot;;
-        if ( $tag_id )
-                $templates[] = &quot;tag-$tag_id.php&quot;;
</del><ins>+        $templates[] = &quot;tag-{$tag-&gt;slug}.php&quot;;
+        $templates[] = &quot;tag-{$tag-&gt;term_id}.php&quot;;
</ins><span class="cx">         $templates[] = &quot;tag.php&quot;;
</span><span class="cx"> 
</span><span class="cx">         return get_query_template( 'tag', $templates );
</span><span class="lines">@@ -888,15 +877,13 @@
</span><span class="cx">  * @return string
</span><span class="cx">  */
</span><span class="cx"> function get_taxonomy_template() {
</span><del>-        $taxonomy = get_query_var('taxonomy');
-        $term = get_query_var('term');
</del><ins>+        $term = get_queried_object();
+        $taxonomy = $term-&gt;taxonomy;
</ins><span class="cx"> 
</span><span class="cx">         $templates = array();
</span><del>-        if ( $taxonomy &amp;&amp; $term )
-                $templates[] = &quot;taxonomy-$taxonomy-$term.php&quot;;
-        if ( $taxonomy )
-                $templates[] = &quot;taxonomy-$taxonomy.php&quot;;
</del><span class="cx"> 
</span><ins>+        $templates[] = &quot;taxonomy-$taxonomy-{$term-&gt;slug}.php&quot;;
+        $templates[] = &quot;taxonomy-$taxonomy.php&quot;;
</ins><span class="cx">         $templates[] = &quot;taxonomy.php&quot;;
</span><span class="cx"> 
</span><span class="cx">         return get_query_template( 'taxonomy', $templates );
</span><span class="lines">@@ -1015,8 +1002,12 @@
</span><span class="cx">  */
</span><span class="cx"> function get_single_template() {
</span><span class="cx">         $object = get_queried_object();
</span><del>-        $templates = array('single-' . $object-&gt;post_type . '.php', 'single.php');
</del><span class="cx"> 
</span><ins>+        $templates = array();
+
+        $templates[] = &quot;single-{$object-&gt;post_type}.php&quot;;
+        $templates[] = &quot;single.php&quot;;
+
</ins><span class="cx">         return get_query_template( 'single', $templates );
</span><span class="cx"> }
</span><span class="cx"> 
</span></span></pre>
</div>
</div>

</body>
</html>