2013-07-28 18:55:10 -04:00
|
|
|
<?php
|
|
|
|
/**
|
2013-10-11 18:02:11 -04:00
|
|
|
* Implement Custom Header functionality for Twenty Fourteen
|
|
|
|
*
|
2013-07-28 18:55:10 -04:00
|
|
|
* @package WordPress
|
|
|
|
* @subpackage Twenty_Fourteen
|
2013-10-11 18:02:11 -04:00
|
|
|
* @since Twenty Fourteen 1.0
|
2013-07-28 18:55:10 -04:00
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
2013-10-11 18:02:11 -04:00
|
|
|
* Set up the WordPress core custom header settings.
|
|
|
|
*
|
|
|
|
* @since Twenty Fourteen 1.0
|
2013-07-28 18:55:10 -04:00
|
|
|
*
|
|
|
|
* @uses twentyfourteen_header_style()
|
|
|
|
* @uses twentyfourteen_admin_header_style()
|
|
|
|
* @uses twentyfourteen_admin_header_image()
|
|
|
|
*/
|
|
|
|
function twentyfourteen_custom_header_setup() {
|
2013-12-03 12:06:11 -05:00
|
|
|
/**
|
|
|
|
* Filter Twenty Fourteen custom-header support arguments.
|
|
|
|
*
|
|
|
|
* @since Twenty Fourteen 1.0
|
|
|
|
*
|
|
|
|
* @param array $args {
|
|
|
|
* An array of custom-header support arguments.
|
|
|
|
*
|
|
|
|
* @type bool $header_text Whether to display custom header text. Default false.
|
|
|
|
* @type int $width Width in pixels of the custom header image. Default 1260.
|
|
|
|
* @type int $height Height in pixels of the custom header image. Default 240.
|
|
|
|
* @type bool $flex_height Whether to allow flexible-height header images. Default true.
|
|
|
|
* @type string $admin_head_callback Callback function used to style the image displayed in
|
|
|
|
* the Appearance > Header screen.
|
|
|
|
* @type string $admin_preview_callback Callback function used to create the custom header markup in
|
|
|
|
* the Appearance > Header screen.
|
|
|
|
* }
|
|
|
|
*/
|
2013-08-14 23:13:29 -04:00
|
|
|
add_theme_support( 'custom-header', apply_filters( 'twentyfourteen_custom_header_args', array(
|
2013-12-03 13:27:10 -05:00
|
|
|
'default-text-color' => 'fff',
|
2013-07-28 18:55:10 -04:00
|
|
|
'width' => 1260,
|
|
|
|
'height' => 240,
|
|
|
|
'flex-height' => true,
|
2013-12-03 13:27:10 -05:00
|
|
|
'wp-head-callback' => 'twentyfourteen_header_style',
|
2013-07-28 18:55:10 -04:00
|
|
|
'admin-head-callback' => 'twentyfourteen_admin_header_style',
|
|
|
|
'admin-preview-callback' => 'twentyfourteen_admin_header_image',
|
2013-08-14 23:13:29 -04:00
|
|
|
) ) );
|
2013-07-28 18:55:10 -04:00
|
|
|
}
|
|
|
|
add_action( 'after_setup_theme', 'twentyfourteen_custom_header_setup' );
|
|
|
|
|
2013-12-03 13:27:10 -05:00
|
|
|
if ( ! function_exists( 'twentyfourteen_header_style' ) ) :
|
|
|
|
/**
|
|
|
|
* Styles the header image and text displayed on the blog
|
|
|
|
*
|
|
|
|
* @see twentyfourteen_custom_header_setup().
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
function twentyfourteen_header_style() {
|
2013-12-05 12:30:11 -05:00
|
|
|
$text_color = get_header_textcolor();
|
2013-12-03 13:27:10 -05:00
|
|
|
|
2013-12-05 12:30:11 -05:00
|
|
|
// If no custom color for text is set, let's bail.
|
|
|
|
if ( display_header_text() && $text_color === get_theme_support( 'custom-header', 'default-text-color' ) )
|
2013-12-03 13:27:10 -05:00
|
|
|
return;
|
2013-12-05 12:30:11 -05:00
|
|
|
|
|
|
|
// If we get this far, we have custom styles.
|
2013-12-03 13:27:10 -05:00
|
|
|
?>
|
2013-12-05 12:30:11 -05:00
|
|
|
<style type="text/css" id="twentyfourteen-header-css">
|
2013-12-03 13:27:10 -05:00
|
|
|
<?php
|
|
|
|
// Has the text been hidden?
|
2013-12-05 12:30:11 -05:00
|
|
|
if ( ! display_header_text() ) :
|
2013-12-03 13:27:10 -05:00
|
|
|
?>
|
2013-12-05 12:30:11 -05:00
|
|
|
.site-title,
|
|
|
|
.site-description {
|
|
|
|
clip: rect(1px 1px 1px 1px); /* IE7 */
|
2013-12-03 13:27:10 -05:00
|
|
|
clip: rect(1px, 1px, 1px, 1px);
|
2013-12-05 16:03:11 -05:00
|
|
|
position: absolute;
|
2013-12-03 13:27:10 -05:00
|
|
|
}
|
|
|
|
<?php
|
2013-12-05 12:30:11 -05:00
|
|
|
// If the user has set a custom color for the text, use that.
|
|
|
|
elseif ( $text_color != get_theme_support( 'custom-header', 'default-text-color' ) ) :
|
2013-12-03 13:27:10 -05:00
|
|
|
?>
|
|
|
|
.site-title a {
|
2013-12-05 12:30:11 -05:00
|
|
|
color: #<?php echo esc_attr( $text_color ); ?>;
|
2013-12-03 13:27:10 -05:00
|
|
|
}
|
|
|
|
<?php endif; ?>
|
|
|
|
</style>
|
|
|
|
<?php
|
|
|
|
}
|
|
|
|
endif; // twentyfourteen_header_style
|
|
|
|
|
|
|
|
|
2013-07-28 18:55:10 -04:00
|
|
|
if ( ! function_exists( 'twentyfourteen_admin_header_style' ) ) :
|
|
|
|
/**
|
2013-12-03 12:06:11 -05:00
|
|
|
* Style the header image displayed on the Appearance > Header screen.
|
2013-07-28 18:55:10 -04:00
|
|
|
*
|
2013-12-03 12:06:11 -05:00
|
|
|
* @see twentyfourteen_custom_header_setup()
|
2013-10-11 18:02:11 -04:00
|
|
|
*
|
|
|
|
* @since Twenty Fourteen 1.0
|
2013-07-28 18:55:10 -04:00
|
|
|
*/
|
|
|
|
function twentyfourteen_admin_header_style() {
|
|
|
|
?>
|
2013-12-05 12:30:11 -05:00
|
|
|
<style type="text/css" id="twentyfourteen-admin-header-css">
|
2013-07-28 18:55:10 -04:00
|
|
|
.appearance_page_custom-header #headimg {
|
|
|
|
background-color: #000;
|
|
|
|
border: none;
|
2013-12-03 13:27:10 -05:00
|
|
|
max-width: 1260px;
|
2013-07-28 18:55:10 -04:00
|
|
|
min-height: 48px;
|
|
|
|
}
|
|
|
|
#headimg h1 {
|
2013-12-03 13:27:10 -05:00
|
|
|
font-family: Lato, sans-serif;
|
2013-07-28 18:55:10 -04:00
|
|
|
font-size: 18px;
|
2013-12-03 13:27:10 -05:00
|
|
|
line-height: 48px;
|
|
|
|
margin: 0 0 0 30px;
|
2013-07-28 18:55:10 -04:00
|
|
|
}
|
2014-07-14 13:41:15 -04:00
|
|
|
.rtl #headimg h1 {
|
|
|
|
margin: 0 30px 0 0;
|
|
|
|
}
|
2013-07-28 18:55:10 -04:00
|
|
|
#headimg h1 a {
|
|
|
|
color: #fff;
|
|
|
|
text-decoration: none;
|
|
|
|
}
|
|
|
|
#headimg img {
|
|
|
|
vertical-align: middle;
|
|
|
|
}
|
|
|
|
</style>
|
|
|
|
<?php
|
|
|
|
}
|
|
|
|
endif; // twentyfourteen_admin_header_style
|
|
|
|
|
|
|
|
if ( ! function_exists( 'twentyfourteen_admin_header_image' ) ) :
|
|
|
|
/**
|
2013-12-03 12:06:11 -05:00
|
|
|
* Create the custom header image markup displayed on the Appearance > Header screen.
|
2013-10-11 18:02:11 -04:00
|
|
|
*
|
2013-12-03 12:06:11 -05:00
|
|
|
* @see twentyfourteen_custom_header_setup()
|
2013-07-28 18:55:10 -04:00
|
|
|
*
|
2013-10-11 18:02:11 -04:00
|
|
|
* @since Twenty Fourteen 1.0
|
2013-07-28 18:55:10 -04:00
|
|
|
*/
|
2013-08-14 23:13:29 -04:00
|
|
|
function twentyfourteen_admin_header_image() {
|
|
|
|
?>
|
2013-07-28 18:55:10 -04:00
|
|
|
<div id="headimg">
|
2013-10-11 13:14:09 -04:00
|
|
|
<?php if ( get_header_image() ) : ?>
|
|
|
|
<img src="<?php header_image(); ?>" alt="">
|
2013-07-28 18:55:10 -04:00
|
|
|
<?php endif; ?>
|
2014-10-31 23:44:23 -04:00
|
|
|
<h1 class="displaying-header-text"><a id="name"<?php echo sprintf( ' style="color:#%s;"', get_header_textcolor() ); ?> onclick="return false;" href="<?php echo esc_url( home_url( '/' ) ); ?>" tabindex="-1"><?php bloginfo( 'name' ); ?></a></h1>
|
2013-07-28 18:55:10 -04:00
|
|
|
</div>
|
2013-08-14 23:13:29 -04:00
|
|
|
<?php
|
|
|
|
}
|
|
|
|
endif; // twentyfourteen_admin_header_image
|