diff --git a/wp-content/themes/twentyten/functions.php b/wp-content/themes/twentyten/functions.php
index b14bc26033..db08b0b215 100644
--- a/wp-content/themes/twentyten/functions.php
+++ b/wp-content/themes/twentyten/functions.php
@@ -2,8 +2,32 @@
/**
* TwentyTen functions and definitions
*
- * Sets up the theme and provides some helper functions used
- * in other parts of the theme. All functions are pluggable
+ * Sets up the theme and provides some helper functions. Some helper functions
+ * are used in the theme as custom template tags. Others are attached to action and
+ * filter hooks in WordPress to change core functionality.
+ *
+ * The first function, twentyten_setup(), sets up the theme by registering support
+ * for various features in WordPress, such as post thumbnails, navigation menus, and the like.
+ *
+ * When using a child theme (see http://codex.wordpress.org/Theme_Development), you can
+ * override certain functions (those wrapped in a function_exists() call) by defining
+ * them first in your child theme's functions.php file. The child theme's functions.php
+ * file is included before the parent theme's file, so the child theme functions would
+ * be used.
+ *
+ * Functions that are not pluggable (not wrapped in function_exists()) are instead attached
+ * to a filter or action hook. The hook can be removed by using remove_action() or
+ * remove_filter() and you can attach your own function to the hook. For example:
+ *
+ *
+ * remove_action( 'after_setup_theme', 'twentyten_setup' );
+ * add_action( 'after_setup_theme', 'my_child_theme_setup' );
+ * function my_child_theme_setup() {
+ * ...
+ * }
+ *
+ *
+ * For more information on hooks, see http://codex.wordpress.org/Plugin_API.
*
* @package WordPress
* @subpackage Twenty Ten
@@ -11,43 +35,48 @@
*/
/**
- * Set the content width based on the Theme CSS. Can be overriden
+ * Set the content width based on the theme's design and stylesheet.
*
- * Used in attachment.php to set the width of images. Should
- * be equal to the width set for .onecolumn #content in style.css
+ * Used to set the width of images and content. Should be equal to the width the theme
+ * is designed for, generally via the style.css stylesheet.
*/
if ( ! isset( $content_width ) )
$content_width = 640;
-if ( ! function_exists( 'twentyten_init' ) ) :
+/** Tell WordPress to run twentyten_setup() when the 'after_setup_theme' hook is run. */
+add_action( 'after_setup_theme', 'twentyten_setup' );
+
/**
- * Set up defaults for our theme.
+ * Sets up theme defaults and registers support for various WordPress features.
*
- * 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
+ * Note that this function is hooked into the after_setup_theme hook, which runs
+ * before the init hook. The init hook is too late for some features, such as indicating
+ * support post thumbnails.
*
- * @uses add_theme_support()
+ * To override twentyten_setup() in a child theme, remove the action hook and add your own
+ * function tied to the after_setup_theme hook.
+ *
+ * @uses add_theme_support() To add support for post thumbnails, navigation menus, and automatic feed links.
+ * @uses add_custom_background() To add support for a custom background.
+ * @uses add_editor_style() To style the visual editor.
+ * @uses load_theme_textdomain() For translation/localization support.
+ * @uses add_custom_image_header() To add support for a custom header.
+ * @uses register_default_headers() To register the default custom header images provided with the theme.
+ * @uses set_post_thumbnail_size() To set a custom post thumbnail size.
+ *
+ * @since 3.0.0
*/
-function twentyten_init() {
- // This theme allows users to set a custom background
- add_custom_background();
+function twentyten_setup() {
// This theme styles the visual editor with editor-style.css to match the theme style.
add_editor_style();
- // This theme needs post thumbnails
+ // This theme uses 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' );
@@ -60,22 +89,33 @@ function twentyten_init() {
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
+ // This theme allows users to set a custom background
+ add_custom_background();
- // Add a filter to twentyten_header_image_width and twentyten_header_image_height to change these values
+ // Your changeable header business starts here
+ define( 'HEADER_TEXTCOLOR', '' );
+ // No CSS, just IMG call. The %s is a placeholder for the theme template directory URI.
+ define( 'HEADER_IMAGE', '%s/images/headers/forestfloor.jpg' );
+
+ // The height and width of your custom header. You can hook into the theme's own filters to change these values.
+ // 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 ) );
+ // We'll be using post thumbnails for custom header images on posts and pages.
+ // 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 );
+
+ // Don't support text inside the header image.
define( 'NO_HEADER_TEXT', true );
+ // Add a way for the custom header to be styled in the admin panel that controls
+ // custom headers. See twentyten_admin_header_style(), below.
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
+ // ... and thus ends the changeable header business.
+ // Default custom headers packaged with the theme. %s is a placeholder for the theme template directory URI.
register_default_headers( array (
'berries' => array (
'url' => '%s/images/headers/berries.jpg',
@@ -119,12 +159,14 @@ function twentyten_init() {
)
) );
}
-endif;
-add_action( 'after_setup_theme', 'twentyten_init' );
if ( ! function_exists( 'twentyten_admin_header_style' ) ) :
/**
- * Callback to style the header image inside the admin
+ * Styles the header image displayed on the Appearance > Header admin panel.
+ *
+ * Referenced via add_custom_image_header() in twentyten_setup().
+ *
+ * @since 3.0.0
*/
function twentyten_admin_header_style() {
?>
@@ -141,65 +183,69 @@ function twentyten_admin_header_style() {
}
endif;
-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;
-
if ( ! function_exists( 'twentyten_the_page_number' ) ) :
/**
- * Echos the page number being browsed
+ * Prints the page number currently being browsed, with a vertical bar before it.
*
- * @uses twentyten_get_page_number
+ * Used in Twenty Ten's header.php to add the page number to the