Make WordPress Core


Ignore:
Timestamp:
03/20/2012 09:32:42 PM (12 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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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 { }
Note: See TracChangeset for help on using the changeset viewer.