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

git-svn-id: https://develop.svn.wordpress.org/trunk@13885 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Andrew Nacin 2010-03-29 22:03:15 +00:00
parent dc9cefd8a5
commit f15366a78c
19 changed files with 363 additions and 46 deletions

View File

@ -1,3 +1,13 @@
<?php
/**
* The template for displaying 404 pages (Not Found)
*
* @package WordPress
* @subpackage Twenty Ten
* @since 3.0.0
*/
?>
<?php get_header(); ?>
<div id="container">

View File

@ -1,3 +1,18 @@
<?php
/**
* Generic template for Archive pages.
*
* Used to display archive-type pages if nothing more specific matches a query.
* For example, puts together date-based pages if no date.php file exists.
*
* Learn more: http://codex.wordpress.org/Template_Hierarchy
*
* @package WordPress
* @subpackage Twenty Ten
* @since 3.0.0
*/
?>
<?php get_header(); ?>
<div id="container">

View File

@ -1,3 +1,13 @@
<?php
/**
* The template used to display attachments.
*
* @package WordPress
* @subpackage Twenty Ten
* @since 3.0.0
*/
?>
<?php get_header(); ?>
<div id="container">

View File

@ -1,3 +1,13 @@
<?php
/**
* The template used to display Author Archive pages
*
* @package WordPress
* @subpackage Twenty Ten
* @since 3.0.0
*/
?>
<?php get_header(); ?>
<div id="container">

View File

@ -1,3 +1,13 @@
<?php
/**
* The template used to display Category Archive pages
*
* @package WordPress
* @subpackage Twenty Ten
* @since 3.0.0
*/
?>
<?php get_header(); ?>
<div id="container">
@ -13,7 +23,7 @@
* If you want to overload this in a child theme then include a file
* called loop-category.php and that will be used instead.
*/
get_template_part( 'loop', 'category' );
get_template_part( 'loop', 'category' );
?>
</div><!-- #content -->

View File

@ -1,3 +1,18 @@
<?php
/**
* The template used to display Comments
*
* The area of the page that contains both current comments
* and the comment form. The actual display of comments is
* handled by a callback to twentyten_comment which is
* located in the functions.php file
*
* @package WordPress
* @subpackage Twenty Ten
* @since 3.0.0
*/
?>
<div id="comments">
<?php if ( post_password_required() ) : ?>
<div class="nopassword"><?php _e( 'This post is password protected. Enter the password to view any comments.', 'twentyten' ); ?></div>

View File

@ -1,3 +1,16 @@
<?php
/**
* The template used to display the footer
*
* Contains the closing of the id=main div and all content
* after. Calls sidebar-footer.php for bottom widgets
*
* @package WordPress
* @subpackage Twenty Ten
* @since 3.0.0
*/
?>
</div><!-- #main -->
<div id="footer">

View File

