<?php
function automotive_services_sidebar_setting( $wp_customize ) {
$selective_refresh = isset( $wp_customize->selective_refresh ) ? 'postMessage' : 'refresh';
	$wp_customize->add_panel(
		'automotive_services_sidebar', array(
			'priority' => 31,
			'title' => esc_html__( 'Sidebar Options', 'automotive-services' ),
		)
	);

	/*=========================================
	Archive Post  Section
	=========================================*/
	$wp_customize->add_section(
		'automotive_services_sidebar_settings', array(
			'title' => esc_html__( 'Sidebar Options', 'automotive-services' ),
			'priority' => 1,
			'panel' => 'automotive_services_general',
		)
	);
	
	// Archive Post Settings 
	$wp_customize->add_setting(
		'archive_post_settings'
			,array(
			'capability'     	=> 'edit_theme_options',
			'sanitize_callback' => 'automotive_services_sanitize_text',
			'priority' => 1,
		)
	);

	$wp_customize->add_control(
	'archive_post_settings',
		array(
			'type' => 'hidden',
			'label' => __('All Sidebar Setting','automotive-services'),
			'section' => 'automotive_services_sidebar_settings',
		)
	);
	

	// Archive Sidebar Hide/ Show Setting // 
	$wp_customize->add_setting( 
		'automotive_services_archive_sidebar_setting' , 
			array(
			'default' => '1',
			'sanitize_callback' => 'automotive_services_sanitize_checkbox',
			'capability' => 'edit_theme_options',
			'priority' => 2,
		) 
	);
	
	$wp_customize->add_control(
	'automotive_services_archive_sidebar_setting', 
		array(
			'label'	      => esc_html__( 'Hide / Show Archive Sidebar', 'automotive-services' ),
			'section'     => 'automotive_services_sidebar_settings',
			'settings'    => 'automotive_services_archive_sidebar_setting',
			'type'        => 'checkbox'
		) 
	);

	// Index Sidebar Hide/ Show Setting // 
	$wp_customize->add_setting( 
		'automotive_services_index_sidebar_setting' , 
			array(
			'default' => '1',
			'sanitize_callback' => 'automotive_services_sanitize_checkbox',
			'capability' => 'edit_theme_options',
			'priority' => 2,
		) 
	);
	
	$wp_customize->add_control(
	'automotive_services_index_sidebar_setting', 
		array(
			'label'	      => esc_html__( 'Hide / Show Index Sidebar', 'automotive-services' ),
			'section'     => 'automotive_services_sidebar_settings',
			'settings'    => 'automotive_services_index_sidebar_setting',
			'type'        => 'checkbox'
		) 
	);

	// Pages Sidebar Hide/ Show Setting // 
	$wp_customize->add_setting( 
		'automotive_services_paged_sidebar_setting' , 
			array(
			'default' => '1',
			'sanitize_callback' => 'automotive_services_sanitize_checkbox',
			'capability' => 'edit_theme_options',
			'priority' => 2,
		) 
	);
	
	$wp_customize->add_control(
	'automotive_services_paged_sidebar_setting', 
		array(
			'label'	      => esc_html__( 'Hide / Show Pages Sidebar', 'automotive-services' ),
			'section'     => 'automotive_services_sidebar_settings',
			'settings'    => 'automotive_services_paged_sidebar_setting',
			'type'        => 'checkbox'
		) 
	);

	// Search Result Sidebar Hide/ Show Setting // 
	$wp_customize->add_setting( 
		'automotive_services_search_result_sidebar_setting' , 
			array(
			'default' => '1',
			'sanitize_callback' => 'automotive_services_sanitize_checkbox',
			'capability' => 'edit_theme_options',
			'priority' => 2,
		) 
	);
	
	$wp_customize->add_control(
	'automotive_services_search_result_sidebar_setting', 
		array(
			'label'	      => esc_html__( 'Hide / Show Search Result Sidebar', 'automotive-services' ),
			'section'     => 'automotive_services_sidebar_settings',
			'settings'    => 'automotive_services_search_result_sidebar_setting',
			'type'        => 'checkbox'
		) 
	);

	// Single Post Sidebar Hide/ Show Setting // 
	$wp_customize->add_setting( 
		'automotive_services_single_post_sidebar_setting' , 
			array(
			'default' => '1',
			'sanitize_callback' => 'automotive_services_sanitize_checkbox',
			'capability' => 'edit_theme_options',
			'priority' => 2,
		) 
	);
	
	$wp_customize->add_control(
	'automotive_services_single_post_sidebar_setting', 
		array(
			'label'	      => esc_html__( 'Hide / Show Single Post Sidebar', 'automotive-services' ),
			'section'     => 'automotive_services_sidebar_settings',
			'settings'    => 'automotive_services_single_post_sidebar_setting',
			'type'        => 'checkbox'
		) 
	);

	// Sidebar Page Sidebar Date Hide/ Show Setting // 
	$wp_customize->add_setting( 
		'automotive_services_single_page_sidebar_setting' , 
			array(
			'default' => '1',
			'sanitize_callback' => 'automotive_services_sanitize_checkbox',
			'capability' => 'edit_theme_options',
			'priority' => 2,
		) 
	);
	
	$wp_customize->add_control(
	'automotive_services_single_page_sidebar_setting', 
		array(
			'label'	      => esc_html__( 'Hide / Show Page Width Sidebar', 'automotive-services' ),
			'section'     => 'automotive_services_sidebar_settings',
			'settings'    => 'automotive_services_single_page_sidebar_setting',
			'type'        => 'checkbox'
		) 
	);

	$wp_customize->add_setting( 'automotive_services_sidebar_position', array(
        'default'   => 'right',
        'sanitize_callback' => 'automotive_services_sanitize_sidebar_position',
    ));

    $wp_customize->add_control( 'automotive_services_sidebar_position', array(
        'label'    => __( 'Sidebar Position', 'automotive-services' ),
        'section'  => 'automotive_services_sidebar_settings',
        'settings' => 'automotive_services_sidebar_position',
        'type'     => 'radio',
        'choices'  => array(
            'right' => __( 'Right Sidebar', 'automotive-services' ),
            'left'  => __( 'Left Sidebar', 'automotive-services' ),
        ),
    ));

	$wp_customize->add_setting( 'automotive_services_upgrade_page_settings_15',
	array(
		'sanitize_callback' => 'sanitize_text_field'
		)
	);
	$wp_customize->add_control( new Automotive_Services_Control_Upgrade(
		$wp_customize, 'automotive_services_upgrade_page_settings_15',
			array(
				'priority'      => 200,
				'section'       => 'automotive_services_sidebar_settings',
				'settings'      => 'automotive_services_upgrade_page_settings_15',
				'label'         => __( 'Automotive Services Pro comes with additional features.', 'automotive-services' ),
				'choices'       => array( __( '15+ Ready-Made Sections', 'automotive-services' ), __( 'One-Click Demo Import', 'automotive-services' ), __( 'WooCommerce Integrated', 'automotive-services' ), __( 'Drag & Drop Section Reordering', 'automotive-services' ),__( 'Advanced Typography Control', 'automotive-services' ),__( 'Intuitive Customization Options', 'automotive-services' ),__( '24/7 Support', 'automotive-services' ), )
			)
		)
	); 

}

add_action( 'customize_register', 'automotive_services_sidebar_setting' );