3 * Implements a custom header for Twenty Thirteen.
4 * See http://codex.wordpress.org/Custom_Headers
7 * @subpackage Twenty_Thirteen
8 * @since Twenty Thirteen 1.0
12 * Sets up the WordPress core custom header arguments and settings.
14 * @uses add_theme_support() to register support for 3.4 and up.
15 * @uses twentythirteen_header_style() to style front-end.
16 * @uses twentythirteen_admin_header_style() to style wp-admin form.
17 * @uses twentythirteen_admin_header_image() to add custom markup to wp-admin form.
18 * @uses register_default_headers() to set up the bundled header images.
20 * @since Twenty Thirteen 1.0
22 function twentythirteen_custom_header_setup() {
24 // Text color and image (empty to use none).
25 'default-text-color' => '220e10',
26 'default-image' => '%s/images/headers/circle.png',
28 // Set height and width, with a maximum value for the width.
32 // Callbacks for styling the header and the admin preview.
33 'wp-head-callback' => 'twentythirteen_header_style',
34 'admin-head-callback' => 'twentythirteen_admin_header_style',
35 'admin-preview-callback' => 'twentythirteen_admin_header_image',
38 add_theme_support( 'custom-header', $args );
41 * Default custom headers packaged with the theme.
42 * %s is a placeholder for the theme template directory URI.
44 register_default_headers( array(
46 'url' => '%s/images/headers/circle.png',
47 'thumbnail_url' => '%s/images/headers/circle-thumbnail.png',
48 'description' => _x( 'Circle', 'header image description', 'twentythirteen' )
51 'url' => '%s/images/headers/diamond.png',
52 'thumbnail_url' => '%s/images/headers/diamond-thumbnail.png',
53 'description' => _x( 'Diamond', 'header image description', 'twentythirteen' )
56 'url' => '%s/images/headers/star.png',
57 'thumbnail_url' => '%s/images/headers/star-thumbnail.png',
58 'description' => _x( 'Star', 'header image description', 'twentythirteen' )
62 add_action( 'after_setup_theme', 'twentythirteen_custom_header_setup' );
65 * Loads our special font CSS files.
67 * @since Twenty Thirteen 1.0
69 function twentythirteen_custom_header_fonts() {
70 // Add Open Sans and Bitter fonts.
71 wp_enqueue_style( 'twentythirteen-fonts', twentythirteen_fonts_url(), array(), null );
73 // Add Genericons font.
74 wp_enqueue_style( 'genericons', get_template_directory_uri() . '/fonts/genericons.css', array(), '2.09' );
76 add_action( 'admin_print_styles-appearance_page_custom-header', 'twentythirteen_custom_header_fonts' );
79 * Styles the header text displayed on the blog.
81 * get_header_textcolor() options: Hide text (returns 'blank'), or any hex value.
83 * @since Twenty Thirteen 1.0
85 function twentythirteen_header_style() {
86 $header_image = get_header_image();
87 $text_color = get_header_textcolor();
89 // If no custom options for text are set, let's bail.
90 if ( empty( $header_image ) && $text_color == get_theme_support( 'custom-header', 'default-text-color' ) )
93 // If we get this far, we have custom styles.
95 <style type="text/css" id="twentythirteen-header-css">
97 if ( ! empty( $header_image ) ) :
100 background: url(<?php header_image(); ?>) no-repeat scroll top;
101 background-size: 1600px auto;
106 // Has the text been hidden?
107 if ( ! display_header_text() ) :
112 clip: rect(1px 1px 1px 1px); /* IE7 */
113 clip: rect(1px, 1px, 1px, 1px);
116 if ( empty( $header_image ) ) :
118 .site-header .home-link {
124 // If the user has set a custom color for the text, use that.
125 elseif ( $text_color != get_theme_support( 'custom-header', 'default-text-color' ) ) :
129 color: #<?php echo esc_attr( $text_color ); ?>;
137 * Styles the header image displayed on the Appearance > Header admin panel.
139 * @since Twenty Thirteen 1.0
141 function twentythirteen_admin_header_style() {
142 $header_image = get_header_image();
144 <style type="text/css" id="twentythirteen-admin-header-css">
145 .appearance_page_custom-header #headimg {
147 -webkit-box-sizing: border-box;
148 -moz-box-sizing: border-box;
149 box-sizing: border-box;
151 if ( ! empty( $header_image ) ) {
152 echo 'background: url(' . esc_url( $header_image ) . ') no-repeat scroll top; background-size: 1600px auto;';
156 #headimg .home-link {
157 -webkit-box-sizing: border-box;
158 -moz-box-sizing: border-box;
159 box-sizing: border-box;
163 if ( ! empty( $header_image ) || display_header_text() ) {
164 echo 'min-height: 230px;';
168 <?php if ( ! display_header_text() ) : ?>
171 position: absolute !important;
172 clip: rect(1px 1px 1px 1px); /* IE7 */
173 clip: rect(1px, 1px, 1px, 1px);
177 font: bold 60px/1 Bitter, Georgia, serif;
179 padding: 58px 0 10px;
182 text-decoration: none;
184 #headimg h1 a:hover {
185 text-decoration: underline;
188 font: 200 italic 24px "Source Sans Pro", Helvetica, sans-serif;
192 .default-header img {
201 * Outputs markup to be displayed on the Appearance > Header admin panel.
202 * This callback overrides the default markup displayed there.
204 * @since Twenty Thirteen 1.0
206 function twentythirteen_admin_header_image() {
208 <div id="headimg" style="background: url(<?php header_image(); ?>) no-repeat scroll top; background-size: 1600px auto;">
209 <?php $style = ' style="color:#' . get_header_textcolor() . ';"'; ?>
210 <div class="home-link">
211 <h1 class="displaying-header-text"><a id="name"<?php echo $style; ?> onclick="return false;" href="#"><?php bloginfo( 'name' ); ?></a></h1>
212 <h2 id="desc" class="displaying-header-text"<?php echo $style; ?>><?php bloginfo( 'description' ); ?></h2>