Twenty Eleven updates and fixes, see #17198

* Add explanatory comments in all templates, following Twenty Ten's example
 * Stick with twentyeleven_ for prefixing filter names
 * Use post format content templates in search results
 * First pass at adding a template for adding a sidebar to pages
 * Add a featured post header to standard sticky posts
 * Style fixes: print media, comment styles for pages with sidebars, color of meta links on image post format

git-svn-id: http://svn.automattic.com/wordpress/trunk@17802 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
lancewillett 2011-05-04 22:54:50 +00:00
parent 8d24de2171
commit ac33e2df00
15 changed files with 214 additions and 42 deletions

View File

@ -17,7 +17,16 @@ get_header(); ?>
<section id="primary">
<div id="content" role="main">
<?php the_post(); ?>
<?php
/* Queue the first post, that way we know
* what date we're dealing with (if that is the case).
*
* We reset this later so we can run the loop
* properly with a call to rewind_posts().
*/
if ( have_posts() )
the_post();
?>
<header class="page-header">
<h1 class="page-title">
@ -33,14 +42,26 @@ get_header(); ?>
</h1>
</header>
<?php rewind_posts(); ?>
<?php
/* Since we called the_post() above, we need to
* rewind the loop back to the beginning that way
* we can run the loop properly, in full.
*/
rewind_posts();
?>
<?php twentyeleven_content_nav( 'nav-above' ); ?>
<?php /* Start the Loop */ ?>
<?php while ( have_posts() ) : the_post(); ?>
<?php get_template_part( 'content', get_post_format() ); ?>
<?php
/* Include the Post-Format-specific template for the content.
* If you want to overload this in a child theme then include a file
* called loop-___.php (where ___ is the Post Format name) and that will be used instead.
*/
get_template_part( 'content', get_post_format() );
?>
<?php endwhile; ?>

View File

@ -12,13 +12,28 @@ get_header(); ?>
<section id="primary">
<div id="content" role="main">
<?php the_post(); ?>
<?php
/* Queue the first post, that way we know
* what date we're dealing with (if that is the case).
*
* We reset this later so we can run the loop
* properly with a call to rewind_posts().
*/
if ( have_posts() )
the_post();
?>
<header class="page-header">
<h1 class="page-title author"><?php printf( __( 'Author Archives: %s', 'twentyeleven' ), '<span class="vcard"><a class="url fn n" href="' . get_author_posts_url( get_the_author_meta( "ID" ) ) . '" title="' . esc_attr( get_the_author() ) . '" rel="me">' . get_the_author() . '</a></span>' ); ?></h1>
</header>
<?php rewind_posts(); ?>
<?php
/* Since we called the_post() above, we need to
* rewind the loop back to the beginning that way
* we can run the loop properly, in full.
*/
rewind_posts();
?>
<?php twentyeleven_content_nav( 'nav-above' ); ?>
@ -39,7 +54,13 @@ get_header(); ?>
<?php /* Start the Loop */ ?>
<?php while ( have_posts() ) : the_post(); ?>
<?php get_template_part( 'content', get_post_format() ); ?>
<?php
/* Include the Post-Format-specific template for the content.
* If you want to overload this in a child theme then include a file
* called loop-___.php (where ___ is the Post Format name) and that will be used instead.
*/
get_template_part( 'content', get_post_format() );
?>
<?php endwhile; ?>

View File

@ -25,7 +25,13 @@ get_header(); ?>
<?php /* Start the Loop */ ?>
<?php while ( have_posts() ) : the_post(); ?>
<?php get_template_part( 'content', get_post_format() ); ?>
<?php
/* Include the Post-Format-specific template for the content.
* If you want to overload this in a child theme then include a file
* called loop-___.php (where ___ is the Post Format name) and that will be used instead.
*/
get_template_part( 'content', get_post_format() );
?>
<?php endwhile; ?>

View File

