<?php
if ( ! get_theme_mod( 'construktly_enable_contact_section', false ) ) {
	return;
}

$section_content          = array();
$section_content['title'] = get_theme_mod( 'construktly_contact_title', __( 'Get in touch', 'construktly' ) );
$section_content['text']  = get_theme_mod( 'construktly_contact_text' );

$section_content = apply_filters( 'construktly_contact_section_content', $section_content );

construktly_render_contact_section( $section_content );

/**
 * Render Contact Section
 */
function construktly_render_contact_section( $section_content ) {
	$location_address = get_theme_mod( 'construktly_contact_section_location' );
	?>
	<section id="construktly_contact_section" class="construktly-frontpage-section construktly-grey-background construktly-contact-section contact-style-4">
		<?php
		if ( is_customize_preview() ) :
			construktly_section_link( 'construktly_contact_section' );
		endif;
		?>
		<div class="ascendoor-wrapper">
			<div class="contact-main-wrapper">
				<?php if ( ! empty( $section_content['title'] || $section_content['text'] ) ) { ?>
					<div class="section-header-subtitle contact-header-wrap">
						<h3 class="section-title"><?php echo esc_html( $section_content['title'] ); ?></h3>
						<p class="section-subtitle"><?php echo esc_html( $section_content['text'] ); ?></p>
					</div>
				<?php } ?>
				<div class="Contact-address-wrap">
					<div class="contact-address">
						<div class="contact-address-inner">
							<div class="icon">
								<i class="fas fa-phone-alt"></i>
							</div>
							<div class="inner">
								<h4 class="title"><?php echo esc_html( __( 'Phone', 'construktly' ) ); ?></h4>
								<?php
								for ( $i = 1; $i <= 2; $i++ ) {
									$contact_number = get_theme_mod( 'construktly_contact_section_no_' . $i );
									if ( ! empty( $contact_number ) ) {
										?>
										<p>
											<a href="tel: <?php echo esc_attr( $contact_number ); ?>"><?php echo esc_html( $contact_number ); ?></a>
										</p>
										<?php
									}
								}
								?>
							</div>
						</div>
					</div>
					<div class="contact-address">
						<div class="contact-address-inner">
							<div class="icon">
								<i class="fas fa-envelope"></i>
							</div>
							<div class="inner">
								<h4 class="title"><?php echo esc_html( __( 'Email', 'construktly' ) ); ?></h4>
								<?php
								for ( $i = 1; $i <= 2; $i++ ) {
									$email = get_theme_mod( 'construktly_contact_section_email_' . $i );
									if ( ! empty( $email ) ) {
										?>
										<p>
											<a href="mailto: <?php echo esc_attr( $email ); ?>"><?php echo esc_html( $email ); ?></a>
										</p>
										<?php
									}
								}
								?>
							</div>
						</div>
					</div>
					<div class="contact-address">
						<div class="contact-address-inner">
							<div class="icon">
								<i class="fas fa-map-marker-alt"></i>
							</div>
							<div class="inner">
								<h4 class="title"><?php echo esc_html( __( 'Location', 'construktly' ) ); ?></h4>
								<p><?php echo wp_kses_post( $location_address ); ?></p>
							</div>
						</div>
					</div>
				</div>
			</div>
		</div>
	</section>
	<?php
}
