<!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" />
<title>[22048] trunk/wp-content/themes/twentytwelve: Add tag.php and category.php to Twenty Twelve.</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { 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 #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg > ul, #logmsg > ol { margin-left: 0; margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#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>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://core.trac.wordpress.org/changeset/22048">22048</a></dd>
<dt>Author</dt> <dd>nacin</dd>
<dt>Date</dt> <dd>2012-09-27 07:01:16 +0000 (Thu, 27 Sep 2012)</dd>
</dl>

<h3>Log Message</h3>
<pre>Add tag.php and category.php to Twenty Twelve. While by no means required, it pulls some extra logic out of archive.php, instead leveraging the template hierarchy so it is hopefully more understandable to users tweaking their themes. Use alternative control structure syntax in all templates. fixes <a href="http://core.trac.wordpress.org/ticket/21951">#21951</a>.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkwpcontentthemestwentytwelvearchivephp">trunk/wp-content/themes/twentytwelve/archive.php</a></li>
<li><a href="#trunkwpcontentthemestwentytwelveauthorphp">trunk/wp-content/themes/twentytwelve/author.php</a></li>
<li><a href="#trunkwpcontentthemestwentytwelveimagephp">trunk/wp-content/themes/twentytwelve/image.php</a></li>
<li><a href="#trunkwpcontentthemestwentytwelveindexphp">trunk/wp-content/themes/twentytwelve/index.php</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li><a href="#trunkwpcontentthemestwentytwelvecategoryphp">trunk/wp-content/themes/twentytwelve/category.php</a></li>
<li><a href="#trunkwpcontentthemestwentytwelvetagphp">trunk/wp-content/themes/twentytwelve/tag.php</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkwpcontentthemestwentytwelvearchivephp"></a>
<div class="modfile"><h4>Modified: trunk/wp-content/themes/twentytwelve/archive.php (22047 => 22048)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-content/themes/twentytwelve/archive.php        2012-09-27 06:54:17 UTC (rev 22047)
+++ trunk/wp-content/themes/twentytwelve/archive.php        2012-09-27 07:01:16 UTC (rev 22048)
</span><span class="lines">@@ -6,7 +6,8 @@
</span><span class="cx">  * For example, puts together date-based pages if no date.php file exists.
</span><span class="cx">  *
</span><span class="cx">  * If you'd like to further customize these archive views, you may create a
</span><del>- * new template file for each specific one, like tag.php for Tag archives or
</del><ins>+ * new template file for each specific one. For example, Twenty Twelve already
+ * has tag.php for Tag archives, category.php for Category archives, and
</ins><span class="cx">  * author.php for Author archives.
</span><span class="cx">  *
</span><span class="cx">  * Learn more: http://codex.wordpress.org/Template_Hierarchy
</span><span class="lines">@@ -24,35 +25,16 @@
</span><span class="cx">                 &lt;?php if ( have_posts() ) : ?&gt;
</span><span class="cx">                         &lt;header class=&quot;archive-header&quot;&gt;
</span><span class="cx">                                 &lt;h1 class=&quot;archive-title&quot;&gt;&lt;?php
</span><del>-                                        if ( is_day() ) {
</del><ins>+                                        if ( is_day() ) :
</ins><span class="cx">                                                 printf( __( 'Daily Archives: %s', 'twentytwelve' ), '&lt;span&gt;' . get_the_date() . '&lt;/span&gt;' );
</span><del>-                                        } elseif ( is_month() ) {
</del><ins>+                                        elseif ( is_month() ) :
</ins><span class="cx">                                                 printf( __( 'Monthly Archives: %s', 'twentytwelve' ), '&lt;span&gt;' . get_the_date( _x( 'F Y', 'monthly archives date format', 'twentytwelve' ) ) . '&lt;/span&gt;' );
</span><del>-                                        } elseif ( is_year() ) {
</del><ins>+                                        elseif ( is_year() ) :
</ins><span class="cx">                                                 printf( __( 'Yearly Archives: %s', 'twentytwelve' ), '&lt;span&gt;' . get_the_date( _x( 'Y', 'yearly archives date format', 'twentytwelve' ) ) . '&lt;/span&gt;' );
</span><del>-                                        } elseif ( is_tag() ) {
-                                                printf( __( 'Tag Archives: %s', 'twentytwelve' ), '&lt;span&gt;' . single_tag_title( '', false ) . '&lt;/span&gt;' );
-                                        } elseif ( is_category() ) {
-                                                printf( __( 'Category Archives: %s', 'twentytwelve' ), '&lt;span&gt;' . single_cat_title( '', false ) . '&lt;/span&gt;' );
-                                        } else {
</del><ins>+                                        else :
</ins><span class="cx">                                                 _e( 'Archives', 'twentytwelve' );
</span><del>-                                        }
</del><ins>+                                        endif;
</ins><span class="cx">                                 ?&gt;&lt;/h1&gt;
</span><del>-
-                                &lt;?php
-                                        // Show an optional tag description.
-                                        if ( is_tag() ) {
-                                                $tag_description = tag_description();
-                                                if ( $tag_description )
-                                                        echo '&lt;div class=&quot;archive-meta&quot;&gt;' . $tag_description . '&lt;/div&gt;';
-                                        }
-                                        // Show an optional category description.
-                                        if ( is_category() ) {
-                                                $category_description = category_description();
-                                                if ( $category_description )
-                                                        echo '&lt;div class=&quot;archive-meta&quot;&gt;' . $category_description . '&lt;/div&gt;';
-                                        }
-                                ?&gt;
</del><span class="cx">                         &lt;/header&gt;&lt;!-- .archive-header --&gt;
</span><span class="cx"> 
</span><span class="cx">                         &lt;?php
</span></span></pre></div>
<a id="trunkwpcontentthemestwentytwelveauthorphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-content/themes/twentytwelve/author.php (22047 => 22048)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-content/themes/twentytwelve/author.php        2012-09-27 06:54:17 UTC (rev 22047)
+++ trunk/wp-content/themes/twentytwelve/author.php        2012-09-27 07:01:16 UTC (rev 22048)
</span><span class="lines">@@ -2,6 +2,10 @@
</span><span class="cx"> /**
</span><span class="cx">  * The template for displaying Author Archive pages.
</span><span class="cx">  *
</span><ins>+ * Used to display archive-type pages for posts by an author.
+ *
+ * Learn more: http://codex.wordpress.org/Template_Hierarchy
+ *
</ins><span class="cx">  * @package WordPress
</span><span class="cx">  * @subpackage Twenty_Twelve
</span><span class="cx">  * @since Twenty Twelve 1.0
</span></span></pre></div>
<a id="trunkwpcontentthemestwentytwelvecategoryphp"></a>
<div class="addfile"><h4>Added: trunk/wp-content/themes/twentytwelve/category.php (0 => 22048)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-content/themes/twentytwelve/category.php                                (rev 0)
+++ trunk/wp-content/themes/twentytwelve/category.php        2012-09-27 07:01:16 UTC (rev 22048)
</span><span class="lines">@@ -0,0 +1,51 @@
</span><ins>+&lt;?php
+/**
+ * The template for displaying Category pages.
+ *
+ * Used to display archive-type pages for posts in a category.
+ *
+ * Learn more: http://codex.wordpress.org/Template_Hierarchy
+ *
+ * @package WordPress
+ * @subpackage Twenty_Twelve
+ * @since Twenty Twelve 1.0
+ */
+
+get_header(); ?&gt;
+
+        &lt;section id=&quot;primary&quot; class=&quot;site-content&quot;&gt;
+                &lt;div id=&quot;content&quot; role=&quot;main&quot;&gt;
+
+                &lt;?php if ( have_posts() ) : ?&gt;
+                        &lt;header class=&quot;archive-header&quot;&gt;
+                                &lt;h1 class=&quot;archive-title&quot;&gt;&lt;?php printf( __( 'Category Archives: %s', 'twentytwelve' ), '&lt;span&gt;' . single_cat_title( '', false ) . '&lt;/span&gt;' ); ?&gt;&lt;/h1&gt;
+
+                        &lt;?php if ( category_description() ) : // Show an optional category description ?&gt;
+                                &lt;div class=&quot;archive-meta&quot;&gt;&lt;?php echo category_description(); ?&gt;&lt;/div&gt;
+                        &lt;?php endif; ?&gt;
+                        &lt;/header&gt;&lt;!-- .archive-header --&gt;
+
+                        &lt;?php
+                        /* Start the Loop */
+                        while ( have_posts() ) : the_post();
+
+                                /* Include the post format-specific template for the content. If you want to
+                                 * this in a child theme then include a file called called content-___.php
+                                 * (where ___ is the post format) and that will be used instead.
+                                 */
+                                get_template_part( 'content', get_post_format() );
+
+                        endwhile;
+
+                        twentytwelve_content_nav( 'nav-below' );
+                        ?&gt;
+
+                &lt;?php else : ?&gt;
+                        &lt;?php get_template_part( 'content', 'none' ); ?&gt;
+                &lt;?php endif; ?&gt;
+
+                &lt;/div&gt;&lt;!-- #content --&gt;
+        &lt;/section&gt;&lt;!-- #primary --&gt;
+
+&lt;?php get_sidebar(); ?&gt;
+&lt;?php get_footer(); ?&gt;
</ins><span class="cx">\ No newline at end of file
</span></span></pre></div>
<a id="trunkwpcontentthemestwentytwelveimagephp"></a>
<div class="modfile"><h4>Modified: trunk/wp-content/themes/twentytwelve/image.php (22047 => 22048)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-content/themes/twentytwelve/image.php        2012-09-27 06:54:17 UTC (rev 22047)
+++ trunk/wp-content/themes/twentytwelve/image.php        2012-09-27 07:01:16 UTC (rev 22048)
</span><span class="lines">@@ -2,6 +2,8 @@
</span><span class="cx"> /**
</span><span class="cx">  * The template for displaying image attachments.
</span><span class="cx">  *
</span><ins>+ * Learn more: http://codex.wordpress.org/Template_Hierarchy
+ *
</ins><span class="cx">  * @package WordPress
</span><span class="cx">  * @subpackage Twenty_Twelve
</span><span class="cx">  * @since Twenty Twelve 1.0
</span><span class="lines">@@ -51,23 +53,25 @@
</span><span class="cx">  * or the first image (if we're looking at the last image in a gallery), or, in a gallery of one, just the link to that image file
</span><span class="cx">  */
</span><span class="cx"> $attachments = array_values( get_children( array( 'post_parent' =&gt; $post-&gt;post_parent, 'post_status' =&gt; 'inherit', 'post_type' =&gt; 'attachment', 'post_mime_type' =&gt; 'image', 'order' =&gt; 'ASC', 'orderby' =&gt; 'menu_order ID' ) ) );
</span><del>-foreach ( $attachments as $k =&gt; $attachment ) {
</del><ins>+foreach ( $attachments as $k =&gt; $attachment ) :
</ins><span class="cx">         if ( $attachment-&gt;ID == $post-&gt;ID )
</span><span class="cx">                 break;
</span><del>-}
</del><ins>+endforeach;
+
</ins><span class="cx"> $k++;
</span><span class="cx"> // If there is more than 1 attachment in a gallery
</span><del>-if ( count( $attachments ) &gt; 1 ) {
-        if ( isset( $attachments[ $k ] ) )
</del><ins>+if ( count( $attachments ) &gt; 1 ) :
+        if ( isset( $attachments[ $k ] ) ) :
</ins><span class="cx">                 // get the URL of the next image attachment
</span><span class="cx">                 $next_attachment_url = get_attachment_link( $attachments[ $k ]-&gt;ID );
</span><del>-        else
</del><ins>+        else :
</ins><span class="cx">                 // or get the URL of the first image attachment
</span><span class="cx">                 $next_attachment_url = get_attachment_link( $attachments[ 0 ]-&gt;ID );
</span><del>-} else {
</del><ins>+        endif;
+else :
</ins><span class="cx">         // or, if there's only 1 image, get the URL of the image
</span><span class="cx">         $next_attachment_url = wp_get_attachment_url();
</span><del>-}
</del><ins>+endif;
</ins><span class="cx"> ?&gt;
</span><span class="cx">                                                                 &lt;a href=&quot;&lt;?php echo esc_url( $next_attachment_url ); ?&gt;&quot; title=&quot;&lt;?php the_title_attribute(); ?&gt;&quot; rel=&quot;attachment&quot;&gt;&lt;?php
</span><span class="cx">                                                                 $attachment_size = apply_filters( 'twentytwelve_attachment_size', array( 960, 960 ) );
</span></span></pre></div>
<a id="trunkwpcontentthemestwentytwelveindexphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-content/themes/twentytwelve/index.php (22047 => 22048)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-content/themes/twentytwelve/index.php        2012-09-27 06:54:17 UTC (rev 22047)
+++ trunk/wp-content/themes/twentytwelve/index.php        2012-09-27 07:01:16 UTC (rev 22048)
</span><span class="lines">@@ -5,7 +5,8 @@
</span><span class="cx">  * This is the most generic template file in a WordPress theme
</span><span class="cx">  * and one of the two required files for a theme (the other being style.css).
</span><span class="cx">  * It is used to display a page when nothing more specific matches a query.
</span><del>- * E.g., it puts together the home page when no home.php file exists.
</del><ins>+ * For example, it puts together the home page when no home.php file exists.
+ *
</ins><span class="cx">  * Learn more: http://codex.wordpress.org/Template_Hierarchy
</span><span class="cx">  *
</span><span class="cx">  * @package WordPress
</span></span></pre></div>
<a id="trunkwpcontentthemestwentytwelvetagphp"></a>
<div class="addfile"><h4>Added: trunk/wp-content/themes/twentytwelve/tag.php (0 => 22048)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-content/themes/twentytwelve/tag.php                                (rev 0)
+++ trunk/wp-content/themes/twentytwelve/tag.php        2012-09-27 07:01:16 UTC (rev 22048)
</span><span class="lines">@@ -0,0 +1,52 @@
</span><ins>+&lt;?php
+/**
+ * The template for displaying Tag pages.
+ *
+ * Used to display archive-type pages for posts in a tag.
+ *
+ * Learn more: http://codex.wordpress.org/Template_Hierarchy
+ *
+ * @package WordPress
+ * @subpackage Twenty_Twelve
+ * @since Twenty Twelve 1.0
+ */
+
+get_header(); ?&gt;
+
+        &lt;section id=&quot;primary&quot; class=&quot;site-content&quot;&gt;
+                &lt;div id=&quot;content&quot; role=&quot;main&quot;&gt;
+
+                &lt;?php if ( have_posts() ) : ?&gt;
+                        &lt;header class=&quot;archive-header&quot;&gt;
+                                &lt;h1 class=&quot;archive-title&quot;&gt;&lt;?php printf( __( 'Tag Archives: %s', 'twentytwelve' ), '&lt;span&gt;' . single_tag_title( '', false ) . '&lt;/span&gt;' ); ?&gt;&lt;/h1&gt;
+
+                        &lt;?php if ( tag_description() ) : // Show an optional tag description ?&gt;
+                                &lt;div class=&quot;archive-meta&quot;&gt;&lt;?php echo tag_description(); ?&gt;&lt;/div&gt;
+                        &lt;?php endif; ?&gt;
+
+                        &lt;/header&gt;&lt;!-- .archive-header --&gt;
+
+                        &lt;?php
+                        /* Start the Loop */
+                        while ( have_posts() ) : the_post();
+
+                                /* Include the post format-specific template for the content. If you want to
+                                 * this in a child theme then include a file called called content-___.php
+                                 * (where ___ is the post format) and that will be used instead.
+                                 */
+                                get_template_part( 'content', get_post_format() );
+
+                        endwhile;
+
+                        twentytwelve_content_nav( 'nav-below' );
+                        ?&gt;
+
+                &lt;?php else : ?&gt;
+                        &lt;?php get_template_part( 'content', 'none' ); ?&gt;
+                &lt;?php endif; ?&gt;
+
+                &lt;/div&gt;&lt;!-- #content --&gt;
+        &lt;/section&gt;&lt;!-- #primary --&gt;
+
+&lt;?php get_sidebar(); ?&gt;
+&lt;?php get_footer(); ?&gt;
</ins><span class="cx">\ No newline at end of file
</span></span></pre>
</div>
</div>

</body>
</html>