Ticket #37516: poc-37516.2.diff
File poc-37516.2.diff, 5.5 KB (added by , 8 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 'transport' => 'postMessage', 3765 'sanitize_callback' => 'absint', 3766 3767 3768 ) ); 3769 3770 $this->add_control( 'header_text_title', array( 3771 'label' => __( 'Display Site Title' ), 3772 'section' => 'title_tagline', 3773 'settings' => 'header_text_title', 3774 'type' => 'checkbox', 3775 ) ); 3776 3760 3777 $this->add_setting( 'blogdescription', array( 3761 3778 'default' => get_option( 'blogdescription' ), 3762 3779 'type' => 'option', … … 3768 3785 'section' => 'title_tagline', 3769 3786 ) ); 3770 3787 3788 $this->add_setting( 'header_text_tagline', array( 3789 'default' => get_option( 'header_text_tagline' ) || get_option( 'blogdescrption' ), 3790 'type' => 'option', 3791 'capability' => 'manage_options', 3792 'transport' => 'postMessage', 3793 'sanitize_callback' => 'absint', 3794 ) ); 3795 3796 $this->add_control( 'header_text_tagline', array( 3797 'label' => __( 'Display Site Tagline' ), 3798 'section' => 'title_tagline', 3799 'settings' => 'header_text_tagline', 3800 'type' => 'checkbox', 3801 ) ); 3802 3771 3803 // Add a setting to hide header text if the theme doesn't support custom headers. 3772 3804 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', 3805 3806 $this->add_setting( 'header_text_title', array( 3807 'default' => get_option( 'header_text_title' ) || get_option( 'blogname' ), 3808 //'type' => 'option', 3809 //'capability' => 'manage_options', 3810 'theme_supports' => array( 'custom-logo', 'header-text' ), 3811 'sanitize_callback' => 'absint', 3812 3813 ) ); 3814 3815 $this->add_control( 'header_text_title', array( 3816 'label' => __( 'Display Site Title' ), 3817 'section' => 'title_tagline', 3818 'settings' => 'header_text_title', 3819 'type' => 'checkbox', 3777 3820 ) ); 3778 3821 3779 $this->add_control( 'header_text', array( 3780 'label' => __( 'Display Site Title and Tagline' ), 3822 $this->add_setting( 'header_text_tagline', array( 3823 'default' => get_option( 'header_text_tagline' ) || get_option( 'blogname' ), 3824 //'type' => 'option', 3825 //'capability' => 'manage_options', 3826 'theme_supports' => array( 'custom-logo', 'header-text' ), 3827 'sanitize_callback' => 'absint', 3828 3829 ) ); 3830 3831 $this->add_control( 'header_text_tagline', array( 3832 'label' => __( 'Display Site Tagline' ), 3781 3833 'section' => 'title_tagline', 3782 'settings' => 'header_text ',3834 'settings' => 'header_text_tagline', 3783 3835 'type' => 'checkbox', 3784 3836 ) ); 3837 3785 3838 } 3786 3839 3787 3840 $this->add_setting( 'site_icon', array( … … 3850 3903 'sanitize_js_callback' => 'maybe_hash_hex_color', 3851 3904 ) ); 3852 3905 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 3906 $this->add_control( new WP_Customize_Color_Control( $this, 'header_textcolor', array( 3864 3907 'label' => __( 'Header Text Color' ), 3865 3908 '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( get_bloginfo( 'name' ), '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( get_bloginfo( 'description' ), 'description' ); 3888 } 3889 ) ); 3890 } 3891 add_action( 'customize_register', 'filter_register_blogname_partials' ); 3892 No newline at end of file