<?php
function pet_house_sidebar_setting( $wp_customize ) {
$selective_refresh = isset( $wp_customize->selective_refresh ) ? 'postMessage' : 'refresh';
	$wp_customize->add_panel(
		'pet_house_sidebar', array(
			'priority' => 31,
			'title' => esc_html__( 'Sidebar Options', 'pet-house' ),
		)
	);

	/*=========================================
	Sidebar Option  Section
	=========================================*/
	$wp_customize->add_section(
		'pet_house_sidebar_settings', array(
			'title' => esc_html__( 'Sidebar Options', 'pet-house' ),
			'priority' => 1,
			'panel' => 'pet_house_general',
		)
	);
	

	// Archive Sidebar Hide/ Show Setting // 
	$wp_customize->add_setting( 
		'pet_house_archive_sidebar_setting' , 
			array(
			'default' => '1',
			'sanitize_callback' => 'pet_house_sanitize_checkbox',
			'capability' => 'edit_theme_options',
			'priority' => 2,
		) 
	);
	
	$wp_customize->add_control(
	'pet_house_archive_sidebar_setting', 
		array(
			'label'	      => esc_html__( 'Hide / Show Archive Sidebar', 'pet-house' ),
			'section'     => 'pet_house_sidebar_settings',
			'settings'    => 'pet_house_archive_sidebar_setting',
			'type'        => 'checkbox'
		) 
	);

	// Index Sidebar Hide/ Show Setting // 
	$wp_customize->add_setting( 
		'pet_house_index_sidebar_setting' , 
			array(
			'default' => '1',
			'sanitize_callback' => 'pet_house_sanitize_checkbox',
			'capability' => 'edit_theme_options',
			'priority' => 2,
		) 
	);
	
	$wp_customize->add_control(
	'pet_house_index_sidebar_setting', 
		array(
			'label'	      => esc_html__( 'Hide / Show Index Sidebar', 'pet-house' ),
			'section'     => 'pet_house_sidebar_settings',
			'settings'    => 'pet_house_index_sidebar_setting',
			'type'        => 'checkbox'
		) 
	);

	// Pages Sidebar Hide/ Show Setting // 
	$wp_customize->add_setting( 
		'pet_house_paged_sidebar_setting' , 
			array(
			'default' => '1',
			'sanitize_callback' => 'pet_house_sanitize_checkbox',
			'capability' => 'edit_theme_options',
			'priority' => 2,
		) 
	);
	
	$wp_customize->add_control(
	'pet_house_paged_sidebar_setting', 
		array(
			'label'	      => esc_html__( 'Hide / Show Pages Sidebar', 'pet-house' ),
			'section'     => 'pet_house_sidebar_settings',
			'settings'    => 'pet_house_paged_sidebar_setting',
			'type'        => 'checkbox'
		) 
	);

	// Search Result Sidebar Hide/ Show Setting // 
	$wp_customize->add_setting( 
		'pet_house_search_result_sidebar_setting' , 
			array(
			'default' => '1',
			'sanitize_callback' => 'pet_house_sanitize_checkbox',
			'capability' => 'edit_theme_options',
			'priority' => 2,
		) 
	);
	
	$wp_customize->add_control(
	'pet_house_search_result_sidebar_setting', 
		array(
			'label'	      => esc_html__( 'Hide / Show Search Result Sidebar', 'pet-house' ),
			'section'     => 'pet_house_sidebar_settings',
			'settings'    => 'pet_house_search_result_sidebar_setting',
			'type'        => 'checkbox'
		) 
	);

	// Single Post Sidebar Hide/ Show Setting // 
	$wp_customize->add_setting( 
		'pet_house_single_post_sidebar_setting' , 
			array(
			'default' => '1',
			'sanitize_callback' => 'pet_house_sanitize_checkbox',
			'capability' => 'edit_theme_options',
			'priority' => 2,
		) 
	);
	
	$wp_customize->add_control(
	'pet_house_single_post_sidebar_setting', 
		array(
			'label'	      => esc_html__( 'Hide / Show Single Post Sidebar', 'pet-house' ),
			'section'     => 'pet_house_sidebar_settings',
			'settings'    => 'pet_house_single_post_sidebar_setting',
			'type'        => 'checkbox'
		) 
	);

	// Sidebar Page Sidebar Date Hide/ Show Setting // 
	$wp_customize->add_setting( 
		'pet_house_single_page_sidebar_setting' , 
			array(
			'default' => '1',
			'sanitize_callback' => 'pet_house_sanitize_checkbox',
			'capability' => 'edit_theme_options',
			'priority' => 2,
		) 
	);
	
	$wp_customize->add_control(
	'pet_house_single_page_sidebar_setting', 
		array(
			'label'	      => esc_html__( 'Hide / Show Page Width Sidebar', 'pet-house' ),
			'section'     => 'pet_house_sidebar_settings',
			'settings'    => 'pet_house_single_page_sidebar_setting',
			'type'        => 'checkbox'
		) 
	);

	$wp_customize->add_setting( 'pet_house_sidebar_position', array(
        'default'   => 'right',
        'sanitize_callback' => 'pet_house_sanitize_sidebar_position',
    ));

    $wp_customize->add_control( 'pet_house_sidebar_position', array(
        'label'    => __( 'Sidebar Position', 'pet-house' ),
        'section'  => 'pet_house_sidebar_settings',
        'settings' => 'pet_house_sidebar_position',
        'type'     => 'radio',
        'choices'  => array(
            'right' => __( 'Right Sidebar', 'pet-house' ),
            'left'  => __( 'Left Sidebar', 'pet-house' ),
        ),
    ));

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

add_action( 'customize_register', 'pet_house_sidebar_setting' );