<?php
/**
 *
 * @package Slider Premium
 */
?>
<?php $showContent = get_theme_mod('slider_section_show_content', 'on'); ?>
<div class="slider_section" id="slider">

	<div id="ht-bx-slider">
		<?php

		$color_overlay_classes = '';
		$color_overlay_opacity = get_theme_mod( 'cover_mainslider_template_overlay_opacity' );
		$color_overlay_opacity = ( false === $color_overlay_opacity ) ? 65 : $color_overlay_opacity;
		$color_overlay_classes .= ' opacity-' . $color_overlay_opacity;

		$args = array( 'post_type' => 'slider', 'orderby'   => 'id', 'order' => 'DESC',);
		if(!empty($pageId)){
			$args['page_id'] = absint($pageId);
			
		}
		$text = '';
		$query = new WP_Query($args);
		if($query->have_posts()){
			while($query->have_posts()) : $query->the_post(); 
				$pageLink = '';
				$slider_btn_link = get_post_meta($post->ID,'slider_btn_link',false);
				$sliderBtnTxt = get_post_meta($post->ID,'sliderBtnTxt',false);
				if(!empty($slider_btn_link) && is_array($slider_btn_link)){
					$pageLink = esc_url(get_permalink($slider_btn_link[0]));
				}
				if(!empty($sliderBtnTxt) && is_array($sliderBtnTxt)){
					$pageLinkTxt = $sliderBtnTxt[0];
				}else{
					$pageLinkTxt = 'Start Free Trial';
				}
				?>

				<div class="ht-slide">
					<div class="slider-content-box">
						<?php if($showContent == 'on'){?>
						<div class="slider_content">
							<div class="border-overlay"></div>
							<div class="ht-slide-overlay <?php echo esc_attr( $color_overlay_classes ); ?>"></div>
							
							<div class="title animated wow zoomIn"><?php echo (get_the_title()); ?></div>
							<div class="sub-title animated wow zoomIn">
								<?php echo (get_the_content()); ?>
							</div>
							<?php 
								if(!empty($pageLink)){ ?>
									<div class="slider-btn animated zoomIn">	
										<a class="btn btn-lg" href="<?php echo $pageLink; ?>"><?php echo($pageLinkTxt); ?>
											<div class="btnborder"></div>
										</a>
									</div>
							<?php }?>
						</div>
						<?php }?>
					</div>
					<div class="sliderimg">
							
						<?php 
						if(has_post_thumbnail()){
							$total_slider_image = wp_get_attachment_image_src(get_post_thumbnail_id(),'full');	
							echo '<img class="slide-mainimg" alt="'. esc_html(get_the_title()) .'" src="'.esc_url($total_slider_image[0]).'">';

						}?>
							<div class="img-border"></div>
					</div>
				</div>
					<?php
				endwhile;
			}else{ 
				for($i=0;$i<2;$i++){?>
				<div class="ht-slide">
					<div class="slider-content-box ">
						<?php if($showContent == 'on'){?>
							<div class="slider_content">
								<div class="border-overlay"></div>
								<div class="ht-slide-overlay <?php echo esc_attr( $color_overlay_classes ); ?>"></div>
								
								<div class="title animated zoomIn">Happily Ever After begins here</div>	
								<div class="sub-title animated wow zoomIn">It is a long established fact that a reader will be distracted by the readable content of a page when looking at its layout.</div>
								<div class="slider-btn animated zoomIn">	
									<a class="btn btn-lg" href="#"><?php _e( 'Request A Quate', 'luzuk-premium' ); ?>
										<div class="btnborder"></div>
									</a>
								</div>
							</div>
						<?php }?>
					</div>
					<div class="sliderimg">
						<?php echo '<img class="slide-mainimg" alt="Slider" src="'. esc_html(get_template_directory_uri()) .'/images/banner1.jpg">';?>
						<div class="img-border"></div>
					</div>
				</div>
				<?php }
			}?>
		</div>
	</div>
