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
23 function twentythirteen_custom_header_setup() {
25 // Text color and image (empty to use none).
26 'default-text-color' => '220e10',
27 'default-image' => '%s/images/headers/circle.png',
29 // Set height and width, with a maximum value for the width.
33 // Callbacks for styling the header and the admin preview.
34 'wp-head-callback' => 'twentythirteen_header_style',
35 'admin-head-callback' => 'twentythirteen_admin_header_style',
36 'admin-preview-callback' => 'twentythirteen_admin_header_image',
39 add_theme_support( 'custom-header', $args );
42 * Default custom headers packaged with the theme.
43 * %s is a placeholder for the theme template directory URI.
45 register_default_headers( array(
47 'url' => '%s/images/headers/circle.png',
48 'thumbnail_url' => '%s/images/headers/circle-thumbnail.png',
49 'description' => _x( 'Circle', 'header image description', 'twentythirteen' )
52 'url' => '%s/images/headers/diamond.png',
53 'thumbnail_url' => '%s/images/headers/diamond-thumbnail.png',
54 'description' => _x( 'Diamond', 'header image description', 'twentythirteen' )
57 'url' => '%s/images/headers/star.png',
58 'thumbnail_url' => '%s/images/headers/star-thumbnail.png',
59 'description' => _x( 'Star', 'header image description', 'twentythirteen' )
63 add_action( 'after_setup_theme', 'twentythirteen_custom_header_setup', 11 );
66 * Load our special font CSS files.
68 * @since Twenty Thirteen 1.0
70 function twentythirteen_custom_header_fonts() {
71 // Add Source Sans Pro and Bitter fonts.
72 wp_enqueue_style( 'twentythirteen-fonts', twentythirteen_fonts_url(), array(), null );
74 // Add Genericons font.
75 wp_enqueue_style( 'genericons', get_template_directory_uri() . '/fonts/genericons.css', array(), '2.09' );
77 add_action( 'admin_print_styles-appearance_page_custom-header', 'twentythirteen_custom_header_fonts' );
80 * Style the header text displayed on the blog.
82 * get_header_textcolor() options: Hide text (returns 'blank'), or any hex value.
84 * @since Twenty Thirteen 1.0
86 function twentythirteen_header_style() {
87 $header_image = get_header_image();
88 $text_color = get_header_textcolor();
90 // If no custom options for text are set, let's bail.
91 if ( empty( $header_image ) && $text_color == get_theme_support( 'custom-header', 'default-text-color' ) )
94 // If we get this far, we have custom styles.
96 <style type="text/css" id="twentythirteen-header-css">
98 if ( ! empty( $header_image ) ) :
101 background: url(<?php header_image(); ?>) no-repeat scroll top;
102 background-size: 1600px auto;
107 // Has the text been hidden?
108 if ( ! display_header_text() ) :
113 clip: rect(1px 1px 1px 1px); /* IE7 */
114 clip: rect(1px, 1px, 1px, 1px);
117 if ( empty( $header_image ) ) :
119 .site-header .home-link {
125 // If the user has set a custom color for the text, use that.
126 elseif ( $text_color != get_theme_support( 'custom-header', 'default-text-color' ) ) :
130 color: #<?php echo esc_attr( $text_color ); ?>;
138 * Style the header image displayed on the Appearance > Header admin panel.
140 * @since Twenty Thirteen 1.0
142 function twentythirteen_admin_header_style() {
143 $header_image = get_header_image();
145 <style type="text/css" id="twentythirteen-admin-header-css">
146 .appearance_page_custom-header #headimg {
148 -webkit-box-sizing: border-box;
149 -moz-box-sizing: border-box;
150 box-sizing: border-box;
152 if ( ! empty( $header_image ) ) {
153 echo 'background: url(' . esc_url( $header_image ) . ') no-repeat scroll top; background-size: 1600px auto;';
157 #headimg .home-link {
158 -webkit-box-sizing: border-box;
159 -moz-box-sizing: border-box;
160 box-sizing: border-box;
164 if ( ! empty( $header_image ) || display_header_text() ) {
165 echo 'min-height: 230px;';
169 <?php if ( ! display_header_text() ) : ?>
172 position: absolute !important;
173 clip: rect(1px 1px 1px 1px); /* IE7 */
174 clip: rect(1px, 1px, 1px, 1px);
178 font: bold 60px/1 Bitter, Georgia, serif;
180 padding: 58px 0 10px;
183 text-decoration: none;
185 #headimg h1 a:hover {
186 text-decoration: underline;
189 font: 200 italic 24px "Source Sans Pro", Helvetica, sans-serif;
193 .default-header img {
202 * Output markup to be displayed on the Appearance > Header admin panel.
204 * This callback overrides the default markup displayed there.
206 * @since Twenty Thirteen 1.0
208 function twentythirteen_admin_header_image() {
210 <div id="headimg" style="background: url(<?php header_image(); ?>) no-repeat scroll top; background-size: 1600px auto;">
211 <?php $style = ' style="color:#' . get_header_textcolor() . ';"'; ?>
212 <div class="home-link">
213 <h1 class="displaying-header-text"><a id="name"<?php echo $style; ?> onclick="return false;" href="#"><?php bloginfo( 'name' ); ?></a></h1>
214 <h2 id="desc" class="displaying-header-text"<?php echo $style; ?>><?php bloginfo( 'description' ); ?></h2>