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

$charity_elite_section_content = array();
$charity_elite_section_content = apply_filters( 'charity_elite_counter_section_content', $charity_elite_section_content );

charity_elite_render_counter_section( $charity_elite_section_content );

/**
 * Render Counter Section
 */
function charity_elite_render_counter_section( $charity_elite_section_content ) {
	$charity_elite_counter_subtitle = get_theme_mod( 'charity_elite_counter_subtitle', '' );
	$charity_elite_counter_title    = get_theme_mod( 'charity_elite_counter_title', __( 'Our Achivements', 'charity-elite' ) );
	$charity_elite_counter_bg_image = get_theme_mod( 'charity_elite_counter_bg_image', '' );
	?>
	<section id="charity_elite_counter_section" class="ascendoor-frontpage-section section-has-background counter-section counter-style-1" style="background-color: #8F040A;">
		<?php
		if ( is_customize_preview() ) :
			charity_elite_section_link( 'charity_elite_counter_section' );
		endif;
		if ( ! empty( $charity_elite_counter_bg_image ) ) {
			?>
			<div class="counter-background-img">
				<img src="<?php echo esc_url( $charity_elite_counter_bg_image ); ?>">
			</div>
			<?php
		}
		?>
		<div class="ascendoor-wrapper">
			<?php if ( ! empty( $charity_elite_counter_subtitle || $charity_elite_counter_title ) ) { ?>
				<div class="section-header-subtitle">
					<p class="section-subtitle"><?php echo esc_html( $charity_elite_counter_subtitle ); ?></p>
					<h3 class="section-title"><?php echo esc_html( $charity_elite_counter_title ); ?></h3>
				</div>
			<?php } ?>
			<div class="section-body">
				<div class="counter-wrapper">
					<?php
					for ( $charity_elite_i = 1; $charity_elite_i <= 4; $charity_elite_i++ ) {
						$charity_elite_icon         = get_theme_mod( 'charity_elite_counter_icon_' . $charity_elite_i );
						$charity_elite_label        = get_theme_mod( 'charity_elite_counter_label_' . $charity_elite_i );
						$charity_elite_value        = get_theme_mod( 'charity_elite_counter_value_' . $charity_elite_i );
						$charity_elite_value_suffix = get_theme_mod( 'charity_elite_counter_value_suffix_' . $charity_elite_i );
						?>
						<div class="counter-single">
							<?php if ( ! empty( $charity_elite_icon ) ) { ?>
								<div class="counter-img">
									<img src="<?php echo esc_url( $charity_elite_icon ); ?>" alt="<?php echo esc_attr( $charity_elite_label ); ?>">
								</div>
							<?php } ?>
							<div class="counter-txt">
								<h3>
									<span class="count"><?php echo esc_html( $charity_elite_value ); ?></span> <?php echo esc_html( $charity_elite_value_suffix ); ?>
								</h3>
								<p><?php echo esc_html( $charity_elite_label ); ?></p>
							</div>
						</div>
						<?php
					}
					?>
				</div>
			</div>
		</div>
	</section>
	<?php
}
