add_section( 'layout_options', array( 'title' => esc_html__( 'Layout Options', 'blogwhite' ), 'priority' => 120, 'panel'=>'theme_option', ) ); // Add sidebar $wp_customize->add_setting( 'blog_sidebar_position', array( 'default' => 'right-sidebar', 'sanitize_callback' => 'blogwhite_sanitize_select', ) ); $wp_customize->add_control('blog_sidebar_position',array( 'label' => esc_html__( 'Sidebar Position', 'blogwhite'), 'section' => 'layout_options', 'type' => 'select', 'choices' => array( 'right-sidebar' => esc_html__( 'Right Sidebar', 'blogwhite'), 'no-sidebar' => esc_html__( 'No Sidebar', 'blogwhite'), 'left-sidebar' => esc_html__( 'Left Sidebar', 'blogwhite' ), ), )); // Post Sidebar Position $wp_customize->add_setting( 'post_sidebar_position', array ( 'default' => 'right-sidebar', 'sanitize_callback' => 'blogwhite_sanitize_select', ) ); $wp_customize->add_control('post_sidebar_position',array( 'label' => esc_html__( 'Post Sidebar Position', 'blogwhite' ), 'section' => 'layout_options', 'type' => 'select', 'choices' => array( 'right-sidebar' => esc_html__( 'Right Sidebar', 'blogwhite' ), 'left-sidebar' => esc_html__( 'Left Sidebar', 'blogwhite' ), 'no-sidebar' => esc_html__( 'No Sidebar', 'blogwhite' ), ), )); // Page Sidebar Position. $wp_customize->add_setting('page_sidebar_position', array( 'default' => 'right-sidebar', 'sanitize_callback' => 'blogwhite_sanitize_select', )); $wp_customize->add_control('page_sidebar_position',array( 'label' => esc_html__( 'Page Sidebar Position', 'blogwhite' ), 'section' => 'layout_options', 'type' => 'select', 'choices' => array( 'right-sidebar'=> esc_html__( 'Right Sidebar', 'blogwhite' ), 'left-sidebar' => esc_html__( 'Left Sidebar', 'blogwhite' ), 'no-sidebar' => esc_html__( 'No Sidebar', 'blogwhite' ), ), )); } add_action( 'customize_register', 'blogwhite_sidebar_position' ); if ( ! function_exists( 'blogwhite_sanitize_select' ) ) { function blogwhite_sanitize_select( $input, $setting ) { // Ensure input is a slug. $input = sanitize_text_field( $input ); // Get list of choices from the control associated with the setting. $choices = $setting->manager->get_control( $setting->id )->choices; // If the input is a valid key, return it; otherwise, return the default. return ( array_key_exists( $input, $choices ) ? $input : $setting->default ); } }