WordPress.org

Make WordPress Core

Changeset 20225


Ignore:
Timestamp:
03/20/12 21:32:42 (5 years ago)
Author:
nacin
Message:

Move Twenty Ten and the rest of Twenty Eleven to add_theme_support() for headers and backgrounds. props sabreuse for initial patch. fixes #20265. see #20249.

Location:
trunk/wp-content/themes
Files:
4 edited

Legend:

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

    r20222 r20225  
    6363 * @uses load_theme_textdomain() For translation/localization support. 
    6464 * @uses add_editor_style() To style the visual editor. 
    65  * @uses add_theme_support() To add support for post thumbnails, automatic feed links, and Post Formats. 
     65 * @uses add_theme_support() To add support for post thumbnails, automatic feed links, custom headers 
     66 *  and backgrounds, and post formats. 
    6667 * @uses register_nav_menus() To add support for navigation menus. 
    67  * @uses add_custom_background() To add support for a custom background. 
    68  * @uses add_custom_image_header() To add support for a custom header. 
    6968 * @uses register_default_headers() To register the default custom header images provided with the theme. 
    7069 * @uses set_post_thumbnail_size() To set a custom post thumbnail size. 
     
    235234 * Styles the header image displayed on the Appearance > Header admin panel. 
    236235 * 
    237  * Referenced via add_custom_image_header() in twentyeleven_setup(). 
     236 * Referenced via add_theme_support('custom-header') in twentyeleven_setup(). 
    238237 * 
    239238 * @since Twenty Eleven 1.0 
     
    285284 * Custom header image markup displayed on the Appearance > Header admin panel. 
    286285 * 
    287  * Referenced via add_custom_image_header() in twentyeleven_setup(). 
     286 * Referenced via add_theme_support('custom-header') in twentyeleven_setup(). 
    288287 * 
    289288 * @since Twenty Eleven 1.0 
  • trunk/wp-content/themes/twentyeleven/showcase.php

    r19379 r20225  
    6767                    $counter_slider = 0; 
    6868 
     69                    $header_image_width  = get_theme_support( 'custom-header', 'width' ); 
     70                    $header_image_height = get_theme_support( 'custom-header', 'height' ); 
    6971                    ?> 
    7072 
     
    9092 
    9193                        // Hang on. Let's check this here image out. 
    92                         $image = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), array( HEADER_IMAGE_WIDTH, HEADER_IMAGE_WIDTH ) ); 
     94                        $image = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), array( $header_image_width, $header_image_width ) ); 
    9395 
    9496                        // Is it bigger than or equal to our header? 
    95                         if ( $image[1] >= HEADER_IMAGE_WIDTH ) { 
     97                        if ( $image[1] >= $header_image_width ) { 
    9698                            // If bigger, let's add a BIGGER class. It's EXTRA classy now. 
    9799                            $feature_class = 'feature-image large'; 
     
    108110                             */ 
    109111                            if ( has_post_thumbnail() ) { 
    110                                 if ( $image[1] >= HEADER_IMAGE_WIDTH ) 
     112                                if ( $image[1] >= $header_image_width ) 
    111113                                    $thumbnail_size = 'large-feature'; 
    112114                                else 
  • trunk/wp-content/themes/twentyten/functions.php

    r19582 r20225  
    6262 * functions.php file. 
    6363 * 
    64  * @uses add_theme_support() To add support for post thumbnails and automatic feed links. 
     64 * @uses add_theme_support() To add support for post thumbnails, custom headers and backgrounds, and automatic feed links. 
    6565 * @uses register_nav_menus() To add support for navigation menus. 
    66  * @uses add_custom_background() To add support for a custom background. 
    6766 * @uses add_editor_style() To style the visual editor. 
    6867 * @uses load_theme_textdomain() For translation/localization support. 
    69  * @uses add_custom_image_header() To add support for a custom header. 
    7068 * @uses register_default_headers() To register the default custom header images provided with the theme. 
    7169 * @uses set_post_thumbnail_size() To set a custom post thumbnail size. 
     
    10199    ) ); 
    102100 
    103     // This theme allows users to set a custom background 
    104     add_custom_background(); 
    105  
    106     // Your changeable header business starts here 
    107     if ( ! defined( 'HEADER_TEXTCOLOR' ) ) 
    108         define( 'HEADER_TEXTCOLOR', '' ); 
    109  
    110     // No CSS, just IMG call. The %s is a placeholder for the theme template directory URI. 
    111     if ( ! defined( 'HEADER_IMAGE' ) ) 
    112         define( 'HEADER_IMAGE', '%s/images/headers/path.jpg' ); 
    113  
    114     // The height and width of your custom header. You can hook into the theme's own filters to change these values. 
    115     // Add a filter to twentyten_header_image_width and twentyten_header_image_height to change these values. 
    116     define( 'HEADER_IMAGE_WIDTH', apply_filters( 'twentyten_header_image_width', 940 ) ); 
    117     define( 'HEADER_IMAGE_HEIGHT', apply_filters( 'twentyten_header_image_height', 198 ) ); 
     101    // This theme allows users to set a custom background. 
     102    add_theme_support( 'custom-background' ); 
     103 
     104    // The custom header business starts here. 
     105 
     106    add_theme_support( 'custom-header', array( 
     107        // The default image to use. 
     108        // The %s is a placeholder for the theme template directory URI. 
     109        'default-image' => '%s/images/headers/path.jpg', 
     110        // The height and width of our custom header. 
     111        'width' => apply_filters( 'twentyten_header_image_width', 940 ), 
     112        'height' => apply_filters( 'twentyten_header_image_height', 198 ), 
     113        // Don't support text inside the header image. 
     114        'header-text' => false, 
     115        // Callback for styling the header preview in the admin. 
     116        'admin-header-callback' => 'twentyten_admin_header_style', 
     117    ) ); 
    118118 
    119119    // We'll be using post thumbnails for custom header images on posts and pages. 
    120120    // We want them to be 940 pixels wide by 198 pixels tall. 
    121121    // Larger images will be auto-cropped to fit, smaller ones will be ignored. See header.php. 
    122     set_post_thumbnail_size( HEADER_IMAGE_WIDTH, HEADER_IMAGE_HEIGHT, true ); 
    123  
    124     // Don't support text inside the header image. 
    125     if ( ! defined( 'NO_HEADER_TEXT' ) ) 
    126         define( 'NO_HEADER_TEXT', true ); 
    127  
    128     // Add a way for the custom header to be styled in the admin panel that controls 
    129     // custom headers. See twentyten_admin_header_style(), below. 
    130     add_custom_image_header( '', 'twentyten_admin_header_style' ); 
    131  
    132     // ... and thus ends the changeable header business. 
     122    set_post_thumbnail_size( get_theme_support( 'custom-header', 'width' ), get_theme_support( 'custom-header', 'height' ), true ); 
     123 
     124    // ... and thus ends the custom header business. 
    133125 
    134126    // Default custom headers packaged with the theme. %s is a placeholder for the theme template directory URI. 
     
    202194    border-top: 4px solid #000; 
    203195} 
    204 /* If NO_HEADER_TEXT is false, you would style the text with these selectors: 
     196/* If header-text was supported, you would style the text with these selectors: 
    205197    #headimg #name { } 
    206198    #headimg #desc { } 
  • trunk/wp-content/themes/twentyten/header.php

    r19599 r20225  
    7171                            has_post_thumbnail( $post->ID ) && 
    7272                            ( /* $src, $width, $height */ $image = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'post-thumbnail' ) ) && 
    73                             $image[1] >= HEADER_IMAGE_WIDTH ) : 
     73                            $image[1] >= get_theme_support( 'custom-header', 'width' ) ) : 
    7474                        // Houston, we have a new header image! 
    7575                        echo get_the_post_thumbnail( $post->ID ); 
    7676                    elseif ( get_header_image() ) : ?> 
    77                         <img src="<?php header_image(); ?>" width="<?php echo HEADER_IMAGE_WIDTH; ?>" height="<?php echo HEADER_IMAGE_HEIGHT; ?>" alt="" /> 
     77                        <img src="<?php header_image(); ?>" width="<?php echo get_theme_support( 'custom-header', 'width' ); ?>" height="<?php echo get_theme_support( 'custom-header', 'height' ); ?>" alt="" /> 
    7878                    <?php endif; ?> 
    7979            </div><!-- #branding --> 
Note: See TracChangeset for help on using the changeset viewer.