Ticket #20768: 20768.3.diff
| File 20768.3.diff, 9.4 KB (added by nacin, 13 months ago) |
|---|
-
twentyten/functions.php
101 101 102 102 // The custom header business starts here. 103 103 104 add_theme_support( 'custom-header',array(104 $custom_header_support = array( 105 105 // The default image to use. 106 106 // The %s is a placeholder for the theme template directory URI. 107 107 'default-image' => '%s/images/headers/path.jpg', … … 114 114 'header-text' => false, 115 115 // Callback for styling the header preview in the admin. 116 116 'admin-head-callback' => 'twentyten_admin_header_style', 117 ) ); 117 ); 118 119 add_theme_support( 'custom-header', $custom_header_support ); 120 121 if ( ! function_exists( 'get_custom_header' ) ) { 122 // This is all for compatibility with versions of WordPress prior to 3.4. 123 define( 'HEADER_TEXTCOLOR', '' ); 124 define( 'NO_HEADER_TEXT', true ); 125 define( 'HEADER_IMAGE', $custom_header_support['default-image'] ); 126 define( 'HEADER_IMAGE_WIDTH', $custom_header_support['width'] ); 127 define( 'HEADER_IMAGE_HEIGHT', $custom_header_support['height'] ); 128 add_custom_image_header( '', $custom_header_support['admin-head-callback'] ); 129 } 118 130 119 131 // We'll be using post thumbnails for custom header images on posts and pages. 120 132 // We want them to be 940 pixels wide by 198 pixels tall. 121 133 // Larger images will be auto-cropped to fit, smaller ones will be ignored. See header.php. 122 set_post_thumbnail_size( get_theme_support( 'custom-header', 'width' ), get_theme_support( 'custom-header', 'height' ), true );134 set_post_thumbnail_size( $custom_header_support['width'], $custom_header_support['height'], true ); 123 135 124 136 // ... and thus ends the custom header business. 125 137 -
twentyten/header.php
66 66 <div id="site-description"><?php bloginfo( 'description' ); ?></div> 67 67 68 68 <?php 69 // Compatibility with versions of WordPress prior to 3.4. 70 if ( function_exists( 'get_custom_header' ) ) { 71 // We need to figure out what the minimum width should be for our featured image. 72 // This result would be the suggested width if the theme were to implement flexible widths. 73 $header_image_width = get_theme_support( 'custom-header', 'width' ); 74 } else { 75 $header_image_width = HEADER_IMAGE_WIDTH; 76 } 77 69 78 // Check if this is a post or page, if it has a thumbnail, and if it's a big one 70 79 if ( is_singular() && current_theme_supports( 'post-thumbnails' ) && 71 80 has_post_thumbnail( $post->ID ) && 72 81 ( /* $src, $width, $height */ $image = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'post-thumbnail' ) ) && 73 $image[1] >= get_theme_support( 'custom-header', 'width' )) :82 $image[1] >= $header_image_width ) : 74 83 // Houston, we have a new header image! 75 84 echo get_the_post_thumbnail( $post->ID ); 76 elseif ( get_header_image() ) : 85 elseif ( get_header_image() ) : 86 // Compatibility with versions of WordPress prior to 3.4. 77 87 if ( function_exists( 'get_custom_header' ) ) { 78 $header_ width = get_custom_header()->width;79 $header_ height = get_custom_header()->height;88 $header_image_width = get_custom_header()->width; 89 $header_image_height = get_custom_header()->height; 80 90 } else { 81 $header_height = $header_width = ''; 91 $header_image_width = HEADER_IMAGE_WIDTH; 92 $header_image_height = HEADER_IMAGE_HEIGHT; 82 93 } 83 ?>84 <img src="<?php header_image(); ?>" width="<?php echo $header_ width; ?>" height="<?php echo $header_height; ?>" alt="" />94 ?> 95 <img src="<?php header_image(); ?>" width="<?php echo $header_image_width; ?>" height="<?php echo $header_image_height; ?>" alt="" /> 85 96 <?php endif; ?> 86 97 </div><!-- #branding --> 87 98 -
twentyeleven/showcase.php
66 66 */ 67 67 $counter_slider = 0; 68 68 69 $header_image_width = get_theme_support( 'custom-header', 'width' ); 70 ?> 69 // Compatibility with versions of WordPress prior to 3.4. 70 if ( function_exists( 'get_custom_header' ) ) 71 $header_image_width = get_theme_support( 'custom-header', 'width' ); 72 else 73 $header_image_width = HEADER_IMAGE_WIDTH; 74 ?> 71 75 72 76 <div class="featured-posts"> 73 77 <h1 class="showcase-heading"><?php _e( 'Featured Post', 'twentyeleven' ); ?></h1> -
twentyeleven/header.php
79 79 // Check to see if the header image has been removed 80 80 $header_image = get_header_image(); 81 81 if ( $header_image ) : 82 $header_image_width = get_custom_header()->width; 83 ?> 82 // Compatibility with versions of WordPress prior to 3.4. 83 if ( function_exists( 'get_custom_header' ) ) { 84 // We need to figure out what the minimum width should be for our featured image. 85 // This result would be the suggested width if the theme were to implement flexible widths. 86 $header_image_width = get_theme_support( 'custom-header', 'width' ); 87 } else { 88 $header_image_width = HEADER_IMAGE_WIDTH; 89 } 90 ?> 84 91 <a href="<?php echo esc_url( home_url( '/' ) ); ?>"> 85 92 <?php 86 93 // The header image … … 90 97 $image[1] >= $header_image_width ) : 91 98 // Houston, we have a new header image! 92 99 echo get_the_post_thumbnail( $post->ID, 'post-thumbnail' ); 93 else : ?> 94 <img src="<?php header_image(); ?>" width="<?php echo $header_image_width; ?>" height="<?php echo get_custom_header()->height; ?>" alt="" /> 100 else : 101 // Compatibility with versions of WordPress prior to 3.4. 102 if ( function_exists( 'get_custom_header' ) ) { 103 $header_image_width = get_custom_header()->width; 104 $header_image_height = get_custom_header()->height; 105 } else { 106 $header_image_width = HEADER_IMAGE_WIDTH; 107 $header_image_height = HEADER_IMAGE_HEIGHT; 108 } 109 ?> 110 <img src="<?php header_image(); ?>" width="<?php echo $header_image_width; ?>" height="<?php echo $header_image_height; ?>" alt="" /> 95 111 <?php endif; // end check for featured image or standard header ?> 96 112 </a> 97 113 <?php endif; // end check for removed header image ?> -
twentyeleven/functions.php
114 114 add_theme_support( 'post-thumbnails' ); 115 115 116 116 // Add support for custom headers. 117 add_theme_support( 'custom-header',array(117 $custom_header_support = array( 118 118 // The default header text color. 119 119 'default-text-color' => '000', 120 120 // The height and width of our custom header. … … 130 130 'admin-head-callback' => 'twentyeleven_admin_header_style', 131 131 // Callback used to display the header preview in the admin. 132 132 'admin-preview-callback' => 'twentyeleven_admin_header_image', 133 ) ); 133 ); 134 135 add_theme_support( 'custom-header', $custom_header_support ); 134 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 } 145 135 146 // We'll be using post thumbnails for custom header images on posts and pages. 136 147 // We want them to be the size of the header image that we just defined 137 148 // 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 );149 set_post_thumbnail_size( $custom_header_support['width'], $custom_header_support['height'], true ); 139 150 140 151 // Add Twenty Eleven's custom image sizes. 141 152 // 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 );153 add_image_size( 'large-feature', $custom_header_support['width'], $custom_header_support['height'], true ); 143 154 // Used for featured posts if a large-feature doesn't exist. 144 155 add_image_size( 'small-feature', 500, 300 ); 145 156 … … 207 218 $text_color = get_header_textcolor(); 208 219 209 220 // If no custom options for text are set, let's bail. 210 if ( $text_color == get_theme_support( 'custom-header', 'default-text-color' ))221 if ( $text_color == HEADER_TEXTCOLOR ) 211 222 return; 223 212 224 // If we get this far, we have custom styles. Let's do this. 213 225 ?> 214 226 <style type="text/css"> … … 269 281 } 270 282 <?php 271 283 // 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' )) :284 if ( get_header_textcolor() != HEADER_TEXTCOLOR ) : 273 285 ?> 274 286 #site-title a, 275 287 #site-description {