<?php
/**
 * Blog Options
 *
 * @package relax-spa
 */


add_action( 'customize_register', 'relax_spa_customize_sidebar' );

function relax_spa_customize_sidebar( $wp_customize ) {

  $wp_customize->add_section( 'relax_spa_sidebar_options', array(
    'title'          => esc_attr__( 'Sidebar', 'relax-spa' ),
    'panel'          => 'relax_spa_general_panel',
    'priority'       => 3,
    'capability'     => 'edit_theme_options',
  ) );

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

  $wp_customize->add_control( new Relax_Spa_Radio_Buttonset_Control(
    $wp_customize, 'relax_spa_page_layout', array(
    'label' => esc_html__( 'Page Sidebar Layout', 'relax-spa' ),
    '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.', 'relax-spa'),
    'section' => 'relax_spa_sidebar_options',
    'settings' => 'relax_spa_page_layout',
    'type'=> 'radio-buttonset',
    'choices'     => array(
      'left-sidebar' => esc_html__( 'Sidebar at left', 'relax-spa' ),
      'right-sidebar' => esc_html__( 'Sidebar at right', 'relax-spa' ), 
      'no-sidebar'    =>  esc_html__( 'No sidebar', 'relax-spa' )     
    ),
  ) ) );

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

  $wp_customize->add_control( new Relax_Spa_Separator_Control(
    $wp_customize, 'relax_spa_sidebar_options_separator1', array(
      'section' => 'relax_spa_sidebar_options',
    )
  ) );

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

  $wp_customize->add_control( new Relax_Spa_Radio_Buttonset_Control(
    $wp_customize, 'relax_spa_post_layout', array(
    'label' => esc_html__( 'Post Sidebar Layout', 'relax-spa' ),
    '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.', 'relax-spa'),
    'section' => 'relax_spa_sidebar_options',
    'settings' => 'relax_spa_post_layout',
    'type'=> 'radio-buttonset',
    'choices'     => array(
      'left-sidebar' => esc_html__( 'Sidebar at left', 'relax-spa' ),
      'right-sidebar' => esc_html__( 'Sidebar at right', 'relax-spa' ), 
      'no-sidebar'    =>  esc_html__( 'No sidebar', 'relax-spa' )     
    ),
  ) ) );

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

  $wp_customize->add_control( new Relax_Spa_Separator_Control(
    $wp_customize, 'relax_spa_sidebar_options_separator2', array(
      'section' => 'relax_spa_sidebar_options',
    )
  ) );

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

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

}