<?php
/**
 *
 * @package Slider Premium
 */
?>
<?php $showContent = get_theme_mod('slider_section_show_content', 'on'); ?>
<div id="slider" class="slider_section">
    <div class="container">
        <div class="swiper cubeSwiper">
            <div  class="swiper-wrapper">
                <?php
                $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(); 
                    

                    if( get_theme_mod('slider_areaOpacity',true) ) {
                        $slider_areaOpacity = 'opacity:'.esc_attr(get_theme_mod('slider_areaOpacity')).';';
                    }
                    if( get_theme_mod('slider_Tfontsize',true) ) {
                        $slider_Tfontsize = 'font-size:'.esc_attr(get_theme_mod('slider_Tfontsize')).';';
                    }

                    $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';
                    }

                    // $sliderchangedate = get_post_meta($post->ID, 'sliderchangedate', false);
                    // $sliderdatetext = !empty($sliderchangedate[0]) ? $sliderchangedate[0] : '';

                    ?>
                <div class="swiper-slide">
                    <div class="slider-area">
                        <div class="slider-overlay"></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>
                        <?php if($showContent == 'on'){?>
                            <div class="slider_content animated " >
                                <div class="subtitle-brd"></div>
                                <div class="sub-title animated ">THE BEST WAY TO</div>
                                <div class="title animated "><?php echo (get_the_title()); ?></div>
                                <div class="text animated "><?php echo (get_the_content()); ?></div>
                                <?php 
                                    if(!empty($pageLink)){ ?>
                                    <div class="slide-btna">
                                        <div class="btn5">  
                                            <a href="<?php echo $pageLink; ?>"> 
                                                <span><?php echo($pageLinkTxt); ?></span>
                                            </a>
                                        </div>
                                    </div>
                                <?php }?>
                            </div>
                        <?php }?>
                    </div>
                </div>
                        <?php
                    endwhile;
                }else{ 
                for($i=0;$i<6;$i++){?>
                <div class="swiper-slide">
                    <div class="slider-area">
                        <div class="slider-overlay"></div>
                        <div class="sliderimg ">
                            <?php echo '<img class="slide-mainimg " alt="Slider" src="'. esc_html(get_template_directory_uri()) .'/images/slider1.jpg">';?>
                        </div>
                        <?php if($showContent == 'on'){?>
                            <div class="slider_content animated " >
                                <div class="subtitle-brd"></div>
                                <div class="sub-title animated ">THE BEST WAY TO</div>
                                <div class="title animated ">Find Your Dream Home</div>
                                <div class="text animated ">We’ve More Than 745,000 Apartments, Place & Plot.</div>
                                <div class="slide-btna ">
                                    <div class="btn5">
                                        <a href="#">
                                            <span><?php _e( 'Book Now', 'luzuk-premium' ); ?></span>
                                        </a>
                                    </div>
                                </div>
                            </div>
                        <?php }?>
                    </div>
                </div>
                <?php }
            }?>
            </div>
        </div>
    </div>
    <div class="pagination-container"> 
        <button class="cube-button-prev">
            <svg width="36.735" height="90.151" viewBox="0 0 36.735 90.151">
              <path id="Path_6" data-name="Path 6" d="M80.4,10.579a9.341,9.341,0,0,0-8.969,6.953,26.165,26.165,0,0,1-50.443,0,9.341,9.341,0,0,0-8.969-6.953H9.26A9.26,9.26,0,0,1,0,1.318V0H90.151V1.318a9.26,9.26,0,0,1-9.26,9.26Z" transform="translate(0 90.151) rotate(-90)"/>
            </svg>
            <i class="fa fa-angle-left" aria-hidden="true"></i>
        </button>
        <button class="cube-button-next">
            <svg width="36.735" height="90.151" viewBox="0 0 36.735 90.151">
              <path id="Path_5" data-name="Path 5" d="M80.4,26.156A9.341,9.341,0,0,1,71.43,19.2a26.165,26.165,0,0,0-50.443,0,9.341,9.341,0,0,1-8.969,6.953H9.26A9.26,9.26,0,0,0,0,35.417v1.318H90.151V35.417a9.26,9.26,0,0,0-9.26-9.26Z" transform="translate(0 90.151) rotate(-90)"/>
            </svg>
            <i class="fa fa-angle-right" aria-hidden="true"></i>
        </button>
    </div>
    <script type="text/javascript">
        var swiper = new Swiper("#slider .cubeSwiper", {
          // swiper effect
          effect: "cube",
          grabCursor: true,
          speed: 2000,
          loop: true,
          autoplay: false,
          // autoplay: {
          //   delay: 4000,
          //   // Pause on hover
          //   pauseOnMouseEnter: true,
          //   disableOnInteraction: false
          // },
          navigation: {
            nextEl: ".cube-button-next",
            prevEl: ".cube-button-prev"
          }
        });
    </script>
<div class="clearfix"></div>
</div>