Make WordPress Core

Ticket #37516: theme-mod-37516.diff

File theme-mod-37516.diff, 6.5 KB (added by tellyworth, 7 years ago)

Reimplement previous patch using theme mods instead of options

  • 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_theme_mod( 'header_display_title' ) ) {
     169                bloginfo( 'name' );
     170        }
    167171}
    168172
    169173/**
     
    175179 * @return void
    176180 */
    177181function twentyseventeen_customize_partial_blogdescription() {
    178         bloginfo( 'description' );
     182        if ( get_theme_mod( 'header_display_tagline' ) ) {
     183                bloginfo( 'description' );
     184        }
    179185}
    180186
    181187/**
  • 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_theme_mod( 'header_display_title', true ) ) : ?>
     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_theme_mod( 'header_display_title', true ) ) : ?>
     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_theme_mod( 'header_display_tagline', true ) ) : ?>
     34                                        <p class="site-description"><?php echo $description; ?></p>
     35                                <?php endif; ?>
    3036                        <?php endif; ?>
    3137                </div><!-- .site-branding-text -->
    3238
  • src/wp-includes/class-wp-customize-manager.php

     
    48104810                        'section'    => 'title_tagline',
    48114811                ) );
    48124812
     4813                // Theme feature for enabling and disabling the site title
     4814                if ( current_theme_supports( 'custom-title-tagline', 'display-title' ) ) {
     4815                        $this->add_setting( 'header_display_title', array(
     4816                                'default'    => get_option( 'blogname' ),
     4817                                'transport'         => 'postMessage',
     4818                                'sanitize_callback' => 'absint',
     4819                        ) );
     4820
     4821                        $this->add_control( 'header_display_title', array(
     4822                                'label'    => __( 'Display Site Title' ),
     4823                                'section'  => 'title_tagline',
     4824                                'settings' => 'header_display_title',
     4825                                'type'     => 'checkbox',
     4826                        ) );
     4827                }
     4828
     4829                // Theme feature for enabling and disabling the site tagline
     4830                if ( current_theme_supports( 'custom-title-tagline', 'display-tagline' ) ) {
     4831                        $this->add_setting( 'header_display_tagline', array(
     4832                                'default'    => get_option( 'blogdescrption' ),
     4833                                'transport'         => 'postMessage',
     4834                                'sanitize_callback' => 'absint',
     4835                        ) );
     4836
     4837                        $this->add_control( 'header_display_tagline', array(
     4838                                'label'    => __( 'Display Site Tagline' ),
     4839                                'section'  => 'title_tagline',
     4840                                'settings' => 'header_display_tagline',
     4841                                'type'     => 'checkbox',
     4842                        ) );
     4843                }
     4844
    48134845                // Add a setting to hide header text if the theme doesn't support custom headers.
    4814                 if ( ! current_theme_supports( 'custom-header', 'header-text' ) ) {
     4846                if ( ! current_theme_supports( 'custom-header', 'header-text' ) && ! current_theme_supports( 'custom-title-tagline' ) ) {
    48154847                        $this->add_setting( 'header_text', array(
    48164848                                'theme_supports'    => array( 'custom-logo', 'header-text' ),
    48174849                                'default'           => 1,
     
    48954927
    48964928                // Input type: checkbox
    48974929                // With custom value
    4898                 $this->add_control( 'display_header_text', array(
    4899                         'settings' => 'header_textcolor',
    4900                         'label'    => __( 'Display Site Title and Tagline' ),
    4901                         'section'  => 'title_tagline',
    4902                         'type'     => 'checkbox',
    4903                         'priority' => 40,
    4904                 ) );
     4930                if ( !current_theme_supports( 'custom-title-tagline' ) ) {
     4931                        $this->add_control( 'display_header_text', array(
     4932                                'settings' => 'header_textcolor',
     4933                                'label'    => __( 'Display Site Title and Tagline' ),
     4934                                'section'  => 'title_tagline',
     4935                                'type'     => 'checkbox',
     4936                                'priority' => 40,
     4937                        ) );
     4938                }
    49054939
    49064940                $this->add_control( new WP_Customize_Color_Control( $this, 'header_textcolor', array(
    49074941                        'label'   => __( 'Header Text Color' ),
  • src/wp-includes/theme.php

     
    24192419
    24202420                                return false;
    24212421                        }
     2422
     2423                        break;
     2424
     2425                case 'custom-title-tagline':
     2426                        if ( ! is_array( $args ) ) {
     2427                                $args = array(
     2428                                        0 => array(),
     2429                                );
     2430                        }
     2431
     2432                        $defaults = array(
     2433                                'display-title'          => true,
     2434                                'display-tagline'        => true,
     2435                        );
     2436
     2437                        $args[0] = wp_parse_args( array_intersect_key( $args[0], $defaults ), $defaults );
     2438
     2439                        break;
     2440
    24222441        }
    24232442
    24242443        $_wp_theme_features[ $feature ] = $args;