<?php
       
//faq
           function faqShortcode($isHome = 0) {
            global $query;

            $args = array('post_type' => 'our-faq');

            if (!empty($pageId)) {
                $args['page_id'] = absint($pageId);
            } else {
                $args['paged'] = max(1, get_query_var('paged'));
            }

            if(!empty($isHome) && $isHome == 1){
                $cols = get_theme_mod('faq_section_npp_count', 5);
                $cols++;
                $args['posts_per_page'] = $cols;
            }else{
                $args['posts_per_page'] = (!empty($args['posts_per_page'])) ? $args['posts_per_page'] : -1;
         // $cols = 5;
            }
            $faqPageId = get_theme_mod('faq_section_page_link');
            $query = new WP_Query($args);

            ob_start();?>
            <?php
              $faqinn_Heading = get_theme_mod('faqinn_heading', 'F.A.Q.');
              $faqinn_text = get_theme_mod('faqinn_text', ' Frequently Asked Questions'); 
          ?>
            <div class="col-lg-5 faqinn-leftbxcon">
                <div class="faqinn-leftbx">
                  <div class="subtitle">
                          <h5><?php echo ($faqinn_text);  ?> </h5>
                        </div>
                    <div class="faqinnlfbx-detail">
                        <div class="leftbx-content">
                            <div class="lhsbx">
                              <div class="faqinn-brd"></div>
                            </div>
                        </div>
                    </div>
                    <div class="faqinn-heading wow zoomIn">
                        <h2> <?php echo ($faqinn_Heading);  ?></h2>
                    </div>
                </div>
            </div>
            <div class="col-lg-7 faqinn-rightbxcon">
                 <?php
    // print_r($query);
            echo '<div class="faq">';
            if ($query->have_posts()){
                while ($query->have_posts()) : $query->the_post();
                    $post = get_post();
                    ?>

        <!-- <div class="row"> -->
            <div class=" faq-content">
                <button class="accordion"> <h4 class="faq-title"><?php the_title(); ?></h4></button>
                <div class="panel">
                    <div class="faq-description"> 
                        <p><?php
                           if(!empty($isHome) && $isHome==1){
                            if (has_excerpt()) {
                                echo get_the_excerpt();
                            } else {
                                    //echo luzuk_excerpt(get_the_content(),300);
                               echo get_the_content();
                           }
                                    // if(!empty($faqPageId)){
                                    //     echo '<a href="'.get_permalink($faqPageId).'">Read More..</a>';
                                    // }else{
                                    //     echo '<a href="'.get_permalink($faqPageId).'">Read More..</a>';
                                    // }
                           }else{
                            echo get_the_content();
                            }?>  
                        </p>
                    </div>
                </div>
            </div>       
        <!-- </div> -->
    <?php
endwhile;
}else{
    for($i=0; $i<6; $i++){
        ?>
        <!-- <div class="row"> -->
        <div class="faq-content">
            <button class="accordion"> 
                <h4 class="faq-title">There are many variations of passages of Lorem</h4>
            </button>
            <div class="panel">
                <div class="faq-description"> 
                  <p>
                    <?php
                        if(!empty($isHome) && $isHome==1){
                            ?>
                            There are many variations of passages of Lorem Ipsum available, but the majority have suffered alteration in some form, by injected humour, or randomised words which don't look even slightly believable. 
                            <br>
                            <?php
                        }else{
                            ?>
                            There are many variations of passages of Lorem Ipsum available, but the majority have suffered alteration in some form, by injected humour, or randomised words which don't look even slightly believable. 
                            <?php
                        }?>
                    </p>
                </div>
            </div>
        </div>
    <!-- </div> -->
    <?php   
}
}
echo '</div>';

?> 
    <div class="clearfix"></div>
</div>
<script>
    var acc = document.getElementsByClassName("accordion");
    var i;

    for (i = 0; i < acc.length; i++) {
        acc[i].onclick = function(){
            this.classList.toggle("active");
            this.nextElementSibling.classList.toggle("show");
        }
    }
</script>
<?php
$text = ob_get_contents();
ob_clean();
ob_end_flush();
wp_reset_postdata();
    // echo $text;
return $text;
}