@ -16,7 +16,12 @@
<?php if ( post_password_required() ) : ?>
<div class="nopassword"><?php _e( 'This post is password protected. Enter the password to view any comments.', 'twentyeleven' ); ?></div>
</div><!-- .comments -->
<?php return;
<?php
/* Stop the rest of comments.php from being processed,
* but don't kill the script entirely -- we still have
* to fully load the template.
*/
return;
endif;
?>
@ -39,7 +44,15 @@
<?php endif; // check for comment navigation ?>
<ol class="commentlist">
<?php wp_list_comments( array( 'callback' => 'twentyeleven_comment' ) ); ?>
<?php
/* Loop through and list the comments. Tell wp_list_comments()
* to use twentyeleven_comment() to format the comments.
* If you want to overload this in a child theme then you can
* define twentyeleven_comment() and that will be used instead.
* See twentyeleven_comment() in twentyeleven/functions.php for more.
*/
wp_list_comments( array( 'callback' => 'twentyeleven_comment' ) );
?>
</ol>
<?php if ( get_comment_pages_count() > 1 && get_option( 'page_comments' ) ) : // are there comments to navigate through ?>

View File

@ -10,7 +10,14 @@
<article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
<header class="entry-header">
<?php if ( is_sticky() ) : ?>
<hgroup>
<h1 class="entry-title"><a href="<?php the_permalink(); ?>" title="<?php printf( esc_attr__( 'Permalink to %s', 'twentyeleven' ), the_title_attribute( 'echo=0' ) ); ?>" rel="bookmark"><?php the_title(); ?></a></h1>
<h2 class="entry-format"><?php _e( 'Featured', 'twentyeleven' ); ?></h2>
</hgroup>
<?php else : ?>
<h1 class="entry-title"><a href="<?php the_permalink(); ?>" title="<?php printf( esc_attr__( 'Permalink to %s', 'twentyeleven' ), the_title_attribute( 'echo=0' ) ); ?>" rel="bookmark"><?php the_title(); ?></a></h1>
<?php endif; ?>
<?php if ( 'post' == $post->post_type ) : ?>
<div class="entry-meta">

View File

@ -14,27 +14,12 @@
<footer id="colophon" role="contentinfo">
<?php if ( is_active_sidebar( 'sidebar-3' ) || is_active_sidebar( 'sidebar-4' ) || is_active_sidebar( 'sidebar-5' ) ) : ?>
<div id="supplementary" <?php twentyeleven_footer_sidebar_class(); ?>>
<?php if ( is_active_sidebar( 'sidebar-3' ) ) : ?>
<div id="first" class="widget-area" role="complementary">
<?php dynamic_sidebar( 'sidebar-3' ); ?>
</div><!-- #first .widget-area -->
<?php endif; ?>
<?php if ( is_active_sidebar( 'sidebar-4' ) ) : ?>
<div id="second" class="widget-area" role="complementary">
<?php dynamic_sidebar( 'sidebar-4' ); ?>
</div><!-- #second .widget-area -->
<?php endif; ?>
<?php if ( is_active_sidebar( 'sidebar-5' ) ) : ?>
<div id="third" class="widget-area" role="complementary">
<?php dynamic_sidebar( 'sidebar-5' ); ?>
</div><!-- #third .widget-area -->
<?php endif; ?>
</div><!-- #supplementary -->
<?php endif; ?>
<?php
/* A sidebar in the footer? Yep. You can can customize
* your footer with three columns of widgets.
*/
get_sidebar( 'footer' );
?>
<div id="site-generator">
<a href="http://wordpress.org/" rel="generator">Proudly powered by WordPress</a><span class="sep"> | </span><?php printf( __( 'Theme: %1$s.', 'twentyeleven' ), 'Twenty Eleven' ); ?>

View File

