Make WordPress Core


Ignore:
Timestamp:
12/03/2013 06:26:26 PM (13 years ago)
Author:
lancewillett
Message:

Twenty Fourteen: re-add the Header Text Customization Option. Props iamtakashi, fixes #26338; see #25540.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-content/themes/twentyfourteen/inc/custom-header.php

    r26556 r26573  
    3737         */
    3838        add_theme_support( 'custom-header', apply_filters( 'twentyfourteen_custom_header_args', array(
    39                 'header-text'            => false,
     39                'default-text-color'     => 'fff',
    4040                'width'                  => 1260,
    4141                'height'                 => 240,
    4242                'flex-height'            => true,
     43                'wp-head-callback'       => 'twentyfourteen_header_style',
    4344                'admin-head-callback'    => 'twentyfourteen_admin_header_style',
    4445                'admin-preview-callback' => 'twentyfourteen_admin_header_image',
     
    4647}
    4748add_action( 'after_setup_theme', 'twentyfourteen_custom_header_setup' );
     49
     50if ( ! function_exists( 'twentyfourteen_header_style' ) ) :
     51/**
     52 * Styles the header image and text displayed on the blog
     53 *
     54 * @see twentyfourteen_custom_header_setup().
     55 *
     56 */
     57function twentyfourteen_header_style() {
     58        $header_text_color = get_header_textcolor();
     59
     60        // If no custom options for text are set, let's bail
     61        // $header_text_color options: HEADER_TEXTCOLOR is default, hide text (returns 'blank') or any hex value
     62        if ( HEADER_TEXTCOLOR == $header_text_color )
     63                return;
     64        // If we get this far, we have custom styles. Let's do this.
     65        ?>
     66        <style type="text/css">
     67        <?php
     68                // Has the text been hidden?
     69                if ( 'blank' == $header_text_color ) :
     70        ?>
     71                .site-title {
     72                        position: absolute !important;
     73                        clip: rect(1px 1px 1px 1px); /* IE6, IE7 */
     74                        clip: rect(1px, 1px, 1px, 1px);
     75                }
     76        <?php
     77                // If the user has set a custom color for the text use that
     78                else :
     79        ?>
     80                .site-title a {
     81                        color: #<?php echo $header_text_color; ?> !important;
     82                }
     83        <?php endif; ?>
     84        </style>
     85        <?php
     86}
     87endif; // twentyfourteen_header_style
     88
    4889
    4990if ( ! function_exists( 'twentyfourteen_admin_header_style' ) ) :
     
    61102                background-color: #000;
    62103                border: none;
    63                 max-width: 1230px;
     104                max-width: 1260px;
    64105                min-height: 48px;
    65106        }
    66107        #headimg h1 {
    67                 font-family: lato, sans-serif;
     108                font-family: Lato, sans-serif;
    68109                font-size: 18px;
    69                 line-height: 1.3333333333;
    70                 margin: 12px 0 12px 27px;
     110                line-height: 48px;
     111                margin: 0 0 0 30px;
    71112        }
    72113        #headimg h1 a {
     
    96137                <img src="<?php header_image(); ?>" alt="">
    97138                <?php endif; ?>
    98                 <h1><a id="name" onclick="return false;" href="<?php echo esc_url( home_url( '/' ) ); ?>"><?php bloginfo( 'name' ); ?></a></h1>
     139                <h1 class="displaying-header-text"><a id="name"<?php echo sprintf( ' style="color:#%s;"', get_header_textcolor() ); ?> onclick="return false;" href="<?php echo esc_url( home_url( '/' ) ); ?>"><?php bloginfo( 'name' ); ?></a></h1>
    99140        </div>
    100141<?php
Note: See TracChangeset for help on using the changeset viewer.