/**
 * Use for the show the testimonials at home page and in testimonial page with shortcode
 * @param int $pageId default is null the id of a post
 * @param boolean $isCustomizer default is false if set to true it mean the output is set for the home page
 * @param int $i default null
 * @param boolean $showStaticVals default is false
 * @return string
 * @author luzuk <support@luzuk.com>
 * */
function testimonialShortCode($pageId = null, $isCustomizer = false, $i = null) {
    ob_start();

    $args = array('post_type' => 'our-testimonial');
    if (!empty($pageId)) {
        $args['page_id'] = absint($pageId);
    }
    $colCls = '';
    if($isCustomizer == true){
    $cols = get_theme_mod('test_npp_count', 6);
    $testimonials_page = get_theme_mod('luzuk_testimonials_data'.$i);
     $testimonials_page_icon = get_theme_mod('testimonials_page_icon'.$i);
    $cols++;
    switch($cols){
        
            }
           $icons = array(1=>'heart', 2=>'star', 3=>'flash', 4=>'bell',5=>'heart', 6=>'star', 7=>'flash', 8=>'bell');     
    }
    $text = '';
    
    $query = new WP_Query($args);
    if ($query->have_posts()):
        $postN = 0;
        
        while ($query->have_posts()) : $query->the_post();
        $luzuk_image = wp_get_attachment_image_src(get_post_thumbnail_id(), 'total-team-thumb');
        $post = get_post();

        if (($postN % 3) == 0 && $isCustomizer == false) {
            
        }
        ++$postN;

        ?>
         <div class="swiper-slide">
            <div class="tetimonoal-area">  
                <div class="ts-area-single ">
                    <div class="ts-area-c">    
                          <p>
                            <?php
                                  if (has_excerpt()) {
                                      echo get_the_excerpt();
                                  } else {
                                      echo luzuk_excerpt( get_the_content() , 110 );
                                  }
                              ?>   
                          </p>   
                    </div> 
                    <div class="ts-area-content">
                        <div class="row no-gutter">
                            <div class="col-xl-5 col-lg-5 col-md-5 col-sm-5 pd-0">
                                <h3 class="ts-area-title"><?php the_title(); ?></h3>
                            </div>
                             <div class="col-xl-2 col-lg-2 col-md-2 col-sm-2 ">
                                <div class="ts-area-thumb">
                                    <?php
                                          if (has_post_thumbnail()) {
                                            $image_url = $luzuk_image[0];
                                          } else {
                                            $image_url = get_template_directory_uri() . '/images/about1.jpg';
                                          }
                                    ?>
                                    <img  src="<?php echo esc_url($image_url); ?>" alt="<?php the_title(); ?>" />
                                </div>
                             </div>
                             <div class="col-xl-5 col-lg-5 col-md-5 col-sm-5 col-xs-12 pd-0">
                                <div class="text-designation">
                                    <?php
                                        $name2 = get_post_meta($post->ID, 'testimonial_Sub_Title', false);
                                        echo (!empty($name2[0])) ? $name2[0] : '';
                                    ?> 
                                </div>
                             </div>
                        </div>
                      <div class="clearfix"></div>
                    </div>
                </div>
                <div class="clearfix"></div>
            </div>
        </div>
            
        <?php
        //$test++;
    endwhile;
    $text = ob_get_contents();
    ob_clean();
endif;
wp_reset_postdata();
return $text;

}





