Ticket #37516: poc-37516.diff
File poc-37516.diff, 5.3 KB (added by , 7 years ago) |
---|
-
src/wp-includes/class-wp-customize-manager.php
3757 3757 'section' => 'title_tagline', 3758 3758 ) ); 3759 3759 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 3760 3773 $this->add_setting( 'blogdescription', array( 3761 3774 'default' => get_option( 'blogdescription' ), 3762 3775 'type' => 'option', … … 3768 3781 'section' => 'title_tagline', 3769 3782 ) ); 3770 3783 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 3771 3797 // Add a setting to hide header text if the theme doesn't support custom headers. 3772 3798 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 3777 3807 ) ); 3778 3808 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' ), 3781 3811 'section' => 'title_tagline', 3782 'settings' => 'header_text ',3812 'settings' => 'header_text_title', 3783 3813 'type' => 'checkbox', 3784 3814 ) ); 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 3785 3832 } 3786 3833 3787 3834 $this->add_setting( 'site_icon', array( … … 3850 3897 'sanitize_js_callback' => 'maybe_hash_hex_color', 3851 3898 ) ); 3852 3899 3853 // Input type: checkbox3854 // With custom value3855 $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 3863 3900 $this->add_control( new WP_Customize_Color_Control( $this, 'header_textcolor', array( 3864 3901 'label' => __( 'Header Text Color' ), 3865 3902 'section' => 'colors', -
src/wp-includes/general-template.php
3844 3844 3845 3845 return $settings; 3846 3846 } 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 */ 3853 function 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 3863 function add_filter_bloginfo_header_text( $header_name ) { 3864 add_filter( 'bloginfo', 'filter_bloginfo_header_text', 10, 2 ); 3865 } 3866 3867 add_action( 'get_header', 'add_filter_bloginfo_header_text' ); 3868 3869 function 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 } 3891 add_action( 'customize_register', 'filter_register_blogname_partials' ); 3892 No newline at end of file