The Twenty Twelve for WordPress.
props drewstrojny, lancewillett.
also props corvannoorloos, jeffsebring, kobenland, iandstewart, mfields,
mtdesign, op12no2, philiparthurmoore, sixhours, mamaduka.
see #19978.
git-svn-id: http://core.svn.wordpress.org/trunk@21261 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2012-07-12 00:20:46 -04:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* Implement an optional custom header for Twenty Twelve.
|
|
|
|
* http://codex.wordpress.org/Custom_Headers
|
|
|
|
*
|
2012-07-12 19:28:33 -04:00
|
|
|
* @package WordPress
|
|
|
|
* @subpackage Twenty_Twelve
|
The Twenty Twelve for WordPress.
props drewstrojny, lancewillett.
also props corvannoorloos, jeffsebring, kobenland, iandstewart, mfields,
mtdesign, op12no2, philiparthurmoore, sixhours, mamaduka.
see #19978.
git-svn-id: http://core.svn.wordpress.org/trunk@21261 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2012-07-12 00:20:46 -04:00
|
|
|
* @since Twenty Twelve 1.0
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
2012-07-25 13:12:40 -04:00
|
|
|
* Set up the WordPress core custom header arguments and settings.
|
2012-07-25 13:30:19 -04:00
|
|
|
* Use add_theme_support() to register support for 3.4 and up.
|
The Twenty Twelve for WordPress.
props drewstrojny, lancewillett.
also props corvannoorloos, jeffsebring, kobenland, iandstewart, mfields,
mtdesign, op12no2, philiparthurmoore, sixhours, mamaduka.
see #19978.
git-svn-id: http://core.svn.wordpress.org/trunk@21261 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2012-07-12 00:20:46 -04:00
|
|
|
*
|
|
|
|
* @uses twentytwelve_header_style()
|
|
|
|
* @uses twentytwelve_admin_header_style()
|
|
|
|
* @uses twentytwelve_admin_header_image()
|
|
|
|
*
|
2012-07-25 13:30:19 -04:00
|
|
|
* @since Twenty Twelve 1.0
|
The Twenty Twelve for WordPress.
props drewstrojny, lancewillett.
also props corvannoorloos, jeffsebring, kobenland, iandstewart, mfields,
mtdesign, op12no2, philiparthurmoore, sixhours, mamaduka.
see #19978.
git-svn-id: http://core.svn.wordpress.org/trunk@21261 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2012-07-12 00:20:46 -04:00
|
|
|
*/
|
|
|
|
function twentytwelve_custom_header_setup() {
|
|
|
|
$args = array(
|
|
|
|
// Text color and image (empty to use none).
|
|
|
|
'default-text-color' => '444',
|
|
|
|
'default-image' => '',
|
|
|
|
|
|
|
|
// Set height and width, with a maximum value for the width.
|
|
|
|
'height' => 250,
|
|
|
|
'width' => 960,
|
|
|
|
'max-width' => 2000,
|
|
|
|
|
|
|
|
// Support flexible height and width.
|
|
|
|
'flex-height' => true,
|
|
|
|
'flex-width' => true,
|
|
|
|
|
|
|
|
// Random image rotation off by default.
|
|
|
|
'random-default' => false,
|
|
|
|
|
|
|
|
// Callbacks for styling the header and the admin preview.
|
|
|
|
'wp-head-callback' => 'twentytwelve_header_style',
|
|
|
|
'admin-head-callback' => 'twentytwelve_admin_header_style',
|
|
|
|
'admin-preview-callback' => 'twentytwelve_admin_header_image',
|
|
|
|
);
|
|
|
|
|
2012-07-25 13:30:19 -04:00
|
|
|
add_theme_support( 'custom-header', $args );
|
The Twenty Twelve for WordPress.
props drewstrojny, lancewillett.
also props corvannoorloos, jeffsebring, kobenland, iandstewart, mfields,
mtdesign, op12no2, philiparthurmoore, sixhours, mamaduka.
see #19978.
git-svn-id: http://core.svn.wordpress.org/trunk@21261 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2012-07-12 00:20:46 -04:00
|
|
|
}
|
|
|
|
add_action( 'after_setup_theme', 'twentytwelve_custom_header_setup' );
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Styles the header text displayed on the blog.
|
|
|
|
*
|
|
|
|
* get_header_textcolor() options: 444 is default, hide text (returns 'blank'), or any hex value.
|
|
|
|
*
|
|
|
|
* @since Twenty Twelve 1.0
|
|
|
|
*/
|
|
|
|
function twentytwelve_header_style() {
|
|
|
|
$text_color = get_header_textcolor();
|
|
|
|
|
|
|
|
// If no custom options for text are set, let's bail
|
|
|
|
if ( $text_color == get_theme_support( 'custom-header', 'default-text-color' ) )
|
|
|
|
return;
|
|
|
|
|
|
|
|
// If we get this far, we have custom styles.
|
|
|
|
?>
|
|
|
|
<style type="text/css">
|
|
|
|
<?php
|
|
|
|
// Has the text been hidden?
|
|
|
|
if ( ! display_header_text() ) :
|
|
|
|
?>
|
|
|
|
.site-title,
|
|
|
|
.site-description {
|
|
|
|
position: absolute !important;
|
|
|
|
clip: rect(1px 1px 1px 1px); /* IE6, IE7 */
|
|
|
|
clip: rect(1px, 1px, 1px, 1px);
|
|
|
|
}
|
|
|
|
<?php
|
|
|
|
// If the user has set a custom color for the text, use that.
|
|
|
|
else :
|
|
|
|
?>
|
|
|
|
.site-title a,
|
|
|
|
.site-description {
|
|
|
|
color: #<?php echo $text_color; ?> !important;
|
|
|
|
}
|
|
|
|
<?php endif; ?>
|
|
|
|
</style>
|
|
|
|
<?php
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Styles the header image displayed on the Appearance > Header admin panel.
|
|
|
|
*
|
|
|
|
* @since Twenty Twelve 1.0
|
|
|
|
*/
|
|
|
|
function twentytwelve_admin_header_style() {
|
|
|
|
?>
|
|
|
|
<style type="text/css">
|
|
|
|
.appearance_page_custom-header #headimg {
|
|
|
|
border: none;
|
|
|
|
}
|
|
|
|
#headimg h1,
|
|
|
|
#headimg h2 {
|
|
|
|
line-height: 1.6;
|
|
|
|
margin: 0;
|
|
|
|
padding: 0;
|
|
|
|
}
|
|
|
|
#headimg h1 {
|
|
|
|
font-size: 30px;
|
|
|
|
}
|
|
|
|
#headimg h1 a {
|
|
|
|
color: #515151;
|
|
|
|
text-decoration: none;
|
|
|
|
}
|
|
|
|
#headimg h1 a:hover {
|
|
|
|
color: #21759b;
|
|
|
|
}
|
|
|
|
#headimg h2 {
|
|
|
|
color: #777;
|
|
|
|
font: normal 13px/1.8 "HelveticaNeue-Light", "Helvetica Neue Light", "Helvetica Neue", sans-serif;
|
|
|
|
margin-bottom: 24px;
|
|
|
|
}
|
|
|
|
#headimg img {
|
|
|
|
max-width: <?php echo get_theme_support( 'custom-header', 'max-width' ); ?>px;
|
|
|
|
}
|
|
|
|
</style>
|
|
|
|
<?php
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Custom header image markup displayed on the Appearance > Header admin panel.
|
|
|
|
*
|
|
|
|
* @since Twenty Twelve 1.0
|
|
|
|
*/
|
|
|
|
function twentytwelve_admin_header_image() {
|
|
|
|
?>
|
|
|
|
<div id="headimg">
|
|
|
|
<?php
|
|
|
|
if ( ! display_header_text() )
|
|
|
|
$style = ' style="display:none;"';
|
|
|
|
else
|
|
|
|
$style = ' style="color:#' . get_header_textcolor() . ';"';
|
|
|
|
?>
|
|
|
|
<h1><a id="name"<?php echo $style; ?> onclick="return false;" href="<?php echo esc_url( home_url( '/' ) ); ?>"><?php bloginfo( 'name' ); ?></a></h1>
|
|
|
|
<h2 id="desc"<?php echo $style; ?>><?php bloginfo( 'description' ); ?></h2>
|
|
|
|
<?php $header_image = get_header_image();
|
|
|
|
if ( ! empty( $header_image ) ) : ?>
|
|
|
|
<img src="<?php echo esc_url( $header_image ); ?>" class="header-image" width="<?php echo get_custom_header()->width; ?>" height="<?php echo get_custom_header()->height; ?>" alt="" />
|
|
|
|
<?php endif; ?>
|
|
|
|
</div>
|
|
|
|
<?php }
|