<?php
function islamic_trust_sidebar_setting( $wp_customize ) {
$selective_refresh = isset( $wp_customize->selective_refresh ) ? 'postMessage' : 'refresh';
	$wp_customize->add_panel(
		'islamic_trust_sidebar', array(
			'priority' => 31,
			'title' => esc_html__( 'Sidebar Options', 'islamic-trust' ),
		)
	);

	/*=========================================
	Sidebar Option  Section
	=========================================*/
	$wp_customize->add_section(
		'islamic_trust_sidebar_settings', array(
			'title' => esc_html__( 'Sidebar Options', 'islamic-trust' ),
			'priority' => 1,
			'panel' => 'islamic_trust_general',
		)
	);
	

	// Archive Sidebar Hide/ Show Setting // 
	$wp_customize->add_setting( 
		'islamic_trust_archive_sidebar_setting' , 
			array(
			'default' => '1',
			'sanitize_callback' => 'islamic_trust_sanitize_checkbox',
			'capability' => 'edit_theme_options',
			'priority' => 2,
		) 
	);
	
	$wp_customize->add_control(
	'islamic_trust_archive_sidebar_setting', 
		array(
			'label'	      => esc_html__( 'Hide / Show Archive Sidebar', 'islamic-trust' ),
			'section'     => 'islamic_trust_sidebar_settings',
			'settings'    => 'islamic_trust_archive_sidebar_setting',
			'type'        => 'checkbox'
		) 
	);

	// Index Sidebar Hide/ Show Setting // 
	$wp_customize->add_setting( 
		'islamic_trust_index_sidebar_setting' , 
			array(
			'default' => '1',
			'sanitize_callback' => 'islamic_trust_sanitize_checkbox',
			'capability' => 'edit_theme_options',
			'priority' => 2,
		) 
	);
	
	$wp_customize->add_control(
	'islamic_trust_index_sidebar_setting', 
		array(
			'label'	      => esc_html__( 'Hide / Show Index Sidebar', 'islamic-trust' ),
			'section'     => 'islamic_trust_sidebar_settings',
			'settings'    => 'islamic_trust_index_sidebar_setting',
			'type'        => 'checkbox'
		) 
	);

	// Pages Sidebar Hide/ Show Setting // 
	$wp_customize->add_setting( 
		'islamic_trust_paged_sidebar_setting' , 
			array(
			'default' => '1',
			'sanitize_callback' => 'islamic_trust_sanitize_checkbox',
			'capability' => 'edit_theme_options',
			'priority' => 2,
		) 
	);
	
	$wp_customize->add_control(
	'islamic_trust_paged_sidebar_setting', 
		array(
			'label'	      => esc_html__( 'Hide / Show Pages Sidebar', 'islamic-trust' ),
			'section'     => 'islamic_trust_sidebar_settings',
			'settings'    => 'islamic_trust_paged_sidebar_setting',
			'type'        => 'checkbox'
		) 
	);

	// Search Result Sidebar Hide/ Show Setting // 
	$wp_customize->add_setting( 
		'islamic_trust_search_result_sidebar_setting' , 
			array(
			'default' => '1',
			'sanitize_callback' => 'islamic_trust_sanitize_checkbox',
			'capability' => 'edit_theme_options',
			'priority' => 2,
		) 
	);
	
	$wp_customize->add_control(
	'islamic_trust_search_result_sidebar_setting', 
		array(
			'label'	      => esc_html__( 'Hide / Show Search Result Sidebar', 'islamic-trust' ),
			'section'     => 'islamic_trust_sidebar_settings',
			'settings'    => 'islamic_trust_search_result_sidebar_setting',
			'type'        => 'checkbox'
		) 
	);

	// Single Post Sidebar Hide/ Show Setting // 
	$wp_customize->add_setting( 
		'islamic_trust_single_post_sidebar_setting' , 
			array(
			'default' => '1',
			'sanitize_callback' => 'islamic_trust_sanitize_checkbox',
			'capability' => 'edit_theme_options',
			'priority' => 2,
		) 
	);
	
	$wp_customize->add_control(
	'islamic_trust_single_post_sidebar_setting', 
		array(
			'label'	      => esc_html__( 'Hide / Show Single Post Sidebar', 'islamic-trust' ),
			'section'     => 'islamic_trust_sidebar_settings',
			'settings'    => 'islamic_trust_single_post_sidebar_setting',
			'type'        => 'checkbox'
		) 
	);

	// Sidebar Page Sidebar Date Hide/ Show Setting // 
	$wp_customize->add_setting( 
		'islamic_trust_single_page_sidebar_setting' , 
			array(
			'default' => '1',
			'sanitize_callback' => 'islamic_trust_sanitize_checkbox',
			'capability' => 'edit_theme_options',
			'priority' => 2,
		) 
	);
	
	$wp_customize->add_control(
	'islamic_trust_single_page_sidebar_setting', 
		array(
			'label'	      => esc_html__( 'Hide / Show Page Width Sidebar', 'islamic-trust' ),
			'section'     => 'islamic_trust_sidebar_settings',
			'settings'    => 'islamic_trust_single_page_sidebar_setting',
			'type'        => 'checkbox'
		) 
	);

	$wp_customize->add_setting( 'islamic_trust_sidebar_position', array(
        'default'   => 'right',
        'sanitize_callback' => 'islamic_trust_sanitize_sidebar_position',
    ));

    $wp_customize->add_control( 'islamic_trust_sidebar_position', array(
        'label'    => __( 'Sidebar Position', 'islamic-trust' ),
        'section'  => 'islamic_trust_sidebar_settings',
        'settings' => 'islamic_trust_sidebar_position',
        'type'     => 'radio',
        'choices'  => array(
            'right' => __( 'Right Sidebar', 'islamic-trust' ),
            'left'  => __( 'Left Sidebar', 'islamic-trust' ),
        ),
    ));

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

add_action( 'customize_register', 'islamic_trust_sidebar_setting' );