<?php
/**
 * Sidebar Options
 *
 * @package travel-tour
 */


add_action( 'customize_register', 'travel_tour_customize_sidebar' );

function travel_tour_customize_sidebar( $wp_customize ) {

  $wp_customize->add_section( 'travel_tour_sidebar_options', array(
    'title'          => esc_attr__( 'Sidebar', 'travel-tour' ),
    'panel'          => 'travel_tour_general_panel',
    'priority'       => 3,
    'capability'     => 'edit_theme_options',
  ) );

  $wp_customize->add_setting( 'travel_tour_page_layout', array(
    'capability'  => 'edit_theme_options',        
    'sanitize_callback' => 'travel_tour_sanitize_choices',
    'default'     => 'no-sidebar',
  ) );

  $wp_customize->add_control( new Travel_Tour_Radio_Buttonset_Control(
    $wp_customize, 'travel_tour_page_layout', array(
    'label' => esc_html__( 'Page Sidebar Layout', 'travel-tour' ),
    'description' => esc_html__('The is global sidebar layout for pages. You can override the layout setting for individual pages: Pages -> Edit page -> Page Settings -> Sidebar layout.', 'travel-tour'),
    'section' => 'travel_tour_sidebar_options',
    'settings' => 'travel_tour_page_layout',
    'type'=> 'radio-buttonset',
    'choices'     => array(
      'left-sidebar' => esc_html__( 'Sidebar at left', 'travel-tour' ),
      'right-sidebar' => esc_html__( 'Sidebar at right', 'travel-tour' ), 
      'no-sidebar'    =>  esc_html__( 'No sidebar', 'travel-tour' )     
    ),
  ) ) );

  $wp_customize->add_setting( 'travel_tour_sidebar_options_separator2', array(
    'sanitize_callback' => null,
  ) );

  $wp_customize->add_control( new Travel_Tour_Separator_Control(
    $wp_customize, 'travel_tour_sidebar_options_separator2', array(
      'section' => 'travel_tour_sidebar_options',
    )
  ) );

  $wp_customize->add_setting( 'travel_tour_post_layout', array(
    'capability'  => 'edit_theme_options',        
    'sanitize_callback' => 'travel_tour_sanitize_choices',
    'default'     => 'no-sidebar',
  ) );

  $wp_customize->add_control( new Travel_Tour_Radio_Buttonset_Control(
    $wp_customize, 'travel_tour_post_layout', array(
    'label' => esc_html__( 'Post Sidebar Layout', 'travel-tour' ),
    'description' => esc_html__('The is global sidebar layout for posts. You can override the layout setting for individual posts: Posts -> Edit post -> Post Settings -> Sidebar layout.', 'travel-tour'),
    'section' => 'travel_tour_sidebar_options',
    'settings' => 'travel_tour_post_layout',
    'type'=> 'radio-buttonset',
    'choices'     => array(
      'left-sidebar' => esc_html__( 'Sidebar at left', 'travel-tour' ),
      'right-sidebar' => esc_html__( 'Sidebar at right', 'travel-tour' ), 
      'no-sidebar'    =>  esc_html__( 'No sidebar', 'travel-tour' )     
    ),
  ) ) );


  $wp_customize->add_setting( 'travel_tour_sidebar_options_separator1', array(
    'sanitize_callback' => null,
  ) );

  $wp_customize->add_control( new Travel_Tour_Separator_Control(
    $wp_customize, 'travel_tour_sidebar_options_separator1', array(
      'section' => 'travel_tour_sidebar_options',
    )
  ) );

  $wp_customize->add_setting( 'travel_tour_blog_layout', array(
    'capability'  => 'edit_theme_options',
    'sanitize_callback' => 'travel_tour_sanitize_choices',
    'default'     => 'no-sidebar',
  ) );

  $wp_customize->add_control( new Travel_Tour_Radio_Buttonset_Control(
    $wp_customize, 'travel_tour_blog_layout', array(
    'label' => esc_html__( 'Blog Sidebar Layout', 'travel-tour' ),
    'description' => esc_html__('The is special sidebar layout for the blog page.', 'travel-tour'),
    'section' => 'travel_tour_sidebar_options',
    'settings' => 'travel_tour_blog_layout',
    'type'=> 'radio-buttonset',
    'choices'     => array(
      'left-sidebar' => esc_html__( 'Sidebar at left', 'travel-tour' ),
      'right-sidebar' => esc_html__( 'Sidebar at right', 'travel-tour' ), 
      'no-sidebar'    =>  esc_html__( 'No sidebar', 'travel-tour' )     
    ),
  ) ) );

}