Make WordPress Core

Ticket #37516: poc-37516.diff

File poc-37516.diff, 5.3 KB (added by tellyworth, 7 years ago)
  • src/wp-includes/class-wp-customize-manager.php

     
    37573757                        'section'    => 'title_tagline',
    37583758                ) );
    37593759
     3760                $this->add_setting( 'header_text_title', array(
     3761                        'default'    => get_option( 'header_text_title' ) || get_option( 'blogname' ),
     3762                        'type'       => 'option',
     3763                        'capability' => 'manage_options',
     3764                ) );
     3765
     3766                $this->add_control( 'header_text_title', array(
     3767                        'label'    => __( 'Display Site Title' ),
     3768                        'section'  => 'title_tagline',
     3769                        'settings' => 'header_text_title',
     3770                        'type'     => 'checkbox',
     3771                ) );
     3772
    37603773                $this->add_setting( 'blogdescription', array(
    37613774                        'default'    => get_option( 'blogdescription' ),
    37623775                        'type'       => 'option',
     
    37683781                        'section'    => 'title_tagline',
    37693782                ) );
    37703783
     3784                $this->add_setting( 'header_text_tagline', array(
     3785                        'default'    => get_option( 'header_text_tagline' ) || get_option( 'blogdescrption' ),
     3786                        'type'       => 'option',
     3787                        'capability' => 'manage_options',
     3788                ) );
     3789
     3790                $this->add_control( 'header_text_tagline', array(
     3791                        'label'    => __( 'Display Site Tagline' ),
     3792                        'section'  => 'title_tagline',
     3793                        'settings' => 'header_text_tagline',
     3794                        'type'     => 'checkbox',
     3795                ) );
     3796
    37713797                // Add a setting to hide header text if the theme doesn't support custom headers.
    37723798                if ( ! current_theme_supports( 'custom-header', 'header-text' ) ) {
    3773                         $this->add_setting( 'header_text', array(
    3774                                 'theme_supports'    => array( 'custom-logo', 'header-text' ),
    3775                                 'default'           => 1,
    3776                                 'sanitize_callback' => 'absint',
     3799
     3800                        $this->add_setting( 'header_text_title', array(
     3801                                'default'    => get_option( 'header_text_title' ) || get_option( 'blogname' ),
     3802                                //'type'       => 'option',
     3803                                //'capability' => 'manage_options',
     3804                                        'theme_supports'    => array( 'custom-logo', 'header-text' ),
     3805                                        'sanitize_callback' => 'absint',
     3806
    37773807                        ) );
    37783808
    3779                         $this->add_control( 'header_text', array(
    3780                                 'label'    => __( 'Display Site Title and Tagline' ),
     3809                        $this->add_control( 'header_text_title', array(
     3810                                'label'    => __( 'Display Site Title' ),
    37813811                                'section'  => 'title_tagline',
    3782                                 'settings' => 'header_text',
     3812                                'settings' => 'header_text_title',
    37833813                                'type'     => 'checkbox',
    37843814                        ) );
     3815
     3816                        $this->add_setting( 'header_text_tagline', array(
     3817                                'default'    => get_option( 'header_text_tagline' ) || get_option( 'blogname' ),
     3818                                //'type'       => 'option',
     3819                                //'capability' => 'manage_options',
     3820                                        'theme_supports'    => array( 'custom-logo', 'header-text' ),
     3821                                        'sanitize_callback' => 'absint',
     3822
     3823                        ) );
     3824
     3825                        $this->add_control( 'header_text_tagline', array(
     3826                                'label'    => __( 'Display Site Tagline' ),
     3827                                'section'  => 'title_tagline',
     3828                                'settings' => 'header_text_tagline',
     3829                                'type'     => 'checkbox',
     3830                        ) );
     3831
    37853832                }
    37863833
    37873834                $this->add_setting( 'site_icon', array(
     
    38503897                        'sanitize_js_callback' => 'maybe_hash_hex_color',
    38513898                ) );
    38523899
    3853                 // Input type: checkbox
    3854                 // With custom value
    3855                 $this->add_control( 'display_header_text', array(
    3856                         'settings' => 'header_textcolor',
    3857                         'label'    => __( 'Display Site Title and Tagline' ),
    3858                         'section'  => 'title_tagline',
    3859                         'type'     => 'checkbox',
    3860                         'priority' => 40,
    3861                 ) );
    3862 
    38633900                $this->add_control( new WP_Customize_Color_Control( $this, 'header_textcolor', array(
    38643901                        'label'   => __( 'Header Text Color' ),
    38653902                        'section' => 'colors',
  • src/wp-includes/general-template.php

     
    38443844
    38453845        return $settings;
    38463846}
     3847
     3848/**
     3849 * TEMPORARY - this needs a better solution
     3850 * Used to demonstrate https://core.trac.wordpress.org/ticket/37516 only
     3851 * apply_filters( 'bloginfo', $output, $show );
     3852 */
     3853function filter_bloginfo_header_text( $output, $show ) {
     3854        if ( 'name' === $show )
     3855                return ( get_option( 'header_text_title') ? $output : '' );
     3856        elseif ( 'description' === $show )
     3857                return ( get_option( 'header_text_tagline' ) ? $output : '' );
     3858
     3859
     3860        return $output;
     3861}
     3862
     3863function add_filter_bloginfo_header_text( $header_name ) {
     3864        add_filter( 'bloginfo', 'filter_bloginfo_header_text', 10, 2 );
     3865}
     3866
     3867add_action( 'get_header', 'add_filter_bloginfo_header_text' );
     3868
     3869function filter_register_blogname_partials( WP_Customize_Manager $wp_customize ) {
     3870
     3871    if ( ! isset( $wp_customize->selective_refresh ) ) {
     3872        return;
     3873    }
     3874
     3875    $wp_customize->selective_refresh->add_partial( 'header_text_title', array(
     3876        'selector' => '.site-title a',
     3877        'settings' => array( 'blogname', 'header_text_title' ),
     3878        'render_callback' => function() {
     3879            return filter_bloginfo_header_text( bloginfo( 'name', 'display' ), 'name' );
     3880        },
     3881    ) );
     3882
     3883    $wp_customize->selective_refresh->add_partial( 'header_text_tagline', array(
     3884        'selector' => '.site-description',
     3885        'settings' => array( 'blogdescription', 'header_text_tagline' ),
     3886        'render_callback' => function() {
     3887                return filter_bloginfo_header_text( bloginfo( 'description', 'display' ), 'description' );
     3888        }
     3889    ) );
     3890}
     3891add_action( 'customize_register', 'filter_register_blogname_partials' );
     3892 No newline at end of file