<?php
    
//faq
          

/**
 * 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', 8);
    $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');

        if ($isCustomizer === true) {
            $testimonial_area_designation = get_theme_mod('testimonial_area_designation' . $i);

        } else {
            $testimonial_area_designation = '';
        }

        $post = get_post();

                   //designation
        $designation = get_post_meta($post->ID, 'designation', false);
        $testimonial_area_designation = !empty($designation[0]) ? $designation[0] : '';
            ?>
        <div class="item innertest-item">
            <div class="tetimonoal-area">
                <div class="ts-main-area">
                    <div class="ts-area-single pd-0">
                        <div class=" inndata">                   
                            <div class="ts-area-thumb">
                                <img src="<?php echo (!empty($luzuk_image[0])) ? $luzuk_image[0] : get_template_directory_uri() . '/images/team-thumb.png' ?>" class="img-responsive" alt="<?php the_title(); ?>" />
                            </div>
                            <div class="ts-area-content">
                                <div class="ts-area-bx">                  
                                    <h6 class="ts-area-title"><?php the_title(); ?></h6>
                                    <div class="ts-area-desg"><?php echo ($testimonial_area_designation); ?></div>
                                </div>
                            </div>              
                            <div class="ts-area-c section-area-text">   
                                <p><?php
                                    if (has_excerpt()) {
                                        echo get_the_excerpt();
                                    } else {
                                        echo get_the_content();
                                    }
                                    ?> 
                                </p>              
                            </div>
                        </div>
                    </div>
                </div>
            </div>
            <!--iNNer page-->
            <div class="inner-t-area">
                <div class="ts-main-area">
                    <div class="ts-area-single">
                        <div class="row ">
                            <div class="ts-thumbbx">
                                <div class="ts-area-thumb">
                                    <img src="<?php echo (!empty($luzuk_image[0])) ? $luzuk_image[0] : get_template_directory_uri() . '/images/team-thumb.png' ?>" class="img-responsive" alt="<?php the_title(); ?>" />
                                </div>
                            </div>
                            <div class="tsconbx "> 
                                <h3 class="ts-area-title"><?php the_title(); ?></h3>
                                <div class="ts-area-desg inner-area-title ">
                                    <?php echo ($testimonial_area_designation); ?>
                                </div>
                            </div>
                        </div>
                        <div class="clearfix"></div>
                        <div class="ts-area-content ">
                            <div class="ts-area-c">  
                                <p><?php
                                    if (has_excerpt()) {
                                        echo get_the_excerpt();
                                    } else {
                                        echo get_the_content();
                                    }
                                    ?> 
                                </p>               
                            </div> 
                                <div class="clearfix"></div>
                            </div>
                    </div>
                    <div class="clearfix"></div>
                  </div>
            </div> 
            <!--iNNer page End-->
            <div class="clearfix"></div>
<script type="text/javascript">
    var title = 0;
    jQuery("#innerpage-box .ts-area-single").each(function(){
      if ($(this).height() > title) { title = $(this).height(); }
    });
    jQuery("#innerpage-box .ts-area-single").height(title);


    // on Resize change height

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


/*service*/
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',4);  
    $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:
        case 17:
        case 19:
        case 21:
        case 23:
        $colCls = 'col-md-4 col-sm-6';
        break;
        default: 
        $colCls = 'col-md-3 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  ">
    <div serviceinn-match-height="groupName" class="single-service">
        <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-text">
                    <a href="<?php the_permalink(); ?>">
                        <h3 class="post-title "><?php the_title(); ?></h3>
                    </a>
                    <p class="post-text inner-area-text"> <?php
                        if(has_excerpt()){
                          echo get_the_excerpt();
                         }else{
                          echo luzuk_excerpt( get_the_content() , 120 );
                         } 
                        ?>
                    </p> 
                     <?php
                      $homepageservicesbutton1 = get_theme_mod('homepageservices_txt1', 'Lern More'); 
                    ?>         
                    <?php if($homepageservicesbutton1){ ?>
                        <div class="readmore1 ">
                            <a href="<?php echo esc_url(get_permalink()); ?>">
                                <?php echo ($homepageservicesbutton1 );  ?>  
                            </a>
                        </div>
                    <?php }?>

                    <!--inner page button-->
                    <?php
                      $homepageservicesbutton = get_theme_mod('homepageservices_txt', 'Learn More'); 
                    ?>
                     
                    <?php if($homepageservicesbutton){ ?>
                        <div class="readmore">
                            <a href="<?php echo esc_url(get_permalink()); ?>" class="more-button"><?php echo ($homepageservicesbutton );  ?></a>
                        </div>
                    <?php }?>
                    <!--inner page button-->
                    <div class="clearfix"></div>
                </div>
            </a>
        </div>     
    </div>
    <script>
        var matchHeight = function () {
        
        function init() {
            eventListeners();
            matchHeight();
        }
        
        function eventListeners(){
            $(window).on('resize', function() {
                matchHeight();
            });
        }
        
        function matchHeight(){
            var groupName = $('[serviceinn-match-height]');
            var groupHeights = [];
            
            groupName.css('min-height', 'auto');
            
            groupName.each(function() {
                groupHeights.push($(this).outerHeight());
            });
            
            var maxHeight = Math.max.apply(null, groupHeights);
            groupName.css('min-height', maxHeight);
        };
        
        return {
            init: init
        };
        
    } ();

    $(document).ready(function() {
        matchHeight.init();
    });
    </script>
