Ticket #20265: 20265.2.diff
File 20265.2.diff, 8.6 KB (added by , 12 years ago) |
---|
-
wp-content/themes/twentyten/functions.php
101 101 ) ); 102 102 103 103 // This theme allows users to set a custom background 104 add_ custom_background();104 add_theme_support('custom-background', array('callback' => '')); 105 105 106 106 // Your changeable header business starts here 107 if ( ! defined( 'HEADER_TEXTCOLOR' ) ) 108 define( 'HEADER_TEXTCOLOR', '' ); 107 $header_args = array( 108 'random-default' => false, 109 'height' => 198, 110 'width' => 940, 111 'header-text' => false, 112 'default-image' => '%s/images/headers/path.jpg', 113 'callback' => '', 114 'admin-header-callback' => 'twentyten_admin_header_style', 115 ); 116 add_theme_support( 'custom-header', $header_args ); 109 117 110 // No CSS, just IMG call. The %s is a placeholder for the theme template directory URI.111 if ( ! defined( 'HEADER_IMAGE' ) )112 define( 'HEADER_IMAGE', '%s/images/headers/path.jpg' );113 118 114 // The height and width of your custom header. You can hook into the theme's own filters to change these values.115 // Add a filter to twentyten_header_image_width and twentyten_header_image_height to change these values.116 define( 'HEADER_IMAGE_WIDTH', apply_filters( 'twentyten_header_image_width', 940 ) );117 define( 'HEADER_IMAGE_HEIGHT', apply_filters( 'twentyten_header_image_height', 198 ) );118 119 119 // We'll be using post thumbnails for custom header images on posts and pages. 120 120 // We want them to be 940 pixels wide by 198 pixels tall. 121 121 // Larger images will be auto-cropped to fit, smaller ones will be ignored. See header.php. 122 set_post_thumbnail_size( HEADER_IMAGE_WIDTH, HEADER_IMAGE_HEIGHT, true );122 set_post_thumbnail_size( get_theme_support( 'custom-header', 'width' ), get_theme_support( 'custom-header', 'height' ), true ); 123 123 124 // Don't support text inside the header image.125 if ( ! defined( 'NO_HEADER_TEXT' ) )126 define( 'NO_HEADER_TEXT', true );127 124 128 // Add a way for the custom header to be styled in the admin panel that controls129 // custom headers. See twentyten_admin_header_style(), below.130 add_custom_image_header( '', 'twentyten_admin_header_style' );131 132 125 // ... and thus ends the changeable header business. 133 126 134 127 // Default custom headers packaged with the theme. %s is a placeholder for the theme template directory URI. -
wp-content/themes/twentyeleven/functions.php
62 62 * 63 63 * @uses load_theme_textdomain() For translation/localization support. 64 64 * @uses add_editor_style() To style the visual editor. 65 * @uses add_theme_support() To add support for post thumbnails, automatic feed links, and Post Formats.65 * @uses add_theme_support() To add support for post thumbnails, automatic feed links, custom backgrounds, and custom image headers, and Post Formats. 66 66 * @uses register_nav_menus() To add support for navigation menus. 67 * @uses add_custom_background() To add support for a custom background.68 * @uses add_custom_image_header() To add support for a custom header.69 67 * @uses register_default_headers() To register the default custom header images provided with the theme. 70 68 * @uses set_post_thumbnail_size() To set a custom post thumbnail size. 71 69 * … … 104 102 add_theme_support( 'post-formats', array( 'aside', 'link', 'gallery', 'status', 'quote', 'image' ) ); 105 103 106 104 // Add support for custom backgrounds 107 add_ custom_background();105 add_theme_support('custom-background', array('callback' => '')); 108 106 109 107 // This theme uses Featured Images (also known as post thumbnails) for per-post/per-page Custom Header images 110 108 add_theme_support( 'post-thumbnails' ); 111 109 112 // The next four constants set how Twenty Eleven supports custom headers.113 114 // The default header text color115 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 ) );124 125 110 // We'll be using post thumbnails for custom header images on posts and pages. 126 111 // We want them to be the size of the header image that we just defined 127 112 // 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 );113 set_post_thumbnail_size( get_theme_support( 'custom-header', 'width' ), get_theme_support( 'custom-header', 'height' ), true ); 129 114 130 115 // 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 116 add_image_size( 117 'large-feature', 118 get_theme_support( 'custom-header', 'width' ), 119 get_theme_support( 'custom-header', 'height' ), 120 true 121 ); // Used for large feature (header) images 122 132 123 add_image_size( 'small-feature', 500, 300 ); // Used for featured posts if a large-feature doesn't exist 133 124 125 // Add support for custom headers 134 126 // Turn on random header image rotation by default. 135 add_theme_support( 'custom-header', array( 'random-default' => true ) ); 127 add_theme_support( 'custom-header', array( 128 'default-image' => '', 129 'random-default' => true, 130 'width' => 1000, 131 'height' => 288, 132 'default-text-color' => '000', 133 'callback' => 'twentyeleven_header_style', 134 'admin-header-callback' => 'twentyeleven_admin_header_style', 135 'admin-image-div-callback' => 'twentyeleven_admin_header_image', 136 ) ); 136 137 137 // Add a way for the custom header to be styled in the admin panel that controls138 // 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 138 // ... and thus ends the changeable header business. 142 139 143 140 // Default custom headers packaged with the theme. %s is a placeholder for the theme template directory URI. … … 203 200 function twentyeleven_header_style() { 204 201 205 202 // If no custom options for text are set, let's bail 206 // get_header_textcolor() options: HEADER_TEXTCOLORis default, hide text (returns 'blank') or any hex value207 if ( HEADER_TEXTCOLOR== get_header_textcolor() )203 // get_header_textcolor() options: get_theme_support( 'custom-header', 'default-text-color' ) is default, hide text (returns 'blank') or any hex value 204 if ( get_theme_support( 'custom-header', 'default-text-color' ) == get_header_textcolor() ) 208 205 return; 209 206 // If we get this far, we have custom styles. Let's do this. 210 207 ?> … … 237 234 /** 238 235 * Styles the header image displayed on the Appearance > Header admin panel. 239 236 * 240 * Referenced via add_ custom_image_header() in twentyeleven_setup().237 * Referenced via add_theme_support() in twentyeleven_setup(). 241 238 * 242 239 * @since Twenty Eleven 1.0 243 240 */ … … 266 263 } 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, 272 269 #site-description { … … 287 284 /** 288 285 * Custom header image markup displayed on the Appearance > Header admin panel. 289 286 * 290 * Referenced via add_ custom_image_header() in twentyeleven_setup().287 * Referenced via add_theme_support() in twentyeleven_setup(). 291 288 * 292 289 * @since Twenty Eleven 1.0 293 290 */ 294 291 function twentyeleven_admin_header_image() { ?> 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) )294 if ( 'blank' == get_theme_mod( 'header_textcolor', get_theme_support( 'custom-header', 'default-text-color' ) ) || '' == get_theme_mod( 'header_textcolor', get_theme_support( 'custom-header', 'default-text-color' ) ) ) 298 295 $style = ' style="display:none;"'; 299 296 else 300 $style = ' style="color:#' . get_theme_mod( 'header_textcolor', HEADER_TEXTCOLOR) . ';"';297 $style = ' style="color:#' . get_theme_mod( 'header_textcolor', get_theme_support( 'custom-header', 'default-text-color' ) ) . ';"'; 301 298 ?> 302 299 <h1><a id="name"<?php echo $style; ?> onclick="return false;" href="<?php echo esc_url( home_url( '/' ) ); ?>"><?php bloginfo( 'name' ); ?></a></h1> 303 300 <div id="desc"<?php echo $style; ?>><?php bloginfo( 'description' ); ?></div>