/*services*/
function serviceShortCode($pageId = null, $isCustomizer = false, $i = null) {

    ob_start();

    $args = array('post_type' => 'our-services');
    if (!empty($pageId)) {
        $args['page_id'] = absint($pageId);
    }
    $args['posts_per_page'] = -1;
    $colCls = '';
    // if($isCustomizer == true){
    $cols = get_theme_mod('service_npp_count',3);  
    $services_page_icon1 = get_theme_mod('services_page_icon1'.$i);
    ++$cols;
    switch ($cols) {
        case 1:
        $colCls = 'col-md-12 col-sm-12';
        break;
        case 2: 
        $colCls = 'col-md-6 col-sm-6';
        break;
        case 3:
        case 5:
        case 6:
        case 9:
        case 11:
        case 13:
        case 15:
        $colCls = 'col-md-4 col-sm-6';
        break;
        default: 
        $colCls = 'col-md-4 col-sm-6';
        break;
        }
    // }
        $text = '';
        $query = new WP_Query($args);
        if ($query->have_posts()):
            $postN = 0;

        while ($query->have_posts()) : $query->the_post();
            $luzuk_image = wp_get_attachment_image_src(get_post_thumbnail_id(), 'total-service-thumb');
            $post = get_post();

        ?>

        <div class="<?php echo $colCls; ?> single-service-bx wow zoomIn"> 
            <div class="single-service" data-match-height="single-service ">
                <div class="service-numb">
                    <h5>0<?php echo $i; ?></h5>
                </div>
                <div class="service-icon">
                    <a href="<?php the_permalink(); ?>">
                        <?php
                            if (has_post_thumbnail()) {
                                $image_url = $luzuk_image[0];
                            } else {
                                $image_url = get_template_directory_uri() . '/images/services.jpg';
                            }
                        ?>                                                        
                        <img class="img-responsive" src="<?php echo esc_url($image_url); ?>" alt="<?php the_title(); ?>" />
                        <div class="ser-ovly"></div>
                        <div class="sertxbx">
                            <a href="<?php the_permalink(); ?>">
                                <h4 class="post-title inner-area-title wow fadeInDown"><?php the_title(); ?></h4>
                            </a>
                            <p class="section-area-text">
                                <?php

                                    if(has_excerpt()){
                                      echo get_the_excerpt();
                                     }else{
                                      echo luzuk_excerpt( get_the_content() , 75 );
                                     } 
                                ?>
                                <?php if( get_theme_mod('service_arrw_display','show' ) == 'show') :?>
                                    <a href="<?php echo esc_url(get_permalink()); ?>">
                                        <i class="fa fa-angle-double-right" aria-hidden="true"></i>
                                    </a>
                                <?php endif ?>
                            </p>
                        </div>
                    </a>
                </div>
            </div> 
        </div>
        <!-- inner-page -->
        <div class="col-lg-4 col-md-6 col-sm-6 col-xs-12 inn-single-service-bx wow zoomIn">
            <div class="singleinner-service">
                <?php 
                    $sertxtlimit = get_theme_mod('sertxtlimit', '75');
                ?> 
                <div class="service_inbox serviceinbox">
                    <div class="service_inimg">
                        <a href="<?php the_permalink(); ?>">
                           <?php
                            if (has_post_thumbnail()) {
                                $image_url = $luzuk_image[0];
                            } else {
                                $image_url = get_template_directory_uri() . '/images/services.jpg';
                            }
                            ?> 
                            <img class="service-img" src="<?php echo esc_url($image_url); ?>" alt="<?php the_title(); ?>" />
                            <div class="servinn-ovly"></div>
                        </a>
                    </div>
                    <div class="ser-contbx">
                        <div class="serbx">
                            <a href="<?php the_permalink(); ?>">
                                <h3 class="title"> <?php the_title(); ?> </h3>
                            </a>
                            <p class="description">
                                 <?php 
                                       if (has_excerpt()) {
                                                  echo get_the_excerpt();
                                              } else {
                                                  echo luzuk_excerpt(get_the_content(),$sertxtlimit );  
                                           }
                                    ?> 
                                <!-- </?php

                                    if(has_excerpt()){
                                      echo get_the_excerpt();
                                     }else{
                                      echo luzuk_excerpt( get_the_content() , 110 );
                                     } 
                                ?> -->
                               
                            </p>
                            <div class="serbtn">  
                                <a href="<?php echo esc_url(get_permalink()); ?>">
                                    <i class="fa fa-angle-double-right" aria-hidden="true"></i>
                                </a>
                            </div> 
                        </div>
                    </div>
                    <div class="clearfix"></div>
                </div>
            </div>
        </div>
        <!-- inner-page -->
    <script type="text/javascript">
        var title = 0;
        jQuery("#innerpage-box .service_inbox").each(function(){
          if ($(this).height() > title) { title = $(this).height(); }
        });
        jQuery("#innerpage-box .service_inbox").height(title);


        // on Resize change height

        jQuery(window).resize(function(){
          jQuery("#innerpage-box .service_inbox").height("");
          var title = 0;
          jQuery("#innerpage-box .service_inbox").each(function(){
            if ($(this).height() > title) { title = $(this).height(); }
          });
          jQuery("#innerpage-box .service_inbox").height(title);
        });
    </script>

            <?php
        endwhile;
        $text = ob_get_contents();
        ob_clean();
    endif;
    wp_reset_postdata();
    return $text;
}



