<?php
/**
 *
 * @package Slider Premium
 */
?>
<?php $showContent = get_theme_mod('slider_section_show_content', 'on'); ?>
<div class="slider_section" id="slider" data-wow-duration="1s">
    <div class="container">
        <div class="owl-slider">
            <div id="carousel" class="owl-carousel">
                <?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')).';';
                    }
                //Button 
                    $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 = "Let's talk";
                    }

                // email
                    $slidemailtxt = get_post_meta($post->ID, 'slidemailtxt', false);
                    $slidemail_txt = !empty($slidemailtxt[0]) ? $slidemailtxt[0] : '';
                    
                // Phone Text
                    $sliderSubtitle = get_post_meta($post->ID, 'sliderSubtitle', false);
                    $sliderdatetext = !empty($sliderSubtitle[0]) ? $sliderSubtitle[0] : '';

                // Phone Number
                    $sliderphno = get_post_meta(get_the_ID(), 'sliderphno', true);
                    $sliderph_no = !empty($sliderphno) ? esc_html($sliderphno) : '';

                ?>
                <div class="item">
                    <div class="slbx">
                        <div class="conbxinn " data-wow-duration="1s">
                            <div class="row">
                                <div class="imbx " data-wow-duration="1s">
                                <?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]).'">';
                                }?>
                                    <?php  if(!empty( $sliderdatetext || $sliderph_no )){ ?>
                                    <div class="h-phone ">
                                        <div class="oly"></div>
                                        <div class="icnbx">
                                            <i class="fa-solid fa-phone-volume"></i>
                                        </div>
                                        <div class="phbx">
                                            <p> <?php echo $sliderdatetext; ?></p>
                                            <h3> <a href="tel:<?php echo $sliderph_no;?>"> <?php echo $sliderph_no; ?></a> </h3>
                                        </div>
                                    </div> 
                                    <?php }?>
                               </div>
                                <?php if($showContent == 'on'){ ?>
                                <div class="slider_content " data-wow-duration="1s">                
                                    <div class="slider_title animated bounceInDown" data-wow-duration="1s">
                                        <?php echo (get_the_title()); ?>   
                                        <div class="t-brd"></div>
                                    </div>                    
                                    <div class="slide-text animated fadeInLeft">
                                        <?php echo (get_the_content()); ?>
                                    </div>                           
                                                                
                                    <div class="btn5 animated bounceInLeft">  
                                        <?php  if(!empty($pageLink)){ ?>     
                                        <a class="s_bttn" href="<?php echo $pageLink; ?>">
                                            <?php echo($pageLinkTxt); ?> 
                                        </a>
                                        <?php }?>

                                        <?php  if(!empty($slidemail_txt)){ ?>     
                                        <a class="e_bttn" href="tel:<?php echo $slidemail_txt;?>">
                                            <i class="fa-solid fa-envelope-open-text"></i> <?php echo($slidemail_txt); ?>
                                        </a>
                                        <?php }?>
                                    </div>
                                </div>
                                <?php }?>
                            </div>
                        </div>
                    </div>
                </div>
                <?php
                    endwhile;
                }else{ 
                    for($i=0;$i<6;$i++){?>
                <div class="item">
                    <div class="slbx">
                        <div class="conbxinn " data-wow-duration="1s">
                            <div class="row">
                                <div class="imbx">
                                    <?php echo '<img class="slide-mainimg" alt="Slider" src="'. esc_html(get_template_directory_uri()) .'/images/slider.jpg">';?>  
                                        <div class="h-phone ">
                                            <div class="oly"></div>
                                            <div class="icnbx">
                                                <i class="fa-solid fa-phone-volume"></i>
                                            </div>
                                            <div class="phbx">
                                                <p> SCHEDULE MY FREE CALL </p>
                                                <h3> <a href="#">+123 456 7890 </a> </h3>
                                            </div>
                                        </div> 
                                </div>
                                <?php if($showContent == 'on'){?>     
                                <div class="slider_content" data-wow-duration="1s">
                                    <div class="slider_title animated bounceInDown" data-wow-duration="1s">
                                        Navigating <span> Tax Challenges </span> with Precision and Expertise.  
                                    </div>
                                    <div class="slide-text animated fadeInLeft">
                                        Lorem ipsum dolor sit amet, consectetur adipiscing elit. Mauris vitae lacus sit amet felis ullamcorper eleifend vitae vitae est. Quisque sem nibh, bibendum vel ultrices pretium, molestie sed nisi.
                                    </div>                               
                                    
                                    <div class="btn5 animated bounceInLeft">
                                        <a class="s_bttn" href="#">
                                            <?php _e( "Let's talk" , 'luzuk-premium' ); ?>
                                        </a>
                                        <a class="e_bttn" href="#">
                                            <i class="fa-solid fa-envelope-open-text"></i> info@mail.com
                                        </a>
                                    </div>
                                   
                                </div>
                                <?php }?>    
                            </div>
                            <!-- <div class="clearfix"></div> -->
                        </div>
                       
                    </div>
                </div>
                <?php }

                }?>
            </div>
        </div>
    </div>
</div>
<script>
        $(document).ready(function() {
          $('.slider_section .owl-carousel').owlCarousel({
            refreshClass: 'owl-refresh',
            autoplayTimeout:6000,
            loop: true,
            margin: 30,
            autoHeight: false,
            autoWidth: false,
            autoplay: true,
         //   animateOut: 'lightSpeedOut',
           // animateIn: 'zoomIn',
            navText: [
                    '<i class="fa fa-caret-left"></i> ',
                    '<i class="fa fa-caret-right" ></i>'
                ],
            responsiveClass: true,

            responsive: {
              0: {
                items: 1,
                nav: true,
                margin: 10
              },
              600: {
                items:1,
                nav: true,
                margin: 10
              },
              1000: {
                items:1,
                nav: true,
                loop: true,
                margin: 10
              }
            }
          })
        })

</script>
