WordPress.org

Make WordPress Core

Ticket #17748: 18267.diff

File 18267.diff, 4.3 KB (added by jorbin, 3 years ago)
  • wp-content/themes/twentyeleven/functions.php

     
    100100        // This theme uses wp_nav_menu() in one location. 
    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 Feature 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          */ 
    119         define( 'HEADER_TEXTCOLOR', '000' ); 
     112        // The next four constants set how twentyeleven supports custom headers 
     113         
     114    // The default header text color 
     115    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. 
     117        // by leaving empty, we default to random image rotation 
     118        define( 'HEADER_IMAGE', '' );  
    123119 
    124         // The height and width of your custom header. You can hook into the theme's own filters to change these values. 
     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 ) ); 
    127123        define( 'HEADER_IMAGE_HEIGHT', apply_filters( 'twentyeleven_header_image_height', 288 ) ); 
    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 header images 
    136132        add_image_size( 'small-feature', 500, 300 ); // Used for featured posts if a large-feature doesn't exist 
    137133 
    138134        // Add a way for the custom header to be styled in the admin panel that controls 
     
    354350add_filter( 'get_the_excerpt', 'twentyeleven_custom_excerpt_more' ); 
    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 */ 
    370355function twentyeleven_page_menu_args( $args ) { 
     
    563548if ( ! function_exists( 'twentyeleven_posted_on' ) ) : 
    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 
    568554 */ 
     
    580566endif; 
    581567 
    582568/** 
    583  * Adds Twenty Eleven author class to the array of body 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 the post is a singular post being displayed 
    584572 * 
    585573 * @since Twenty Eleven 1.0 
    586574 */ 
    587 function twentyeleven_author_class( $classes ) { 
     575function twentyeleven_body_classes( $classes ) { 
    588576 
    589577        if ( ! is_multi_author() ) { 
    590578                $classes[] = 'single-author'; 
    591579        } 
     580 
     581        if ( is_singular() && ! is_home() && ! is_page_template( 'showcase.php' ) && ! is_page_template( 'sidebar-page.php' ) ) 
     582                $classes[] = 'singular'; 
    592583         
    593584        return $classes; 
    594585} 
    595 add_filter( 'body_class', 'twentyeleven_author_class' ); 
     586add_filter( 'body_class', 'twentyeleven_body_classes' ); 
     587