@ -1,22 +1,81 @@
<?php
/**
* TwentyTen functions and definitions
*
* Sets up the theme and provides some helper functions used
* in other parts of the theme. All functions are pluggable
*
* @package WordPress
* @subpackage Twenty Ten
* @since 3.0.0
*/
// Set the content width based on the Theme CSS
/**
* Set the content width based on the Theme CSS. Can be overriden
*
* Used in attachment.php to set the width of images. Should
* be equal to the width set for .onecolumn #content in style.css
*/
if ( ! isset( $content_width ) )
$content_width = 640;
if ( ! function_exists( 'twentyten_init' ) ) :
/**
* Set up defaults for our theme.
*
* Sets up theme defaults and tells wordpress that this is a
* theme that will take advantage of Post Thumbnails, Custom
* Background, Nav Menus and automatic feed links. To
* override any of the settings in a child theme, create your
* own twentyten_init function
*
* @uses add_theme_support()
*/
function twentyten_init() {
// This theme allows users to set a custom background
add_custom_background();
// This theme styles the visual editor with editor-style.css to match the theme style.
add_editor_style();
// This theme needs post thumbnails
add_theme_support( 'post-thumbnails' );
// This theme uses wp_nav_menu()
add_theme_support( 'nav-menus' );
// We'll be using them for custom header images on posts and pages
// so we want them to be 940 pixels wide by 198 pixels tall (larger images will be auto-cropped to fit)
set_post_thumbnail_size( HEADER_IMAGE_WIDTH, HEADER_IMAGE_HEIGHT, true );
// Add default posts and comments RSS feed links to head
add_theme_support( 'automatic-feed-links' );
// Make theme available for translation
// Translations can be filed in the /languages/ directory
load_theme_textdomain( 'twentyten', TEMPLATEPATH . '/languages' );
$locale = get_locale();
$locale_file = TEMPLATEPATH . "/languages/$locale.php";
if ( is_readable( $locale_file ) )
require_once( $locale_file );
// Your Changeable header business starts here
// No CSS, just IMG call
define( 'HEADER_TEXTCOLOR', '' );
define( 'HEADER_IMAGE', '%s/images/headers/forestfloor.jpg' ); // %s is theme dir uri
// Add a filter to twentyten_header_image_width and twentyten_header_image_height to change these values
define( 'HEADER_IMAGE_WIDTH', apply_filters( 'twentyten_header_image_width', 940 ) );
define( 'HEADER_IMAGE_HEIGHT', apply_filters( 'twentyten_header_image_height', 198 ) );
define( 'NO_HEADER_TEXT', true );
add_custom_image_header( '', 'twentyten_admin_header_style' );
// and thus ends the changeable header business
// Default custom headers. %s is a placeholder for the theme template directory
register_default_headers( array (
'berries' => array (
'url' => '%s/images/headers/berries.jpg',
@ -59,38 +118,14 @@ function twentyten_init() {
'description' => __( 'Sunset', 'twentyten' )
)
) );
add_custom_background();
// This theme styles the visual editor with editor-style.css to match the theme style.
add_editor_style();
// This theme needs post thumbnails
add_theme_support( 'post-thumbnails' );
// This theme uses wp_nav_menu()
add_theme_support( 'nav-menus' );
// We'll be using them for custom header images on posts and pages
// so we want them to be 940 pixels wide by 198 pixels tall (larger images will be auto-cropped to fit)
set_post_thumbnail_size( HEADER_IMAGE_WIDTH, HEADER_IMAGE_HEIGHT, true );
// Add default posts and comments RSS feed links to head
add_theme_support( 'automatic-feed-links' );
// Make theme available for translation
// Translations can be filed in the /languages/ directory
load_theme_textdomain( 'twentyten', TEMPLATEPATH . '/languages' );
$locale = get_locale();
$locale_file = TEMPLATEPATH . "/languages/$locale.php";
if ( is_readable( $locale_file ) )
require_once( $locale_file );
}
endif;
add_action( 'after_setup_theme', 'twentyten_init' );
if ( ! function_exists( 'twentyten_admin_header_style' ) ) :
/**
* Callback to style the header image inside the admin
*/
function twentyten_admin_header_style() {
?>
<style type="text/css">
@ -106,41 +141,66 @@ function twentyten_admin_header_style() {
}
endif;
// Get the page number
if ( ! function_exists( 'twentyten_get_page_number' ) ) :
/**
* Returns the page number currently being browsed
*
* Returns a vertical bar followed by page and the page
* number. Is pluggable
*
* @retun string
*/
function twentyten_get_page_number() {
if ( get_query_var( 'paged' ) )
return ' | ' . __( 'Page ' , 'twentyten' ) . get_query_var( 'paged' );
}
endif;
// Echo the page number
if ( ! function_exists( 'twentyten_the_page_number' ) ) :
/**
* Echos the page number being browsed
*
* @uses twentyten_get_page_number
*
*/
function twentyten_the_page_number() {
echo twentyten_get_page_number();
}
endif;
// Control excerpt length
if ( ! function_exists( 'twentyten_excerpt_length' ) ) :
/**
* Sets the excerpt length to 40 charachters. Is pluggable
*
* @return int
*/
function twentyten_excerpt_length( $length ) {
return 40;
}
endif;
add_filter( 'excerpt_length', 'twentyten_excerpt_length' );
// Make a nice read more link on excerpts
if ( ! function_exists( 'twentyten_excerpt_more' ) ) :
/**
* Sets the read more link for excerpts to something pretty
*
* @return string
*
*/
function twentyten_excerpt_more( $more ) {
return '&nbsp;&hellip; <a href="'. get_permalink() . '">' . __('Continue&nbsp;reading&nbsp;<span class="meta-nav">&rarr;</span>', 'twentyten') . '</a>';
}
endif;
add_filter( 'excerpt_more', 'twentyten_excerpt_more' );
// Template for comments and pingbacks
if ( ! function_exists( 'twentyten_comment' ) ) :
/**
* Template for comments and pingbacks
*
* Used as a callback by wp_list_comments for displaying the
* comments. Is pluggable
*
*/
function twentyten_comment( $comment, $args, $depth ) {
$GLOBALS ['comment'] = $comment; ?>
<?php if ( '' == $comment->comment_type ) : ?>
@ -171,8 +231,12 @@ function twentyten_comment( $comment, $args, $depth ) {
}
endif;
// Remove inline styles on gallery shortcode
if ( ! function_exists( 'twentyten_remove_gallery_css' ) ) :
/**
* Remove inline styles on gallery shortcode
*
* @return string
*/
function twentyten_remove_gallery_css( $css ) {
return preg_replace( "#<style type='text/css'>(.*?)</style>#s", '', $css );
}
@ -180,18 +244,48 @@ endif;
add_filter( 'gallery_style', 'twentyten_remove_gallery_css' );
if ( ! function_exists( 'twentyten_cat_list' ) ) :
/**
* Returns the list of categories
*
* Returns the list of categories based on if we are or are
* not browsing a category archive page.
*
* @uses twentyten_term_list
*
* @return string
*/
function twentyten_cat_list() {
return twentyten_term_list( 'category', ', ', __( 'Posted in %s', 'twentyten' ), __( 'Also posted in %s', 'twentyten' ) );
}
endif;
if ( ! function_exists( 'twentyten_tag_list' ) ) :
/**
* Returns the list of tags
*
* Returns the list of tags based on if we are or are not
* browsing a tag archive page
*
* @uses twentyten_term_list
*
* @return string
*/
function twentyten_tag_list() {
return twentyten_term_list( 'post_tag', ', ', __( 'Tagged %s', 'twentyten' ), __( 'Also tagged %s', 'twentyten' ) );
}
endif;
if ( ! function_exists( 'twentyten_term_list' ) ) :
/**
* Returns the list of taxonomy items in multiple ways
*
* Returns the list of taxonomy items differently based on
* if we are browsing a term archive page or a different
* type of page. If browsing a term archive page and the
* post has no other taxonomied terms, it returns empty
*
* @return string
*/
function twentyten_term_list( $taxonomy, $glue = ', ', $text = '', $also_text = '' ) {
global $wp_query, $post;
$current_term = $wp_query->get_queried_object();
@ -219,8 +313,12 @@ function twentyten_term_list( $taxonomy, $glue = ', ', $text = '', $also_text =
}
endif;
// Register widgetized areas
if ( ! function_exists( 'twentyten_widgets_init' ) ) :
/**
* Register widgetized areas
*
* @uses register_sidebar
*/
function twentyten_widgets_init() {
// Area 1
register_sidebar( array (

View File

@ -1,3 +1,15 @@
<?php
/**
* The Header for our theme.
*
* Displays all of the <head> section and everything up till <div id="main">
*
* @package WordPress
* @subpackage Twenty Ten
* @since 3.0.0
*/
?>
<!DOCTYPE html>
<html <?php language_attributes(); ?>>
<head>

View File

@ -1,3 +1,21 @@
<?php
/**
* The main template file
*
* This is the most generic template file in a WordPress theme
* and one of the two required files for a theme (the other being style.css).
* It is used to display a page when nothing more specific matches a query.
* E.g., it puts together the home page when no home.php file exists.
* Learn more: http://codex.wordpress.org/Template_Hierarchy
*
* @package WordPress
* @subpackage Twenty Ten
* @since 3.0.0
*/
?>
<?php get_header(); ?>
<div id="container">

View File

@ -1,3 +1,19 @@
<?php
/**
* The loop that displays posts
*
* The loop displays the posts and the post content. See
* http://codex.wordpress.org/The_Loop to understand it and
* http://codex.wordpress.org/Template_Tags to understand
* the tags used in it.
*
* @package WordPress
* @subpackage Twenty Ten
* @since 3.0.0
*/
?>
<?php /* Display navigation to next/previous pages when applicable */ ?>
<?php if ( $wp_query->max_num_pages > 1 ) : ?>
<div id="nav-above" class="navigation">
<div class="nav-previous"><?php next_posts_link( __( '<span class="meta-nav">&larr;</span> Older posts', 'twentyten' ) ); ?></div>
@ -5,6 +21,7 @@
</div><!-- #nav-above -->
<?php endif; ?>
<?php /* If there are no posts to display, such as an empty archive page */ ?>
<?php if ( ! have_posts() ) : ?>
<div id="post-0" class="post error404 not-found">
<h1 class="entry-title"><?php _e( 'Not Found', 'twentyten' ); ?></h1>
@ -15,7 +32,10 @@
</div><!-- #post-0 -->
<?php endif; ?>
<?php /* Start the Loop */ ?>
<?php while ( have_posts() ) : the_post(); ?>
<?php /* How to Display posts in the Gallery Category */ ?>
<?php if ( in_category( 'Gallery' ) ) : ?>
<div id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
<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>
@ -62,7 +82,7 @@
</div><!-- #entry-utility -->
</div>
<?php /* How to display posts in the asides category */ ?>
<?php elseif ( in_category( 'asides' ) ) : ?>
<div id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
<?php if ( is_archive() || is_search() ) : //Only display Excerpts for archives & search ?>
@ -92,7 +112,7 @@
</div><!-- #entry-utility -->
</div><!-- #post-<?php the_ID(); ?> -->
<?php /* How to display all other posts */ ?>
<?php else : ?>
<div id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
<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>
@ -139,6 +159,7 @@
<?php endif; // if different categories queried ?>
<?php endwhile; ?>
<?php /* Display navigation to next/previous pages when applicable */ ?>
<?php if ( $wp_query->max_num_pages > 1 ) : ?>
<div id="nav-below" class="navigation">
<div class="nav-previous"><?php next_posts_link( __( '<span class="meta-nav">&larr;</span> Older posts', 'twentyten' ) ); ?></div>

View File

@ -1,10 +1,17 @@
<?php
/*
Template Name: One column, no sidebar
Description: A template with no sidebar
*/
get_header(); ?>
/**
* Template Name: One column, no sidebar
*
* A custom page template without sidebar.
* Selectable from a dropdown menu on the edit page screen.
*
* @package WordPress
* @subpackage Twenty Ten
* @since 3.0.0
*/
?>
<?php get_header(); ?>
<div id="container" class="onecolumn">
<div id="content">

View File

@ -1,3 +1,18 @@
<?php
/**
* The template used to display all pages
*
* This is the template that displays all pages by default.
* Please note that this is the wordpress construct of pages
* and that other 'pages' on your wordpress site will use a
* different template.
*
* @package WordPress
* @subpackage Twenty Ten
* @since 3.0.0
*/
?>
<?php get_header(); ?>
<div id="container">

View File

@ -1,3 +1,13 @@
<?php
/**
* The Search Results template
*
* @package WordPress
* @subpackage Twenty Ten
* @since 3.0.0
*/
?>
<?php get_header(); ?>
<div id="container">

View File

@ -1,3 +1,16 @@
<?php
/**
* The Search Form
*
* Optional file that allows displaying a custom search form
* when the get_search_form() template tag is used.
*
* @package WordPress
* @subpackage Twenty Ten
* @since 3.0.0
*/
?>
<form id="searchform" name="searchform" method="get" action="<?php echo home_url(); ?>">
<div>
<label for="s"><?php _e( 'Search', 'twentyten' ); ?></label>

View File

@ -1,3 +1,13 @@
<?php
/**
* The Footer widget areas
*
* @package WordPress
* @subpackage Twenty Ten
* @since 3.0.0
*/
?>
<?php
if (
is_active_sidebar( 'first-footer-widget-area' ) ||

View File

@ -1,3 +1,13 @@
<?php
/**
* The Sidebar containing the primary and secondary widget areas
*
* @package WordPress
* @subpackage Twenty Ten
* @since 3.0.0
*/
?>
<div id="primary" class="widget-area">
<ul class="xoxo">
<?php if ( ! dynamic_sidebar( 'primary-widget-area' ) ) : // begin primary widget area ?>

View File

@ -1,3 +1,13 @@
<?php
/**
* The Template used to display all single posts
*
* @package WordPress
* @subpackage Twenty Ten
* @since 3.0.0
*/
?>
<?php get_header(); ?>
<div id="container">

View File

@ -1,3 +1,13 @@
<?php
/**
* The template used to display Tag Archive pages
*
* @package WordPress
* @subpackage Twenty Ten
* @since 3.0.0
*/
?>
<?php get_header(); ?>
<div id="container">