<?php

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

$section_content          = array();
$section_content['count'] = get_theme_mod( 'construktly_associate_count', 5 );
$section_content          = apply_filters( 'construktly_associate_section_content', $section_content );

construktly_render_associate_section( $section_content );

/**
 * Render Associate Section
 */
function construktly_render_associate_section( $section_content ) {
	?>
	<section id="construktly_associate_section" class="construktly-frontpage-section construktly-brands-slider">
		<?php
		if ( is_customize_preview() ) :
			construktly_section_link( 'construktly_associate_section' );
		endif;
		?>
		<div class="ascendoor-wrapper">
			<div class="construktly-section-body">
				<div class="construktly-brands-slider-wrapper brand-slider">
					<?php
					for ( $i = 1; $i <= $section_content['count']; $i++ ) {
						$logo     = get_theme_mod( 'construktly_associate_logo_' . $i );
						$logo_url = get_theme_mod( 'construktly_associate_logo_url_' . $i );
						$logo_url = ! empty( $logo_url ) ? $logo_url : '#';
						if ( ! empty( $logo ) ) {
							?>
							<div class="construktly-brand-single">
								<a href="<?php echo esc_url( $logo_url ); ?>" target="_blank"><img src="<?php echo esc_url( $logo ); ?>" alt="<?php echo esc_attr__( 'associate-logo', 'construktly' ); ?>"></a>
							</div>
							<?php
						}
					}
					?>
				</div>
			</div>
		</div>
	</section>
	<?php
}
