Ticket #20768: 20768.diff

File 20768.diff, 5.0 KB (added by kobenland, 12 months ago)

Patch provides backward compatibility to 3.2 for Twenty Eleven and 3.1 for Twenty Ten.

  • wp-content/themes/twentyeleven/functions.php

     
    104104        add_theme_support( 'post-thumbnails' ); 
    105105 
    106106        // Add support for custom headers. 
    107         add_theme_support( 'custom-header', array( 
     107        $custom_header_args = array( 
    108108                // The default header text color. 
    109109                'default-text-color' => '000', 
    110110                // The height and width of our custom header. 
     
    120120                'admin-head-callback' => 'twentyeleven_admin_header_style', 
    121121                // Callback used to display the header preview in the admin. 
    122122                'admin-preview-callback' => 'twentyeleven_admin_header_image', 
    123         ) ); 
     123        ); 
     124         
     125        add_theme_support( 'custom-header', $custom_header_args ); 
     126         
     127        if ( ! function_exists( 'wp_get_theme' ) ) { 
     128                // Compat: Versions of WordPress prior to 3.4. 
     129                define( 'HEADER_TEXTCOLOR', $custom_header_args['default-text-color'] ); 
     130                define( 'HEADER_IMAGE', '' ); 
     131                define( 'HEADER_IMAGE_WIDTH', $custom_header_args['width'] ); 
     132                define( 'HEADER_IMAGE_HEIGHT', $custom_header_args['height'] ); 
     133                add_custom_image_header( $custom_header_args['wp-head-callback'], $custom_header_args['admin-head-callback'], $custom_header_args['admin-preview-callback'] ); 
     134        } 
    124135 
    125136        // We'll be using post thumbnails for custom header images on posts and pages. 
    126137        // We want them to be the size of the header image that we just defined 
     
    303314<?php } 
    304315endif; // twentyeleven_admin_header_image 
    305316 
     317if ( ! function_exists( 'get_custom_header' ) ) : 
     318/** 
     319 * Get the header image data. 
     320 *  
     321 * Provides backward compatibility for WordPress versions prior to 3.4 
     322 * 
     323 * @since       Twenty Eleven 1.3 
     324 * 
     325 * @return      object 
     326*/ 
     327function get_custom_header() { 
     328        return (object) array( 
     329                'url'           => get_header_image(), 
     330                'thumbnail_url' => get_header_image(), 
     331                'width'         => HEADER_IMAGE_WIDTH, 
     332                'height'        => HEADER_IMAGE_HEIGHT, 
     333        ); 
     334} 
     335endif; 
     336 
    306337/** 
    307338 * Sets the post excerpt length to 40 words. 
    308339 * 
  • wp-content/themes/twentyten/functions.php

     
    9898 
    9999        // The custom header business starts here. 
    100100 
    101         add_theme_support( 'custom-header', array( 
     101        $custom_header_args = array( 
    102102                // The default image to use. 
    103103                // The %s is a placeholder for the theme template directory URI. 
    104104                'default-image' => '%s/images/headers/path.jpg', 
     
    111111                'header-text' => false, 
    112112                // Callback for styling the header preview in the admin. 
    113113                'admin-head-callback' => 'twentyten_admin_header_style', 
    114         ) ); 
     114        ); 
     115         
     116        add_theme_support( 'custom-header', $custom_header_args ); 
     117         
     118        if ( ! function_exists( 'wp_get_theme' ) ) { 
     119                // Compat: Versions of WordPress prior to 3.4. 
     120                define( 'HEADER_TEXTCOLOR', '' ); 
     121                define( 'NO_HEADER_TEXT', true ); 
     122                define( 'HEADER_IMAGE', $custom_header_args['default-image'] ); 
     123                define( 'HEADER_IMAGE_WIDTH', $custom_header_args['width'] ); 
     124                define( 'HEADER_IMAGE_HEIGHT', $custom_header_args['height'] ); 
     125                add_custom_image_header( '', $custom_header_args['admin-head-callback'] ); 
     126        } 
    115127 
    116128        // We'll be using post thumbnails for custom header images on posts and pages. 
    117129        // We want them to be 940 pixels wide by 198 pixels tall. 
     
    199211} 
    200212endif; 
    201213 
     214if ( ! function_exists( 'get_custom_header' ) ) : 
     215/** 
     216 * Get the header image data. 
     217* 
     218* Provides backward compatibility for WordPress versions prior to 3.4 
     219* 
     220* @since        Twenty Ten 1.3 
     221* 
     222* @return       object 
     223*/ 
     224function get_custom_header() { 
     225        return (object) array( 
     226                'url'           => get_header_image(), 
     227                'thumbnail_url' => get_header_image(), 
     228                'width'         => HEADER_IMAGE_WIDTH, 
     229                'height'        => HEADER_IMAGE_HEIGHT, 
     230        ); 
     231} 
     232endif; 
     233 
    202234/** 
    203235 * Get our wp_nav_menu() fallback, wp_page_menu(), to show a home link. 
    204236 * 
  • wp-content/themes/twentyten/header.php

     
    7373                                                        $image[1] >= get_theme_support( 'custom-header', 'width' ) ) : 
    7474                                                // Houston, we have a new header image! 
    7575                                                echo get_the_post_thumbnail( $post->ID ); 
    76                                         elseif ( get_header_image() ) :  
    77                                                 if ( function_exists( 'get_custom_header' ) ) { 
    78                                                         $header_width  = get_custom_header()->width; 
    79                                                         $header_height = get_custom_header()->height; 
    80                                                 } else { 
    81                                                         $header_height = $header_width = ''; 
    82                                                 } 
    83                                                 ?> 
    84                                                 <img src="<?php header_image(); ?>" width="<?php echo $header_width; ?>" height="<?php echo $header_height; ?>" alt="" /> 
     76                                        elseif ( get_header_image() ) : ?> 
     77                                                <img src="<?php header_image(); ?>" width="<?php echo get_custom_header()->width; ?>" height="<?php echo get_custom_header()->height; ?>" alt="" /> 
    8578                                        <?php endif; ?> 
    8679                        </div><!-- #branding --> 
    8780