Made a bit of progress but something’s not quite right. I managed to locate the functions in the original theme’s functions file. I also found that it linked to a customize.php file in the ‘inc’ folder. I added some details in and it worked, but I thought it better to move these into the child theme functions.php file. So I basically copied out those functions from functions.php and customize.php into my own functions.php, added ‘child’ to the function names (and anywhere else I saw the name). Now it shows as an option in the customize panel, but changing the colour does nothing.
I’ll be honest, I have pretty much no idea what any of these things mean below…but it seems I’ve missed something between copying it from the parent functions to the child functions… Any ideas?
function ruffie_child_curtomize_register( $wp_customize ){
// Header background color
$wp_customize->add_setting( 'header_background_color', array(
'default' => '#fffff',
'sanitize_callback' => 'sanitize_hex_color'
) );
$wp_customize->add_control( new WP_Customize_Color_Control( $wp_customize, 'header_background_color', array(
'label' => __( 'Header Background Color', 'ruffie' ),
'section' => 'colors',
'settings' => 'header_background_color',
) ) );
}
add_action('customize_register', 'ruffie_child_curtomize_register');
function ruffie_child_sanitize_checkbox( $input ) {
// Boolean check
return ( ( isset( $input ) && true == $input ) ? true : false );
}
function ruffie_child_customize_styles(){
$options = [
esc_attr( get_theme_mod('header_background_color', '#ffffff') )
];
$css = '
*,
.site-header-wrapper{
background-color: %1$s;
}
';
wp_add_inline_style( 'ruffie-child-style', vsprintf($css, $options) );
}
add_action( 'wp_enqueue_scripts', 'ruffie_child_customize_styles' );