<!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">                 <?php if ( have_posts() ) : ?>
</span><span class="cx">                         <header class="archive-header">
</span><span class="cx">                                 <h1 class="archive-title"><?php
</span><del>-                                        if ( is_day() ) {
</del><ins>+                                        if ( is_day() ) :
</ins><span class="cx">                                                 printf( __( 'Daily Archives: %s', 'twentytwelve' ), '<span>' . get_the_date() . '</span>' );
</span><del>-                                        } elseif ( is_month() ) {
</del><ins>+                                        elseif ( is_month() ) :
</ins><span class="cx">                                                 printf( __( 'Monthly Archives: %s', 'twentytwelve' ), '<span>' . get_the_date( _x( 'F Y', 'monthly archives date format', 'twentytwelve' ) ) . '</span>' );
</span><del>-                                        } elseif ( is_year() ) {
</del><ins>+                                        elseif ( is_year() ) :
</ins><span class="cx">                                                 printf( __( 'Yearly Archives: %s', 'twentytwelve' ), '<span>' . get_the_date( _x( 'Y', 'yearly archives date format', 'twentytwelve' ) ) . '</span>' );
</span><del>-                                        } elseif ( is_tag() ) {
-                                                printf( __( 'Tag Archives: %s', 'twentytwelve' ), '<span>' . single_tag_title( '', false ) . '</span>' );
-                                        } elseif ( is_category() ) {
-                                                printf( __( 'Category Archives: %s', 'twentytwelve' ), '<span>' . single_cat_title( '', false ) . '</span>' );
-                                        } else {
</del><ins>+                                        else :
</ins><span class="cx">                                                 _e( 'Archives', 'twentytwelve' );
</span><del>-                                        }
</del><ins>+                                        endif;
</ins><span class="cx">                                 ?></h1>
</span><del>-
-                                <?php
-                                        // Show an optional tag description.
-                                        if ( is_tag() ) {
-                                                $tag_description = tag_description();
-                                                if ( $tag_description )
-                                                        echo '<div class="archive-meta">' . $tag_description . '</div>';
-                                        }
-                                        // Show an optional category description.
-                                        if ( is_category() ) {
-                                                $category_description = category_description();
-                                                if ( $category_description )
-                                                        echo '<div class="archive-meta">' . $category_description . '</div>';
-                                        }
-                                ?>
</del><span class="cx">                         </header><!-- .archive-header -->
</span><span class="cx">
</span><span class="cx">                         <?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>+<?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(); ?>
+
+        <section id="primary" class="site-content">
+                <div id="content" role="main">
+
+                <?php if ( have_posts() ) : ?>
+                        <header class="archive-header">
+                                <h1 class="archive-title"><?php printf( __( 'Category Archives: %s', 'twentytwelve' ), '<span>' . single_cat_title( '', false ) . '</span>' ); ?></h1>
+
+                        <?php if ( category_description() ) : // Show an optional category description ?>
+                                <div class="archive-meta"><?php echo category_description(); ?></div>
+                        <?php endif; ?>
+                        </header><!-- .archive-header -->
+
+                        <?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' );
+                        ?>
+
+                <?php else : ?>
+                        <?php get_template_part( 'content', 'none' ); ?>
+                <?php endif; ?>
+
+                </div><!-- #content -->
+        </section><!-- #primary -->
+
+<?php get_sidebar(); ?>
+<?php get_footer(); ?>
</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' => $post->post_parent, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => 'ASC', 'orderby' => 'menu_order ID' ) ) );
</span><del>-foreach ( $attachments as $k => $attachment ) {
</del><ins>+foreach ( $attachments as $k => $attachment ) :
</ins><span class="cx">         if ( $attachment->ID == $post->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 ) > 1 ) {
-        if ( isset( $attachments[ $k ] ) )
</del><ins>+if ( count( $attachments ) > 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 ]->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 ]->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"> ?>
</span><span class="cx">                                                                 <a href="<?php echo esc_url( $next_attachment_url ); ?>" title="<?php the_title_attribute(); ?>" rel="attachment"><?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>+<?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(); ?>
+
+        <section id="primary" class="site-content">
+                <div id="content" role="main">
+
+                <?php if ( have_posts() ) : ?>
+                        <header class="archive-header">
+                                <h1 class="archive-title"><?php printf( __( 'Tag Archives: %s', 'twentytwelve' ), '<span>' . single_tag_title( '', false ) . '</span>' ); ?></h1>
+
+                        <?php if ( tag_description() ) : // Show an optional tag description ?>
+                                <div class="archive-meta"><?php echo tag_description(); ?></div>
+                        <?php endif; ?>
+
+                        </header><!-- .archive-header -->
+
+                        <?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' );
+                        ?>
+
+                <?php else : ?>
+                        <?php get_template_part( 'content', 'none' ); ?>
+                <?php endif; ?>
+
+                </div><!-- #content -->
+        </section><!-- #primary -->
+
+<?php get_sidebar(); ?>
+<?php get_footer(); ?>
</ins><span class="cx">\ No newline at end of file
</span></span></pre>
</div>
</div>
</body>
</html>