If the setting and controls are added exactly as they appear in class-wp-customize-manager.php
the JQuery script in wp-admin/custom-header.php
will toggle the header text color control properly. The theme_supports
line must be commented out or removed as it is “used to hide a setting if the theme lacks support for a specific feature”.[1]
add_action( 'customize_register', function ( $wp_customize ) {
$wp_customize->add_setting( 'header_textcolor', array(
// 'theme_supports' => array( 'custom-header', 'header-text' ),
'default' => get_theme_support( 'custom-header', 'default-text-color' ),
'sanitize_callback' => array( $wp_customize, '_sanitize_header_textcolor' ),
'sanitize_js_callback' => 'maybe_hash_hex_color',
) );
$wp_customize->add_control( 'display_header_text', array(
'settings' => 'header_textcolor',
'label' => __( 'Display Site Title and Tagline' ),
'section' => 'title_tagline',
'type' => 'checkbox',
'priority' => 40,
) );
$wp_customize->add_control( new WP_Customize_Color_Control( $wp_customize, 'header_textcolor', array(
'label' => __( 'Header Text Color' ),
'section' => 'colors',
) ) );
});