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

$lawyer_consultant_firm_slider_category = get_theme_mod( 'lawyer_consultant_firm_slider_slider_category', 'slider' );
$lawyer_consultant_firm_trending_slider_heading = get_theme_mod( 'lawyer_consultant_firm_slider_heading');
$lawyer_consultant_firm_args = array(
	'post_type'           => 'post',
	'category_name'       => sanitize_text_field( $lawyer_consultant_firm_slider_category ),
	'posts_per_page'      => 6,
	'ignore_sticky_posts' => true,
);

$lawyer_consultant_firm_query = new WP_Query( $lawyer_consultant_firm_args );

if ( $lawyer_consultant_firm_query->have_posts() ) :
	$lawyer_consultant_firm_button_label = get_theme_mod( 'lawyer_consultant_firm_slider_button_label' );
	$lawyer_consultant_firm_button_link  = get_theme_mod( 'lawyer_consultant_firm_slider_button_link' );
	$lawyer_consultant_firm_button_link  = ! empty( $lawyer_consultant_firm_button_link ) ? esc_url( $lawyer_consultant_firm_button_link ) : '';
	$lawyer_consultant_firm_default_image_url = get_template_directory_uri() . '/resource/img/default.png';
    $lawyer_consultant_firm_banner_background_url = get_theme_mod('lawyer_consultant_firm_slider_background_image');
	?>
    <?php 
	$lawyer_consultant_firm_banner_background_url = get_theme_mod('lawyer_consultant_firm_slider_background_image', get_template_directory_uri() . '/resource/img/default.png' );
	?>
	<section id="lawyer_consultant_firm_slider_section" class="slider-section slider-style-1 wow fadeInDown" data-wow-duration="1.5s"  style="background-image: url('<?php echo esc_url($lawyer_consultant_firm_banner_background_url); ?>');" alt="<?php esc_attr_e('Banner Image', 'lawyer-consultant-firm'); ?>">
		<?php if ( is_customize_preview() ) : lawyer_consultant_firm_section_link( 'lawyer_consultant_firm_slider_section' ); endif; ?>
		<div class="slider-section-wrapper">
			<div class="asterthemes-wrapper">			
				<div class="owl-carousel">
					<?php
					while ( $lawyer_consultant_firm_query->have_posts() ) :
						$lawyer_consultant_firm_query->the_post();
						?>
						<div class="slider-single-outer">
							<div class="slider-single">
                                <div class="slider-caption">
									<div class="asterthemes-wrapper">
										<div class="slider-catption-wrapper">
											<?php if ( ! empty( $lawyer_consultant_firm_trending_slider_heading ) ) { ?>
												<h3><?php echo esc_html( $lawyer_consultant_firm_trending_slider_heading ); ?></h3>
											<?php } ?>
											<h2 class="slider-caption-title">
												<?php the_title(); ?>
											</h2>
											<?php if ( ! empty( $lawyer_consultant_firm_button_label ) && ! empty( $lawyer_consultant_firm_button_link ) ) : ?>
												<div class="banner-slider-btn">
													<a href="<?php echo esc_url( $lawyer_consultant_firm_button_link ); ?>" class="asterthemes-button">
														<?php echo esc_html( $lawyer_consultant_firm_button_label ); ?>
														<i class="fas fa-arrow-right"></i>
													</a>
												</div>
											<?php endif; ?>
										</div>
									</div>
								</div>
								<div class="slider-img wow zoomIn">
									<?php
									if ( has_post_thumbnail() ) {
										the_post_thumbnail( 'full' );
									} else {
										echo '<img src="' . esc_url( get_template_directory_uri() . '/resource/img/default1.png' ) . '" alt="' . esc_attr( get_the_title() ) . '">';
									}
									?>
								</div>
							</div>
						</div>
						<?php
					endwhile;
					wp_reset_postdata();
					?>
				</div>
			</div>
		</div>
	</section>
<?php endif; ?>