<?php
/**
 * About Section
 *
 * @package Tamal_Portfolio
 */

$wp_customize->add_section(
	'tamal_portfolio_contact_section',
	array(
		'panel'    => 'tamal_portfolio_front_page_options',
		'title'    => esc_html__( 'Contact Section', 'tamal-portfolio' ),
		'priority' => priority_section('tamal_portfolio_contact_section'),
	)
);

// About Section - Enable Section.
$wp_customize->add_setting(
	'tamal_portfolio_enable_contact_section',
	array(
		'default'           => false,
		'sanitize_callback' => 'tamal_portfolio_sanitize_switch',
	)
);

$wp_customize->add_control(
	new Tamal_Portfolio_Toggle_Switch_Custom_Control(
		$wp_customize,
		'tamal_portfolio_enable_contact_section',
		array(
			'label'    => esc_html__( 'Enable About Section', 'tamal-portfolio' ),
			'section'  => 'tamal_portfolio_contact_section',
			'settings' => 'tamal_portfolio_enable_contact_section',
		)
	)
);

if ( isset( $wp_customize->selective_refresh ) ) {
	$wp_customize->selective_refresh->add_partial(
		'tamal_portfolio_enable_contact_section',
		array(
			'selector' => '#contact .section-link',
			'settings' => 'tamal_portfolio_enable_contact_section',
		)
	);
}

// Background grey
$wp_customize->add_setting(
    'tamal_portfolio_contact_section_background_grey',
    array(
        'default'           => false,
        'sanitize_callback' => 'tamal_portfolio_sanitize_switch',
    )
);
$wp_customize->add_control(
    new Tamal_Portfolio_Toggle_Switch_Custom_Control(
        $wp_customize,
        'tamal_portfolio_contact_section_background_grey',
        array(
            'label'    => esc_html__( 'Background Grey', 'tamal-portfolio' ),
            'section'  => 'tamal_portfolio_contact_section',
            'settings' => 'tamal_portfolio_contact_section_background_grey',
            'active_callback' => 'tamal_portfolio_is_contact_section_enabled',
        )
    )
);

// Headline
$wp_customize->add_setting(
    'tamal_portfolio_contact_section_headline',
    array(
        'default'           => __( 'Contact me', 'tamal-portfolio' ),
        'sanitize_callback' => 'sanitize_text_field',
    )
);
$wp_customize->add_control(
    'tamal_portfolio_contact_section_headline',
    array(
        'label'           => esc_html__( 'Headline', 'tamal-portfolio' ),
        'section'         => 'tamal_portfolio_contact_section',
        'settings'        => 'tamal_portfolio_contact_section_headline',
        'type'            => 'text',
        'active_callback' => 'tamal_portfolio_is_contact_section_enabled',
    )
);

// Map
$wp_customize->add_setting(
    'tamal_portfolio_contact_section_map',
    array(
        'default'           => __( '', 'tamal-portfolio' ),
        'sanitize_callback' => 'wp_kses_post',
    )
);
$wp_customize->add_control(
    'tamal_portfolio_contact_section_map',
    array(
        'label'           => esc_html__( 'Map', 'tamal-portfolio' ),
        'section'         => 'tamal_portfolio_contact_section',
        'settings'        => 'tamal_portfolio_contact_section_map',
        'type'            => 'textarea',
        'active_callback' => 'tamal_portfolio_is_contact_section_enabled',
    )
);

// Fields
$wp_customize->add_setting(
    'tamal_portfolio_contact_section_list',
    array(
        'default'           => '',
        'sanitize_callback' => 'customizer_repeater_sanitize',
    )
);
$wp_customize->add_control(
    new Tamal_Portfolio_Customize_Field_Repeater(
        $wp_customize,
        'tamal_portfolio_contact_section_list',
        array(
            'label'   => esc_html__('Contact Item','tamal-portfolio'),
            'label_item'   => esc_html__('Contact Item','tamal-portfolio'),
            'section' => 'tamal_portfolio_contact_section',
            'custom_repeater_icon_control' => true,
            'custom_repeater_text_control' => true,
            'active_callback' => 'tamal_portfolio_is_contact_section_enabled',
        )
    )
);

$wp_customize->add_setting(
    'tamal_portfolio_contact_section_form',
    array(
        'sanitize_callback' => 'sanitize_text_field',
    )
);
$wp_customize->add_control(
    'tamal_portfolio_contact_section_form',
    array(
        'label'           => esc_html__( 'Form', 'tamal-portfolio' ),
        'section'         => 'tamal_portfolio_contact_section',
        'settings'        => 'tamal_portfolio_contact_section_form',
        'type'            => 'text',
        'active_callback' => 'tamal_portfolio_is_contact_section_enabled',
    )
);