</div>


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

//team
function teamShortCode($pageId = null, $isCustomizer = false, $i = null) { 

    ob_start();

    $args = array('post_type' => 'our-team');
    if (!empty($pageId)) {
        $args['page_id'] = absint($pageId);
    }
    $args['posts_per_page'] = -1;
    $colCls = '';
    // if($isCustomizer == true){
    $cols = get_theme_mod('team_area_npp_count', 2);
    $cols++;
    switch($cols){
         case 1:
        $colCls = 'col-md-12 col-sm-12 col-xs-12';
        break;
        case 2: 
        $colCls = 'col-md-6 col-sm-6 col-xs-12';
        break;
        case 3:
        case 5:
        case 6:
        case 9:
        case 11:
        case 13:
        case 15:
        $colCls = 'col-md-4 col-sm-6 col-xs-12';
        break;
        default: 
        $colCls = 'col-md-3 col-sm-6 col-xs-12';
        break;
    } 

    // } 
 $text = '';
 $query = new WP_Query($args);
 if ($query->have_posts()):
    $postN = 0;

    while ($query->have_posts()) : $query->the_post();
        $team_area_image = wp_get_attachment_image_src(get_post_thumbnail_id(), 'total-team-thumb');
        if ($isCustomizer === true) {
            $team_area_designation = get_theme_mod('team_area_designation' . $i);
            $team_area_facebook = get_theme_mod('team_area_facebook' . $i);
            $team_area_twitter = get_theme_mod('team_area_twitter' . $i);
            $team_area_linkedin = get_theme_mod('team_area_linkedin' . $i);
            $team_area_instagram = get_theme_mod('team_area_instagram' . $i);
            $team_area_pinterest = get_theme_mod('team_area_pinterest' . $i);
        } else {
            $team_area_facebook = '';
            $team_area_twitter = '';
            $team_area_linkedin = '';
            $team_area_instagram = '';
            $team_area_pinterest = '';
            $team_area_designation = '';
        }

        $post = get_post();
            //Social media urls
        $teamFacebook = get_post_meta($post->ID, 'teamFacebook', false);
        $team_area_facebook = !empty($teamFacebook[0]) ? $teamFacebook[0] : '';

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

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

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

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

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

        ?>

        <div class=" single-team">
            <div class="our-team">
                <?php if ($team_area_designation) { ?>
                <div class="team-designation " >
                    <?php echo ($team_area_designation); ?>
                </div>
                <?php } ?>
                <div class="single-team-img">
                    <?php
                        if (has_post_thumbnail()) {
                            $image_url = $team_area_image[0];
                        } else {
                            $image_url = get_template_directory_uri() . '/images/team-thumb.png';
                        }
                    ?>                  
                    <img src="<?php echo esc_url($image_url); ?>" alt="<?php the_title(); ?>" />

                </div>
                <div class="conbx">
                    <div class="team-text"> <h4><?php the_title(); ?></h4> </div>
                    <?php if ($team_area_facebook || $team_area_twitter || $team_area_instagram || $team_area_linkedin || $team_area_pinterest) { ?>
                    <div class="team-social-icon"> 
                        <?php if ($team_area_facebook) { ?>
                        <a target="_blank" href="<?php echo esc_url($team_area_facebook) ?>">
                                <i class="fa fa-facebook"></i></a>
                        <?php } ?>
                        <?php if ($team_area_twitter) { ?>
                            <a target="_blank" href="<?php echo esc_url($team_area_twitter) ?>" ><i class="fa-brands fa-x-twitter"></i></a>
                        <?php } ?>
                        <?php if ($team_area_instagram) { ?>
                            <a target="_blank" href="<?php echo esc_url($team_area_instagram) ?>" ><i class="fa fa-instagram"></i></a> 
                        <?php } ?>
                       <?php if ($team_area_pinterest) { ?>
                        <a target="_blank" href="<?php echo esc_url($team_area_pinterest) ?>"><i class="fa fa-pinterest"></i></a>
                        <?php } ?>
                        <?php if ($team_area_linkedin) { ?>
                            <a target="_blank" href="<?php echo esc_url($team_area_linkedin) ?>" ><i class="fa fa-linkedin"></i></a> 
                        <?php } ?>
                    </div>
                    <?php } ?> 
                    <div class="clearfix"></div>   
                </div>
            </div>

            <!-- teampage -->
            <div class="teaminn-page">
                <div class="single-team-img">
                    
                    <?php if ($team_area_designation) { ?>
                    <div class="team-designation " >
                        <?php echo ($team_area_designation); ?>
                    </div>
                    <?php } ?>
                
                    <?php
                    if (has_post_thumbnail()) {
                        $image_url = $team_area_image[0];
                    } else {
                        $image_url = get_template_directory_uri() . '/images/team-thumb.png';
                    }
                    ?>                  
                    <img src="<?php echo esc_url($image_url); ?>" alt="<?php the_title(); ?>" />
                </div>     
                <div class="team-con">
                    <div class="team-text">
                        <a href="<?php the_permalink(); ?>"> 
                            <h4 class="inner-area-title " ><?php the_title(); ?></h4>
                        </a> 
                        <?php if ($team_area_facebook || $team_area_twitter || $team_area_instagram || $team_area_linkedin || $team_area_pinterest) { ?>
                        <div class="team-social-icon">
                            <?php if ($team_area_facebook) { ?>
                            <li><a target="_blank" href="<?php echo esc_url($team_area_facebook) ?>">
                                <i class="fa fa-facebook"></i></a></li>
                            <?php } ?>
                            <?php if ($team_area_twitter) { ?>
                               <li> <a target="_blank" href="<?php echo esc_url($team_area_twitter) ?>" ><i class="fa-brands fa-x-twitter"></i></a></li>
                            <?php } ?>
                            <?php if ($team_area_instagram) { ?>
                               <li> <a target="_blank" href="<?php echo esc_url($team_area_instagram) ?>" ><i class="fa fa-instagram"></i></a> </li>
                            <?php } ?>
                               <?php if ($team_area_pinterest) { ?>
                               <li> <a target="_blank" href="<?php echo esc_url($team_area_pinterest) ?>"><i class="fa fa-pinterest"></i></a></li>
                                <?php } ?>
                              <?php if ($team_area_linkedin) { ?>
                               <li> <a target="_blank" href="<?php echo esc_url($team_area_linkedin) ?>" ><i class="fa fa-linkedin"></i></a> </li>
                            <?php } ?>
                        </div>
                        <?php } ?> 
                        <div class="clearfix"></div>
                    </div>
                </div>
                <div class="clearfix"></div>
            </div>
            <!--team page-->
<script type="text/javascript">
    var title = 0;
    jQuery("#innerpage-box .our-team").each(function(){
      if ($(this).height() > title) { title = $(this).height(); }
    });
    jQuery("#innerpage-box .our-team").height(title);


    // on Resize change height

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

            <?php
        endwhile;
        $text = ob_get_contents();
        ob_clean();
    endif;
    wp_reset_postdata();
    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>
 * */


/*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', 5);  
    ++$cols;
    switch ($cols) {
        case 1:
        $colCls = 'col-md-12 col-sm-12 col-xs-12'; 
        break;
        case 2:
        $colCls = 'col-md-6 col-sm-6 col-xs-12';
        break;
        case 3:
        case 5:
        case 6:
        case 9:
        $colCls = 'col-md-4 col-sm-6 col-xs-12';
        break;
        case 4:
        case 7:
        case 8:
        case 10:
        case 11:
        case 12:
        $colCls = 'col-md-3 col-sm-6 col-xs-12';
        break;
        default:
        $colCls = 'col-md-4 col-sm-6 col-xs-12';
        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="gllbx">
                <div class="lz-gallery-images">     
                    <?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(); ?>">
                        <figure class="spa-gall">
                            <img class="secondry-bg img-responsive" src="<?php echo esc_url($image_url); ?>" alt="<?php the_title(); ?>" />
                            <div class="ovlay"></div>
                            <div class="over-text">
                                <h3> <?php the_title(); ?></h3>
                            </div>
                            <div class="icnbx"><i class="fa fa-eye"></i> </div>
                        </figure>
                    </a>
                </div>
            </div>
                <?php
            endwhile;
            $text = ob_get_contents();
            ob_clean();
        endif;
        wp_reset_postdata();
        return $text;
     }


// Gallery innerpg

// **************************
// ======event =========
// **************************

// ***end***

