Make WordPress Core

Ticket #37516: theme-example-37516.diff

File theme-example-37516.diff, 3.2 KB (added by tellyworth, 8 years ago)

An example of how a theme might support the new custom-title-tagline feature.

  • src/wp-content/themes/twentyseventeen/functions.php

     
    5555
    5656        add_image_size( 'twentyseventeen-thumbnail-avatar', 100, 100, true );
    5757
     58        add_theme_support( 'custom-title-tagline' );
     59
    5860        // Set the default content width.
    5961        $GLOBALS['content_width'] = 525;
    6062
  • src/wp-content/themes/twentyseventeen/inc/customizer.php

     
    1919
    2020        $wp_customize->selective_refresh->add_partial( 'blogname', array(
    2121                'selector' => '.site-title a',
     22                'settings' => array( 'blogname', 'header_display_title' ),
    2223                'render_callback' => 'twentyseventeen_customize_partial_blogname',
    2324        ) );
    2425        $wp_customize->selective_refresh->add_partial( 'blogdescription', array(
    2526                'selector' => '.site-description',
     27                'settings' => array( 'blogdescription', 'header_display_tagline' ),
    2628                'render_callback' => 'twentyseventeen_customize_partial_blogdescription',
    2729        ) );
    2830
     
    163165 * @return void
    164166 */
    165167function twentyseventeen_customize_partial_blogname() {
    166         bloginfo( 'name' );
     168        if ( get_option( 'header_display_title' ) )
     169                bloginfo( 'name' );
    167170}
    168171
    169172/**
     
    175178 * @return void
    176179 */
    177180function twentyseventeen_customize_partial_blogdescription() {
    178         bloginfo( 'description' );
     181        if ( get_option( 'header_display_tagline' ) )
     182                bloginfo( 'description' );
    179183}
    180184
    181185/**
  • src/wp-content/themes/twentyseventeen/template-parts/header/site-branding.php

     
    1616
    1717                <div class="site-branding-text">
    1818                        <?php if ( is_front_page() ) : ?>
    19                                 <h1 class="site-title"><a href="<?php echo esc_url( home_url( '/' ) ); ?>" rel="home"><?php bloginfo( 'name' ); ?></a></h1>
     19                                <?php if ( get_option( 'header_display_title' ) ) : ?>
     20                                        <h1 class="site-title"><a href="<?php echo esc_url( home_url( '/' ) ); ?>" rel="home"><?php bloginfo( 'name' ); ?></a></h1>
     21                                <?php endif; ?>
    2022                        <?php else : ?>
    21                                 <p class="site-title"><a href="<?php echo esc_url( home_url( '/' ) ); ?>" rel="home"><?php bloginfo( 'name' ); ?></a></p>
     23                                <?php if ( get_option( 'header_display_title' ) ) : ?>
     24                                        <p class="site-title"><a href="<?php echo esc_url( home_url( '/' ) ); ?>" rel="home"><?php bloginfo( 'name' ); ?></a></p>
     25                                <?php endif; ?>
    2226                        <?php endif; ?>
    2327
    2428                        <?php
     
    2630
    2731                        if ( $description || is_customize_preview() ) :
    2832                        ?>
    29                                 <p class="site-description"><?php echo $description; ?></p>
     33                                <?php if ( get_option( 'header_display_tagline' ) ) : ?>
     34                                        <p class="site-description"><?php echo $description; ?></p>
     35                                <?php endif; ?>
    3036                        <?php endif; ?>
    3137                </div><!-- .site-branding-text -->
    3238