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

$aster_it_courses_banner_category = get_theme_mod( 'aster_it_courses_banner_slider_category', 'slider' );

$aster_it_courses_args = array(
	'post_type'           => 'post',
	'category_name'       => sanitize_text_field( $aster_it_courses_banner_category ),
	'posts_per_page'      => 3,
	'ignore_sticky_posts' => true,
);

$aster_it_courses_query = new WP_Query( $aster_it_courses_args );

if ( $aster_it_courses_query->have_posts() ) :
	$aster_it_courses_button_label = get_theme_mod( 'aster_it_courses_banner_button_label' );
	$aster_it_courses_button_link  = get_theme_mod( 'aster_it_courses_banner_button_link' );
	$aster_it_courses_button_link  = ! empty( $aster_it_courses_button_link ) ? esc_url( $aster_it_courses_button_link ) : '';
	?>

	<section id="aster_it_courses_banner_section" class="banner-section banner-style-1 wow fadeInDown" data-wow-duration="1.5s">
		<?php if ( is_customize_preview() ) : aster_it_courses_section_link( 'aster_it_courses_banner_section' ); endif; ?>
		<div class="banner-section-wrapper">
			<div class="asterthemes-banner-wrapper banner-slider aster-it-courses-carousel-navigation" data-slick='{"autoplay": true }'>
				<?php
				while ( $aster_it_courses_query->have_posts() ) :
					$aster_it_courses_query->the_post();
					?>
					<div class="banner-single-outer">
						<div class="banner-single">
							<div class="banner-img">
								<?php
								if ( has_post_thumbnail() ) {
									the_post_thumbnail( 'full' );
								} else {
									echo '<img src="' . esc_url( get_template_directory_uri() . '/resource/img/default.png' ) . '" alt="' . esc_attr( get_the_title() ) . '">';
								}
								?>
							</div>
							<div class="banner-caption">
								<div class="asterthemes-wrapper">
									<div class="banner-catption-wrapper wow fadeInUp" data-wow-duration="1.5s">
										<h2 class="banner-caption-title">
											<a href="<?php the_permalink(); ?>"><?php the_title(); ?></a>
										</h2>
										<div class="mag-post-excerpt"><?php the_excerpt(); ?></div>
										<?php if ( ! empty( $aster_it_courses_button_label ) && ! empty( $aster_it_courses_button_link ) ) : ?>
											<div class="banner-slider-btn">
												<a href="<?php echo esc_url( $aster_it_courses_button_link ); ?>" class="asterthemes-button">
													<?php echo esc_html( $aster_it_courses_button_label ); ?>
												</a>
											</div>
										<?php endif; ?>
										<?php if ( get_theme_mod('aster_it_courses_right_image_text') != '' ) { ?>
											<div class="image-box mt-4">
											<div class="image-team">
												<?php if ( get_theme_mod( 'aster_it_courses_slider_team_image_1' ) ) { ?>
													<img class="team-img-small-1" src="<?php echo esc_url( get_theme_mod( 'aster_it_courses_slider_team_image_1' ) ); ?>">
												<?php } ?>
												<?php if ( get_theme_mod( 'aster_it_courses_slider_team_image_2' ) ) { ?>
													<img class="team-img-small-2" src="<?php echo esc_url( get_theme_mod( 'aster_it_courses_slider_team_image_2' ) ); ?>">
												<?php } ?>
												<?php if ( get_theme_mod( 'aster_it_courses_slider_team_image_3' ) ) { ?>
													<img class="team-img-small-3" src="<?php echo esc_url( get_theme_mod( 'aster_it_courses_slider_team_image_3' ) ); ?>">
												<?php } ?>
											</div>
											<div class="review-content">
													<p class="mb-0 count"><?php echo esc_html(get_theme_mod('aster_it_courses_right_image_box_3_count', '')); ?></p>
													<p class="mb-0 mt-0"><?php echo esc_html(get_theme_mod('aster_it_courses_right_image_text', '')); ?></p>
											</div>
											</div>
										<?php } ?>
									</div>
								</div>
							</div>
						</div>
					</div>
					<?php
				endwhile;
				wp_reset_postdata();
				?>
			</div>
		</div>
	</section>

<?php endif; ?>