mirror of
https://github.com/WordPress/WordPress.git
synced 2024-09-28 15:17:42 +02:00
Move Twenty Ten and the rest of Twenty Eleven to add_theme_support() for headers and backgrounds. props sabreuse for initial patch. fixes #20265. see #20249.
git-svn-id: http://svn.automattic.com/wordpress/trunk@20225 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
0d68c107ad
commit
1a265e464c
@ -62,10 +62,9 @@ if ( ! function_exists( 'twentyeleven_setup' ) ):
|
|||||||
*
|
*
|
||||||
* @uses load_theme_textdomain() For translation/localization support.
|
* @uses load_theme_textdomain() For translation/localization support.
|
||||||
* @uses add_editor_style() To style the visual editor.
|
* @uses add_editor_style() To style the visual editor.
|
||||||
* @uses add_theme_support() To add support for post thumbnails, automatic feed links, and Post Formats.
|
* @uses add_theme_support() To add support for post thumbnails, automatic feed links, custom headers
|
||||||
|
* and backgrounds, and post formats.
|
||||||
* @uses register_nav_menus() To add support for navigation menus.
|
* @uses register_nav_menus() To add support for navigation menus.
|
||||||
* @uses add_custom_background() To add support for a custom background.
|
|
||||||
* @uses add_custom_image_header() To add support for a custom header.
|
|
||||||
* @uses register_default_headers() To register the default custom header images provided with the theme.
|
* @uses register_default_headers() To register the default custom header images provided with the theme.
|
||||||
* @uses set_post_thumbnail_size() To set a custom post thumbnail size.
|
* @uses set_post_thumbnail_size() To set a custom post thumbnail size.
|
||||||
*
|
*
|
||||||
@ -234,7 +233,7 @@ if ( ! function_exists( 'twentyeleven_admin_header_style' ) ) :
|
|||||||
/**
|
/**
|
||||||
* Styles the header image displayed on the Appearance > Header admin panel.
|
* Styles the header image displayed on the Appearance > Header admin panel.
|
||||||
*
|
*
|
||||||
* Referenced via add_custom_image_header() in twentyeleven_setup().
|
* Referenced via add_theme_support('custom-header') in twentyeleven_setup().
|
||||||
*
|
*
|
||||||
* @since Twenty Eleven 1.0
|
* @since Twenty Eleven 1.0
|
||||||
*/
|
*/
|
||||||
@ -284,7 +283,7 @@ if ( ! function_exists( 'twentyeleven_admin_header_image' ) ) :
|
|||||||
/**
|
/**
|
||||||
* Custom header image markup displayed on the Appearance > Header admin panel.
|
* Custom header image markup displayed on the Appearance > Header admin panel.
|
||||||
*
|
*
|
||||||
* Referenced via add_custom_image_header() in twentyeleven_setup().
|
* Referenced via add_theme_support('custom-header') in twentyeleven_setup().
|
||||||
*
|
*
|
||||||
* @since Twenty Eleven 1.0
|
* @since Twenty Eleven 1.0
|
||||||
*/
|
*/
|
||||||
|
@ -66,6 +66,8 @@ get_header(); ?>
|
|||||||
*/
|
*/
|
||||||
$counter_slider = 0;
|
$counter_slider = 0;
|
||||||
|
|
||||||
|
$header_image_width = get_theme_support( 'custom-header', 'width' );
|
||||||
|
$header_image_height = get_theme_support( 'custom-header', 'height' );
|
||||||
?>
|
?>
|
||||||
|
|
||||||
<div class="featured-posts">
|
<div class="featured-posts">
|
||||||
@ -89,10 +91,10 @@ get_header(); ?>
|
|||||||
$feature_class = 'feature-image small';
|
$feature_class = 'feature-image small';
|
||||||
|
|
||||||
// Hang on. Let's check this here image out.
|
// Hang on. Let's check this here image out.
|
||||||
$image = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), array( HEADER_IMAGE_WIDTH, HEADER_IMAGE_WIDTH ) );
|
$image = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), array( $header_image_width, $header_image_width ) );
|
||||||
|
|
||||||
// Is it bigger than or equal to our header?
|
// Is it bigger than or equal to our header?
|
||||||
if ( $image[1] >= HEADER_IMAGE_WIDTH ) {
|
if ( $image[1] >= $header_image_width ) {
|
||||||
// If bigger, let's add a BIGGER class. It's EXTRA classy now.
|
// If bigger, let's add a BIGGER class. It's EXTRA classy now.
|
||||||
$feature_class = 'feature-image large';
|
$feature_class = 'feature-image large';
|
||||||
}
|
}
|
||||||
@ -107,7 +109,7 @@ get_header(); ?>
|
|||||||
* make it a large featured post, otherwise render it small
|
* make it a large featured post, otherwise render it small
|
||||||
*/
|
*/
|
||||||
if ( has_post_thumbnail() ) {
|
if ( has_post_thumbnail() ) {
|
||||||
if ( $image[1] >= HEADER_IMAGE_WIDTH )
|
if ( $image[1] >= $header_image_width )
|
||||||
$thumbnail_size = 'large-feature';
|
$thumbnail_size = 'large-feature';
|
||||||
else
|
else
|
||||||
$thumbnail_size = 'small-feature';
|
$thumbnail_size = 'small-feature';
|
||||||
|
@ -61,12 +61,10 @@ if ( ! function_exists( 'twentyten_setup' ) ):
|
|||||||
* To override twentyten_setup() in a child theme, add your own twentyten_setup to your child theme's
|
* To override twentyten_setup() in a child theme, add your own twentyten_setup to your child theme's
|
||||||
* functions.php file.
|
* functions.php file.
|
||||||
*
|
*
|
||||||
* @uses add_theme_support() To add support for post thumbnails and automatic feed links.
|
* @uses add_theme_support() To add support for post thumbnails, custom headers and backgrounds, and automatic feed links.
|
||||||
* @uses register_nav_menus() To add support for navigation menus.
|
* @uses register_nav_menus() To add support for navigation menus.
|
||||||
* @uses add_custom_background() To add support for a custom background.
|
|
||||||
* @uses add_editor_style() To style the visual editor.
|
* @uses add_editor_style() To style the visual editor.
|
||||||
* @uses load_theme_textdomain() For translation/localization support.
|
* @uses load_theme_textdomain() For translation/localization support.
|
||||||
* @uses add_custom_image_header() To add support for a custom header.
|
|
||||||
* @uses register_default_headers() To register the default custom header images provided with the theme.
|
* @uses register_default_headers() To register the default custom header images provided with the theme.
|
||||||
* @uses set_post_thumbnail_size() To set a custom post thumbnail size.
|
* @uses set_post_thumbnail_size() To set a custom post thumbnail size.
|
||||||
*
|
*
|
||||||
@ -100,36 +98,30 @@ function twentyten_setup() {
|
|||||||
'primary' => __( 'Primary Navigation', 'twentyten' ),
|
'primary' => __( 'Primary Navigation', 'twentyten' ),
|
||||||
) );
|
) );
|
||||||
|
|
||||||
// This theme allows users to set a custom background
|
// This theme allows users to set a custom background.
|
||||||
add_custom_background();
|
add_theme_support( 'custom-background' );
|
||||||
|
|
||||||
// Your changeable header business starts here
|
// The custom header business starts here.
|
||||||
if ( ! defined( 'HEADER_TEXTCOLOR' ) )
|
|
||||||
define( 'HEADER_TEXTCOLOR', '' );
|
|
||||||
|
|
||||||
// No CSS, just IMG call. The %s is a placeholder for the theme template directory URI.
|
add_theme_support( 'custom-header', array(
|
||||||
if ( ! defined( 'HEADER_IMAGE' ) )
|
// The default image to use.
|
||||||
define( 'HEADER_IMAGE', '%s/images/headers/path.jpg' );
|
// The %s is a placeholder for the theme template directory URI.
|
||||||
|
'default-image' => '%s/images/headers/path.jpg',
|
||||||
// The height and width of your custom header. You can hook into the theme's own filters to change these values.
|
// The height and width of our custom header.
|
||||||
// Add a filter to twentyten_header_image_width and twentyten_header_image_height to change these values.
|
'width' => apply_filters( 'twentyten_header_image_width', 940 ),
|
||||||
define( 'HEADER_IMAGE_WIDTH', apply_filters( 'twentyten_header_image_width', 940 ) );
|
'height' => apply_filters( 'twentyten_header_image_height', 198 ),
|
||||||
define( 'HEADER_IMAGE_HEIGHT', apply_filters( 'twentyten_header_image_height', 198 ) );
|
// Don't support text inside the header image.
|
||||||
|
'header-text' => false,
|
||||||
|
// Callback for styling the header preview in the admin.
|
||||||
|
'admin-header-callback' => 'twentyten_admin_header_style',
|
||||||
|
) );
|
||||||
|
|
||||||
// We'll be using post thumbnails for custom header images on posts and pages.
|
// We'll be using post thumbnails for custom header images on posts and pages.
|
||||||
// We want them to be 940 pixels wide by 198 pixels tall.
|
// We want them to be 940 pixels wide by 198 pixels tall.
|
||||||
// Larger images will be auto-cropped to fit, smaller ones will be ignored. See header.php.
|
// Larger images will be auto-cropped to fit, smaller ones will be ignored. See header.php.
|
||||||
set_post_thumbnail_size( HEADER_IMAGE_WIDTH, HEADER_IMAGE_HEIGHT, true );
|
set_post_thumbnail_size( get_theme_support( 'custom-header', 'width' ), get_theme_support( 'custom-header', 'height' ), true );
|
||||||
|
|
||||||
// Don't support text inside the header image.
|
// ... and thus ends the custom header business.
|
||||||
if ( ! defined( 'NO_HEADER_TEXT' ) )
|
|
||||||
define( 'NO_HEADER_TEXT', true );
|
|
||||||
|
|
||||||
// Add a way for the custom header to be styled in the admin panel that controls
|
|
||||||
// custom headers. See twentyten_admin_header_style(), below.
|
|
||||||
add_custom_image_header( '', 'twentyten_admin_header_style' );
|
|
||||||
|
|
||||||
// ... and thus ends the changeable header business.
|
|
||||||
|
|
||||||
// Default custom headers packaged with the theme. %s is a placeholder for the theme template directory URI.
|
// Default custom headers packaged with the theme. %s is a placeholder for the theme template directory URI.
|
||||||
register_default_headers( array(
|
register_default_headers( array(
|
||||||
@ -201,7 +193,7 @@ function twentyten_admin_header_style() {
|
|||||||
border-bottom: 1px solid #000;
|
border-bottom: 1px solid #000;
|
||||||
border-top: 4px solid #000;
|
border-top: 4px solid #000;
|
||||||
}
|
}
|
||||||
/* If NO_HEADER_TEXT is false, you would style the text with these selectors:
|
/* If header-text was supported, you would style the text with these selectors:
|
||||||
#headimg #name { }
|
#headimg #name { }
|
||||||
#headimg #desc { }
|
#headimg #desc { }
|
||||||
*/
|
*/
|
||||||
|
@ -70,11 +70,11 @@
|
|||||||
if ( is_singular() && current_theme_supports( 'post-thumbnails' ) &&
|
if ( is_singular() && current_theme_supports( 'post-thumbnails' ) &&
|
||||||
has_post_thumbnail( $post->ID ) &&
|
has_post_thumbnail( $post->ID ) &&
|
||||||
( /* $src, $width, $height */ $image = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'post-thumbnail' ) ) &&
|
( /* $src, $width, $height */ $image = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'post-thumbnail' ) ) &&
|
||||||
$image[1] >= HEADER_IMAGE_WIDTH ) :
|
$image[1] >= get_theme_support( 'custom-header', 'width' ) ) :
|
||||||
// Houston, we have a new header image!
|
// Houston, we have a new header image!
|
||||||
echo get_the_post_thumbnail( $post->ID );
|
echo get_the_post_thumbnail( $post->ID );
|
||||||
elseif ( get_header_image() ) : ?>
|
elseif ( get_header_image() ) : ?>
|
||||||
<img src="<?php header_image(); ?>" width="<?php echo HEADER_IMAGE_WIDTH; ?>" height="<?php echo HEADER_IMAGE_HEIGHT; ?>" alt="" />
|
<img src="<?php header_image(); ?>" width="<?php echo get_theme_support( 'custom-header', 'width' ); ?>" height="<?php echo get_theme_support( 'custom-header', 'height' ); ?>" alt="" />
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
</div><!-- #branding -->
|
</div><!-- #branding -->
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user