<?php
/**
 * Sidebar Options
 *
 * @package chic-lifestyle
 */


add_action( 'customize_register', 'chic_lifestyle_customize_sidebar' );

function chic_lifestyle_customize_sidebar( $wp_customize ) {

  $wp_customize->add_section( 'chic_lifestyle_sidebar_options', array(
    'title'          => esc_attr__( 'Sidebar', 'chic-lifestyle' ),
    'panel'          => 'chic_lifestyle_general_panel',
    'priority'       => 4,
    'capability'     => 'edit_theme_options',
  ) );

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

  $wp_customize->add_control( new Chic_Lifestyle_Radio_Buttonset_Control(
    $wp_customize, 'chic_lifestyle_page_layout', array(
    'label' => esc_html__( 'Page Sidebar Layout', 'chic-lifestyle' ),
    '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.', 'chic-lifestyle'),
    'section' => 'chic_lifestyle_sidebar_options',
    'settings' => 'chic_lifestyle_page_layout',
    'type'=> 'radio-buttonset',
    'choices'     => array(
      'left-sidebar' => esc_html__( 'Sidebar at left', 'chic-lifestyle' ),
      'right-sidebar' => esc_html__( 'Sidebar at right', 'chic-lifestyle' ), 
      'no-sidebar'    =>  esc_html__( 'No sidebar', 'chic-lifestyle' )     
    ),
  ) ) );

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

  $wp_customize->add_control( new Chic_Lifestyle_Separator_Control(
    $wp_customize, 'chic_lifestyle_sidebar_options_separator1', array(
      'section' => 'chic_lifestyle_sidebar_options',
    )
  ) );

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

  $wp_customize->add_control( new Chic_Lifestyle_Radio_Buttonset_Control(
    $wp_customize, 'chic_lifestyle_post_layout', array(
    'label' => esc_html__( 'Post Sidebar Layout', 'chic-lifestyle' ),
    '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.', 'chic-lifestyle'),
    'section' => 'chic_lifestyle_sidebar_options',
    'settings' => 'chic_lifestyle_post_layout',
    'type'=> 'radio-buttonset',
    'choices'     => array(
      'left-sidebar' => esc_html__( 'Sidebar at left', 'chic-lifestyle' ),
      'right-sidebar' => esc_html__( 'Sidebar at right', 'chic-lifestyle' ), 
      'no-sidebar'    =>  esc_html__( 'No sidebar', 'chic-lifestyle' )     
    ),
  ) ) );

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

  $wp_customize->add_control( new Chic_Lifestyle_Separator_Control(
    $wp_customize, 'chic_lifestyle_sidebar_options_separator2', array(
      'section' => 'chic_lifestyle_sidebar_options',
    )
  ) );

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

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

}