Make WordPress Core


Ignore:
Timestamp:
08/14/2013 04:38:01 PM (11 years ago)
Author:
lancewillett
Message:

Twenty Fourteen: first pass at matching code standards achieved with Twenty Thirteen development. See #24858, props obenland.

File:
1 edited

Legend:

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

    r24832 r25021  
    2323 */
    2424function twentyfourteen_custom_header_setup() {
    25     $args = array(
    26         'default-image'          => '',
     25    add_theme_support( 'custom-header', apply_filters( 'twentyfourteen_custom_header_args', array(
    2726        'default-text-color'     => 'fff',
    2827        'width'                  => 1260,
     
    3231        'admin-head-callback'    => 'twentyfourteen_admin_header_style',
    3332        'admin-preview-callback' => 'twentyfourteen_admin_header_image',
    34     );
     33    ) ) );
    3534
    36     $args = apply_filters( 'twentyfourteen_custom_header_args', $args );
    37 
    38     if ( function_exists( 'wp_get_theme' ) ) {
    39         add_theme_support( 'custom-header', $args );
    40     } else {
    41         // Compat: Versions of WordPress prior to 3.4.
    42         define( 'HEADER_TEXTCOLOR',    $args['default-text-color'] );
    43         define( 'HEADER_IMAGE',        $args['default-image'] );
    44         define( 'HEADER_IMAGE_WIDTH',  $args['width'] );
    45         define( 'HEADER_IMAGE_HEIGHT', $args['height'] );
    46         add_custom_image_header( $args['wp-head-callback'], $args['admin-head-callback'], $args['admin-preview-callback'] );
    47     }
    4835}
    4936add_action( 'after_setup_theme', 'twentyfourteen_custom_header_setup' );
    50 
    51 /**
    52  * Shiv for get_custom_header().
    53  *
    54  * get_custom_header() was introduced to WordPress
    55  * in version 3.4. To provide backward compatibility
    56  * with previous versions, we will define our own version
    57  * of this function.
    58  *
    59  * @todo Remove this function when WordPress 3.6 is released.
    60  * @return stdClass All properties represent attributes of the curent header image.
    61  *
    62  * @package WordPress
    63  * @subpackage Twenty_Fourteen
    64  */
    65 
    66 if ( ! function_exists( 'get_custom_header' ) ) {
    67     function get_custom_header() {
    68         return (object) array(
    69             'url'           => get_header_image(),
    70             'thumbnail_url' => get_header_image(),
    71             'width'         => HEADER_IMAGE_WIDTH,
    72             'height'        => HEADER_IMAGE_HEIGHT,
    73         );
    74     }
    75 }
    7637
    7738if ( ! function_exists( 'twentyfourteen_header_style' ) ) :
     
    8344 */
    8445function twentyfourteen_header_style() {
     46    $header_text_color = get_header_textcolor();
    8547
    8648    // If no custom options for text are set, let's bail
    87     // get_header_textcolor() options: HEADER_TEXTCOLOR is default, hide text (returns 'blank') or any hex value
    88     if ( HEADER_TEXTCOLOR == get_header_textcolor() )
     49    // $header_text_color options: HEADER_TEXTCOLOR is default, hide text (returns 'blank') or any hex value
     50    if ( HEADER_TEXTCOLOR == $header_text_color )
    8951        return;
    9052    // If we get this far, we have custom styles. Let's do this.
     
    9355    <?php
    9456        // Has the text been hidden?
    95         if ( 'blank' == get_header_textcolor() ) :
     57        if ( 'blank' == $header_text_color ) :
    9658    ?>
    9759        .site-title {
     
    10567    ?>
    10668        .site-title a  {
    107             color: #<?php echo get_header_textcolor(); ?> !important;
     69            color: #<?php echo $header_text_color; ?> !important;
    10870        }
    10971    <?php endif; ?>
     
    154116 *
    155117 */
    156 function twentyfourteen_admin_header_image() { ?>
     118function twentyfourteen_admin_header_image() {
     119    $header_image = get_header_image();
     120?>
    157121    <div id="headimg">
    158         <?php
    159         if ( 'blank' == get_header_textcolor() || '' == get_header_textcolor() )
    160             $style = ' style="display:none;"';
    161         else
    162             $style = ' style="color:#' . get_header_textcolor() . ';"';
    163         ?>
    164         <?php $header_image = get_header_image();
    165         if ( ! empty( $header_image ) ) : ?>
    166             <img src="<?php echo esc_url( $header_image ); ?>" alt="" />
     122        <?php if ( ! empty( $header_image ) ) : ?>
     123        <img src="<?php echo esc_url( $header_image ); ?>" alt="">
    167124        <?php endif; ?>
    168         <h1><a id="name"<?php echo $style; ?> onclick="return false;" href="<?php echo esc_url( home_url( '/' ) ); ?>"><?php bloginfo( 'name' ); ?></a></h1>
     125        <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>
    169126    </div>
    170 <?php }
     127<?php
     128}
    171129endif; // twentyfourteen_admin_header_image
Note: See TracChangeset for help on using the changeset viewer.