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() {
|
2017-12-01 00:11:00 +01:00
|
|
|
add_theme_support(
|
2018-08-17 03:51:36 +02:00
|
|
|
'custom-header',
|
2020-07-01 15:52:01 +02:00
|
|
|
/**
|
2020-08-11 02:34:08 +02:00
|
|
|
* Filters Twenty Fourteen custom-header support arguments.
|
2020-07-01 15:52:01 +02:00
|
|
|
*
|
|
|
|
* @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.
|
|
|
|
* }
|
|
|
|
*/
|
2018-08-17 03:51:36 +02:00
|
|
|
apply_filters(
|
|
|
|
'twentyfourteen_custom_header_args',
|
|
|
|
array(
|
2017-12-01 00:11:00 +01:00
|
|
|
'default-text-color' => 'fff',
|
|
|
|
'width' => 1260,
|
|
|
|
'height' => 240,
|
|
|
|
'flex-height' => true,
|
|
|
|
'wp-head-callback' => 'twentyfourteen_header_style',
|
|
|
|
'admin-head-callback' => 'twentyfourteen_admin_header_style',
|
|
|
|
'admin-preview-callback' => 'twentyfourteen_admin_header_image',
|
|
|
|
)
|
|
|
|
)
|
|
|
|
);
|
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' ) ) :
|
2017-12-01 00:11:00 +01:00
|
|
|
/**
|
|
|
|
* Styles the header image and text displayed on the blog
|
|
|
|
*
|
|
|
|
* @see twentyfourteen_custom_header_setup().
|
|
|
|
*/
|
|
|
|
function twentyfourteen_header_style() {
|
|
|
|
$text_color = get_header_textcolor();
|
2013-12-03 19:27:10 +01:00
|
|
|
|
2017-12-01 00:11:00 +01:00
|
|
|
// If no custom color for text is set, let's bail.
|
2020-02-09 17:55:09 +01:00
|
|
|
if ( display_header_text() && get_theme_support( 'custom-header', 'default-text-color' ) === $text_color ) {
|
2017-12-01 00:11:00 +01:00
|
|
|
return;
|
|
|
|
}
|
2013-12-05 18:30:11 +01:00
|
|
|
|
2017-12-01 00:11:00 +01:00
|
|
|
// If we get this far, we have custom styles.
|
|
|
|
?>
|
|
|
|
<style type="text/css" id="twentyfourteen-header-css">
|
|
|
|
<?php
|
2013-12-03 19:27:10 +01:00
|
|
|
// Has the text been hidden?
|
2013-12-05 18:30:11 +01:00
|
|
|
if ( ! display_header_text() ) :
|
2018-08-17 03:51:36 +02: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
|
|
|
}
|
2018-08-17 03:51:36 +02:00
|
|
|
<?php
|
|
|
|
// If the user has set a custom color for the text, use that.
|
2020-02-09 17:55:09 +01:00
|
|
|
elseif ( get_theme_support( 'custom-header', 'default-text-color' ) != $text_color ) :
|
2018-08-17 03:51:36 +02:00
|
|
|
?>
|
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>
|
2018-08-17 03:51:36 +02:00
|
|
|
<?php
|
2017-12-01 00:11:00 +01:00
|
|
|
}
|
2020-01-29 01:45:18 +01:00
|
|
|
endif; // twentyfourteen_header_style()
|
2013-12-03 19:27:10 +01:00
|
|
|
|
|
|
|
|
2013-07-29 00:55:10 +02:00
|
|
|
if ( ! function_exists( 'twentyfourteen_admin_header_style' ) ) :
|
2017-12-01 00:11:00 +01:00
|
|
|
/**
|
|
|
|
* Style the header image displayed on the Appearance > Header screen.
|
|
|
|
*
|
|
|
|
* @see twentyfourteen_custom_header_setup()
|
|
|
|
*
|
|
|
|
* @since Twenty Fourteen 1.0
|
|
|
|
*/
|
|
|
|
function twentyfourteen_admin_header_style() {
|
2018-08-17 03:51:36 +02:00
|
|
|
?>
|
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>
|
2018-08-17 03:51:36 +02:00
|
|
|
<?php
|
2017-12-01 00:11:00 +01:00
|
|
|
}
|
2020-01-29 01:45:18 +01:00
|
|
|
endif; // twentyfourteen_admin_header_style()
|
2013-07-29 00:55:10 +02:00
|
|
|
|
|
|
|
if ( ! function_exists( 'twentyfourteen_admin_header_image' ) ) :
|
2017-12-01 00:11:00 +01:00
|
|
|
/**
|
|
|
|
* Create the custom header image markup displayed on the Appearance > Header screen.
|
|
|
|
*
|
|
|
|
* @see twentyfourteen_custom_header_setup()
|
|
|
|
*
|
|
|
|
* @since Twenty Fourteen 1.0
|
|
|
|
*/
|
|
|
|
function twentyfourteen_admin_header_image() {
|
2018-08-17 03:51:36 +02:00
|
|
|
?>
|
2013-07-29 00:55:10 +02:00
|
|
|
<div id="headimg">
|
2013-10-11 19:14:09 +02:00
|
|
|
<?php if ( get_header_image() ) : ?>
|
2021-08-04 16:24:02 +02:00
|
|
|
<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>
|
2018-08-17 03:51:36 +02:00
|
|
|
<?php
|
2017-12-01 00:11:00 +01:00
|
|
|
}
|
2020-01-29 01:45:18 +01:00
|
|
|
endif; // twentyfourteen_admin_header_image()
|