<?php
if ( ! get_theme_mod( 'roof_water_proofing_enable_banner_section', true ) ) {
	return;
}

$roof_water_proofing_slider_content_ids  = array();
$roof_water_proofing_slider_content_type = get_theme_mod( 'roof_water_proofing_banner_slider_content_type', 'post' );

for ( $roof_water_proofing_i = 1; $roof_water_proofing_i <= 3; $roof_water_proofing_i++ ) {
	$roof_water_proofing_slider_content_ids[] = get_theme_mod( 'roof_water_proofing_banner_slider_content_' . $roof_water_proofing_slider_content_type . '_' . $roof_water_proofing_i );
}
$roof_water_proofing_banner_slider_args = array(
	'post_type'           => $roof_water_proofing_slider_content_type,
	'post__in'            => array_filter( $roof_water_proofing_slider_content_ids ),
	'orderby'             => 'post__in',
	'posts_per_page'      => absint( 3 ),
	'ignore_sticky_posts' => true,
);
$roof_water_proofing_banner_slider_args = apply_filters( 'roof_water_proofing_banner_section_args', $roof_water_proofing_banner_slider_args );

roof_water_proofing_render_banner_section( $roof_water_proofing_banner_slider_args );

/**
 * Render Banner Section.
 */
function roof_water_proofing_render_banner_section( $roof_water_proofing_banner_slider_args ) {     ?>

	<section id="roof_water_proofing_banner_section" class="banner-section banner-style-1">
		<?php
		if ( is_customize_preview() ) :
			roof_water_proofing_section_link( 'roof_water_proofing_banner_section' );
		endif;
		?>
		<div class="banner-section-wrapper">
			<?php
			$roof_water_proofing_query = new WP_Query( $roof_water_proofing_banner_slider_args );
			if ( $roof_water_proofing_query->have_posts() ) :
				?>
				<div class="asterthemes-banner-wrapper banner-slider roof-water-proofing-carousel-navigation" data-slick='{"autoplay": false }'>
					<?php
					$roof_water_proofing_i = 1;
					while ( $roof_water_proofing_query->have_posts() ) :
						$roof_water_proofing_query->the_post();
						$roof_water_proofing_button_label = get_theme_mod( 'roof_water_proofing_banner_button_label_' . $roof_water_proofing_i, '' );
						$roof_water_proofing_button_link  = get_theme_mod( 'roof_water_proofing_banner_button_link_' . $roof_water_proofing_i, '' );
						$roof_water_proofing_button_link  = ! empty( $roof_water_proofing_button_link ) ? $roof_water_proofing_button_link : get_the_permalink();
						?>
						<div class="banner-single-outer">
							<div class="banner-single">
								<div class="banner-img">
									<?php if ( has_post_thumbnail() ) : ?>
									    <?php the_post_thumbnail( 'full' ); ?>
									<?php else : ?>
									    <img src="<?php echo esc_url( get_template_directory_uri() ); ?>/resource/img/default.jpg" alt="Default Image" />
									<?php endif; ?>
								</div>
								<div class="banner-caption">
									<div class="asterthemes-wrapper">
										<div class="banner-catption-wrapper wow zoomIn delay-1000" data-wow-duration="2s">
											<h1 class="banner-caption-title">
											    <?php
											    $roof_water_proofing_title = get_the_title();
											    echo $roof_water_proofing_title;
											    ?>
											</h1>
											<?php if ( ! empty( $roof_water_proofing_button_label ) ) { ?>
												<div class="banner-slider-btn">
													<a href="<?php echo esc_url( $roof_water_proofing_button_link ); ?>" class="asterthemes-button"><?php echo esc_html( $roof_water_proofing_button_label ); ?></a>
												</div>
											<?php } ?>
										</div>
									</div>
								</div>
							</div>
						</div>
						<?php
						$roof_water_proofing_i++;
					endwhile;
					wp_reset_postdata();
					?>
				</div>
				<?php
			endif;
			?>
		</div>
	</section>
	<?php
}