<?php
function film_studio_sidebar_setting( $wp_customize ) {
$selective_refresh = isset( $wp_customize->selective_refresh ) ? 'postMessage' : 'refresh';
	$wp_customize->add_panel(
		'film_studio_sidebar', array(
			'priority' => 31,
			'title' => esc_html__( 'Sidebar Options', 'film-studio' ),
		)
	);

	/*=========================================
	Sidebar Option  Section
	=========================================*/
	$wp_customize->add_section(
		'film_studio_sidebar_settings', array(
			'title' => esc_html__( 'Sidebar Options', 'film-studio' ),
			'priority' => 1,
			'panel' => 'film_studio_general',
		)
	);
	

	// Archive Sidebar Hide/ Show Setting // 
	$wp_customize->add_setting( 
		'film_studio_archive_sidebar_setting' , 
			array(
			'default' => '1',
			'sanitize_callback' => 'film_studio_sanitize_checkbox',
			'capability' => 'edit_theme_options',
			'priority' => 2,
		) 
	);
	
	$wp_customize->add_control(
	'film_studio_archive_sidebar_setting', 
		array(
			'label'	      => esc_html__( 'Hide / Show Archive Sidebar', 'film-studio' ),
			'section'     => 'film_studio_sidebar_settings',
			'settings'    => 'film_studio_archive_sidebar_setting',
			'type'        => 'checkbox'
		) 
	);

	// Index Sidebar Hide/ Show Setting // 
	$wp_customize->add_setting( 
		'film_studio_index_sidebar_setting' , 
			array(
			'default' => '1',
			'sanitize_callback' => 'film_studio_sanitize_checkbox',
			'capability' => 'edit_theme_options',
			'priority' => 2,
		) 
	);
	
	$wp_customize->add_control(
	'film_studio_index_sidebar_setting', 
		array(
			'label'	      => esc_html__( 'Hide / Show Index Sidebar', 'film-studio' ),
			'section'     => 'film_studio_sidebar_settings',
			'settings'    => 'film_studio_index_sidebar_setting',
			'type'        => 'checkbox'
		) 
	);

	// Pages Sidebar Hide/ Show Setting // 
	$wp_customize->add_setting( 
		'film_studio_paged_sidebar_setting' , 
			array(
			'default' => '1',
			'sanitize_callback' => 'film_studio_sanitize_checkbox',
			'capability' => 'edit_theme_options',
			'priority' => 2,
		) 
	);
	
	$wp_customize->add_control(
	'film_studio_paged_sidebar_setting', 
		array(
			'label'	      => esc_html__( 'Hide / Show Pages Sidebar', 'film-studio' ),
			'section'     => 'film_studio_sidebar_settings',
			'settings'    => 'film_studio_paged_sidebar_setting',
			'type'        => 'checkbox'
		) 
	);

	// Search Result Sidebar Hide/ Show Setting // 
	$wp_customize->add_setting( 
		'film_studio_search_result_sidebar_setting' , 
			array(
			'default' => '1',
			'sanitize_callback' => 'film_studio_sanitize_checkbox',
			'capability' => 'edit_theme_options',
			'priority' => 2,
		) 
	);
	
	$wp_customize->add_control(
	'film_studio_search_result_sidebar_setting', 
		array(
			'label'	      => esc_html__( 'Hide / Show Search Result Sidebar', 'film-studio' ),
			'section'     => 'film_studio_sidebar_settings',
			'settings'    => 'film_studio_search_result_sidebar_setting',
			'type'        => 'checkbox'
		) 
	);

	// Single Post Sidebar Hide/ Show Setting // 
	$wp_customize->add_setting( 
		'film_studio_single_post_sidebar_setting' , 
			array(
			'default' => '1',
			'sanitize_callback' => 'film_studio_sanitize_checkbox',
			'capability' => 'edit_theme_options',
			'priority' => 2,
		) 
	);
	
	$wp_customize->add_control(
	'film_studio_single_post_sidebar_setting', 
		array(
			'label'	      => esc_html__( 'Hide / Show Single Post Sidebar', 'film-studio' ),
			'section'     => 'film_studio_sidebar_settings',
			'settings'    => 'film_studio_single_post_sidebar_setting',
			'type'        => 'checkbox'
		) 
	);

	// Sidebar Page Sidebar Date Hide/ Show Setting // 
	$wp_customize->add_setting( 
		'film_studio_single_page_sidebar_setting' , 
			array(
			'default' => '1',
			'sanitize_callback' => 'film_studio_sanitize_checkbox',
			'capability' => 'edit_theme_options',
			'priority' => 2,
		) 
	);
	
	$wp_customize->add_control(
	'film_studio_single_page_sidebar_setting', 
		array(
			'label'	      => esc_html__( 'Hide / Show Page Width Sidebar', 'film-studio' ),
			'section'     => 'film_studio_sidebar_settings',
			'settings'    => 'film_studio_single_page_sidebar_setting',
			'type'        => 'checkbox'
		) 
	);

	$wp_customize->add_setting( 'film_studio_sidebar_position', array(
        'default'   => 'right',
        'sanitize_callback' => 'film_studio_sanitize_sidebar_position',
    ));

    $wp_customize->add_control( 'film_studio_sidebar_position', array(
        'label'    => __( 'Sidebar Position', 'film-studio' ),
        'section'  => 'film_studio_sidebar_settings',
        'settings' => 'film_studio_sidebar_position',
        'type'     => 'radio',
        'choices'  => array(
            'right' => __( 'Right Sidebar', 'film-studio' ),
            'left'  => __( 'Left Sidebar', 'film-studio' ),
        ),
    ));

	 $wp_customize->add_setting( 'film_studio_upgrade_page_settings_15',
        array(
            'sanitize_callback' => 'sanitize_text_field'
        )
    );
    $wp_customize->add_control( new Film_Studio_Control_Upgrade(
        $wp_customize, 'film_studio_upgrade_page_settings_15',
            array(
                'priority'      => 200,
                'section'       => 'film_studio_sidebar_settings',
                'settings'      => 'film_studio_upgrade_page_settings_15',
                'label'         => __( 'Film Studio Pro comes with additional features.', 'film-studio' ),
                'choices'       => array( __( '15+ Ready-Made Sections', 'film-studio' ), __( 'One-Click Demo Import', 'film-studio' ), __( 'WooCommerce Integrated', 'film-studio' ), __( 'Drag & Drop Section Reordering', 'film-studio' ),__( 'Advanced Typography Control', 'film-studio' ),__( 'Intuitive Customization Options', 'film-studio' ),__( '24/7 Support', 'film-studio' ), )
            )
        )
    ); 
}

add_action( 'customize_register', 'film_studio_sidebar_setting' );