// ==========================
/*********gallery************/ 
// ==========================

function galleryShortCode($pageId = null, $isCustomizer = false, $i = null) {

    ob_start();

    $args = array('post_type' => 'our-gallery');
    if (!empty($pageId)) {
        $args['page_id'] = absint($pageId);
    }
    $args['posts_per_page'] = -1;
    $colCls = '';
    // if($isCustomizer == true){
    $cols = get_theme_mod('luzuk_gallery_npp_count', 7);  
    ++$cols;
    switch ($cols) {
        case 1:
        $colCls = 'col-lg-12 col-md-12 col-sm-12';
        break;
        case 2: 
        $colCls = 'col-lg-6 col-md-6 col-sm-6';
        break;
        case 3:
        case 5:
        case 6:
        case 9:
        case 11:
        case 13:
        case 15:
        $colCls = 'col-lg-4 col-md-6 col-sm-6';
        break;
        default: 
        $colCls = 'col-lg-4 col-md-6 col-sm-6';
        break;
    }
    // }
    $text = '';
    $query = new WP_Query($args);
    if ($query->have_posts()):
        $postN = 0;

        while ($query->have_posts()) : $query->the_post();
            $luzuk_image = wp_get_attachment_image_src(get_post_thumbnail_id(), 'medium_large');
            $post = get_post();
            ?> 

      <div class="<?php echo $colCls; ?> gall-contain wow zoomIn">  
    <!-- <div class="item wow zoomIn "> --> 
        <div class="homegalry"> 
            <div class="lz-gallery-images">
                <figure class="spa-gall">
                    <?php
                        if (has_post_thumbnail()) {
                            $image_url = $luzuk_image[0];
                        } else {
                            $image_url = get_template_directory_uri() . '/images/about1.jpg';
                        }
                    ?>
                    <a data-fancybox="gallery" href="<?php echo esc_url($image_url); ?>" title="<?php the_title(); ?>">  
                        <img class="secondry-bg img-responsive" src="<?php echo esc_url($image_url); ?>" alt="<?php the_title(); ?>" />
                        <div class="over-text">
                        <i class="fa fa-plus" aria-hidden="true"></i>
                    </div>
                    </a>
                 </figure> 
            </div>
            <div class="clearfix"></div>
        </div> 
        
        <script type="text/javascript">
                var title = 0;
            jQuery("#innerpage-box .lz-gallery-images").each(function(){
              if ($(this).height() > title) { title = $(this).height(); }
            });
            jQuery("#innerpage-box .lz-gallery-images").height(title);


            // on Resize change height

            jQuery(window).resize(function(){
              jQuery("#innerpage-box .lz-gallery-images").height("");
              var title = 0;
              jQuery("#innerpage-box .lz-gallery-images").each(function(){
                if ($(this).height() > title) { title = $(this).height(); }
              });
              jQuery("#innerpage-box .lz-gallery-images").height(title);
            });
        </script>
    </div>
                <?php
            endwhile;
            $text = ob_get_contents();
            ob_clean();
        endif;
        wp_reset_postdata();
        return $text;
    }



