When you enables Custom_Headers support for your theme with the following code, a "Display Site Title and Tagline" checkbox on the Site Identity section and a "Header Text Color" control on the Color section will appear:
/**
* Set up the WordPress core custom header feature.
*/
function theme_custom_header_setup() {
add_theme_support( 'custom-header', array(
// Default arguments
) );
}
add_action( 'after_setup_theme', 'theme_custom_header_setup' );
My question is, how can I create another "Display Site Title and Tagline" checkbox, "Header Text Color" setting and control with the same functionalities as listed?
- The color control will deactivate/disappear when the checkbox is unchecked asynchronously, not refresh, and reappear when checked.
- The controls only have 1 setting because when the checkbox is unchecked, the "header_textcolor" setting will turn to have the 'blank' value.
I tried to create 1 setting with 2 controls but doesn't seems to work:
function theme_customize_register( $wp_customize ) {
$wp_customize->add_setting( 'tagline_textcolor', array(
'transport' => 'postMessage',
) );
$wp_customize->add_control( 'tagline_textcolor', array(
'type' => 'checkbox',
'section' => 'title_tagline',
'label' => __( 'Display Tagline Text', 'theme_name' ),
) );
$wp_customize->add_control(
new WP_Customize_Color_Control(
$wp_customize,
'tagline_textcolor',
array(
'label' => __( 'Tagline Text Color', 'theme_name' ),
'section' => 'title_tagline',
)
)
);
}
add_action( 'customize_register', 'theme_customize_register' );
Can you help me with this, or give me a right idea?
WP_Customize_Color_Control()
, only color control is appearing. What I want is the same functionalities as “Display Site Title and Tagline” checkbox, “Header Text Color” setting and control.add_theme_support( 'custom-header' )
(PHP) you will see those controls.. Actually, I already have 2 settings with 2 controls but I want to improve them aswp.customize.instance( 'header_textcolor' ).get()
(JS) functionalities.