Make WordPress Core

Changeset 13885


Ignore:
Timestamp:
03/29/2010 10:03:15 PM (15 years ago)
Author:
nacin
Message:

Rough cut of Twenty Ten inline documentation. see #12695. props jorbin, demetris.

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

Legend:

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

    r13128 r13885  
     1<?php
     2/**
     3 * The template for displaying 404 pages (Not Found)
     4 *
     5 * @package WordPress
     6 * @subpackage Twenty Ten
     7 * @since 3.0.0
     8 */
     9?>
     10
    111<?php get_header(); ?>
    212
  • trunk/wp-content/themes/twentyten/archive.php

    r13816 r13885  
     1<?php
     2/**
     3 * Generic template for Archive pages.
     4 *
     5 * Used to display archive-type pages if nothing more specific matches a query.
     6 * For example, puts together date-based pages if no date.php file exists.
     7 *
     8 * Learn more: http://codex.wordpress.org/Template_Hierarchy
     9 *
     10 * @package WordPress
     11 * @subpackage Twenty Ten
     12 * @since 3.0.0
     13 */
     14?>
     15
    116<?php get_header(); ?>
    217
  • trunk/wp-content/themes/twentyten/attachment.php

    r13830 r13885  
     1<?php
     2/**
     3 * The template used to display attachments.
     4 *
     5 * @package WordPress
     6 * @subpackage Twenty Ten
     7 * @since 3.0.0
     8 */
     9?>
     10
    111<?php get_header(); ?>
    212
  • trunk/wp-content/themes/twentyten/author.php

    r13816 r13885  
     1<?php
     2/**
     3 * The template used to display Author Archive pages
     4 *
     5 * @package WordPress
     6 * @subpackage Twenty Ten
     7 * @since 3.0.0
     8 */
     9?>
     10
    111<?php get_header(); ?>
    212
  • trunk/wp-content/themes/twentyten/category.php

    r13830 r13885  
     1<?php
     2/**
     3 * The template used to display Category Archive pages
     4 *
     5 * @package WordPress
     6 * @subpackage Twenty Ten
     7 * @since 3.0.0
     8 */
     9?>
     10
    111<?php get_header(); ?>
    212
     
    1424                 * called loop-category.php and that will be used instead.
    1525                 */
    16                  get_template_part( 'loop', 'category' );
     26                get_template_part( 'loop', 'category' );
    1727                ?>
    1828
  • trunk/wp-content/themes/twentyten/comments.php

    r13830 r13885  
     1<?php
     2/**
     3 * The template used to display Comments
     4 *
     5 * The area of the page that contains both current comments
     6 * and the comment form.  The actual display of comments is
     7 * handled by a callback to twentyten_comment which is
     8 * located in the functions.php file
     9 *
     10 * @package WordPress
     11 * @subpackage Twenty Ten
     12 * @since 3.0.0
     13 */
     14?>
     15
    116            <div id="comments">
    217<?php if ( post_password_required() ) : ?>
  • trunk/wp-content/themes/twentyten/footer.php

    r13720 r13885  
     1<?php
     2/**
     3 * The template used to display the footer
     4 *
     5 * Contains the closing of the id=main div and all content
     6 * after.  Calls sidebar-footer.php for bottom widgets
     7 *
     8 * @package WordPress
     9 * @subpackage Twenty Ten
     10 * @since 3.0.0
     11 */
     12?>
     13
    114    </div><!-- #main -->
    215
  • trunk/wp-content/themes/twentyten/functions.php

    r13830 r13885  
    11<?php
    2 
    3 // Set the content width based on the Theme CSS
     2/**
     3 * TwentyTen functions and definitions
     4 *
     5 * Sets up the theme and provides some helper functions used
     6 * in other parts of the theme.  All functions are pluggable
     7 *
     8 * @package WordPress
     9 * @subpackage Twenty Ten
     10 * @since 3.0.0
     11 */
     12
     13/**
     14 * Set the content width based on the Theme CSS.  Can be overriden
     15 *
     16 * Used in attachment.php to set the width of images.  Should
     17 * be equal to the width set for .onecolumn #content in style.css
     18 */
    419if ( ! isset( $content_width ) )
    520    $content_width = 640;
    621
    722if ( ! function_exists( 'twentyten_init' ) ) :
     23/**
     24 * Set up defaults for our theme.
     25 *
     26 * Sets up theme defaults and tells wordpress that this is a
     27 * theme that will take advantage of Post Thumbnails, Custom
     28 * Background, Nav Menus and automatic feed links.  To
     29 * override any of the settings in a child theme, create your
     30 * own twentyten_init function
     31 *
     32 * @uses add_theme_support()
     33 */
    834function twentyten_init() {
     35    // This theme allows users to set a custom background
     36    add_custom_background();
     37
     38    // This theme styles the visual editor with editor-style.css to match the theme style.
     39    add_editor_style();
     40
     41    // This theme needs post thumbnails
     42    add_theme_support( 'post-thumbnails' );
     43
     44    // This theme uses wp_nav_menu()
     45    add_theme_support( 'nav-menus' );
     46
     47    // We'll be using them for custom header images on posts and pages
     48    // so we want them to be 940 pixels wide by 198 pixels tall (larger images will be auto-cropped to fit)
     49    set_post_thumbnail_size( HEADER_IMAGE_WIDTH, HEADER_IMAGE_HEIGHT, true );
     50
     51    // Add default posts and comments RSS feed links to head
     52    add_theme_support( 'automatic-feed-links' );
     53
     54    // Make theme available for translation
     55    // Translations can be filed in the /languages/ directory
     56    load_theme_textdomain( 'twentyten', TEMPLATEPATH . '/languages' );
     57
     58    $locale = get_locale();
     59    $locale_file = TEMPLATEPATH . "/languages/$locale.php";
     60    if ( is_readable( $locale_file ) )
     61        require_once( $locale_file );
     62
    963    // Your Changeable header business starts here
    1064    // No CSS, just IMG call
    1165    define( 'HEADER_TEXTCOLOR', '' );
    1266    define( 'HEADER_IMAGE', '%s/images/headers/forestfloor.jpg' ); // %s is theme dir uri
     67
     68    // Add a filter to twentyten_header_image_width and twentyten_header_image_height to change these values
    1369    define( 'HEADER_IMAGE_WIDTH', apply_filters( 'twentyten_header_image_width',  940 ) );
    1470    define( 'HEADER_IMAGE_HEIGHT', apply_filters( 'twentyten_header_image_height',  198 ) );
     71
    1572    define( 'NO_HEADER_TEXT', true );
    1673
    1774    add_custom_image_header( '', 'twentyten_admin_header_style' );
    1875    // and thus ends the changeable header business
     76
     77    // Default custom headers.  %s is a placeholder for the theme template directory
    1978
    2079    register_default_headers( array (
     
    60119        )
    61120    ) );
    62 
    63     add_custom_background();
    64 
    65     // This theme styles the visual editor with editor-style.css to match the theme style.
    66     add_editor_style();
    67 
    68     // This theme needs post thumbnails
    69     add_theme_support( 'post-thumbnails' );
    70 
    71     // This theme uses wp_nav_menu()
    72     add_theme_support( 'nav-menus' );
    73 
    74     // We'll be using them for custom header images on posts and pages
    75     // so we want them to be 940 pixels wide by 198 pixels tall (larger images will be auto-cropped to fit)
    76     set_post_thumbnail_size( HEADER_IMAGE_WIDTH, HEADER_IMAGE_HEIGHT, true );
    77 
    78     // Add default posts and comments RSS feed links to head
    79     add_theme_support( 'automatic-feed-links' );
    80 
    81     // Make theme available for translation
    82     // Translations can be filed in the /languages/ directory
    83     load_theme_textdomain( 'twentyten', TEMPLATEPATH . '/languages' );
    84 
    85     $locale = get_locale();
    86     $locale_file = TEMPLATEPATH . "/languages/$locale.php";
    87     if ( is_readable( $locale_file ) )
    88         require_once( $locale_file );
    89121}
    90122endif;
     
    92124
    93125if ( ! function_exists( 'twentyten_admin_header_style' ) ) :
     126/**
     127 * Callback to style the header image inside the admin
     128 */
    94129function twentyten_admin_header_style() {
    95130?>
     
    107142endif;
    108143
    109 // Get the page number
    110144if ( ! function_exists( 'twentyten_get_page_number' ) ) :
     145/**
     146 * Returns the page number currently being browsed
     147 *
     148 * Returns a vertical bar followed by page and the page
     149 * number.  Is pluggable
     150 *
     151 * @retun string
     152 */
    111153function twentyten_get_page_number() {
    112154    if ( get_query_var( 'paged' ) )
     
    115157endif;
    116158
    117 // Echo the page number
    118159if ( ! function_exists( 'twentyten_the_page_number' ) ) :
     160/**
     161 * Echos the page number being browsed
     162 *
     163 * @uses twentyten_get_page_number
     164 *
     165 */
    119166function twentyten_the_page_number() {
    120167    echo twentyten_get_page_number();
     
    122169endif;
    123170
    124 // Control excerpt length
    125171if ( ! function_exists( 'twentyten_excerpt_length' ) ) :
     172/**
     173 * Sets the excerpt length to 40 charachters.  Is pluggable
     174 *
     175 * @return int
     176 */
    126177function twentyten_excerpt_length( $length ) {
    127178    return 40;
     
    130181add_filter( 'excerpt_length', 'twentyten_excerpt_length' );
    131182
    132 
    133 // Make a nice read more link on excerpts
    134183if ( ! function_exists( 'twentyten_excerpt_more' ) ) :
     184/**
     185 * Sets the read more link for excerpts to something pretty
     186 *
     187 * @return string
     188 *
     189 */
    135190function twentyten_excerpt_more( $more ) {
    136191    return '&nbsp;&hellip; <a href="'. get_permalink() . '">' . __('Continue&nbsp;reading&nbsp;<span class="meta-nav">&rarr;</span>', 'twentyten') . '</a>';
     
    139194add_filter( 'excerpt_more', 'twentyten_excerpt_more' );
    140195
    141 
    142 // Template for comments and pingbacks
    143196if ( ! function_exists( 'twentyten_comment' ) ) :
     197/**
     198 * Template for comments and pingbacks
     199 *
     200 * Used as a callback by wp_list_comments for displaying the
     201 * comments.  Is pluggable
     202 *
     203 */
    144204function twentyten_comment( $comment, $args, $depth ) {
    145205    $GLOBALS ['comment'] = $comment; ?>
     
    172232endif;
    173233
    174 // Remove inline styles on gallery shortcode
    175234if ( ! function_exists( 'twentyten_remove_gallery_css' ) ) :
     235/**
     236 * Remove inline styles on gallery shortcode
     237 *
     238 * @return string
     239 */
    176240function twentyten_remove_gallery_css( $css ) {
    177241    return preg_replace( "#<style type='text/css'>(.*?)</style>#s", '', $css );
     
    181245
    182246if ( ! function_exists( 'twentyten_cat_list' ) ) :
     247/**
     248 * Returns the list of categories
     249 *
     250 * Returns the list of categories based on if we are or are
     251 * not browsing a category archive page.
     252 *
     253 * @uses twentyten_term_list
     254 *
     255 * @return string
     256 */
    183257function twentyten_cat_list() {
    184258    return twentyten_term_list( 'category', ', ', __( 'Posted in %s', 'twentyten' ), __( 'Also posted in %s', 'twentyten' ) );
     
    187261
    188262if ( ! function_exists( 'twentyten_tag_list' ) ) :
     263/**
     264 * Returns the list of tags
     265 *
     266 * Returns the list of tags based on if we are or are not
     267 * browsing a tag archive page
     268 *
     269 * @uses twentyten_term_list
     270 *
     271 * @return string
     272 */
    189273function twentyten_tag_list() {
    190274    return twentyten_term_list( 'post_tag', ', ', __( 'Tagged %s', 'twentyten' ), __( 'Also tagged %s', 'twentyten' ) );
     
    193277
    194278if ( ! function_exists( 'twentyten_term_list' ) ) :
     279/**
     280 * Returns the list of taxonomy items in multiple ways
     281 *
     282 * Returns the list of taxonomy items differently based on
     283 * if we are browsing a term archive page or a different
     284 * type of page.  If browsing a term archive page and the
     285 * post has no other taxonomied terms, it returns empty
     286 *
     287 * @return string
     288 */
    195289function twentyten_term_list( $taxonomy, $glue = ', ', $text = '', $also_text = '' ) {
    196290    global $wp_query, $post;
     
    220314endif;
    221315
    222 // Register widgetized areas
    223316if ( ! function_exists( 'twentyten_widgets_init' ) ) :
     317/**
     318 * Register widgetized areas
     319 *
     320 * @uses register_sidebar
     321 */
    224322function twentyten_widgets_init() {
    225323    // Area 1
  • trunk/wp-content/themes/twentyten/header.php

    r13872 r13885  
     1<?php
     2/**
     3 * The Header for our theme.
     4 *
     5 * Displays all of the <head> section and everything up till <div id="main">
     6 *
     7 * @package WordPress
     8 * @subpackage Twenty Ten
     9 * @since 3.0.0
     10 */
     11?>
     12
    113<!DOCTYPE html>
    214<html <?php language_attributes(); ?>>
  • trunk/wp-content/themes/twentyten/index.php

    r13816 r13885  
     1<?php
     2
     3/**
     4 * The main template file
     5 *
     6 * This is the most generic template file in a WordPress theme
     7 * and one of the two required files for a theme (the other being style.css).
     8 * It is used to display a page when nothing more specific matches a query.
     9 * E.g., it puts together the home page when no home.php file exists.
     10 * Learn more: http://codex.wordpress.org/Template_Hierarchy
     11 *
     12 * @package WordPress
     13 * @subpackage Twenty Ten
     14 * @since 3.0.0
     15 */
     16 
     17?>
     18 
    119<?php get_header(); ?>
    220
  • trunk/wp-content/themes/twentyten/loop.php

    r13830 r13885  
     1<?php
     2/**
     3 * The loop that displays posts
     4 *
     5 * The loop displays the posts and the post content.  See
     6 * http://codex.wordpress.org/The_Loop to understand it and
     7 * http://codex.wordpress.org/Template_Tags to understand
     8 * the tags used in it.
     9 *
     10 * @package WordPress
     11 * @subpackage Twenty Ten
     12 * @since 3.0.0
     13 */
     14?>
     15
     16<?php /* Display navigation to next/previous pages when applicable  */ ?>
    117<?php if ( $wp_query->max_num_pages > 1 ) : ?>
    218    <div id="nav-above" class="navigation">
     
    622<?php endif; ?>
    723
     24<?php /* If there are no posts to display, such as an empty archive page  */ ?>
    825<?php if ( ! have_posts() ) : ?>
    926    <div id="post-0" class="post error404 not-found">
     
    1633<?php endif; ?>
    1734
     35<?php /* Start the Loop  */ ?>
    1836<?php while ( have_posts() ) : the_post(); ?>
     37
     38<?php /* How to Display posts in the Gallery Category  */ ?>
    1939    <?php if ( in_category( 'Gallery' ) ) : ?>
    2040        <div id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
     
    6383        </div>
    6484
    65 
     85<?php /* How to display posts in the asides category */ ?>
    6686    <?php elseif ( in_category( 'asides' ) ) : ?>
    6787        <div id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
     
    93113        </div><!-- #post-<?php the_ID(); ?> -->
    94114
    95 
     115<?php /* How to display all other posts  */ ?>
    96116    <?php else : ?>
    97117        <div id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
     
    140160<?php endwhile; ?>
    141161
     162<?php /* Display navigation to next/previous pages when applicable  */ ?>
    142163<?php if (  $wp_query->max_num_pages > 1 ) : ?>
    143164                <div id="nav-below" class="navigation">
  • trunk/wp-content/themes/twentyten/onecolumn-page.php

    r13818 r13885  
     1<?php
     2/**
     3 * Template Name: One column, no sidebar
     4 *
     5 * A custom page template without sidebar.
     6 * Selectable from a dropdown menu on the edit page screen.
     7 *
     8 * @package WordPress
     9 * @subpackage Twenty Ten
     10 * @since 3.0.0
     11 */
     12?>
    113
    2 <?php
    3 /*
    4 Template Name: One column, no sidebar
    5 Description: A template with no sidebar
    6 */
    7 get_header(); ?>
     14<?php get_header(); ?>
    815
    916        <div id="container" class="onecolumn">
  • trunk/wp-content/themes/twentyten/page.php

    r13846 r13885  
     1<?php
     2/**
     3 * The template used to display all pages
     4 *
     5 * This is the template that displays all pages by default.
     6 * Please note that this is the wordpress construct of pages
     7 * and that other 'pages' on your wordpress site will use a
     8 * different template.
     9 *
     10 * @package WordPress
     11 * @subpackage Twenty Ten
     12 * @since 3.0.0
     13 */
     14?>
     15
    116<?php get_header(); ?>
    217
  • trunk/wp-content/themes/twentyten/search.php

    r13816 r13885  
     1<?php
     2/**
     3 * The Search Results template
     4 *
     5 * @package WordPress
     6 * @subpackage Twenty Ten
     7 * @since 3.0.0
     8 */
     9?>
     10
    111<?php get_header(); ?>
    212
  • trunk/wp-content/themes/twentyten/searchform.php

    r13128 r13885  
     1<?php
     2/**
     3 * The Search Form
     4 *
     5 * Optional file that allows displaying a custom search form
     6 * when the get_search_form() template tag is used.
     7 *
     8 * @package WordPress
     9 * @subpackage Twenty Ten
     10 * @since 3.0.0
     11 */
     12?>
     13
    114    <form id="searchform" name="searchform" method="get" action="<?php echo home_url(); ?>">
    215        <div>
  • trunk/wp-content/themes/twentyten/sidebar-footer.php

    r13830 r13885  
     1<?php
     2/**
     3 * The Footer widget areas
     4 *
     5 * @package WordPress
     6 * @subpackage Twenty Ten
     7 * @since 3.0.0
     8 */
     9?>
     10
    111<?php
    212    if (
  • trunk/wp-content/themes/twentyten/sidebar.php

    r13720 r13885  
     1<?php
     2/**
     3 * The Sidebar containing the primary and secondary widget areas
     4 *
     5 * @package WordPress
     6 * @subpackage Twenty Ten
     7 * @since 3.0.0
     8 */
     9?>
     10
    111        <div id="primary" class="widget-area">
    212            <ul class="xoxo">
  • trunk/wp-content/themes/twentyten/single.php

    r13830 r13885  
     1<?php
     2/**
     3 * The Template used to display all single posts
     4 *
     5 * @package WordPress
     6 * @subpackage Twenty Ten
     7 * @since 3.0.0
     8 */
     9?>
     10
    111<?php get_header(); ?>
    212
  • trunk/wp-content/themes/twentyten/tag.php

    r13830 r13885  
     1<?php
     2/**
     3 * The template used to display Tag Archive pages
     4 *
     5 * @package WordPress
     6 * @subpackage Twenty Ten
     7 * @since 3.0.0
     8 */
     9?>
     10
    111<?php get_header(); ?>
    212
Note: See TracChangeset for help on using the changeset viewer.