Ticket #20768: 20768.diff
| File 20768.diff, 5.0 KB (added by kobenland, 12 months ago) |
|---|
-
wp-content/themes/twentyeleven/functions.php
104 104 add_theme_support( 'post-thumbnails' ); 105 105 106 106 // Add support for custom headers. 107 add_theme_support( 'custom-header',array(107 $custom_header_args = array( 108 108 // The default header text color. 109 109 'default-text-color' => '000', 110 110 // The height and width of our custom header. … … 120 120 'admin-head-callback' => 'twentyeleven_admin_header_style', 121 121 // Callback used to display the header preview in the admin. 122 122 '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 } 124 135 125 136 // We'll be using post thumbnails for custom header images on posts and pages. 126 137 // We want them to be the size of the header image that we just defined … … 303 314 <?php } 304 315 endif; // twentyeleven_admin_header_image 305 316 317 if ( ! 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 */ 327 function 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 } 335 endif; 336 306 337 /** 307 338 * Sets the post excerpt length to 40 words. 308 339 * -
wp-content/themes/twentyten/functions.php
98 98 99 99 // The custom header business starts here. 100 100 101 add_theme_support( 'custom-header',array(101 $custom_header_args = array( 102 102 // The default image to use. 103 103 // The %s is a placeholder for the theme template directory URI. 104 104 'default-image' => '%s/images/headers/path.jpg', … … 111 111 'header-text' => false, 112 112 // Callback for styling the header preview in the admin. 113 113 '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 } 115 127 116 128 // We'll be using post thumbnails for custom header images on posts and pages. 117 129 // We want them to be 940 pixels wide by 198 pixels tall. … … 199 211 } 200 212 endif; 201 213 214 if ( ! 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 */ 224 function 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 } 232 endif; 233 202 234 /** 203 235 * Get our wp_nav_menu() fallback, wp_page_menu(), to show a home link. 204 236 * -
wp-content/themes/twentyten/header.php
73 73 $image[1] >= get_theme_support( 'custom-header', 'width' ) ) : 74 74 // Houston, we have a new header image! 75 75 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="" /> 85 78 <?php endif; ?> 86 79 </div><!-- #branding --> 87 80
