33 * the Appearance > Header screen. |
33 * the Appearance > Header screen. |
34 * @type string $admin_preview_callback Callback function used to create the custom header markup in |
34 * @type string $admin_preview_callback Callback function used to create the custom header markup in |
35 * the Appearance > Header screen. |
35 * the Appearance > Header screen. |
36 * } |
36 * } |
37 */ |
37 */ |
38 add_theme_support( 'custom-header', apply_filters( 'twentyfourteen_custom_header_args', array( |
38 add_theme_support( |
39 'default-text-color' => 'fff', |
39 'custom-header', apply_filters( |
40 'width' => 1260, |
40 'twentyfourteen_custom_header_args', array( |
41 'height' => 240, |
41 'default-text-color' => 'fff', |
42 'flex-height' => true, |
42 'width' => 1260, |
43 'wp-head-callback' => 'twentyfourteen_header_style', |
43 'height' => 240, |
44 'admin-head-callback' => 'twentyfourteen_admin_header_style', |
44 'flex-height' => true, |
45 'admin-preview-callback' => 'twentyfourteen_admin_header_image', |
45 'wp-head-callback' => 'twentyfourteen_header_style', |
46 ) ) ); |
46 'admin-head-callback' => 'twentyfourteen_admin_header_style', |
|
47 'admin-preview-callback' => 'twentyfourteen_admin_header_image', |
|
48 ) |
|
49 ) |
|
50 ); |
47 } |
51 } |
48 add_action( 'after_setup_theme', 'twentyfourteen_custom_header_setup' ); |
52 add_action( 'after_setup_theme', 'twentyfourteen_custom_header_setup' ); |
49 |
53 |
50 if ( ! function_exists( 'twentyfourteen_header_style' ) ) : |
54 if ( ! function_exists( 'twentyfourteen_header_style' ) ) : |
51 /** |
55 /** |
52 * Styles the header image and text displayed on the blog |
56 * Styles the header image and text displayed on the blog |
53 * |
57 * |
54 * @see twentyfourteen_custom_header_setup(). |
58 * @see twentyfourteen_custom_header_setup(). |
55 * |
59 */ |
56 */ |
60 function twentyfourteen_header_style() { |
57 function twentyfourteen_header_style() { |
61 $text_color = get_header_textcolor(); |
58 $text_color = get_header_textcolor(); |
|
59 |
62 |
60 // If no custom color for text is set, let's bail. |
63 // If no custom color for text is set, let's bail. |
61 if ( display_header_text() && $text_color === get_theme_support( 'custom-header', 'default-text-color' ) ) |
64 if ( display_header_text() && $text_color === get_theme_support( 'custom-header', 'default-text-color' ) ) { |
62 return; |
65 return; |
|
66 } |
63 |
67 |
64 // If we get this far, we have custom styles. |
68 // If we get this far, we have custom styles. |
65 ?> |
69 ?> |
66 <style type="text/css" id="twentyfourteen-header-css"> |
70 <style type="text/css" id="twentyfourteen-header-css"> |
67 <?php |
71 <?php |
68 // Has the text been hidden? |
72 // Has the text been hidden? |
69 if ( ! display_header_text() ) : |
73 if ( ! display_header_text() ) : |
70 ?> |
74 ?> |
71 .site-title, |
75 .site-title, |
72 .site-description { |
76 .site-description { |
82 color: #<?php echo esc_attr( $text_color ); ?>; |
86 color: #<?php echo esc_attr( $text_color ); ?>; |
83 } |
87 } |
84 <?php endif; ?> |
88 <?php endif; ?> |
85 </style> |
89 </style> |
86 <?php |
90 <?php |
87 } |
91 } |
88 endif; // twentyfourteen_header_style |
92 endif; // twentyfourteen_header_style |
89 |
93 |
90 |
94 |
91 if ( ! function_exists( 'twentyfourteen_admin_header_style' ) ) : |
95 if ( ! function_exists( 'twentyfourteen_admin_header_style' ) ) : |
92 /** |
96 /** |
93 * Style the header image displayed on the Appearance > Header screen. |
97 * Style the header image displayed on the Appearance > Header screen. |
94 * |
98 * |
95 * @see twentyfourteen_custom_header_setup() |
99 * @see twentyfourteen_custom_header_setup() |
96 * |
100 * |
97 * @since Twenty Fourteen 1.0 |
101 * @since Twenty Fourteen 1.0 |
98 */ |
102 */ |
99 function twentyfourteen_admin_header_style() { |
103 function twentyfourteen_admin_header_style() { |
100 ?> |
104 ?> |
101 <style type="text/css" id="twentyfourteen-admin-header-css"> |
105 <style type="text/css" id="twentyfourteen-admin-header-css"> |
102 .appearance_page_custom-header #headimg { |
106 .appearance_page_custom-header #headimg { |
103 background-color: #000; |
107 background-color: #000; |
104 border: none; |
108 border: none; |
105 max-width: 1260px; |
109 max-width: 1260px; |
120 } |
124 } |
121 #headimg img { |
125 #headimg img { |
122 vertical-align: middle; |
126 vertical-align: middle; |
123 } |
127 } |
124 </style> |
128 </style> |
125 <?php |
129 <?php |
126 } |
130 } |
127 endif; // twentyfourteen_admin_header_style |
131 endif; // twentyfourteen_admin_header_style |
128 |
132 |
129 if ( ! function_exists( 'twentyfourteen_admin_header_image' ) ) : |
133 if ( ! function_exists( 'twentyfourteen_admin_header_image' ) ) : |
130 /** |
134 /** |
131 * Create the custom header image markup displayed on the Appearance > Header screen. |
135 * Create the custom header image markup displayed on the Appearance > Header screen. |
132 * |
136 * |
133 * @see twentyfourteen_custom_header_setup() |
137 * @see twentyfourteen_custom_header_setup() |
134 * |
138 * |
135 * @since Twenty Fourteen 1.0 |
139 * @since Twenty Fourteen 1.0 |
136 */ |
140 */ |
137 function twentyfourteen_admin_header_image() { |
141 function twentyfourteen_admin_header_image() { |
138 ?> |
142 ?> |
139 <div id="headimg"> |
143 <div id="headimg"> |
140 <?php if ( get_header_image() ) : ?> |
144 <?php if ( get_header_image() ) : ?> |
141 <img src="<?php header_image(); ?>" alt=""> |
145 <img src="<?php header_image(); ?>" alt=""> |
142 <?php endif; ?> |
146 <?php endif; ?> |
143 <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> |
147 <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> |
144 </div> |
148 </div> |
145 <?php |
149 <?php |
146 } |
150 } |
147 endif; // twentyfourteen_admin_header_image |
151 endif; // twentyfourteen_admin_header_image |