Make WordPress Core

Changeset 14708


Ignore:
Timestamp:
05/17/2010 06:36:11 AM (14 years ago)
Author:
nacin
Message:

In Twenty Ten, documentation and code improvements. see #12695.

Location:
trunk/wp-content/themes/twentyten
Files:
18 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-content/themes/twentyten/404.php

    r14707 r14708  
    55 * @package WordPress
    66 * @subpackage Twenty_Ten
    7  * @since 3.0.0
     7 * @since Twenty Ten 1.0
    88 */
    99?>
  • trunk/wp-content/themes/twentyten/archive.php

    r14707 r14708  
    1010 * @package WordPress
    1111 * @subpackage Twenty_Ten
    12  * @since 3.0.0
     12 * @since Twenty Ten 1.0
    1313 */
    1414?>
     
    1919            <div id="content" role="main">
    2020
    21 <?php the_post(); ?>
     21<?php
     22    /* Queue the first post, that way we know
     23     * what date we're dealing with (if that is the case).
     24     *
     25     * We reset this later so we can run the loop
     26     * properly with a call to rewind_posts().
     27     */
     28    the_post();
     29?>
    2230
    2331            <h1 class="page-title">
     
    3240<?php endif; ?>
    3341            </h1>
    34 <?php rewind_posts(); ?>
     42
    3543<?php
     44    /* Since we called the_post() above, we need to
     45     * rewind the loop back to the beginning that way
     46     * we can run the loop properly, in full.
     47     */
     48    rewind_posts();
     49
    3650    /* Run the loop for the archives page to output the posts.
    3751     * If you want to overload this in a child theme then include a file
  • trunk/wp-content/themes/twentyten/attachment.php

    r14707 r14708  
    55 * @package WordPress
    66 * @subpackage Twenty_Ten
    7  * @since 3.0.0
     7 * @since Twenty Ten 1.0
    88 */
    99?>
     
    1414            <div id="content" role="main">
    1515
    16 <?php the_post(); ?>
     16<?php if ( have_posts() ) while ( have_posts() ) : the_post(); ?>
    1717
    1818                <p class="page-title"><a href="<?php echo get_permalink( $post->post_parent ); ?>" title="<?php printf( esc_attr__( 'Return to %s', 'twentyten' ), esc_html( get_the_title( $post->post_parent ), 1 ) ); ?>" rel="gallery">&larr; <?php echo get_the_title( $post->post_parent ); ?></a></p>
     
    9999<?php comments_template(); ?>
    100100
     101<?php endwhile; ?>
     102
    101103            </div><!-- #content -->
    102104        </div><!-- #container -->
  • trunk/wp-content/themes/twentyten/author.php

    r14707 r14708  
    55 * @package WordPress
    66 * @subpackage Twenty_Ten
    7  * @since 3.0.0
     7 * @since Twenty Ten 1.0
    88 */
    99?>
     
    1414            <div id="content" role="main">
    1515
    16 <?php the_post(); ?>
     16<?php
     17    /* Queue the first post, that way we know who
     18     * the author is when we try to get their name,
     19     * URL, description, avatar, etc.
     20     *
     21     * We reset this later so we can run the loop
     22     * properly with a call to rewind_posts().
     23     */
     24    the_post();
     25?>
    1726
    1827                <h1 class="page-title author"><?php printf( __( 'Author Archives: %s', 'twentyten' ), "<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>
    1928
    20 <?php if ( get_the_author_meta( 'description' ) ) : // If a user has filled out their description, show a bio on their entries  ?>
     29<?php
     30// If a user has filled out their description, show a bio on their entries.
     31if ( get_the_author_meta( 'description' ) ) : ?>
    2132                    <div id="entry-author-info">
    2233                        <div id="author-avatar">
     
    3041<?php endif; ?>
    3142
    32 <?php rewind_posts(); ?>
     43<?php
     44    /* Since we called the_post() above, we need to
     45     * rewind the loop back to the beginning that way
     46     * we can run the loop properly, in full.
     47     */
     48    rewind_posts();
    3349
    34 <?php
    3550    /* Run the loop for the author archive page to output the authors posts
    3651     * If you want to overload this in a child theme then include a file
  • trunk/wp-content/themes/twentyten/category.php

    r14707 r14708  
    55 * @package WordPress
    66 * @subpackage Twenty_Ten
    7  * @since 3.0.0
     7 * @since Twenty Ten 1.0
    88 */
    99?>
     
    2121                    if ( ! empty( $category_description ) )
    2222                        echo '<div class="archive-meta">' . $categorydesc . '</div>';
    23                 ?>
    2423
    25                 <?php
    2624                /* Run the loop for the category page to output the posts.
    2725                 * If you want to overload this in a child theme then include a file
  • trunk/wp-content/themes/twentyten/comments.php

    r14707 r14708  
    1010 * @package WordPress
    1111 * @subpackage Twenty_Ten
    12  * @since 3.0.0
     12 * @since Twenty Ten 1.0
    1313 */
    1414?>
     
    1919            </div><!-- .comments -->
    2020<?php
     21        /* Stop the rest of comments.php from being processed,
     22         * but don't kill the script entirely -- we still have
     23         * to fully load the template.
     24         */
    2125        return;
    2226    endif;
     
    2832
    2933<?php if ( have_comments() ) : ?>
    30             <h3 id="comments-title">
    31 <?php
     34            <h3 id="comments-title"><?php
    3235            printf( _n( 'One Response to %2$s', '%1$s Responses to %2$s', get_comments_number(), 'twentyten' ),
    3336            number_format_i18n( get_comments_number() ), '<em>' . get_the_title() . '</em>' );
    34 ?>
    35             </h3>
     37            ?></h3>
    3638
    37 <?php if ( get_comment_pages_count() > 1 ) : // are there comments to navigate through ?>
     39<?php if ( get_comment_pages_count() > 1 ) : // Are there comments to navigate through? ?>
    3840            <div class="navigation">
    3941                <div class="nav-previous"><?php previous_comments_link( __( '&larr; Older Comments', 'twentyten' ) ); ?></div>
     
    4345
    4446            <ol class="commentlist">
    45                 <?php wp_list_comments( array( 'callback' => 'twentyten_comment' ) ); ?>
     47                <?php
     48                    /* Loop through and list the comments. Tell wp_list_comments()
     49                     * to use twentyten_comment() to format the comments.
     50                     * If you want to overload this in a child theme then you can
     51                     * define twentyten_comment() and that will be used instead.
     52                     * See twentyten_comment() in twentyten/functions.php for more.
     53                     */
     54                    wp_list_comments( array( 'callback' => 'twentyten_comment' ) );
     55                ?>
    4656            </ol>
    4757
    48 <?php if ( get_comment_pages_count() > 1 ) : // are there comments to navigate through ?>
     58<?php if ( get_comment_pages_count() > 1 ) : // Are there comments to navigate through? ?>
    4959            <div class="navigation">
    5060                <div class="nav-previous"><?php previous_comments_link( __( '&larr; Older Comments', 'twentyten' ) ); ?></div>
     
    5363<?php endif; // check for comment navigation ?>
    5464
    55 <?php else : // this is displayed if there are no comments so far ?>
     65<?php else : // or, if we don't have comments:
    5666
    57 <?php if ( comments_open() ) : // If comments are open, but there are no comments ?>
     67    /* If there are no comments and comments are closed,
     68     * let's leave a little note, shall we?
     69     */
     70    if ( ! comments_open() ) :
     71?>
     72    <p class="nocomments"><?php _e( 'Comments are closed.', 'twentyten' ); ?></p>
     73<?php endif; // end ! comments_opened() ?>
    5874
    59 <?php else : // if comments are closed ?>
    60 
    61         <p class="nocomments"><?php _e( 'Comments are closed.', 'twentyten' ); ?></p>
    62 
    63 <?php endif; ?>
    64 <?php endif; ?>
     75<?php endif; // end have_comments() ?>
    6576
    6677<?php comment_form(); ?>
  • trunk/wp-content/themes/twentyten/footer.php

    r14707 r14708  
    88 * @package WordPress
    99 * @subpackage Twenty_Ten
    10  * @since 3.0.0
     10 * @since Twenty Ten 1.0
    1111 */
    1212?>
     
    1616        <div id="colophon">
    1717
    18 <?php get_sidebar( 'footer' ); ?>
     18<?php
     19    /* A sidebar in the footer? Yep. You can can customize
     20     * your footer with four columns of widgets.
     21     */
     22    get_sidebar( 'footer' );
     23?>
    1924
    2025            <div id="site-info">
  • trunk/wp-content/themes/twentyten/header.php

    r14692 r14708  
    77 * @package WordPress
    88 * @subpackage Twenty_Ten
    9  * @since 3.0.0
     9 * @since Twenty Ten 1.0
    1010 */
    11 ?>
    12 
    13 <!DOCTYPE html>
     11?><!DOCTYPE html>
    1412<html <?php language_attributes(); ?>>
    1513<head>
     
    4745        <div id="masthead">
    4846            <div id="branding" role="banner">
    49                 <?php $heading_tag = ( is_home() || is_front_page() )? 'h1' : 'div'; ?>
     47                <?php $heading_tag = ( is_home() || is_front_page() ) ? 'h1' : 'div'; ?>
    5048                <<?php echo $heading_tag; ?> id="site-title">
    5149                    <span>
    5250                        <a href="<?php echo home_url( '/' ); ?>" title="<?php echo esc_attr( get_bloginfo( 'name', 'display' ) ); ?>" rel="home"><?php bloginfo( 'name' ); ?></a>
    5351                    </span>
    54                 </<?php echo $heading_tag; ?>>             
     52                </<?php echo $heading_tag; ?>>
    5553                <div id="site-description"><?php bloginfo( 'description' ); ?></div>
    5654
  • trunk/wp-content/themes/twentyten/index.php

    r14707 r14708  
    1111 * @package WordPress
    1212 * @subpackage Twenty_Ten
    13  * @since 3.0.0
     13 * @since Twenty Ten 1.0
    1414 */
    1515?>
  • trunk/wp-content/themes/twentyten/loop.php

    r14707 r14708  
    1010 * @package WordPress
    1111 * @subpackage Twenty_Ten
    12  * @since 3.0.0
     12 * @since Twenty Ten 1.0
    1313 */
    1414?>
     
    2727        <h1 class="entry-title"><?php _e( 'Not Found', 'twentyten' ); ?></h1>
    2828        <div class="entry-content">
    29             <p><?php _e( 'Apologies, but no results were found for the requested Archive. Perhaps searching will help find a related post.', 'twentyten' ); ?></p>
     29            <p><?php _e( 'Apologies, but no results were found for the requested archive. Perhaps searching will help find a related post.', 'twentyten' ); ?></p>
    3030            <?php get_search_form(); ?>
    3131        </div><!-- .entry-content -->
     
    3333<?php endif; ?>
    3434
    35 <?php /* Start the Loop */ ?>
     35<?php
     36    /* Start the Loop.
     37     *
     38     * In Twenty Ten we use the same loop in multiple contexts.
     39     * It is broken into three main parts: when we're displaying
     40     * posts that are in the gallery category, when we're displaying
     41     * posts in the asides category, and finally all other posts.
     42     *
     43     * Additionally, we sometimes check for whether we are on an
     44     * archive page, a search page, etc., allowing for small differences
     45     * in the loop on each template without actually duplicating
     46     * the rest of the loop that is shared.
     47     *
     48     * Without further ado, the loop:
     49     */ ?>
    3650<?php while ( have_posts() ) : the_post(); ?>
    3751
    38 <?php /* How to Display posts in the Gallery Category */ ?>
     52<?php /* How to display posts in the Gallery category. */ ?>
     53
    3954    <?php if ( in_category( _x('gallery', 'gallery category slug', 'twentyten') ) ) : ?>
    4055        <div id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
     
    7287
    7388<?php /* How to display posts in the asides category */ ?>
     89
    7490    <?php elseif ( in_category( _x('asides', 'asides category slug', 'twentyten') ) ) : ?>
    7591        <div id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
    76     <?php if ( is_archive() || is_search() ) : // Only display Excerpts for archives & search ?>
     92
     93        <?php if ( is_archive() || is_search() ) : // Display excerpts for archives and search. ?>
    7794            <div class="entry-summary">
    78                 <?php the_excerpt( __( 'Continue reading <span class="meta-nav">&rarr;</span>', 'twentyten' ) ); ?>
     95                <?php the_excerpt(); ?>
    7996            </div><!-- .entry-summary -->
    80     <?php else : ?>
     97        <?php else : ?>
    8198            <div class="entry-content">
    8299                <?php the_content( __( 'Continue reading <span class="meta-nav">&rarr;</span>', 'twentyten' ) ); ?>
    83100            </div><!-- .entry-content -->
    84     <?php endif; ?>
     101        <?php endif; ?>
    85102
    86103            <div class="entry-utility">
     
    90107                <?php edit_post_link( __( 'Edit', 'twentyten' ), '<span class="meta-sep">|</span> <span class="edit-link">', '</span>' ); ?>
    91108            </div><!-- #entry-utility -->
    92         </div><!-- #post-<?php the_ID(); ?> -->
     109        </div><!-- #post-(id) -->
    93110
    94 <?php /* How to display all other posts */ ?>
     111<?php /* How to display all other posts. */ ?>
     112
    95113    <?php else : ?>
    96114        <div id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
     
    101119            </div><!-- .entry-meta -->
    102120
    103     <?php if ( is_archive() || is_search() ) : // Only display Excerpts for archives & search ?>
     121    <?php if ( is_archive() || is_search() ) : // Only display excerpts for archives and search. ?>
    104122            <div class="entry-summary">
    105123                <?php the_excerpt( __( 'Continue reading <span class="meta-nav">&rarr;</span>', 'twentyten' ) ); ?>
     
    115133                <?php if ( count( get_the_category() ) ) : ?>
    116134                    <span class="cat-links">
    117                         <span class="entry-utility-prep entry-utility-prep-cat-links"><?php printf( __('Posted in %s', 'twentyten' ), '</span> '.get_the_category_list( ', ' ) ); ?>
     135                        <span class="entry-utility-prep entry-utility-prep-cat-links"><?php printf( __('Posted in %s', 'twentyten' ), '</span> ' . get_the_category_list( ', ' ) ); ?>
    118136                    </span>
    119137                    <span class="meta-sep">|</span>
     
    135153        <?php comments_template( '', true ); ?>
    136154
    137     <?php endif; // if different categories queried ?>
    138 <?php endwhile; ?>
     155    <?php endif; // This was the if statement that broke the loop into three parts based on categories. ?>
     156
     157<?php endwhile; // End the loop. Whew. ?>
    139158
    140159<?php /* Display navigation to next/previous pages when applicable */ ?>
  • trunk/wp-content/themes/twentyten/onecolumn-page.php

    r14692 r14708  
    44 *
    55 * A custom page template without sidebar.
    6  * Selectable from a dropdown menu on the edit page screen.
     6 *
     7 * The "Template Name:" bit above allows this to be selectable
     8 * from a dropdown menu on the edit page screen.
    79 *
    810 * @package WordPress
    911 * @subpackage Twenty_Ten
    10  * @since 3.0.0
     12 * @since Twenty Ten 1.0
    1113 */
    1214?>
     
    1416<?php get_header(); ?>
    1517
    16         <div id="container" class="onecolumn">
     18        <div id="container" class="one-column">
    1719            <div id="content" role="main">
    1820
    19 <?php the_post(); ?>
     21<?php if ( have_posts() ) while ( have_posts() ) : the_post(); ?>
    2022
    2123                <div id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
     
    3032                <?php comments_template( '', true ); ?>
    3133
     34<?php endwhile; ?>
     35
    3236            </div><!-- #content -->
    3337        </div><!-- #container -->
  • trunk/wp-content/themes/twentyten/page.php

    r14707 r14708  
    1010 * @package WordPress
    1111 * @subpackage Twenty_Ten
    12  * @since 3.0.0
     12 * @since Twenty Ten 1.0
    1313 */
    1414?>
     
    1919            <div id="content" role="main">
    2020
    21 <?php the_post(); ?>
     21<?php if ( have_posts() ) while ( have_posts() ) : the_post(); ?>
    2222
    2323                <div id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
     
    3737                <?php comments_template( '', true ); ?>
    3838
     39<?php endwhile; ?>
     40
    3941            </div><!-- #content -->
    4042        </div><!-- #container -->
  • trunk/wp-content/themes/twentyten/search.php

    r14707 r14708  
    55 * @package WordPress
    66 * @subpackage Twenty_Ten
    7  * @since 3.0.0
     7 * @since Twenty Ten 1.0
    88 */
    99?>
  • trunk/wp-content/themes/twentyten/sidebar-footer.php

    r14707 r14708  
    55 * @package WordPress
    66 * @subpackage Twenty_Ten
    7  * @since 3.0.0
     7 * @since Twenty Ten 1.0
    88 */
    99?>
    1010
    1111<?php
    12     if (
    13         is_active_sidebar( 'first-footer-widget-area' )  ||
    14         is_active_sidebar( 'second-footer-widget-area' ) ||
    15         is_active_sidebar( 'third-footer-widget-area' )  ||
    16         is_active_sidebar( 'fourth-footer-widget-area' )
    17     ) :
     12    /* The footer widget area is triggered if any of the areas
     13     * have widgets. So let's check that first.
     14     *
     15     * If none of the sidebars have widgets, then let's bail early.
     16     */
     17    if (   ! is_active_sidebar( 'first-footer-widget-area'  )
     18        && ! is_active_sidebar( 'second-footer-widget-area' )
     19        && ! is_active_sidebar( 'third-footer-widget-area'  )
     20        && ! is_active_sidebar( 'fourth-footer-widget-area' )
     21    )
     22        return;
     23    // If we get this far, we have widgets. Let do this.
    1824?>
     25
    1926            <div id="footer-widget-area" role="complementary">
     27
    2028<?php if ( is_active_sidebar( 'first-footer-widget-area' ) ) : ?>
    21                     <div id="first" class="widget-area">
    22                         <ul class="xoxo">
    23                             <?php dynamic_sidebar( 'first-footer-widget-area' ); ?>
    24                         </ul>
    25                     </div><!-- #first .widget-area -->
     29                <div id="first" class="widget-area">
     30                    <ul class="xoxo">
     31                        <?php dynamic_sidebar( 'first-footer-widget-area' ); ?>
     32                    </ul>
     33                </div><!-- #first .widget-area -->
    2634<?php endif; ?>
    2735
     
    5159
    5260            </div><!-- #footer-widget-area -->
    53 <?php endif; ?>
  • trunk/wp-content/themes/twentyten/sidebar.php

    r14707 r14708  
    55 * @package WordPress
    66 * @subpackage Twenty_Ten
    7  * @since 3.0.0
     7 * @since Twenty Ten 1.0
    88 */
    99?>
     
    1111        <div id="primary" class="widget-area" role="complementary">
    1212            <ul class="xoxo">
    13 <?php if ( ! dynamic_sidebar( 'primary-widget-area' ) ) : // begin primary widget area ?>
     13
     14<?php
     15    /* When we call the dynamic_sidebar() function, it'll spit out
     16     * the widgets for that widget area. If it instead returns false,
     17     * then the sidebar simply doesn't exist, so we'll hard-code in
     18     * some default sidebar stuff just in case.
     19     */
     20    if ( ! dynamic_sidebar( 'primary-widget-area' ) ) : ?>
     21   
    1422            <li id="search" class="widget-container widget_search">
    1523                <?php get_search_form(); ?>
     
    3139                </ul>
    3240            </li>
    33 <?php endif; // end primary widget area ?>
     41
     42        <?php endif; // end primary widget area ?>
    3443            </ul>
    3544        </div><!-- #primary .widget-area -->
    3645
    37 <?php if ( is_active_sidebar( 'secondary-widget-area' ) ) : // Nothing here by default and design ?>
     46<?php
     47    // A second sidebar for widgets, just because.
     48    if ( is_active_sidebar( 'secondary-widget-area' ) ) : ?>
     49
    3850        <div id="secondary" class="widget-area" role="complementary">
    3951            <ul class="xoxo">
     
    4153            </ul>
    4254        </div><!-- #secondary .widget-area -->
     55
    4356<?php endif; ?>
  • trunk/wp-content/themes/twentyten/single.php

    r14707 r14708  
    55 * @package WordPress
    66 * @subpackage Twenty_Ten
    7  * @since 3.0.0
     7 * @since Twenty Ten 1.0
    88 */
    99?>
     
    5454                        <?php edit_post_link( __( 'Edit', 'twentyten' ), '<span class="edit-link">', '</span>' ); ?>
    5555                    </div><!-- .entry-utility -->
    56                 </div><!-- #post-<?php the_ID(); ?> -->
     56                </div><!-- #post-(id) -->
    5757
    5858                <div id="nav-below" class="navigation">
  • trunk/wp-content/themes/twentyten/style.css

    r14689 r14708  
    8888*/
    8989
    90 .onecolumn #content {
     90.one-column #content {
    9191    margin: 0 auto;
    9292    width: 640px;
     
    13041304    }
    13051305    #content,
    1306     .onecolumn #content {
     1306    .one-column #content {
    13071307        width: 100%;
    13081308        margin: 24pt 0 0;
  • trunk/wp-content/themes/twentyten/tag.php

    r14707 r14708  
    55 * @package WordPress
    66 * @subpackage Twenty_Ten
    7  * @since 3.0.0
     7 * @since Twenty Ten 1.0
    88 */
    99?>
     
    1414            <div id="content" role="main">
    1515
    16 <?php the_post(); ?>
    17 
    18                 <h1 class="page-title">
    19                     <?php printf( __( 'Tag Archives: %s', 'twentyten' ), '<span>' . single_tag_title( '', false ) . '</span>' ); ?>
    20                 </h1>
    21 
    22 <?php rewind_posts(); ?>
     16                <h1 class="page-title"><?php
     17                    printf( __( 'Tag Archives: %s', 'twentyten' ), '<span>' . single_tag_title( '', false ) . '</span>' );
     18                ?></h1>
    2319
    2420<?php
Note: See TracChangeset for help on using the changeset viewer.