Twenty Fourteen: better logic for hide/show title and description, and Customizer handling of the same. Add ID attributes to `style` blocks. Fixes #26338.

git-svn-id: https://develop.svn.wordpress.org/trunk@26668 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Lance Willett 2013-12-05 17:29:10 +00:00
parent 1ac4bceecd
commit 0361c75b09
2 changed files with 18 additions and 17 deletions

View File

@ -55,30 +55,31 @@ if ( ! function_exists( 'twentyfourteen_header_style' ) ) :
* *
*/ */
function twentyfourteen_header_style() { function twentyfourteen_header_style() {
$header_text_color = get_header_textcolor(); $text_color = get_header_textcolor();
// If no custom options for text are set, let's bail // If no custom color for text is set, let's bail.
// $header_text_color options: HEADER_TEXTCOLOR is default, hide text (returns 'blank') or any hex value if ( display_header_text() && $text_color === get_theme_support( 'custom-header', 'default-text-color' ) )
if ( HEADER_TEXTCOLOR == $header_text_color )
return; return;
// If we get this far, we have custom styles. Let's do this.
// If we get this far, we have custom styles.
?> ?>
<style type="text/css"> <style type="text/css" id="twentyfourteen-header-css">
<?php <?php
// Has the text been hidden? // Has the text been hidden?
if ( 'blank' == $header_text_color ) : if ( ! display_header_text() ) :
?> ?>
.site-title { .site-title,
position: absolute !important; .site-description {
clip: rect(1px 1px 1px 1px); /* IE6, IE7 */ position: absolute;
clip: rect(1px 1px 1px 1px); /* IE7 */
clip: rect(1px, 1px, 1px, 1px); clip: rect(1px, 1px, 1px, 1px);
} }
<?php <?php
// If the user has set a custom color for the text use that // If the user has set a custom color for the text, use that.
else : elseif ( $text_color != get_theme_support( 'custom-header', 'default-text-color' ) ) :
?> ?>
.site-title a { .site-title a {
color: #<?php echo $header_text_color; ?>; color: #<?php echo esc_attr( $text_color ); ?>;
} }
<?php endif; ?> <?php endif; ?>
</style> </style>
@ -97,7 +98,7 @@ if ( ! function_exists( 'twentyfourteen_admin_header_style' ) ) :
*/ */
function twentyfourteen_admin_header_style() { function twentyfourteen_admin_header_style() {
?> ?>
<style type="text/css"> <style type="text/css" id="twentyfourteen-admin-header-css">
.appearance_page_custom-header #headimg { .appearance_page_custom-header #headimg {
background-color: #000; background-color: #000;
border: none; border: none;

View File

@ -19,14 +19,14 @@
wp.customize( 'header_textcolor', function( value ) { wp.customize( 'header_textcolor', function( value ) {
value.bind( function( to ) { value.bind( function( to ) {
if ( 'blank' === to ) { if ( 'blank' === to ) {
$( '.site-title a, .site-description' ).css( { $( '.site-title, .site-description' ).css( {
'clip': 'rect(1px, 1px, 1px, 1px)', 'clip': 'rect(1px, 1px, 1px, 1px)',
'position': 'absolute' 'position': 'absolute'
} ); } );
} else { } else {
$( '.site-title a, .site-description' ).css( { $( '.site-title, .site-description' ).css( {
'clip': 'auto', 'clip': 'auto',
'position': 'relative' 'position': 'static'
} ); } );
$( '.site-title a' ).css( { $( '.site-title a' ).css( {