Add Options to customizer.php using child theme
-
I’m modifying some ‘skin’ (color) settings in a wordpress theme which are in the themes customizer.php
I simply want to add colors
The themes customizer.php section, settings and controls look like this:
//Select the Default Theme Skin $wp_customize->add_section( 'forest_skin_options', array( 'title' => __('Choose Skin','forest'), 'priority' => 39, ) ); $wp_customize->add_setting( 'forest_skin', array( 'default'=> 'default', 'sanitize_callback' => 'forest_sanitize_skin' ) ); $skins = array( 'default' => __('Default(blue)','forest'), 'orange' => __('Orange','forest'), 'green' => __('Green','forest'), ); $wp_customize->add_control( 'forest_skin',array( 'settings' => 'forest_skin', 'section' => 'forest_skin_options', 'type' => 'select', 'choices' => $skins, ) ); function forest_sanitize_skin( $input ) { if ( in_array($input, array('default','orange','brown','green','grayscale') ) ) return $input; else return ''; }I could simply change it to this to add colors:
//Select the Default Theme Skin $wp_customize->add_section( 'forest_skin_options', array( 'title' => __('Choose Skin','forest'), 'priority' => 39, ) ); $wp_customize->add_setting( 'forest_skin', array( 'default'=> 'default', 'sanitize_callback' => 'forest_sanitize_skin' ) ); $skins = array( 'default' => __('Default(blue)','forest'), 'orange' => __('Orange','forest'), 'green' => __('Green','forest'), 'red' => __('red','forest'), 'yellow' => __('yellow','forest'), 'purple' => __('purple','forest'), ); $wp_customize->add_control( 'forest_skin',array( 'settings' => 'forest_skin', 'section' => 'forest_skin_options', 'type' => 'select', 'choices' => $skins, ) ); function forest_sanitize_skin( $input ) { if ( in_array($input, array('default','orange','brown','green','grayscale', 'red', 'yellow', 'purple') ) ) return $input; else return ''; }However, because of the theme updates, I need to add these options to the child theme which I’m having trouble doing.
I’m using the functions.php to call the new customizer.php in my child theme which is working fine but what should I put in my new child customizer.php to add these color options?
The topic ‘Add Options to customizer.php using child theme’ is closed to new replies.