2013-02-19 00:08:56 +01:00
|
|
|
<?php
|
|
|
|
/**
|
2013-09-20 21:34:10 +02:00
|
|
|
* Implement a custom header for Twenty Thirteen
|
|
|
|
*
|
2015-04-12 23:29:32 +02:00
|
|
|
* @link https://codex.wordpress.org/Custom_Headers
|
2013-02-19 00:08:56 +01:00
|
|
|
*
|
|
|
|
* @package WordPress
|
|
|
|
* @subpackage Twenty_Thirteen
|
|
|
|
* @since Twenty Thirteen 1.0
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
2013-09-20 21:34:10 +02:00
|
|
|
* Set up the WordPress core custom header arguments and settings.
|
2013-02-19 00:08:56 +01:00
|
|
|
*
|
|
|
|
* @uses add_theme_support() to register support for 3.4 and up.
|
2016-02-25 13:53:27 +01:00
|
|
|
* @uses twentythirteen_header_style() to style front end.
|
2013-02-19 00:08:56 +01:00
|
|
|
* @uses twentythirteen_admin_header_style() to style wp-admin form.
|
|
|
|
* @uses twentythirteen_admin_header_image() to add custom markup to wp-admin form.
|
|
|
|
* @uses register_default_headers() to set up the bundled header images.
|
|
|
|
*
|
|
|
|
* @since Twenty Thirteen 1.0
|
|
|
|
*/
|
|
|
|
function twentythirteen_custom_header_setup() {
|
|
|
|
$args = array(
|
|
|
|
// Text color and image (empty to use none).
|
|
|
|
'default-text-color' => '220e10',
|
|
|
|
'default-image' => '%s/images/headers/circle.png',
|
|
|
|
|
|
|
|
// Set height and width, with a maximum value for the width.
|
|
|
|
'height' => 230,
|
|
|
|
'width' => 1600,
|
|
|
|
|
|
|
|
// Callbacks for styling the header and the admin preview.
|
|
|
|
'wp-head-callback' => 'twentythirteen_header_style',
|
|
|
|
'admin-head-callback' => 'twentythirteen_admin_header_style',
|
|
|
|
'admin-preview-callback' => 'twentythirteen_admin_header_image',
|
|
|
|
);
|
|
|
|
|
|
|
|
add_theme_support( 'custom-header', $args );
|
|
|
|
|
2013-10-09 22:39:09 +02:00
|
|
|
/*
|
2013-02-19 00:08:56 +01:00
|
|
|
* Default custom headers packaged with the theme.
|
|
|
|
* %s is a placeholder for the theme template directory URI.
|
|
|
|
*/
|
2017-12-01 00:11:00 +01:00
|
|
|
register_default_headers(
|
|
|
|
array(
|
|
|
|
'circle' => array(
|
|
|
|
'url' => '%s/images/headers/circle.png',
|
|
|
|
'thumbnail_url' => '%s/images/headers/circle-thumbnail.png',
|
|
|
|
'description' => _x( 'Circle', 'header image description', 'twentythirteen' ),
|
|
|
|
),
|
|
|
|
'diamond' => array(
|
|
|
|
'url' => '%s/images/headers/diamond.png',
|
|
|
|
'thumbnail_url' => '%s/images/headers/diamond-thumbnail.png',
|
|
|
|
'description' => _x( 'Diamond', 'header image description', 'twentythirteen' ),
|
|
|
|
),
|
|
|
|
'star' => array(
|
|
|
|
'url' => '%s/images/headers/star.png',
|
|
|
|
'thumbnail_url' => '%s/images/headers/star-thumbnail.png',
|
|
|
|
'description' => _x( 'Star', 'header image description', 'twentythirteen' ),
|
|
|
|
),
|
|
|
|
)
|
|
|
|
);
|
2013-02-19 00:08:56 +01:00
|
|
|
}
|
2013-08-26 21:29:09 +02:00
|
|
|
add_action( 'after_setup_theme', 'twentythirteen_custom_header_setup', 11 );
|
2013-02-19 00:08:56 +01:00
|
|
|
|
2013-07-18 20:11:43 +02:00
|
|
|
/**
|
2013-09-20 21:34:10 +02:00
|
|
|
* Load our special font CSS files.
|
2013-07-18 20:11:43 +02:00
|
|
|
*
|
|
|
|
* @since Twenty Thirteen 1.0
|
|
|
|
*/
|
|
|
|
function twentythirteen_custom_header_fonts() {
|
2013-10-15 18:47:09 +02:00
|
|
|
// Add Source Sans Pro and Bitter fonts.
|
2013-07-18 20:11:43 +02:00
|
|
|
wp_enqueue_style( 'twentythirteen-fonts', twentythirteen_fonts_url(), array(), null );
|
|
|
|
|
|
|
|
// Add Genericons font.
|
2014-06-06 20:22:14 +02:00
|
|
|
wp_enqueue_style( 'genericons', get_template_directory_uri() . '/genericons/genericons.css', array(), '3.03' );
|
2013-07-18 20:11:43 +02:00
|
|
|
}
|
|
|
|
add_action( 'admin_print_styles-appearance_page_custom-header', 'twentythirteen_custom_header_fonts' );
|
|
|
|
|
2013-02-19 00:08:56 +01:00
|
|
|
/**
|
2013-09-20 21:34:10 +02:00
|
|
|
* Style the header text displayed on the blog.
|
2013-02-19 00:08:56 +01:00
|
|
|
*
|
|
|
|
* get_header_textcolor() options: Hide text (returns 'blank'), or any hex value.
|
|
|
|
*
|
|
|
|
* @since Twenty Thirteen 1.0
|
|
|
|
*/
|
|
|
|
function twentythirteen_header_style() {
|
|
|
|
$header_image = get_header_image();
|
|
|
|
$text_color = get_header_textcolor();
|
|
|
|
|
|
|
|
// If no custom options for text are set, let's bail.
|
2017-12-01 00:11:00 +01:00
|
|
|
if ( empty( $header_image ) && $text_color == get_theme_support( 'custom-header', 'default-text-color' ) ) {
|
2013-02-19 00:08:56 +01:00
|
|
|
return;
|
2017-12-01 00:11:00 +01:00
|
|
|
}
|
2013-02-19 00:08:56 +01:00
|
|
|
|
|
|
|
// If we get this far, we have custom styles.
|
|
|
|
?>
|
2013-04-16 19:18:30 +02:00
|
|
|
<style type="text/css" id="twentythirteen-header-css">
|
2013-02-19 00:08:56 +01:00
|
|
|
<?php
|
2017-12-01 00:11:00 +01:00
|
|
|
if ( ! empty( $header_image ) ) :
|
2013-02-19 00:08:56 +01:00
|
|
|
?>
|
2017-12-01 00:11:00 +01:00
|
|
|
.site-header {
|
|
|
|
background: url(<?php header_image(); ?>) no-repeat scroll top;
|
|
|
|
background-size: 1600px auto;
|
|
|
|
}
|
|
|
|
@media (max-width: 767px) {
|
2013-02-19 00:08:56 +01:00
|
|
|
.site-header {
|
2017-12-01 00:11:00 +01:00
|
|
|
background-size: 768px auto;
|
2013-02-19 00:08:56 +01:00
|
|
|
}
|
2017-12-01 00:11:00 +01:00
|
|
|
}
|
|
|
|
@media (max-width: 359px) {
|
|
|
|
.site-header {
|
|
|
|
background-size: 360px auto;
|
2014-06-08 21:13:14 +02:00
|
|
|
}
|
2017-12-01 00:11:00 +01:00
|
|
|
}
|
2013-02-19 00:08:56 +01:00
|
|
|
<?php
|
|
|
|
endif;
|
|
|
|
|
|
|
|
// Has the text been hidden?
|
2017-12-01 00:11:00 +01:00
|
|
|
if ( ! display_header_text() ) :
|
2013-02-19 00:08:56 +01:00
|
|
|
?>
|
2017-12-01 00:11:00 +01:00
|
|
|
.site-title,
|
|
|
|
.site-description {
|
|
|
|
position: absolute;
|
|
|
|
clip: rect(1px 1px 1px 1px); /* IE7 */
|
|
|
|
clip: rect(1px, 1px, 1px, 1px);
|
|
|
|
}
|
2013-02-19 00:08:56 +01:00
|
|
|
<?php
|
2017-12-01 00:11:00 +01:00
|
|
|
if ( empty( $header_image ) ) :
|
2013-02-19 00:08:56 +01:00
|
|
|
?>
|
2017-12-01 00:11:00 +01:00
|
|
|
.site-header .home-link {
|
|
|
|
min-height: 0;
|
|
|
|
}
|
2013-02-19 00:08:56 +01:00
|
|
|
<?php
|
2017-12-01 00:11:00 +01:00
|
|
|
endif;
|
2013-02-19 00:08:56 +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-02-26 05:50:09 +01:00
|
|
|
.site-title,
|
2013-02-19 00:08:56 +01:00
|
|
|
.site-description {
|
2013-02-26 05:50:09 +01:00
|
|
|
color: #<?php echo esc_attr( $text_color ); ?>;
|
2013-02-19 00:08:56 +01:00
|
|
|
}
|
|
|
|
<?php endif; ?>
|
|
|
|
</style>
|
|
|
|
<?php
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2013-09-20 21:34:10 +02:00
|
|
|
* Style the header image displayed on the Appearance > Header admin panel.
|
2013-02-19 00:08:56 +01:00
|
|
|
*
|
|
|
|
* @since Twenty Thirteen 1.0
|
|
|
|
*/
|
|
|
|
function twentythirteen_admin_header_style() {
|
|
|
|
$header_image = get_header_image();
|
|
|
|
?>
|
2013-04-16 19:18:30 +02:00
|
|
|
<style type="text/css" id="twentythirteen-admin-header-css">
|
2013-02-19 00:08:56 +01:00
|
|
|
.appearance_page_custom-header #headimg {
|
|
|
|
border: none;
|
|
|
|
-webkit-box-sizing: border-box;
|
|
|
|
-moz-box-sizing: border-box;
|
|
|
|
box-sizing: border-box;
|
|
|
|
<?php
|
|
|
|
if ( ! empty( $header_image ) ) {
|
2013-03-01 17:40:29 +01:00
|
|
|
echo 'background: url(' . esc_url( $header_image ) . ') no-repeat scroll top; background-size: 1600px auto;';
|
2017-12-01 00:11:00 +01:00
|
|
|
}
|
|
|
|
?>
|
2013-02-19 00:08:56 +01:00
|
|
|
padding: 0 20px;
|
|
|
|
}
|
2013-04-23 19:55:55 +02:00
|
|
|
#headimg .home-link {
|
2013-02-19 00:08:56 +01:00
|
|
|
-webkit-box-sizing: border-box;
|
|
|
|
-moz-box-sizing: border-box;
|
|
|
|
box-sizing: border-box;
|
|
|
|
margin: 0 auto;
|
|
|
|
max-width: 1040px;
|
|
|
|
<?php
|
|
|
|
if ( ! empty( $header_image ) || display_header_text() ) {
|
|
|
|
echo 'min-height: 230px;';
|
2017-12-01 00:11:00 +01:00
|
|
|
}
|
|
|
|
?>
|
2013-02-19 00:08:56 +01:00
|
|
|
width: 100%;
|
|
|
|
}
|
|
|
|
<?php if ( ! display_header_text() ) : ?>
|
|
|
|
#headimg h1,
|
|
|
|
#headimg h2 {
|
|
|
|
position: absolute !important;
|
|
|
|
clip: rect(1px 1px 1px 1px); /* IE7 */
|
|
|
|
clip: rect(1px, 1px, 1px, 1px);
|
|
|
|
}
|
|
|
|
<?php endif; ?>
|
|
|
|
#headimg h1 {
|
2013-03-01 17:40:29 +01:00
|
|
|
font: bold 60px/1 Bitter, Georgia, serif;
|
2013-02-19 00:08:56 +01:00
|
|
|
margin: 0;
|
|
|
|
padding: 58px 0 10px;
|
|
|
|
}
|
|
|
|
#headimg h1 a {
|
|
|
|
text-decoration: none;
|
|
|
|
}
|
|
|
|
#headimg h1 a:hover {
|
|
|
|
text-decoration: underline;
|
|
|
|
}
|
|
|
|
#headimg h2 {
|
2013-03-01 17:40:29 +01:00
|
|
|
font: 200 italic 24px "Source Sans Pro", Helvetica, sans-serif;
|
2013-02-19 00:08:56 +01:00
|
|
|
margin: 0;
|
|
|
|
text-shadow: none;
|
|
|
|
}
|
|
|
|
.default-header img {
|
|
|
|
max-width: 230px;
|
|
|
|
width: auto;
|
|
|
|
}
|
|
|
|
</style>
|
|
|
|
<?php
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2013-09-20 21:34:10 +02:00
|
|
|
* Output markup to be displayed on the Appearance > Header admin panel.
|
|
|
|
*
|
2013-02-19 00:08:56 +01:00
|
|
|
* This callback overrides the default markup displayed there.
|
|
|
|
*
|
|
|
|
* @since Twenty Thirteen 1.0
|
|
|
|
*/
|
|
|
|
function twentythirteen_admin_header_image() {
|
2015-01-21 21:49:22 +01:00
|
|
|
$style = 'color: #' . get_header_textcolor() . ';';
|
|
|
|
if ( ! display_header_text() ) {
|
|
|
|
$style = 'display: none;';
|
|
|
|
}
|
2013-02-19 00:08:56 +01:00
|
|
|
?>
|
2015-01-21 21:49:22 +01:00
|
|
|
<div id="headimg" style="background: url(<?php echo esc_url( get_header_image() ); ?>) no-repeat scroll top; background-size: 1600px auto;">
|
2013-04-23 19:55:55 +02:00
|
|
|
<div class="home-link">
|
2015-01-21 21:49:22 +01:00
|
|
|
<h1 class="displaying-header-text"><a id="name" style="<?php echo esc_attr( $style ); ?>" onclick="return false;" href="#" tabindex="-1"><?php bloginfo( 'name' ); ?></a></h1>
|
|
|
|
<h2 id="desc" class="displaying-header-text" style="<?php echo esc_attr( $style ); ?>"><?php bloginfo( 'description' ); ?></h2>
|
2013-02-19 00:08:56 +01:00
|
|
|
</div>
|
|
|
|
</div>
|
2017-12-01 00:11:00 +01:00
|
|
|
<?php
|
|
|
|
}
|