Make WordPress Core


Ignore:
Timestamp:
06/04/2012 02:43:19 PM (12 years ago)
Author:
ryan
Message:

Back compat for bundled themes. Props nacin, SergeyBiryukov, kobenland. fixes #20768

File:
1 edited

Legend:

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

    r20973 r20983  
    115115
    116116    // Add support for custom headers.
    117     add_theme_support( 'custom-header', array(
     117    $custom_header_support = array(
    118118        // The default header text color.
    119119        'default-text-color' => '000',
     
    131131        // Callback used to display the header preview in the admin.
    132132        'admin-preview-callback' => 'twentyeleven_admin_header_image',
    133     ) );
     133    );
     134   
     135    add_theme_support( 'custom-header', $custom_header_support );
     136
     137    if ( ! function_exists( 'get_custom_header' ) ) {
     138        // This is all for compatibility with versions of WordPress prior to 3.4.
     139        define( 'HEADER_TEXTCOLOR', $custom_header_support['default-text-color'] );
     140        define( 'HEADER_IMAGE', '' );
     141        define( 'HEADER_IMAGE_WIDTH', $custom_header_support['width'] );
     142        define( 'HEADER_IMAGE_HEIGHT', $custom_header_support['height'] );
     143        add_custom_image_header( $custom_header_support['wp-head-callback'], $custom_header_support['admin-head-callback'], $custom_header_support['admin-preview-callback'] );
     144        add_custom_background();
     145    }
    134146
    135147    // We'll be using post thumbnails for custom header images on posts and pages.
    136148    // We want them to be the size of the header image that we just defined
    137149    // Larger images will be auto-cropped to fit, smaller ones will be ignored. See header.php.
    138     set_post_thumbnail_size( get_theme_support( 'custom-header', 'width' ), get_theme_support( 'custom-header', 'height' ), true );
     150    set_post_thumbnail_size( $custom_header_support['width'], $custom_header_support['height'], true );
    139151
    140152    // Add Twenty Eleven's custom image sizes.
    141153    // Used for large feature (header) images.
    142     add_image_size( 'large-feature', get_theme_support( 'custom-header', 'width' ), get_theme_support( 'custom-header', 'height' ), true );
     154    add_image_size( 'large-feature', $custom_header_support['width'], $custom_header_support['height'], true );
    143155    // Used for featured posts if a large-feature doesn't exist.
    144156    add_image_size( 'small-feature', 500, 300 );
     
    208220
    209221    // If no custom options for text are set, let's bail.
    210     if ( $text_color == get_theme_support( 'custom-header', 'default-text-color' ) )
     222    if ( $text_color == HEADER_TEXTCOLOR )
    211223        return;
     224       
    212225    // If we get this far, we have custom styles. Let's do this.
    213226    ?>
     
    270283    <?php
    271284        // If the user has set a custom color for the text use that
    272         if ( get_header_textcolor() != get_theme_support( 'custom-header', 'default-text-color' ) ) :
     285        if ( get_header_textcolor() != HEADER_TEXTCOLOR ) :
    273286    ?>
    274287        #site-title a,
Note: See TracChangeset for help on using the changeset viewer.