Changeset 20983
- Timestamp:
- 06/04/2012 02:43:19 PM (12 years ago)
- Location:
- trunk/wp-content/themes
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-content/themes/twentyeleven/functions.php
r20973 r20983 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', … … 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 ); 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 } 134 146 135 147 // We'll be using post thumbnails for custom header images on posts and pages. 136 148 // We want them to be the size of the header image that we just defined 137 149 // 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 ); 139 151 140 152 // Add Twenty Eleven's custom image sizes. 141 153 // 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 ); 143 155 // Used for featured posts if a large-feature doesn't exist. 144 156 add_image_size( 'small-feature', 500, 300 ); … … 208 220 209 221 // 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 ) 211 223 return; 224 212 225 // If we get this far, we have custom styles. Let's do this. 213 226 ?> … … 270 283 <?php 271 284 // 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 ) : 273 286 ?> 274 287 #site-title a, -
trunk/wp-content/themes/twentyeleven/header.php
r20470 r20983 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 … … 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> -
trunk/wp-content/themes/twentyeleven/showcase.php
r20226 r20983 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"> -
trunk/wp-content/themes/twentyten/functions.php
r20973 r20983 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. … … 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 add_custom_background(); 130 } 118 131 119 132 // We'll be using post thumbnails for custom header images on posts and pages. 120 133 // We want them to be 940 pixels wide by 198 pixels tall. 121 134 // 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 );135 set_post_thumbnail_size( $custom_header_support['width'], $custom_header_support['height'], true ); 123 136 124 137 // ... and thus ends the custom header business. -
trunk/wp-content/themes/twentyten/header.php
r20474 r20983 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 -->
Note: See TracChangeset
for help on using the changeset viewer.