<?php
/**
 * General Settings
 *
 * @package Travel Tour
 */


add_action( 'customize_register', 'travel_tour_customize_general_option' );

function travel_tour_customize_general_option( $wp_customize ) {

    $wp_customize->add_section( 'travel_tour_general_section', array(
        'title'         => esc_html__( 'Top Panel', 'travel-tour' ),
        'description'   => esc_html__( 'Top Panel', 'travel-tour' ),
        'panel'         => 'travel_tour_general_panel',
        'priority'      => 6,
    ) );

    $wp_customize->add_setting( 'header_search_display_option', array(
        'sanitize_callback'     =>  'travel_tour_sanitize_checkbox',
        'default'               =>  false
    ) );
            
    $wp_customize->add_control( new Travel_Tour_Toggle_Control( $wp_customize, 'header_search_display_option', array(
        'label' => esc_html__( 'Hide / Show Search Field','travel-tour' ),
        'section' => 'travel_tour_general_section',
        'settings' => 'header_search_display_option',
        'type'=> 'toggle',
    ) ) );

    $wp_customize->selective_refresh->add_partial( 'header_search_display_option', array(
        'selector' => '.search-top',
    ) );

    $wp_customize->add_setting( 'contact_number', array(   
        'sanitize_callback' => 'sanitize_text_field',
        'default'     => '',
    ) );

    $wp_customize->add_control( 'contact_number', array(
        'label' => esc_html__( 'Contact Number', 'travel-tour' ),
        'section' => 'travel_tour_general_section',
        'settings' => 'contact_number',
        'type'=> 'text',
    ) );

    $wp_customize->selective_refresh->add_partial( 'contact_number', array(
        'selector' => '.contact-phone',
    ) );

    $wp_customize->add_setting( 'contact_email', array(   
        'sanitize_callback' => 'sanitize_text_field',
        'default'     => '',
    ) );

    $wp_customize->add_control( 'contact_email', array(
        'label' => esc_html__( 'Contact Email', 'travel-tour' ),
        'section' => 'travel_tour_general_section',
        'settings' => 'contact_email',
        'type'=> 'text',
    ) );

    $wp_customize->selective_refresh->add_partial( 'contact_email', array(
        'selector' => '.contact-email',
    ) );

    $wp_customize->add_setting( new Travel_Tour_Repeater_Setting(
        $wp_customize, 'travel_tour_social_media', array(
            'default'     => '',
            'sanitize_callback' => array( 'Travel_Tour_Repeater_Setting', 'sanitize_repeater_setting' ),
          )
    ) );
    
    $wp_customize->add_control( new Travel_Tour_Control_Repeater(
        $wp_customize, 'travel_tour_social_media', array(
            'section' => 'travel_tour_general_section',
            'settings'    => 'travel_tour_social_media',
            'label'   => esc_html__( 'Social Media', 'travel-tour' ),
            'row_label' => array(
                'type'  => 'field',
                'value' => esc_html__('Social Media', 'travel-tour' ),
                'field' => 'social_media_class',
            ),
            'fields' => array(
                'social_media_class' => array(
                    'type'        => 'select',
                    'label'       => esc_html__( 'Select Social Media', 'travel-tour' ),
                    'default'     => 'facebook',
                    'choices'   => travel_tour_social_media()
                ),
                'social_media_link' => array(
                    'type'      => 'url',
                    'label'     => esc_html__( 'Social Media Links', 'travel-tour' ),
                    'default'   => '',
                ),          
            ),
        )
    ) );

    $wp_customize->selective_refresh->add_partial( 'travel_tour_social_media', array(
        'selector' => '.social-icons',
    ) );

}