@ -353,7 +353,7 @@ add_filter( 'get_the_excerpt', 'twentyeleven_custom_excerpt_more' );
* Add custom body classes
*/
function twentyeleven_singular_class( $classes ) {
if ( is_singular() && ! is_home() && ! is_page_template( 'showcase.php' ) )
if ( is_singular() && ! is_home() && ! is_page_template( 'showcase.php' ) && ! is_page_template( 'sidebar-page.php' ) )
$classes[] = 'singular';
return $classes;

View File

@ -47,13 +47,24 @@
?></title>
<link rel="profile" href="http://gmpg.org/xfn/11" />
<link rel="stylesheet" type="text/css" media="all" href="<?php bloginfo( 'stylesheet_url' ); ?>" />
<?php if ( is_singular() && get_option( 'thread_comments' ) ) wp_enqueue_script( 'comment-reply' ); ?>
<link rel="pingback" href="<?php bloginfo( 'pingback_url' ); ?>" />
<!--[if lt IE 9]>
<script src="<?php echo get_template_directory_uri(); ?>/js/html5.js" type="text/javascript"></script>
<![endif]-->
<?php
/* We add some JavaScript to pages with the comment form
* to support sites with threaded comments (when in use).
*/
if ( is_singular() && get_option( 'thread_comments' ) )
wp_enqueue_script( 'comment-reply' );
<?php wp_head(); ?>
/* Always have wp_head() just before the closing </head>
* tag of your theme, or you will break many plugins, which
* generally use this hook to add elements to <head> such
* as styles, scripts, and meta tags.
*/
wp_head();
?>
</head>
<body <?php body_class(); ?>>
@ -100,8 +111,9 @@
<nav id="access" role="navigation">
<h1 class="section-heading"><?php _e( 'Main menu', 'twentyeleven' ); ?></h1>
<?php /* Allow screen readers / text browsers to skip the navigation menu and get right to the good stuff. */ ?>
<div class="skip-link screen-reader-text"><a href="#content" title="<?php esc_attr_e( 'Skip to content', 'twentyeleven' ); ?>"><?php _e( 'Skip to content', 'twentyeleven' ); ?></a></div>
<?php /* Our navigation menu. If one isn't filled out, wp_nav_menu falls back to wp_page_menu. The menu assiged to the primary position is the one used. If none is assigned, the menu with the lowest ID is used. */ ?>
<?php wp_nav_menu( array( 'theme_location' => 'primary' ) ); ?>
</nav><!-- #access -->
</header><!-- #branding -->

View File

@ -70,7 +70,7 @@ get_header(); ?>
}
?>
<a href="<?php echo $next_attachment_url; ?>" title="<?php echo esc_attr( get_the_title() ); ?>" rel="attachment"><?php
$attachment_size = apply_filters( 'theme_attachment_size', 848 );
$attachment_size = apply_filters( 'twentyeleven_attachment_size', 848 );
echo wp_get_attachment_image( $post->ID, array( $attachment_size, 1024 ) ); // filterable image width with 1024px limit for image height.
?></a>

View File

