<?php
function expert_gamer_sidebar_setting( $wp_customize ) {
$selective_refresh = isset( $wp_customize->selective_refresh ) ? 'postMessage' : 'refresh';
	$wp_customize->add_panel(
		'expert_gamer_sidebar', array(
			'priority' => 31,
			'title' => esc_html__( 'Sidebar Options', 'expert-gamer' ),
		)
	);

	/*=========================================
	Sidebar Option  Section
	=========================================*/
	$wp_customize->add_section(
		'expert_gamer_sidebar_settings', array(
			'title' => esc_html__( 'Sidebar Options', 'expert-gamer' ),
			'priority' => 1,
			'panel' => 'expert_gamer_general',
		)
	);
	

	// Archive Sidebar Hide/ Show Setting // 
	$wp_customize->add_setting( 
		'expert_gamer_archive_sidebar_setting' , 
			array(
			'default' => '1',
			'sanitize_callback' => 'expert_gamer_sanitize_checkbox',
			'capability' => 'edit_theme_options',
			'priority' => 2,
		) 
	);
	
	$wp_customize->add_control(
	'expert_gamer_archive_sidebar_setting', 
		array(
			'label'	      => esc_html__( 'Hide / Show Archive Sidebar', 'expert-gamer' ),
			'section'     => 'expert_gamer_sidebar_settings',
			'settings'    => 'expert_gamer_archive_sidebar_setting',
			'type'        => 'checkbox'
		) 
	);

	// Index Sidebar Hide/ Show Setting // 
	$wp_customize->add_setting( 
		'expert_gamer_index_sidebar_setting' , 
			array(
			'default' => '1',
			'sanitize_callback' => 'expert_gamer_sanitize_checkbox',
			'capability' => 'edit_theme_options',
			'priority' => 2,
		) 
	);
	
	$wp_customize->add_control(
	'expert_gamer_index_sidebar_setting', 
		array(
			'label'	      => esc_html__( 'Hide / Show Index Sidebar', 'expert-gamer' ),
			'section'     => 'expert_gamer_sidebar_settings',
			'settings'    => 'expert_gamer_index_sidebar_setting',
			'type'        => 'checkbox'
		) 
	);

	// Pages Sidebar Hide/ Show Setting // 
	$wp_customize->add_setting( 
		'expert_gamer_paged_sidebar_setting' , 
			array(
			'default' => '1',
			'sanitize_callback' => 'expert_gamer_sanitize_checkbox',
			'capability' => 'edit_theme_options',
			'priority' => 2,
		) 
	);
	
	$wp_customize->add_control(
	'expert_gamer_paged_sidebar_setting', 
		array(
			'label'	      => esc_html__( 'Hide / Show Pages Sidebar', 'expert-gamer' ),
			'section'     => 'expert_gamer_sidebar_settings',
			'settings'    => 'expert_gamer_paged_sidebar_setting',
			'type'        => 'checkbox'
		) 
	);

	// Search Result Sidebar Hide/ Show Setting // 
	$wp_customize->add_setting( 
		'expert_gamer_search_result_sidebar_setting' , 
			array(
			'default' => '1',
			'sanitize_callback' => 'expert_gamer_sanitize_checkbox',
			'capability' => 'edit_theme_options',
			'priority' => 2,
		) 
	);
	
	$wp_customize->add_control(
	'expert_gamer_search_result_sidebar_setting', 
		array(
			'label'	      => esc_html__( 'Hide / Show Search Result Sidebar', 'expert-gamer' ),
			'section'     => 'expert_gamer_sidebar_settings',
			'settings'    => 'expert_gamer_search_result_sidebar_setting',
			'type'        => 'checkbox'
		) 
	);

	// Single Post Sidebar Hide/ Show Setting // 
	$wp_customize->add_setting( 
		'expert_gamer_single_post_sidebar_setting' , 
			array(
			'default' => '1',
			'sanitize_callback' => 'expert_gamer_sanitize_checkbox',
			'capability' => 'edit_theme_options',
			'priority' => 2,
		) 
	);
	
	$wp_customize->add_control(
	'expert_gamer_single_post_sidebar_setting', 
		array(
			'label'	      => esc_html__( 'Hide / Show Single Post Sidebar', 'expert-gamer' ),
			'section'     => 'expert_gamer_sidebar_settings',
			'settings'    => 'expert_gamer_single_post_sidebar_setting',
			'type'        => 'checkbox'
		) 
	);

	// Sidebar Page Sidebar Date Hide/ Show Setting // 
	$wp_customize->add_setting( 
		'expert_gamer_single_page_sidebar_setting' , 
			array(
			'default' => '1',
			'sanitize_callback' => 'expert_gamer_sanitize_checkbox',
			'capability' => 'edit_theme_options',
			'priority' => 2,
		) 
	);
	
	$wp_customize->add_control(
	'expert_gamer_single_page_sidebar_setting', 
		array(
			'label'	      => esc_html__( 'Hide / Show Page Width Sidebar', 'expert-gamer' ),
			'section'     => 'expert_gamer_sidebar_settings',
			'settings'    => 'expert_gamer_single_page_sidebar_setting',
			'type'        => 'checkbox'
		) 
	);

	$wp_customize->add_setting( 'expert_gamer_sidebar_position', array(
        'default'   => 'right',
        'sanitize_callback' => 'expert_gamer_sanitize_sidebar_position',
    ));

    $wp_customize->add_control( 'expert_gamer_sidebar_position', array(
        'label'    => __( 'Sidebar Position', 'expert-gamer' ),
        'section'  => 'expert_gamer_sidebar_settings',
        'settings' => 'expert_gamer_sidebar_position',
        'type'     => 'radio',
        'choices'  => array(
            'right' => __( 'Right Sidebar', 'expert-gamer' ),
            'left'  => __( 'Left Sidebar', 'expert-gamer' ),
        ),
    ));

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

add_action( 'customize_register', 'expert_gamer_sidebar_setting' );