Changeset 20222
- Timestamp:
- 03/20/2012 08:37:53 PM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-content/themes/twentyeleven/functions.php
r19582 r20222 104 104 add_theme_support( 'post-formats', array( 'aside', 'link', 'gallery', 'status', 'quote', 'image' ) ); 105 105 106 // Add support for custom backgrounds 107 add_ custom_background();106 // Add support for custom backgrounds. 107 add_theme_support( 'custom-background' ); 108 108 109 109 // This theme uses Featured Images (also known as post thumbnails) for per-post/per-page Custom Header images 110 110 add_theme_support( 'post-thumbnails' ); 111 111 112 // The next four constants set how Twenty Eleven supports custom headers. 113 114 // The default header text color 115 define( 'HEADER_TEXTCOLOR', '000' ); 116 117 // By leaving empty, we allow for random image rotation. 118 define( 'HEADER_IMAGE', '' ); 119 120 // The height and width of your custom header. 121 // Add a filter to twentyeleven_header_image_width and twentyeleven_header_image_height to change these values. 122 define( 'HEADER_IMAGE_WIDTH', apply_filters( 'twentyeleven_header_image_width', 1000 ) ); 123 define( 'HEADER_IMAGE_HEIGHT', apply_filters( 'twentyeleven_header_image_height', 288 ) ); 112 // Add support for custom headers. 113 add_theme_support( 'custom-header', array( 114 // The default header text color. 115 'default-text-color' => '000', 116 // The height and width of our custom header. 117 'width' => apply_filters( 'twentyeleven_header_image_width', 1000 ), 118 'height' => apply_filters( 'twentyeleven_header_image_height', 288 ), 119 // Random image rotation by default. 120 'random-default' => true, 121 // Callback for styling the header. 122 'callback' => 'twentyeleven_header_style', 123 // Callback for styling the header preview in the admin. 124 'admin-header-callback' => 'twentyeleven_admin_header_style', 125 // Callback used to display the header preview in the admin. 126 'admin-image-div-callback' => 'twentyeleven_admin_header_image', 127 ) ); 124 128 125 129 // We'll be using post thumbnails for custom header images on posts and pages. 126 130 // We want them to be the size of the header image that we just defined 127 131 // Larger images will be auto-cropped to fit, smaller ones will be ignored. See header.php. 128 set_post_thumbnail_size( HEADER_IMAGE_WIDTH, HEADER_IMAGE_HEIGHT, true ); 129 130 // Add Twenty Eleven's custom image sizes 131 add_image_size( 'large-feature', HEADER_IMAGE_WIDTH, HEADER_IMAGE_HEIGHT, true ); // Used for large feature (header) images 132 add_image_size( 'small-feature', 500, 300 ); // Used for featured posts if a large-feature doesn't exist 133 134 // Turn on random header image rotation by default. 135 add_theme_support( 'custom-header', array( 'random-default' => true ) ); 136 137 // Add a way for the custom header to be styled in the admin panel that controls 138 // custom headers. See twentyeleven_admin_header_style(), below. 139 add_custom_image_header( 'twentyeleven_header_style', 'twentyeleven_admin_header_style', 'twentyeleven_admin_header_image' ); 140 141 // ... and thus ends the changeable header business. 132 set_post_thumbnail_size( get_theme_support( 'custom-header', 'width' ), get_theme_support( 'custom-header', 'height' ), true ); 133 134 // Add Twenty Eleven's custom image sizes. 135 // Used for large feature (header) images. 136 add_image_size( 'large-feature', get_theme_support( 'custom-header', 'width' ), get_theme_support( 'custom-header', 'height' ), true ); 137 // Used for featured posts if a large-feature doesn't exist. 138 add_image_size( 'small-feature', 500, 300 ); 142 139 143 140 // Default custom headers packaged with the theme. %s is a placeholder for the theme template directory URI. … … 202 199 */ 203 200 function twentyeleven_header_style() { 204 205 // If no custom options for text are set, let's bail 206 // get_header_textcolor() options: HEADER_TEXTCOLOR is default, hide text (returns 'blank') or any hex value207 if ( HEADER_TEXTCOLOR == get_header_textcolor() )201 $text_color = get_header_textcolor(); 202 203 // If no custom options for text are set, let's bail. 204 if ( $text_color == get_theme_support( 'custom-header', 'default-text-color' ) ) 208 205 return; 209 206 // If we get this far, we have custom styles. Let's do this. … … 212 209 <?php 213 210 // Has the text been hidden? 214 if ( 'blank' == get_header_textcolor()) :211 if ( 'blank' == $text_color ) : 215 212 ?> 216 213 #site-title, … … 226 223 #site-title a, 227 224 #site-description { 228 color: #<?php echo get_header_textcolor(); ?> !important;225 color: #<?php echo $text_color; ?> !important; 229 226 } 230 227 <?php endif; ?> … … 267 264 <?php 268 265 // If the user has set a custom color for the text use that 269 if ( get_header_textcolor() != HEADER_TEXTCOLOR) :266 if ( get_header_textcolor() != get_theme_support( 'custom-header', 'default-text-color' ) ) : 270 267 ?> 271 268 #site-title a, … … 295 292 <div id="headimg"> 296 293 <?php 297 if ( 'blank' == get_theme_mod( 'header_textcolor', HEADER_TEXTCOLOR ) || '' == get_theme_mod( 'header_textcolor', HEADER_TEXTCOLOR ) ) 298 $style = ' style="display:none;"'; 294 $color = get_header_textcolor(); 295 $image = get_header_image(); 296 if ( $color && $color != 'blank' ) 297 $style = ' style="color:#' . $color . '"'; 299 298 else 300 $style = ' style=" color:#' . get_theme_mod( 'header_textcolor', HEADER_TEXTCOLOR ) . ';"';299 $style = ' style="display:none"'; 301 300 ?> 302 301 <h1><a id="name"<?php echo $style; ?> onclick="return false;" href="<?php echo esc_url( home_url( '/' ) ); ?>"><?php bloginfo( 'name' ); ?></a></h1> 303 302 <div id="desc"<?php echo $style; ?>><?php bloginfo( 'description' ); ?></div> 304 <?php $header_image = get_header_image(); 305 if ( ! empty( $header_image ) ) : ?> 306 <img src="<?php echo esc_url( $header_image ); ?>" alt="" /> 303 <?php if ( $image ) : ?> 304 <img src="<?php echo esc_url( $image ); ?>" alt="" /> 307 305 <?php endif; ?> 308 306 </div>
Note: See TracChangeset
for help on using the changeset viewer.