<?php

if ( ! get_theme_mod( 'corporaze_enable_counter_section', false ) ) {
	return;
}

$section_content                     = array();
$section_content['background_image'] = get_theme_mod( 'corporaze_counter_background_image' );

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

corporaze_render_counter_section( $section_content );

/**
 * Render Counter Section
 */
function corporaze_render_counter_section( $section_content ) {

	?>
	<section id="corporaze_counter_section" class="corporaze-frontpage-section corporaze-counter-section section-has-background counter-style-1" style=" background-color: #727272;">
		<?php
		if ( is_customize_preview() ) :
			corporaze_section_link( 'corporaze_counter_section' );
		endif;

		if ( ! empty( $section_content['background_image'] ) ) {
			?>
		<div class="corporaze-counter-background-img">
			<img src="<?php echo esc_url( $section_content['background_image'] ); ?>">
		</div>
		<?php } ?>
		<div class="ascendoor-wrapper">
			<div class="corporaze-counter-details">
				<div class="corporaze-section-body">
					<div class="corporaze-counter-wrapper">
						<?php
						for ( $i = 1; $i <= 4; $i++ ) {
							$icon         = get_theme_mod( 'corporaze_counter_icon_' . $i );
							$label        = get_theme_mod( 'corporaze_counter_label_' . $i );
							$value        = get_theme_mod( 'corporaze_counter_value_' . $i );
							$value_suffix = get_theme_mod( 'corporaze_counter_value_suffix_' . $i );
							?>
							<div class="corporaze-counter-single wow fadeInUp" data-wow-delay="<?php echo esc_attr( $i * 200 ); ?>ms">
								<?php if ( ! empty( $icon ) ) { ?>
								<div class="corporaze-counter-img">
									<img src="<?php echo esc_url( $icon ); ?>" alt="<?php echo esc_attr( $label ); ?>">
								</div>
								<?php } ?>
								<div class="corporaze-counter-txt">
									<h3>
										<span class="count" data-count="<?php echo esc_attr( $value ); ?>"></span><?php echo esc_html( $value_suffix ); ?>
									</h3>
									<p><?php echo esc_html( $label ); ?></p>
								</div>
							</div>
							<?php
						}
						?>
					</div>      
				</div>
			</div>
		</div>
	</section>
	<?php
}
