3 * Implement a custom header for Twenty Thirteen
5 * @link http://codex.wordpress.org/Custom_Headers
8 * @subpackage Twenty_Thirteen
9 * @since Twenty Thirteen 1.0
13 * Set up the WordPress core custom header arguments and settings.
15 * @uses add_theme_support() to register support for 3.4 and up.
16 * @uses twentythirteen_header_style() to style front-end.
17 * @uses twentythirteen_admin_header_style() to style wp-admin form.
18 * @uses twentythirteen_admin_header_image() to add custom markup to wp-admin form.
19 * @uses register_default_headers() to set up the bundled header images.
21 * @since Twenty Thirteen 1.0
25 function twentythirteen_custom_header_setup() {
27 // Text color and image (empty to use none).
28 'default-text-color' => '220e10',
29 'default-image' => '%s/images/headers/circle.png',
31 // Set height and width, with a maximum value for the width.
35 // Callbacks for styling the header and the admin preview.
36 'wp-head-callback' => 'twentythirteen_header_style',
37 'admin-head-callback' => 'twentythirteen_admin_header_style',
38 'admin-preview-callback' => 'twentythirteen_admin_header_image',
41 add_theme_support( 'custom-header', $args );
44 * Default custom headers packaged with the theme.
45 * %s is a placeholder for the theme template directory URI.
47 register_default_headers( array(
49 'url' => '%s/images/headers/circle.png',
50 'thumbnail_url' => '%s/images/headers/circle-thumbnail.png',
51 'description' => _x( 'Circle', 'header image description', 'twentythirteen' )
54 'url' => '%s/images/headers/diamond.png',
55 'thumbnail_url' => '%s/images/headers/diamond-thumbnail.png',
56 'description' => _x( 'Diamond', 'header image description', 'twentythirteen' )
59 'url' => '%s/images/headers/star.png',
60 'thumbnail_url' => '%s/images/headers/star-thumbnail.png',
61 'description' => _x( 'Star', 'header image description', 'twentythirteen' )
65 add_action( 'after_setup_theme', 'twentythirteen_custom_header_setup', 11 );
68 * Load our special font CSS files.
70 * @since Twenty Thirteen 1.0
74 function twentythirteen_custom_header_fonts() {
75 // Add Source Sans Pro and Bitter fonts.
76 wp_enqueue_style( 'twentythirteen-fonts', twentythirteen_fonts_url(), array(), null );
78 // Add Genericons font.
79 wp_enqueue_style( 'genericons', get_template_directory_uri() . '/fonts/genericons.css', array(), '2.09' );
81 add_action( 'admin_print_styles-appearance_page_custom-header', 'twentythirteen_custom_header_fonts' );
84 * Style the header text displayed on the blog.
86 * get_header_textcolor() options: Hide text (returns 'blank'), or any hex value.
88 * @since Twenty Thirteen 1.0
92 function twentythirteen_header_style() {
93 $header_image = get_header_image();
94 $text_color = get_header_textcolor();
96 // If no custom options for text are set, let's bail.
97 if ( empty( $header_image ) && $text_color == get_theme_support( 'custom-header', 'default-text-color' ) )
100 // If we get this far, we have custom styles.
102 <style type="text/css" id="twentythirteen-header-css">
104 if ( ! empty( $header_image ) ) :
107 background: url(<?php header_image(); ?>) no-repeat scroll top;
108 background-size: 1600px auto;
113 // Has the text been hidden?
114 if ( ! display_header_text() ) :
119 clip: rect(1px 1px 1px 1px); /* IE7 */
120 clip: rect(1px, 1px, 1px, 1px);
123 if ( empty( $header_image ) ) :
125 .site-header .home-link {
131 // If the user has set a custom color for the text, use that.
132 elseif ( $text_color != get_theme_support( 'custom-header', 'default-text-color' ) ) :
136 color: #<?php echo esc_attr( $text_color ); ?>;
144 * Style the header image displayed on the Appearance > Header admin panel.
146 * @since Twenty Thirteen 1.0
150 function twentythirteen_admin_header_style() {
151 $header_image = get_header_image();
153 <style type="text/css" id="twentythirteen-admin-header-css">
154 .appearance_page_custom-header #headimg {
156 -webkit-box-sizing: border-box;
157 -moz-box-sizing: border-box;
158 box-sizing: border-box;
160 if ( ! empty( $header_image ) ) {
161 echo 'background: url(' . esc_url( $header_image ) . ') no-repeat scroll top; background-size: 1600px auto;';
165 #headimg .home-link {
166 -webkit-box-sizing: border-box;
167 -moz-box-sizing: border-box;
168 box-sizing: border-box;
172 if ( ! empty( $header_image ) || display_header_text() ) {
173 echo 'min-height: 230px;';
177 <?php if ( ! display_header_text() ) : ?>
180 position: absolute !important;
181 clip: rect(1px 1px 1px 1px); /* IE7 */
182 clip: rect(1px, 1px, 1px, 1px);
186 font: bold 60px/1 Bitter, Georgia, serif;
188 padding: 58px 0 10px;
191 text-decoration: none;
193 #headimg h1 a:hover {
194 text-decoration: underline;
197 font: 200 italic 24px "Source Sans Pro", Helvetica, sans-serif;
201 .default-header img {
210 * Output markup to be displayed on the Appearance > Header admin panel.
212 * This callback overrides the default markup displayed there.
214 * @since Twenty Thirteen 1.0
218 function twentythirteen_admin_header_image() {
220 <div id="headimg" style="background: url(<?php header_image(); ?>) no-repeat scroll top; background-size: 1600px auto;">
221 <?php $style = ' style="color:#' . get_header_textcolor() . ';"'; ?>
222 <div class="home-link">
223 <h1 class="displaying-header-text"><a id="name"<?php echo $style; ?> onclick="return false;" href="#"><?php bloginfo( 'name' ); ?></a></h1>
224 <h2 id="desc" class="displaying-header-text"<?php echo $style; ?>><?php bloginfo( 'description' ); ?></h2>