<?php

$wp_customize->add_section(new constructionarc_Toggle_Section($wp_customize, 'constructionarc_contact_section', array(
    'title' => esc_html__('Contact Section', 'construction-arc'),
    'panel' => 'constructionarc_frontpage_settings',
    'priority' => constructionarc_themes_get_section_position('constructionarc_contact_section'),
    'hiding_control' => 'constructionarc_contact_disable'
)));

//ENABLE/DISABLE CONTACT US SECTION
$wp_customize->add_setting('constructionarc_contact_disable', array(
    'sanitize_callback' => 'constructionarc_themes_sanitize_switch',
    'transport' => 'postMessage',
    'default' => 'enable'
));
$wp_customize->add_control(new constructionarc_Switch_Control($wp_customize, 'constructionarc_contact_disable', array(
    'section' => 'constructionarc_contact_section',
    'label' => esc_html__('Enable', 'construction-arc'),
    'switch_label' => array(
        'enable' => esc_html__('Enable', 'construction-arc'),
        'disable' => esc_html__('Disable', 'construction-arc'),
    ),
    'class' => 'switch-section',
    'priority' => -1,
)));

    $wp_customize->add_setting('constructionarc_contact_nav', array(
        'transport' => 'postMessage',
        'sanitize_callback' => 'wp_kses_post'
    ));
    $wp_customize->add_control(new constructionarc_Custom_Control_Tab($wp_customize, 'constructionarc_contact_nav', array(
        'type' => 'tab',
        'section' => 'constructionarc_contact_section',
        'priority' => 1,
        'buttons' => array(
            array(
                'name' => esc_html__('Content', 'construction-arc'),
                'fields' => array(
                    'constructionarc_google_map_heading',
                    'constructionarc_latitude',
                    'constructionarc_longitude',
                    'constructionarc_contact_map_address',
                    'constructionarc_contact_detail',
                    'constructionarc_contact_details_heading',
                    'constructionarc_show_contact_detail',
                    'constructionarc_contact_title', 
                    'constructionarc_contact_shortcode',
                    'constructionarc_contact_details_heading_right',
                    'constructionarc_contact_detail_item',
                    'constructionarc_contact_details'
                ),
                'active' => true,
            ),
            array(
                'name' => esc_html__('Style', 'construction-arc'),
                'fields' => array(
                ),
            ),
            array(
                'name' => esc_html__('Advanced', 'construction-arc'),
                'fields' => array(
                    'constructionarc_contact_bg_type',
                    'constructionarc_contact_bg_color',
                    'constructionarc_contact_bg_image',
                    'constructionarc_contact_overlay_color',
                    'constructionarc_contact_padding',
                    'constructionarc_contact_cs_seperator'
                ),
            ),
            array(
                'name' => esc_html__('Hidden', 'construction-arc'),
                'class' => 'customizer-hidden',
                'fields' => array(
                    'constructionarc_contact_super_title_color',
                ),
            ),
        ),
    )));


    $wp_customize->add_setting('constructionarc_contact_details_heading_right', array(
        'sanitize_callback' => 'sanitize_text_field',
        'transport' => 'postMessage',
    ));
    $wp_customize->add_control(new constructionarc_Customize_Heading($wp_customize, 'constructionarc_contact_details_heading_right', array(
        'section' => 'constructionarc_contact_section',
        'label' => esc_html__('Contact Information Details', 'construction-arc')
    )));

    $wp_customize->add_setting('constructionarc_contact_detail_item', array(
        'sanitize_callback' => 'sanitize_text_field',
        'default' => 'enable',
        'transport' => 'postMessage'
    ));
    $wp_customize->add_control(new constructionarc_Switch_Control($wp_customize, 'constructionarc_contact_detail_item', array(
        'section' => 'constructionarc_contact_section',
        'label' => esc_html__('Contact Detail', 'construction-arc'),
        'switch_label' => array(
            'enable' => esc_html__('Yes', 'construction-arc'),
            'disable' => esc_html__('No', 'construction-arc'),
        ),
    )));

    $wp_customize->add_setting('constructionarc_contact_details', array(
        'transport' => 'postMessage',
        'sanitize_callback' => 'constructionarc_themes_sanitize_repeater',
        'default' => json_encode(array(
            array(
                'icon' => '',
                'label' => '',
                'description' => '',
            )
        ))
    ));
    $wp_customize->add_control(new constructionarc_Themes_Repeater_Control($wp_customize, 'constructionarc_contact_details', array(
            'label' => esc_html__('Contact Info Items', 'construction-arc'),
            'section' => 'constructionarc_contact_section',
            'box_label' => esc_html__('Contact Info Item', 'construction-arc'),
            'add_label' => esc_html__('Add New', 'construction-arc'),
            'limit' => 3,
        ), 
        array(
            'icon' => array(
                'type' => 'icon',
                'label' => esc_html__('Choose Icon', 'construction-arc'),
                'default' => ''
            ),
            'label' => array(
                'type' => 'text',
                'label' => esc_html__('Label', 'construction-arc'),
                'default' => ''
            ),
            'description' => array(
                'type' => 'text',
                'label' => esc_html__('Content', 'construction-arc'),
                'default' => ''
            )
        )
    ));


    $wp_customize->add_setting('constructionarc_show_contact_detail', array(
        'sanitize_callback' => 'sanitize_text_field',
        'default' => 'enable',
        'transport' => 'postMessage'
    ));
    $wp_customize->add_control(new constructionarc_Switch_Control($wp_customize, 'constructionarc_show_contact_detail', array(
        'section' => 'constructionarc_contact_section',
        'label' => esc_html__('Map & Contact Details', 'construction-arc'),
        'switch_label' => array(
            'enable' => esc_html__('Yes', 'construction-arc'),
            'disable' => esc_html__('No', 'construction-arc'),
        ),
    )));

    $wp_customize->add_setting('constructionarc_google_map_heading', array(
        'sanitize_callback' => 'sanitize_text_field',
        'transport' => 'postMessage',
    ));
    $wp_customize->add_control(new constructionarc_Customize_Heading($wp_customize, 'constructionarc_google_map_heading', array(
        'section' => 'constructionarc_contact_section',
        'label' => esc_html__('Google Map', 'construction-arc'),
        'description' => sprintf(esc_html__('Get the Longitude and Latitude value of the location from %s', 'construction-arc'), '<a target="_blank" href="https://www.latlong.net/">here</a>')
    )));

    $wp_customize->add_setting('constructionarc_latitude', array(
        'sanitize_callback' => 'sanitize_text_field',
        'default' => '24.691943',
        'transport' => 'postMessage'
    ));
    $wp_customize->add_control('constructionarc_latitude', array(
        'section' => 'constructionarc_contact_section',
        'type' => 'text',
        'label' => esc_html__('Latitude', 'construction-arc')
    ));

    $wp_customize->add_setting('constructionarc_longitude', array(
        'sanitize_callback' => 'sanitize_text_field',
        'default' => '78.403931',
        'transport' => 'postMessage'
    ));
    $wp_customize->add_control('constructionarc_longitude', array(
        'section' => 'constructionarc_contact_section',
        'type' => 'text',
        'label' => esc_html__('Longitude', 'construction-arc')
    ));
    
    $wp_customize->add_setting('constructionarc_contact_map_address', array(
        'sanitize_callback' => 'sanitize_text_field',
        'transport' => 'postMessage'
    ));
    $wp_customize->add_control('constructionarc_contact_map_address', array(
        'section' => 'constructionarc_contact_section',
        'type' => 'text',
        'label' => esc_html__('Map Address', 'construction-arc')
    ));

    $wp_customize->add_setting('constructionarc_contact_details_heading', array(
        'sanitize_callback' => 'sanitize_text_field',
        'transport' => 'postMessage',
    ));
    $wp_customize->add_control(new constructionarc_Customize_Heading($wp_customize, 'constructionarc_contact_details_heading', array(
        'section' => 'constructionarc_contact_section',
        'label' => esc_html__('Contact Details', 'construction-arc')
    )));

    $wp_customize->add_setting('constructionarc_contact_title', array(
        'sanitize_callback' => 'sanitize_text_field',
        'default' => esc_html__('Quick Get In Touch', 'construction-arc'),
        'transport' => 'postMessage'
    ));
    $wp_customize->add_control('constructionarc_contact_title', array(
        'section' => 'constructionarc_contact_section',
        'type' => 'text',
        'label' => esc_html__('Title', 'construction-arc')
    ));

    $wp_customize->add_setting('constructionarc_contact_shortcode', array(
        'sanitize_callback' => 'sanitize_text_field',
        'transport' => 'postMessage'
    ));
    $wp_customize->add_control('constructionarc_contact_shortcode', array(
        'section' => 'constructionarc_contact_section',
        'type' => 'text',
        'label' => esc_html__('Contact Form Shortcode', 'construction-arc'),
        'description' => sprintf(esc_html__('Install %s plugin to get the shortcode', 'construction-arc'), '<a target="_blank" href="https://wordpress.org/plugins/contact-form-7/">Contact Form 7</a>')
    ));


    $wp_customize->add_setting('constructionarc_pro_contact', array(
        'sanitize_callback' => 'constructionarc_sanitize_text'
    ));
    $wp_customize->add_control(new constructionarc_Themes_Upgrade_Text($wp_customize, 'constructionarc_pro_contact', array(
        'section' => 'constructionarc_contact_section',
        'label' => esc_html__('For More Settings,', 'construction-arc'),
        'choices' => array(
            esc_html__('Different Layout & Settings', 'construction-arc'),
            esc_html__('(5+) Different Section Title Style', 'construction-arc'),
            esc_html__('Advanced Contact Items Settings', 'construction-arc'),
            esc_html__('Title, sub title & text color options', 'construction-arc'),
			esc_html__('4+ Different Background Options( Color/Video/Gradient/Image ) ', 'construction-arc'),
			esc_html__('More Than 35+ Top & Bottom Separator Shape Illustrator with Color & Height Option', 'construction-arc'),
        ),
        'priority' => 250,
    )));


$wp_customize->selective_refresh->add_partial( 'constructionarc_contact_refresh', array (
    'settings' => array( 
        'constructionarc_contact_disable',
        'constructionarc_latitude',
        'constructionarc_longitude',
        'constructionarc_contact_map_address',
        'constructionarc_contact_details',
        'constructionarc_contact_detail_item',
        'constructionarc_show_contact_detail',
        'constructionarc_contact_shortcode',
    ),
    'selector' => '#contact-section',
    'fallback_refresh' => true,
    'container_inclusive' => true,
    'render_callback' => function () {
        return get_template_part( 'section/section-contact' );
    }
));