<?php
/**
 * Contact Section
 *
 * @package Construktly
 */

$wp_customize->add_section(
	'construktly_contact_section',
	array(
		'panel' => 'construktly_front_page_options',
		'title' => esc_html__( 'Contact Section', 'construktly' ),
	)
);

// Contact Section - Enable Section.
$wp_customize->add_setting(
	'construktly_enable_contact_section',
	array(
		'default'           => false,
		'sanitize_callback' => 'construktly_sanitize_switch',
	)
);

$wp_customize->add_control(
	new Construktly_Toggle_Switch_Custom_Control(
		$wp_customize,
		'construktly_enable_contact_section',
		array(
			'label'    => esc_html__( 'Enable Contact Section', 'construktly' ),
			'section'  => 'construktly_contact_section',
			'settings' => 'construktly_enable_contact_section',
		)
	)
);

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

// Contact Section - Section Title.
$wp_customize->add_setting(
	'construktly_contact_title',
	array(
		'default'           => __( 'Get in touch', 'construktly' ),
		'sanitize_callback' => 'sanitize_text_field',
	)
);

$wp_customize->add_control(
	'construktly_contact_title',
	array(
		'label'           => esc_html__( 'Section Title', 'construktly' ),
		'section'         => 'construktly_contact_section',
		'settings'        => 'construktly_contact_title',
		'type'            => 'text',
		'active_callback' => 'construktly_is_contact_section_enabled',
	)
);

// Contact Section - Section Text.
$wp_customize->add_setting(
	'construktly_contact_text',
	array(
		'default'           => '',
		'sanitize_callback' => 'sanitize_text_field',
	)
);

$wp_customize->add_control(
	'construktly_contact_text',
	array(
		'label'           => esc_html__( 'Section Text', 'construktly' ),
		'section'         => 'construktly_contact_section',
		'settings'        => 'construktly_contact_text',
		'type'            => 'text',
		'active_callback' => 'construktly_is_contact_section_enabled',
	)
);

// Contact Section - Phone Numbers.
for ( $i = 1; $i <= 2; $i++ ) {

	$wp_customize->add_setting(
		'construktly_contact_section_no_' . $i,
		array(
			'default'           => '',
			'sanitize_callback' => 'sanitize_text_field',
		)
	);

	$wp_customize->add_control(
		'construktly_contact_section_no_' . $i,
		array(
			/* translators: %d: count. */
			'label'           => sprintf( esc_html__( 'Contact Number %d', 'construktly' ), $i ),
			'section'         => 'construktly_contact_section',
			'settings'        => 'construktly_contact_section_no_' . $i,
			'type'            => 'text',
			'active_callback' => 'construktly_is_contact_section_enabled',
		)
	);

}

// Contact Section - Email Addresses.
for ( $i = 1; $i <= 2; $i++ ) {

	$wp_customize->add_setting(
		'construktly_contact_section_email_' . $i,
		array(
			'default'           => '',
			'sanitize_callback' => 'sanitize_text_field',
		)
	);

	$wp_customize->add_control(
		'construktly_contact_section_email_' . $i,
		array(
			/* translators: %d: count. */
			'label'           => sprintf( esc_html__( 'Email %d', 'construktly' ), $i ),
			'section'         => 'construktly_contact_section',
			'settings'        => 'construktly_contact_section_email_' . $i,
			'type'            => 'text',
			'active_callback' => 'construktly_is_contact_section_enabled',
		)
	);

}

// Contact Section - Location.
$wp_customize->add_setting(
	'construktly_contact_section_location',
	array(
		'default'           => '',
		'sanitize_callback' => 'wp_kses_post',
	)
);

$wp_customize->add_control(
	'construktly_contact_section_location',
	array(
		'label'           => esc_html__( 'Location / Address', 'construktly' ),
		'section'         => 'construktly_contact_section',
		'settings'        => 'construktly_contact_section_location',
		'type'            => 'textarea',
		'active_callback' => 'construktly_is_contact_section_enabled',
	)
);
