From 7c16b8d1dd9632e0030268d8171622e1cde463a3 Mon Sep 17 00:00:00 2001 From: dd32 Date: Sat, 11 Jun 2011 06:30:59 +0000 Subject: [PATCH] Twenty Eleven Functions.php comments cleanup, merge the 2 body class functions. Props jorbin. See #17748 git-svn-id: http://svn.automattic.com/wordpress/trunk@18272 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-content/themes/twentyeleven/functions.php | 52 +++++++++----------- 1 file changed, 22 insertions(+), 30 deletions(-) diff --git a/wp-content/themes/twentyeleven/functions.php b/wp-content/themes/twentyeleven/functions.php index b723226011..29dd793765 100644 --- a/wp-content/themes/twentyeleven/functions.php +++ b/wp-content/themes/twentyeleven/functions.php @@ -100,39 +100,35 @@ function twentyeleven_setup() { // This theme uses wp_nav_menu() in one location. register_nav_menu( 'primary', __( 'Primary Menu', 'twentyeleven' ) ); - /** - * Add support for an Aside Post Format - */ + // Add support for a variety of post formats add_theme_support( 'post-formats', array( 'aside', 'link', 'gallery', 'status', 'quote', 'image' ) ); - /** - * Add support for custom backgrounds - */ + // Add support for custom backgrounds add_custom_background(); - // This theme uses Feature Images for per-post/per-page Custom Header images + // This theme uses Featured Images (also known as post thumbnails) for per-post/per-page Custom Header images add_theme_support( 'post-thumbnails' ); - /** - * Add support for Custom Headers - */ + // The next four constants set how twentyeleven supports custom headers + + // The default header text color define( 'HEADER_TEXTCOLOR', '000' ); - // No CSS, just an IMG call. The %s is a placeholder for the theme template directory URI. - define( 'HEADER_IMAGE', '' ); // Leaving empty for random image rotation. + // By leaving empty, we default to random image rotation + define( 'HEADER_IMAGE', '' ); - // The height and width of your custom header. You can hook into the theme's own filters to change these values. + // The height and width of your custom header. // Add a filter to twentyeleven_header_image_width and twentyeleven_header_image_height to change these values. define( 'HEADER_IMAGE_WIDTH', apply_filters( 'twentyeleven_header_image_width', 1000 ) ); define( 'HEADER_IMAGE_HEIGHT', apply_filters( 'twentyeleven_header_image_height', 288 ) ); // We'll be using post thumbnails for custom header images on posts and pages. - // We want them to be 1000 pixels wide by 288 pixels tall. + // We want them to be the size of the header image that we just defined // Larger images will be auto-cropped to fit, smaller ones will be ignored. See header.php. set_post_thumbnail_size( HEADER_IMAGE_WIDTH, HEADER_IMAGE_HEIGHT, true ); // Add Twenty Eleven's custom image sizes - add_image_size( 'large-feature', HEADER_IMAGE_WIDTH, HEADER_IMAGE_HEIGHT, true ); // Used for large feature images + add_image_size( 'large-feature', HEADER_IMAGE_WIDTH, HEADER_IMAGE_HEIGHT, true ); // Used for large feature (header) images add_image_size( 'small-feature', 500, 300 ); // Used for featured posts if a large-feature doesn't exist // Add a way for the custom header to be styled in the admin panel that controls @@ -353,17 +349,6 @@ function twentyeleven_custom_excerpt_more( $output ) { } add_filter( 'get_the_excerpt', 'twentyeleven_custom_excerpt_more' ); -/** - * Add custom body classes - */ -function twentyeleven_singular_class( $classes ) { - if ( is_singular() && ! is_home() && ! is_page_template( 'showcase.php' ) && ! is_page_template( 'sidebar-page.php' ) ) - $classes[] = 'singular'; - - return $classes; -} -add_filter( 'body_class', 'twentyeleven_singular_class' ); - /** * Get our wp_nav_menu() fallback, wp_page_menu(), to show a home link. */ @@ -563,6 +548,7 @@ endif; // ends check for twentyeleven_comment() if ( ! function_exists( 'twentyeleven_posted_on' ) ) : /** * Prints HTML with meta information for the current post-date/time and author. + * Create your own twentyeleven_posted_on to override in a child theme * * @since Twenty Eleven 1.0 */ @@ -580,16 +566,22 @@ function twentyeleven_posted_on() { endif; /** - * Adds Twenty Eleven author class to the array of body classes. + * Adds two classes to the array of body classes. + * The first is if the site has only had one author with published posts. + * The second is if a singular post being displayed * * @since Twenty Eleven 1.0 */ -function twentyeleven_author_class( $classes ) { +function twentyeleven_body_classes( $classes ) { if ( ! is_multi_author() ) { $classes[] = 'single-author'; } - + + if ( is_singular() && ! is_home() && ! is_page_template( 'showcase.php' ) && ! is_page_template( 'sidebar-page.php' ) ) + $classes[] = 'singular'; + return $classes; } -add_filter( 'body_class', 'twentyeleven_author_class' ); +add_filter( 'body_class', 'twentyeleven_body_classes' ); +