Make WordPress Core

Ticket #12695: twentytendoc.4.diff

File twentytendoc.4.diff, 19.0 KB (added by jorbin, 14 years ago)

Added some more inline docs to explain twentyten_init

  • wp-content/themes/twentyten/searchform.php

     
     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 * @since 0.7.0
     9 * @package WordPress
     10 * @subpackage 2010
     11 */
     12?>
     13
    114    <form id="searchform" name="searchform" method="get" action="<?php echo home_url(); ?>">
    215                <div>
    316                        <label for="s"><?php _e( 'Search', 'twentyten' ); ?></label>
  • wp-content/themes/twentyten/footer.php

     
     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 * @since 0.7.0
     9 * @package WordPress
     10 * @subpackage 2010
     11 */
     12?>
     13
    114        </div><!-- #main -->
    215
    316        <div id="footer">
  • wp-content/themes/twentyten/author.php

     
     1<?php
     2/**
     3 * The template used to display Author Archive pages
     4 *
     5 * @since 0.7.0
     6 * @package WordPress
     7 * @subpackage 2010
     8 */
     9?>
     10
    111<?php get_header(); ?>
    212
    313                <div id="container">
  • wp-content/themes/twentyten/search.php

     
     1<?php
     2/**
     3 * The Search Results template
     4 *
     5 * @since 0.7.0
     6 * @package WordPress
     7 * @subpackage 2010
     8 */
     9?>
     10
    111<?php get_header(); ?>
    212
    313                <div id="container">
  • wp-content/themes/twentyten/sidebar-footer.php

     
    11<?php
     2/**
     3 * The Footer widget areas
     4 *
     5 * @since 0.7.0
     6 * @package WordPress
     7 * @subpackage 2010
     8 */
     9?>
     10
     11<?php
    212        if (
    313                is_active_sidebar( 'first-footer-widget-area' )  ||
    414                is_active_sidebar( 'second-footer-widget-area' ) ||
  • wp-content/themes/twentyten/index.php

     
     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 * @since 0.7.0
     13 * @package WordPress
     14 * @subpackage 2010
     15 */
     16 
     17?>
     18 
    119<?php get_header(); ?>
    220
    321                <div id="container">
  • wp-content/themes/twentyten/404.php

     
     1<?php
     2/**
     3 * The template for displaying 404 pages (Not Found)
     4 *
     5 * @since 0.7.0
     6 * @package WordPress
     7 * @subpackage 2010
     8 */
     9?>
     10
    111<?php get_header(); ?>
    212
    313        <div id="container">
  • wp-content/themes/twentyten/functions.php

     
    11<?php
     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 * @since 0.7.0
     9 * @package WordPress
     10 * @subpackage 2010
     11 */
    212
    3 // Set the content width based on the Theme CSS
     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 *
     19 *
     20 */
    421if ( ! isset( $content_width ) )
    522        $content_width = 640;
    623
     24
     25/**
     26 * Set up defaults for our theme.
     27 *
     28 * Sets up theme defaults and tells wordpress that this is a
     29 * theme that will take advantage of Post Thumbnails, Custom
     30 * Background, Nav Menus and automatic feed links.  To
     31 * override any of the settings in a child theme, create your
     32 * own twentyten_init function
     33 *
     34 * @uses add_theme_support()
     35 *
     36 * @since 0.7.0
     37 *
     38 *
     39 */
     40
    741if ( ! function_exists( 'twentyten_init' ) ) :
    842function twentyten_init() {
    943        // Your Changeable header business starts here
    1044        // No CSS, just IMG call
    1145        define( 'HEADER_TEXTCOLOR', '' );
    1246        define( 'HEADER_IMAGE', '%s/images/headers/forestfloor.jpg' ); // %s is theme dir uri
     47
     48        // Add a filter to twentyten_header_image_width and twentyten_header_image_height to change these values
    1349        define( 'HEADER_IMAGE_WIDTH', apply_filters( 'twentyten_header_image_width',  940 ) );
    1450        define( 'HEADER_IMAGE_HEIGHT', apply_filters( 'twentyten_header_image_height',  198 ) );
     51
    1552        define( 'NO_HEADER_TEXT', true );
    1653
    1754        add_custom_image_header( '', 'twentyten_admin_header_style' );
    1855        // and thus ends the changeable header business
    1956
     57        // Default custom headers.  %s is a placeholder for the theme template directory
     58
    2059        register_default_headers( array (
    2160                'berries' => array (
    2261                        'url' => '%s/images/headers/berries.jpg',
     
    6099                )
    61100        ) );
    62101
     102        // This theme allows users to set a custom background
    63103        add_custom_background();
    64104
    65105        // This theme styles the visual editor with editor-style.css to match the theme style.
     
    90130endif;
    91131add_action( 'after_setup_theme', 'twentyten_init' );
    92132
     133/**
     134 * Callback to style the header image inside the admin
     135 *
     136 *
     137 */
     138
    93139if ( ! function_exists( 'twentyten_admin_header_style' ) ) :
    94140function twentyten_admin_header_style() {
    95141?>
     
    106152}
    107153endif;
    108154
    109 // Get the page number
     155
     156/**
     157 * Returns the page number currently being browsed
     158 *
     159 * Returns a vertical bar followed by page and the page
     160 * number.  Is pluggable
     161 *
     162 * @since 0.7.0
     163 * @retun string
     164 */
     165
     166
    110167if ( ! function_exists( 'twentyten_get_page_number' ) ) :
    111168function twentyten_get_page_number() {
    112169        if ( get_query_var( 'paged' ) )
     
    114171}
    115172endif;
    116173
    117 // Echo the page number
     174/**
     175 * Echos the page number being browsed
     176 *
     177 * @since 0.7.0
     178 * @uses twentyten_get_page_number
     179 *
     180 */
     181
    118182if ( ! function_exists( 'twentyten_the_page_number' ) ) :
    119183function twentyten_the_page_number() {
    120184        echo twentyten_get_page_number();
    121185}
    122186endif;
    123187
    124 // Control excerpt length
     188/**
     189 * Sets the excerpt length to 40 charachters.  Is pluggable
     190 *
     191 * @since 0.7.0
     192 * @return int
     193 */
     194
    125195if ( ! function_exists( 'twentyten_excerpt_length' ) ) :
    126196function twentyten_excerpt_length( $length ) {
    127197        return 40;
     
    130200add_filter( 'excerpt_length', 'twentyten_excerpt_length' );
    131201
    132202
    133 // Make a nice read more link on excerpts
     203/**
     204 * Sets the read more link for excerpts to something pretty
     205 *
     206 * @since 0.7.0
     207 * @return string
     208 *
     209 */
    134210if ( ! function_exists( 'twentyten_excerpt_more' ) ) :
    135211function twentyten_excerpt_more( $more ) {
    136212        return '&nbsp;&hellip; <a href="'. get_permalink() . '">' . __('Continue&nbsp;reading&nbsp;<span class="meta-nav">&rarr;</span>', 'twentyten') . '</a>';
     
    139215add_filter( 'excerpt_more', 'twentyten_excerpt_more' );
    140216
    141217
    142 // Template for comments and pingbacks
     218/**
     219 * Template for comments and pingbacks
     220 *
     221 * Used as a callback by wp_list_comments for displaying the
     222 * comments.  Is pluggable
     223 *
     224 * @since 0.7.0
     225 */
    143226if ( ! function_exists( 'twentyten_comment' ) ) :
    144227function twentyten_comment( $comment, $args, $depth ) {
    145228        $GLOBALS ['comment'] = $comment; ?>
     
    171254}
    172255endif;
    173256
    174 // Remove inline styles on gallery shortcode
     257/**
     258 * Remove inline styles on gallery shortcode
     259 *
     260 * @since 0.7.0
     261 * @return string
     262 */
    175263if ( ! function_exists( 'twentyten_remove_gallery_css' ) ) :
    176264function twentyten_remove_gallery_css( $css ) {
    177265        return preg_replace( "#<style type='text/css'>(.*?)</style>#s", '', $css );
     
    179267endif;
    180268add_filter( 'gallery_style', 'twentyten_remove_gallery_css' );
    181269
     270/**
     271 * Returns the list of categories
     272 *
     273 * Returns the list of categories based on if we are or are
     274 * not browsing a category archive page.
     275 *
     276 * @uses twentyten_term_list
     277 *
     278 * @since 0.7.0
     279 * @return string
     280 */
     281
    182282if ( ! function_exists( 'twentyten_cat_list' ) ) :
    183283function twentyten_cat_list() {
    184284        return twentyten_term_list( 'category', ', ', __( 'Posted in %s', 'twentyten' ), __( 'Also posted in %s', 'twentyten' ) );
    185285}
    186286endif;
    187287
     288/**
     289 * Returns the list of tags
     290 *
     291 * Returns the list of tags based on if we are or are not
     292 * browsing a tag archive page
     293 *
     294 * @uses twentyten_term_list
     295 *
     296 * @since 0.7.0
     297 * @return string
     298 */
    188299if ( ! function_exists( 'twentyten_tag_list' ) ) :
    189300function twentyten_tag_list() {
    190301        return twentyten_term_list( 'post_tag', ', ', __( 'Tagged %s', 'twentyten' ), __( 'Also tagged %s', 'twentyten' ) );
    191302}
    192303endif;
    193304
     305/**
     306 * Returns the list of taxonomy items in multiple ways
     307 *
     308 * Returns the list of taxonomy items differently based on
     309 * if we are browsing a term archive page or a different
     310 * type of page.  If browsing a term archive page and the
     311 * post has no other taxonomied terms, it returns empty
     312 *
     313 * @since 0.7.0
     314 * @return string
     315 */
    194316if ( ! function_exists( 'twentyten_term_list' ) ) :
    195317function twentyten_term_list( $taxonomy, $glue = ', ', $text = '', $also_text = '' ) {
    196318        global $wp_query, $post;
     
    219341}
    220342endif;
    221343
    222 // Register widgetized areas
     344/**
     345 * Register widgetized areas
     346 *
     347 * @since 0.7.0
     348 * @uses register_sidebar
     349 */
    223350if ( ! function_exists( 'twentyten_widgets_init' ) ) :
    224351function twentyten_widgets_init() {
    225352        // Area 1
  • wp-content/themes/twentyten/sidebar.php

     
     1<?php
     2/**
     3 * The Sidebar containing the primary and secondary widget areas
     4 *
     5 * @since 0.7.0
     6 * @package WordPress
     7 * @subpackage 2010
     8 */
     9?>
     10
    111                <div id="primary" class="widget-area">
    212                        <ul class="xoxo">
    313<?php if ( ! dynamic_sidebar( 'primary-widget-area' ) ) : // begin primary widget area ?>
  • wp-content/themes/twentyten/onecolumn-page.php

     
    1 
    21<?php
    3 /*
    4 Template Name: One column, no sidebar
    5 Description: A template with no sidebar
    6 */
    7 get_header(); ?>
     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 * @since 0.7.0
     9 * @package WordPress
     10 * @subpackage 2010
     11 */
     12?>
    813
     14<?php get_header(); ?>
     15
    916                <div id="container" class="onecolumn">
    1017                        <div id="content">
    1118
  • wp-content/themes/twentyten/loop.php

     
     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 * @since 0.7.0
     11 * @package WordPress
     12 * @subpackage 2010
     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">
    319                <div class="nav-previous"><?php next_posts_link( __( '<span class="meta-nav">&larr;</span> Older posts', 'twentyten' ) ); ?></div>
     
    521        </div><!-- #nav-above -->
    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">
    1027                <h1 class="entry-title"><?php _e( 'Not Found', 'twentyten' ); ?></h1>
     
    1532        </div><!-- #post-0 -->
    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(); ?>>
    2141                        <h2 class="entry-title"><a href="<?php the_permalink(); ?>" title="<?php printf( esc_attr__( 'Permalink to %s', 'twentyten' ), the_title_attribute( 'echo=0' ) ); ?>" rel="bookmark"><?php the_title(); ?></a></h2>
     
    6282                        </div><!-- #entry-utility -->
    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(); ?>>
    6888        <?php if ( is_archive() || is_search() ) : //Only display Excerpts for archives & search ?>
     
    92112                        </div><!-- #entry-utility -->
    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(); ?>>
    98118                        <h2 class="entry-title"><a href="<?php the_permalink(); ?>" title="<?php printf( esc_attr__( 'Permalink to %s', 'twentyten' ), the_title_attribute( 'echo=0' ) ); ?>" rel="bookmark"><?php the_title(); ?></a></h2>
     
    139159        <?php endif; // if different categories queried ?>
    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">
    144165                                        <div class="nav-previous"><?php next_posts_link( __( '<span class="meta-nav">&larr;</span> Older posts', 'twentyten' ) ); ?></div>
  • wp-content/themes/twentyten/tag.php

     
     1<?php
     2/**
     3 * The template used to display Tag Archive pages
     4 *
     5 * @since 0.7.0
     6 * @package WordPress
     7 * @subpackage 2010
     8 */
     9?>
     10
    111<?php get_header(); ?>
    212
    313                <div id="container">
  • wp-content/themes/twentyten/page.php

     
     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 * @since 0.7.0
     11 * @package WordPress
     12 * @subpackage 2010
     13 */
     14?>
     15
    116<?php get_header(); ?>
    217
    318                <div id="container">
  • wp-content/themes/twentyten/category.php

     
     1<?php
     2/**
     3 * The template used to display Category Archive pages
     4 *
     5 * @since 0.7.0
     6 * @package WordPress
     7 * @subpackage 2010
     8 */
     9?>
     10
    111<?php get_header(); ?>
    212
    313                <div id="container">
     
    1323                                 * If you want to overload this in a child theme then include a file
    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
    1929                        </div><!-- #content -->
  • wp-content/themes/twentyten/archive.php

     
     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 * E.g., puts together date-based pages if no date.php file exists.
     7 * Learn more: http://codex.wordpress.org/Template_Hierarchy
     8 *
     9 * @since 0.7.0
     10 * @package WordPress
     11 * @subpackage 2010
     12 */
     13?>
     14
    115<?php get_header(); ?>
    216
    317                <div id="container">
  • wp-content/themes/twentyten/single.php

     
     1<?php
     2/**
     3 * The Template used to display all single posts
     4 *
     5 * @since 0.7.0
     6 * @package WordPress
     7 * @subpackage 2010
     8 */
     9?>
     10
    111<?php get_header(); ?>
    212
    313                <div id="container">
  • wp-content/themes/twentyten/comments.php

     
     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 * @since 0.7.0
     11 * @package WordPress
     12 * @subpackage 2010
     13 */
     14?>
     15
    116                        <div id="comments">
    217<?php if ( post_password_required() ) : ?>
    318                                <div class="nopassword"><?php _e( 'This post is password protected. Enter the password to view any comments.', 'twentyten' ); ?></div>
  • wp-content/themes/twentyten/header.php

     
     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 * @since 0.7.0
     8 * @package WordPress
     9 * @subpackage 2010
     10 */
     11?>
     12
    113<!DOCTYPE html>
    214<html <?php language_attributes(); ?>>
    315<head>
     
    315        <meta charset="<?php bloginfo( 'charset' ); ?>" />
    416    <title><?php
     17        // Returns the title based on the type of page being viewed
    518        if ( is_single() ) {
    619                        single_post_title(); echo ' | '; bloginfo( 'name' );
  • wp-content/themes/twentyten/attachment.php

     
     1<?php
     2/**
     3 * The template used to display Attachment-type pages
     4 *
     5 * @since 0.7.0
     6 * @package WordPress
     7 * @subpackage 2010
     8 */
     9?>
     10
    111<?php get_header(); ?>
    212
    313                <div id="container">