Make WordPress Core

Changeset 18272


Ignore:
Timestamp:
06/11/2011 06:30:59 AM (13 years ago)
Author:
dd32
Message:

Twenty Eleven Functions.php comments cleanup, merge the 2 body class functions. Props jorbin. See #17748

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-content/themes/twentyeleven/functions.php

    r18244 r18272  
    101101    register_nav_menu( 'primary', __( 'Primary Menu', 'twentyeleven' ) );
    102102
    103     /**
    104      * Add support for an Aside Post Format
    105      */
     103    // Add support for a variety of post formats
    106104    add_theme_support( 'post-formats', array( 'aside', 'link', 'gallery', 'status', 'quote', 'image' ) );
    107105
    108     /**
    109      * Add support for custom backgrounds
    110      */
     106    // Add support for custom backgrounds
    111107    add_custom_background();
    112108
    113     // This theme uses Feature Images for per-post/per-page Custom Header images
     109    // This theme uses Featured Images (also known as post thumbnails) for per-post/per-page Custom Header images
    114110    add_theme_support( 'post-thumbnails' );
    115111
    116     /**
    117      * Add support for Custom Headers
    118      */
     112    // The next four constants set how twentyeleven supports custom headers
     113
     114    // The default header text color
    119115    define( 'HEADER_TEXTCOLOR', '000' );
    120116
    121     // No CSS, just an IMG call. The %s is a placeholder for the theme template directory URI.
    122     define( 'HEADER_IMAGE', '' ); // Leaving empty for random image rotation.
    123 
    124     // The height and width of your custom header. You can hook into the theme's own filters to change these values.
     117    // By leaving empty, we default to random image rotation
     118    define( 'HEADER_IMAGE', '' );
     119
     120    // The height and width of your custom header.
    125121    // Add a filter to twentyeleven_header_image_width and twentyeleven_header_image_height to change these values.
    126122    define( 'HEADER_IMAGE_WIDTH', apply_filters( 'twentyeleven_header_image_width', 1000 ) );
     
    128124
    129125    // We'll be using post thumbnails for custom header images on posts and pages.
    130     // We want them to be 1000 pixels wide by 288 pixels tall.
     126    // We want them to be the size of the header image that we just defined
    131127    // Larger images will be auto-cropped to fit, smaller ones will be ignored. See header.php.
    132128    set_post_thumbnail_size( HEADER_IMAGE_WIDTH, HEADER_IMAGE_HEIGHT, true );
    133129
    134130    // Add Twenty Eleven's custom image sizes
    135     add_image_size( 'large-feature', HEADER_IMAGE_WIDTH, HEADER_IMAGE_HEIGHT, true ); // Used for large feature images
     131    add_image_size( 'large-feature', HEADER_IMAGE_WIDTH, HEADER_IMAGE_HEIGHT, true ); // Used for large feature (header) images
    136132    add_image_size( 'small-feature', 500, 300 ); // Used for featured posts if a large-feature doesn't exist
    137133
     
    355351
    356352/**
    357  * Add custom body classes
    358  */
    359 function twentyeleven_singular_class( $classes ) {
    360     if ( is_singular() && ! is_home() && ! is_page_template( 'showcase.php' ) && ! is_page_template( 'sidebar-page.php' ) )
    361         $classes[] = 'singular';
    362 
    363     return $classes;
    364 }
    365 add_filter( 'body_class', 'twentyeleven_singular_class' );
    366 
    367 /**
    368353 * Get our wp_nav_menu() fallback, wp_page_menu(), to show a home link.
    369354 */
     
    564549/**
    565550 * Prints HTML with meta information for the current post-date/time and author.
     551 * Create your own twentyeleven_posted_on to override in a child theme
    566552 *
    567553 * @since Twenty Eleven 1.0
     
    581567
    582568/**
    583  * Adds Twenty Eleven author class to the array of body classes.
    584  *
    585  * @since Twenty Eleven 1.0
    586  */
    587 function twentyeleven_author_class( $classes ) {
     569 * Adds two classes to the array of body classes.
     570 * The first is if the site has only had one author with published posts.
     571 * The second is if a singular post being displayed
     572 *
     573 * @since Twenty Eleven 1.0
     574 */
     575function twentyeleven_body_classes( $classes ) {
    588576
    589577    if ( ! is_multi_author() ) {
    590578        $classes[] = 'single-author';
    591579    }
    592    
     580
     581    if ( is_singular() && ! is_home() && ! is_page_template( 'showcase.php' ) && ! is_page_template( 'sidebar-page.php' ) )
     582        $classes[] = 'singular';
     583
    593584    return $classes;
    594585}
    595 add_filter( 'body_class', 'twentyeleven_author_class' );
     586add_filter( 'body_class', 'twentyeleven_body_classes' );
     587
Note: See TracChangeset for help on using the changeset viewer.