2013-07-29 00:55:10 +02:00
|
|
|
<?php
|
|
|
|
/**
|
2013-10-12 00:02:11 +02:00
|
|
|
* Implement Custom Header functionality for Twenty Fourteen
|
|
|
|
*
|
2013-07-29 00:55:10 +02:00
|
|
|
* @package WordPress
|
|
|
|
* @subpackage Twenty_Fourteen
|
2013-10-12 00:02:11 +02:00
|
|
|
* @since Twenty Fourteen 1.0
|
2013-07-29 00:55:10 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
2013-10-12 00:02:11 +02:00
|
|
|
* Set up the WordPress core custom header settings.
|
|
|
|
*
|
|
|
|
* @since Twenty Fourteen 1.0
|
2013-07-29 00:55:10 +02:00
|
|
|
*
|
|
|
|
* @uses twentyfourteen_header_style()
|
|
|
|
* @uses twentyfourteen_admin_header_style()
|
|
|
|
* @uses twentyfourteen_admin_header_image()
|
|
|
|
*/
|
|
|
|
function twentyfourteen_custom_header_setup() {
|
2013-12-03 18:06:11 +01: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-15 05:13:29 +02:00
|
|
|
add_theme_support( 'custom-header', apply_filters( 'twentyfourteen_custom_header_args', array(
|
2013-12-03 19:27:10 +01:00
|
|
|
'default-text-color' => 'fff',
|
2013-07-29 00:55:10 +02:00
|
|
|
'width' => 1260,
|
|
|
|
'height' => 240,
|
|
|
|
'flex-height' => true,
|
2016-10-27 23:51:31 +02:00
|
|
|
'video' => true,
|
2013-12-03 19:27:10 +01:00
|
|
|
'wp-head-callback' => 'twentyfourteen_header_style',
|
2013-07-29 00:55:10 +02:00
|
|
|
'admin-head-callback' => 'twentyfourteen_admin_header_style',
|
|
|
|
'admin-preview-callback' => 'twentyfourteen_admin_header_image',
|
2013-08-15 05:13:29 +02:00
|
|
|
) ) );
|
2013-07-29 00:55:10 +02:00
|
|
|
}
|
|
|
|
add_action( 'after_setup_theme', 'twentyfourteen_custom_header_setup' );
|
|
|
|
|
2013-12-03 19:27:10 +01: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 18:30:11 +01:00
|
|
|
$text_color = get_header_textcolor();
|
2013-12-03 19:27:10 +01:00
|
|
|
|
2013-12-05 18:30:11 +01: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 19:27:10 +01:00
|
|
|
return;
|
2013-12-05 18:30:11 +01:00
|
|
|
|
|
|
|
// If we get this far, we have custom styles.
|
2013-12-03 19:27:10 +01:00
|
|
|
?>
|
2013-12-05 18:30:11 +01:00
|
|
|
<style type="text/css" id="twentyfourteen-header-css">
|
2013-12-03 19:27:10 +01:00
|
|
|
<?php
|
|
|
|
// Has the text been hidden?
|
2013-12-05 18:30:11 +01:00
|
|
|
if ( ! display_header_text() ) :
|
2013-12-03 19:27:10 +01:00
|
|
|
?>
|
2013-12-05 18:30:11 +01:00
|
|
|
.site-title,
|
|
|
|
.site-description {
|
|
|
|
clip: rect(1px 1px 1px 1px); /* IE7 */
|
2013-12-03 19:27:10 +01:00
|
|
|
clip: rect(1px, 1px, 1px, 1px);
|
2013-12-05 22:03:11 +01:00
|
|
|
position: absolute;
|
2013-12-03 19:27:10 +01:00
|
|
|
}
|
|
|
|
<?php
|
2013-12-05 18:30:11 +01: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 19:27:10 +01:00
|
|
|
?>
|
|
|
|
.site-title a {
|
2013-12-05 18:30:11 +01:00
|
|
|
color: #<?php echo esc_attr( $text_color ); ?>;
|
2013-12-03 19:27:10 +01:00
|
|
|
}
|
|
|
|
<?php endif; ?>
|
|
|
|
</style>
|
|
|
|
<?php
|
|
|
|
}
|
|
|
|
endif; // twentyfourteen_header_style
|
|
|
|
|
|
|
|
|
2013-07-29 00:55:10 +02:00
|
|
|
if ( ! function_exists( 'twentyfourteen_admin_header_style' ) ) :
|
|
|
|
/**
|
2013-12-03 18:06:11 +01:00
|
|
|
* Style the header image displayed on the Appearance > Header screen.
|
2013-07-29 00:55:10 +02:00
|
|
|
*
|
2013-12-03 18:06:11 +01:00
|
|
|
* @see twentyfourteen_custom_header_setup()
|
2013-10-12 00:02:11 +02:00
|
|
|
*
|
|
|
|
* @since Twenty Fourteen 1.0
|
2013-07-29 00:55:10 +02:00
|
|
|
*/
|
|
|
|
function twentyfourteen_admin_header_style() {
|
|
|
|
?>
|
2013-12-05 18:30:11 +01:00
|
|
|
<style type="text/css" id="twentyfourteen-admin-header-css">
|
2013-07-29 00:55:10 +02:00
|
|
|
.appearance_page_custom-header #headimg {
|
|
|
|
background-color: #000;
|
|
|
|
border: none;
|
2013-12-03 19:27:10 +01:00
|
|
|
max-width: 1260px;
|
2013-07-29 00:55:10 +02:00
|
|
|
min-height: 48px;
|
|
|
|
}
|
|
|
|
#headimg h1 {
|
2013-12-03 19:27:10 +01:00
|
|
|
font-family: Lato, sans-serif;
|
2013-07-29 00:55:10 +02:00
|
|
|
font-size: 18px;
|
2013-12-03 19:27:10 +01:00
|
|
|
line-height: 48px;
|
|
|
|
margin: 0 0 0 30px;
|
2013-07-29 00:55:10 +02:00
|
|
|
}
|
2014-07-14 19:41:15 +02:00
|
|
|
.rtl #headimg h1 {
|
|
|
|
margin: 0 30px 0 0;
|
|
|
|
}
|
2013-07-29 00:55:10 +02: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 18:06:11 +01:00
|
|
|
* Create the custom header image markup displayed on the Appearance > Header screen.
|
2013-10-12 00:02:11 +02:00
|
|
|
*
|
2013-12-03 18:06:11 +01:00
|
|
|
* @see twentyfourteen_custom_header_setup()
|
2013-07-29 00:55:10 +02:00
|
|
|
*
|
2013-10-12 00:02:11 +02:00
|
|
|
* @since Twenty Fourteen 1.0
|
2013-07-29 00:55:10 +02:00
|
|
|
*/
|
2013-08-15 05:13:29 +02:00
|
|
|
function twentyfourteen_admin_header_image() {
|
|
|
|
?>
|
2013-07-29 00:55:10 +02:00
|
|
|
<div id="headimg">
|
2013-10-11 19:14:09 +02:00
|
|
|
<?php if ( get_header_image() ) : ?>
|
|
|
|
<img src="<?php header_image(); ?>" alt="">
|
2013-07-29 00:55:10 +02:00
|
|
|
<?php endif; ?>
|
2015-01-20 20:03:23 +01:00
|
|
|
<h1 class="displaying-header-text"><a id="name" style="<?php echo esc_attr( sprintf( 'color: #%s;', get_header_textcolor() ) ); ?>" onclick="return false;" href="<?php echo esc_url( home_url( '/' ) ); ?>" tabindex="-1"><?php bloginfo( 'name' ); ?></a></h1>
|
2013-07-29 00:55:10 +02:00
|
|
|
</div>
|
2013-08-15 05:13:29 +02:00
|
|
|
<?php
|
|
|
|
}
|
|
|
|
endif; // twentyfourteen_admin_header_image
|