<?php
/**
 * Blog Options
 *
 * @package bootstrap-coach
 */


add_action( 'customize_register', 'bootstrap_coach_customize_sidebar' );

function bootstrap_coach_customize_sidebar( $wp_customize ) {

  $wp_customize->add_section( 'bootstrap_coach_sidebar_options', array(
    'title'          => esc_attr__( 'Sidebar', 'bootstrap-coach' ),
    'panel'          => 'bootstrap_coach_general_panel',
    'priority'       => 3,
    'capability'     => 'edit_theme_options',
  ) );

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

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

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

  $wp_customize->add_control( new Bootstrap_Coach_Separator_Control(
    $wp_customize, 'bootstrap_coach_sidebar_options_separator1', array(
      'section' => 'bootstrap_coach_sidebar_options',
    )
  ) );

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

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

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

  $wp_customize->add_control( new Bootstrap_Coach_Separator_Control(
    $wp_customize, 'bootstrap_coach_sidebar_options_separator2', array(
      'section' => 'bootstrap_coach_sidebar_options',
    )
  ) );

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

  $wp_customize->add_control( new Bootstrap_Coach_Radio_Buttonset_Control(
    $wp_customize, 'bootstrap_coach_blog_layout', array(
    'label' => esc_html__( 'Blog Sidebar Layout', 'bootstrap-coach' ),
    'description' => esc_html__('This is special sidebar layout for the blog page.', 'bootstrap-coach'),
    'section' => 'bootstrap_coach_sidebar_options',
    'settings' => 'bootstrap_coach_blog_layout',
    'type'=> 'radio-buttonset',
    'choices'     => array(
      'left-sidebar' => esc_html__( 'Sidebar at left', 'bootstrap-coach' ),
      'right-sidebar' => esc_html__( 'Sidebar at right', 'bootstrap-coach' ), 
      'no-sidebar'    =>  esc_html__( 'No sidebar', 'bootstrap-coach' )     
    ),
  ) ) );

}