Make WordPress Core

Changeset 26573


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.

Location:
trunk/src/wp-content/themes/twentyfourteen
Files:
4 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
  • trunk/src/wp-content/themes/twentyfourteen/inc/customizer.php

    r26567 r26573  
    1717function twentyfourteen_customize_register( $wp_customize ) {
    1818        // Add postMessage support for site title and description.
    19         $wp_customize->get_setting( 'blogname' )->transport        = 'postMessage';
    20         $wp_customize->get_setting( 'blogdescription' )->transport = 'postMessage';
     19        $wp_customize->get_setting( 'blogname' )->transport         = 'postMessage';
     20        $wp_customize->get_setting( 'blogdescription' )->transport  = 'postMessage';
     21        $wp_customize->get_setting( 'header_textcolor' )->transport = 'postMessage';
     22
     23        // Rename the label to "Display Site Title & Tagline" in order to make this option extra clear.
     24        $wp_customize->add_control( 'display_header_text', array(
     25                'settings' => 'header_textcolor',
     26                'label'    => __( 'Display Site Title & Tagline', 'twentyfourteen' ),
     27                'section'  => 'title_tagline',
     28                'type'     => 'checkbox',
     29        ) );
     30
     31        // Rename the label to "Site Title Color" because this only effects the site title in this theme.
     32        $wp_customize->add_control( new WP_Customize_Color_Control( $wp_customize, 'header_textcolor', array(
     33                'label'   => __( 'Site Title Color', 'twentyfourteen' ),
     34                'section' => 'colors',
     35        ) ) );
    2136
    2237        // Add custom description to Colors and Background sections.
     
    5469 */
    5570function twentyfourteen_customize_preview_js() {
    56         wp_enqueue_script( 'twentyfourteen_customizer', get_template_directory_uri() . '/js/customizer.js', array( 'customize-preview' ), '20120827', true );
     71        wp_enqueue_script( 'twentyfourteen_customizer', get_template_directory_uri() . '/js/customizer.js', array( 'customize-preview' ), '20131130', true );
    5772}
    5873add_action( 'customize_preview_init', 'twentyfourteen_customize_preview_js' );
  • trunk/src/wp-content/themes/twentyfourteen/js/customizer.js

    r26332 r26573  
    1616                } );
    1717        } );
     18        // Header text color.
     19        wp.customize( 'header_textcolor', function( value ) {
     20                value.bind( function( to ) {
     21                        if ( 'blank' == to ) {
     22                                $( '.site-title a, .site-description' ).css( {
     23                                        'clip': 'rect(1px, 1px, 1px, 1px)',
     24                                        'position': 'absolute'
     25                                } );
     26                        } else {
     27                                $( '.site-title a,  .site-description' ).css( {
     28                                        'clip': 'auto',
     29                                        'position': 'relative'
     30                                } );
     31
     32                                $( '.site-title a' ).css( {
     33                                        'color': to,
     34                                } );
     35                        }
     36                } );
     37        } );
    1838} )( jQuery );
  • trunk/src/wp-content/themes/twentyfourteen/style.css

    r26569 r26573  
    35583558        }
    35593559
     3560        .site-description:empty {
     3561                margin: 0;
     3562        }
     3563
    35603564        .secondary-navigation {
    35613565                margin: 0 -30px 48px;
Note: See TracChangeset for help on using the changeset viewer.