@ -295,7 +295,8 @@ function twentyeleven_print_link_color_style() {
.entry-title a:hover,
.widget_twentyeleven_ephemera .comments-link a:hover,
section.recent-posts .other-recent-posts a[rel="bookmark"]:hover,
section.recent-posts .other-recent-posts .comments-link a:hover {
section.recent-posts .other-recent-posts .comments-link a:hover,
.format-image footer.entry-meta a:hover {
color: <?php echo $link_color; ?>;
}
section.recent-posts .other-recent-posts .comments-link a:hover {

View File

@ -23,7 +23,13 @@ get_header(); ?>
<?php /* Start the Loop */ ?>
<?php while ( have_posts() ) : the_post(); ?>
<?php get_template_part( 'content', 'search' ); ?>
<?php
/* Include the Post-Format-specific template for the content.
* If you want to overload this in a child theme then include a file
* called loop-___.php (where ___ is the Post Format name) and that will be used instead.
*/
get_template_part( 'content', get_post_format() );
?>
<?php endwhile; ?>

View File

@ -0,0 +1,42 @@
<?php
/**
* The Footer widget areas.
*
* @package WordPress
* @subpackage Twenty_Eleven
* @since Twenty Eleven 1.0
*/
?>
<?php
/* The footer widget area is triggered if any of the areas
* have widgets. So let's check that first.
*
* If none of the sidebars have widgets, then let's bail early.
*/
if ( ! is_active_sidebar( 'sidebar-3' )
&& ! is_active_sidebar( 'sidebar-4' )
&& ! is_active_sidebar( 'sidebar-5' )
)
return;
// If we get this far, we have widgets. Let do this.
?>
<div id="supplementary" <?php twentyeleven_footer_sidebar_class(); ?>>
<?php if ( is_active_sidebar( 'sidebar-3' ) ) : ?>
<div id="first" class="widget-area" role="complementary">
<?php dynamic_sidebar( 'sidebar-3' ); ?>
</div><!-- #first .widget-area -->
<?php endif; ?>
<?php if ( is_active_sidebar( 'sidebar-4' ) ) : ?>
<div id="second" class="widget-area" role="complementary">
<?php dynamic_sidebar( 'sidebar-4' ); ?>
</div><!-- #second .widget-area -->
<?php endif; ?>
<?php if ( is_active_sidebar( 'sidebar-5' ) ) : ?>
<div id="third" class="widget-area" role="complementary">
<?php dynamic_sidebar( 'sidebar-5' ); ?>
</div><!-- #third .widget-area -->
<?php endif; ?>
</div><!-- #supplementary -->

View File

@ -0,0 +1,26 @@
<?php
/**
* Template Name: Sidebar Template
* Description: A Page Template that adds a sidebar to pages
*
* @package WordPress
* @subpackage Twenty Eleven
* @since Twenty Eleven 1.0
*/
get_header(); ?>
<div id="primary">
<div id="content" role="main">
<?php the_post(); ?>
<?php get_template_part( 'content', 'page' ); ?>
<?php comments_template( '', true ); ?>
</div><!-- #content -->
</div><!-- #primary -->
<?php get_sidebar(); ?>
<?php get_footer(); ?>

View File

@ -1052,6 +1052,9 @@ article.format-status .entry-content {
.format-image .entry-meta span.comments-link {
display: block;
}
.format-image footer.entry-meta a {
color: #444;
}
.format-image .wp-caption {
background: #111;
margin-bottom: 0;
@ -1779,6 +1782,18 @@ a.comment-reply-link {
border-color: #d3d3d3;
}
/* sidebar-page.php comments */
/* Make sure we have room for our comment avatars */
.page-template-sidebar-page-php .commentlist > li.comment,
.page-template-sidebar-page-php.commentlist .pingback {
margin-left: 102px;
width: auto;
}
/* And a full-width comment form */
.page-template-sidebar-page-php #respond {
width: auto;
}
/* Comment Form */
#respond {
background: #ddd;
@ -2114,7 +2129,7 @@ p.comment-form-comment {
/* Talking avatars take up too much room at this size */
.commentlist > li.comment,
.commentlist > li.pingback {
margin-left: 0;
margin-left: 0 !important;
}
.commentlist .avatar {
background: transparent;
@ -2146,9 +2161,7 @@ p.comment-form-comment {
font-size: 10pt;
}
footer.entry-meta a[rel=bookmark]:link:after,
footer.entry-meta a[rel=bookmark]:visited:after,
#author-info a:link:after,
#author-info a:visited:after {
footer.entry-meta a[rel=bookmark]:visited:after {
content:" [" attr(href) "] "; /* Show URLs */
}
#page {
@ -2200,6 +2213,9 @@ p.comment-form-comment {
.singular .entry-header .entry-meta {
position: static;
}
.entry-meta .edit-link a {
display: none;
}
#content nav {
display: none;
}
@ -2270,6 +2286,16 @@ p.comment-form-comment {
.commentlist li.comment .comment-content {
margin: 1.625em 0 0;
}
.commentlist .comment-edit-link {
display: none;
}
.commentlist > li::before,
.commentlist > li.bypostauthor::before {
content: '';
}
.commentlist .reply {
display: none;
}
/* Post author highlighting */
.commentlist > li.bypostauthor {

View File

@ -27,7 +27,13 @@ get_header(); ?>
<?php /* Start the Loop */ ?>
<?php while ( have_posts() ) : the_post(); ?>
<?php get_template_part( 'content', get_post_format() ); ?>
<?php
/* Include the Post-Format-specific template for the content.
* If you want to overload this in a child theme then include a file
* called loop-___.php (where ___ is the Post Format name) and that will be used instead.
*/
get_template_part( 'content', get_post_format() );
?>
<?php endwhile; ?>