<?php

/**
 * Liting the team/trainer details 
 * @param : int $pageId default is null
 * @param : boolean $isCustomizer default is false, if set to true will get the data stored with customizer
 * @param : int $i default is null, it will used as a iteration for data with customizer, this will be used only if the $isCustomizer is set to true.
 * @return: Text $text
 */
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_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:
            $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();
            $luzuk_image = wp_get_attachment_image_src(get_post_thumbnail_id(), 'total-team-thumb');
            if ($isCustomizer === true) {
                $team_designation = get_theme_mod('team_designation' . $i);
                $team_facebook = get_theme_mod('team_facebook' . $i);
                $team_twitter = get_theme_mod('team_twitter' . $i);
                 $team_linkedin = get_theme_mod('team_linkedin' . $i);
                  $team_instagram = get_theme_mod('team_instagram' . $i);
                    $team_pinterest = get_theme_mod('team_pinterest' . $i);
            } else {
                $team_facebook = '';
                $team_twitter = '';
                 $team_linkedin = '';
                  $team_instagram = '';
                   $team_pinterest = '';
                   $team_designation = '';
            }

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

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

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

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

            
            ?>
             <div class="row">
            <div class="<?php echo $colCls; ?>">
                <div class="ht-team-member text-center wow zoomIn">
                
                    <div class="ht-team-member-image">
                        <?php
                        if (has_post_thumbnail()) {
                            $image_url = $luzuk_image[0];
                        } else {
                            $image_url = get_template_directory_uri() . '/images/team-thumb.png';
                        }
                        ?>                  
                        <img class="secondry-bg" src="<?php echo esc_url($image_url); ?>" alt="<?php the_title(); ?>" />
                        <div class="team-member-content-overlay"></div>
                    </div>
                        
                       
                        <div class="ht-title-wrap">
                             <?php if ($team_facebook || $team_twitter || $team_instagram || $team_linkedin  || $team_pinterest) { ?>
                                <div class="ht-team-social-id">
                                    <div class="teaminnerborder"></div>
                                    <?php if ($team_facebook) { ?>
                                    <a target="_blank" href="<?php echo esc_url($team_facebook) ?>"><i class="fa fa-facebook"></i></a>
                                    <?php } ?>
                                    <?php if ($team_twitter) { ?>
                                    <a target="_blank" href="<?php echo esc_url($team_twitter) ?>"><i class="fa fa-twitter"></i></a>
                                    <?php } ?>

                                    <?php if ($team_instagram) { ?>
                                    <a target="_blank" href="<?php echo esc_url($team_instagram) ?>"><i class="fa fa-instagram"></i></a>
                                    <?php } ?>
                                    <?php if ($team_linkedin) { ?>
                                    <a target="_blank" href="<?php echo esc_url($team_linkedin) ?>"><i class="fa fa-linkedin"></i></a>
                                    <?php } ?>
                                     <?php if ($team_pinterest) { ?>
                                    <a target="_blank" href="<?php echo esc_url($team_pinterest) ?>"><i class="fa fa-pinterest"></i></a>
                                    <?php } ?>
                                    <div class="clearfix"></div>
                                </div>                
                            <?php } ?>
                                <div class="team-box">
                            <h6 class="member-name"><?php the_title(); ?></h6>  
                            <div class="ht-team-member-excerpt-wrap">
                                <div class="ht-team-member-span">
                                    <?php if (!empty($team_designation)) { ?>
                                    <div class="team-member-designation"><?php echo($team_designation); ?></div>
                                    <?php
                                    } ?>
                                </div>
                            </div>
                        </div>
                        </div> 
                        </div> 
                        <script>
                            jQuery.noConflict();
                            $(function(){
                                function htteammemberHeight(){
                                    var ht = 0;
                                    $('#innerpage-box .ht-team-member').each(function(i){
                                        var tHt = $(this).height();
                                        if(ht<tHt){
                                            ht=tHt;
                                        }
                                    });
                                    $('#innerpage-box .ht-team-member').height(ht+'px');
                                }
                                htteammemberHeight();
                            });
                            $( window ).resize(function(){
                                htteammemberHeight();
                            });
                        </script>               
                <div class="clearfix"></div>          
            </div>
        <?php
    endwhile;
    $text = ob_get_contents();
    ob_clean();
endif;
wp_reset_postdata();
return $text;
}


/**
 * Liting the feature details 
 * @param : int $pageId default is null
 * @param : boolean $isCustomizer default is false, if set to true will get the data stored with customizer
 * @param : int $i default is null, it will used as a iteration for data with customizer, this will be used only if the $isCustomizer is set to true.
 * @return: Text $text
 */
function featuredShortCode($pageId = null, $isCustomizer = false, $i = null) {
    ob_start();

    $args = array('post_type' => 'our-service');
    if (!empty($pageId)) {
        $args['page_id'] = absint($pageId);
    }
    $args['posts_per_page'] = -1;
    $colCls = '';
    // if($isCustomizer == true){
    $cols = get_theme_mod('services_npp_count', 5);
     $services_page_icon1 = get_theme_mod('services_page_icon1'.$i);
    $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 10:
        case 11:
            $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();
            $luzuk_image = wp_get_attachment_image_src(get_post_thumbnail_id(), 'total-features-thumb');

            

            if ($isCustomizer === true) {
                $feature_designation = get_theme_mod('feature_designation' . $i);
            }
            $post = get_post();
            //designation
            $designation = get_post_meta($post->ID, 'designation', false);
            $feature_designation = !empty($designation[0]) ? $designation[0] : '';
           
            ?> 
            <div class="row">
            <div class="<?php echo $colCls; ?> fpost">
                        
                <div class="featured-post-box wow fadeInLeft">
                   
                    <div class="featured-post">
                        <a class="secondry-bg" href="<?php echo esc_url(get_permalink()); ?>">
                             <div class="featured-icon">
                                <span class="<?php echo $services_page_icon1; ?>"></span>
                            </div>
                        </a>

                        <div class="featuredcontent-data">
                              <a class="secondry-bg" href="<?php echo esc_url(get_permalink()); ?>">
                                <div class="featured-img">
                                    <?php
                                    if (has_post_thumbnail()) {
                                        $image_url = $luzuk_image[0];
                                    } else {
                                        $image_url = get_template_directory_uri() . '/images/team-thumb.png';
                                    }
                                    ?>                  
                                    <img class="secondry-bg img-responsive" src="<?php echo esc_url($image_url); ?>" alt="<?php the_title(); ?>" />
                                </div>
                                </a>
                        <div class="featured-data">
                           <h5 class="text"><?php the_title(); ?></h5> 
                            <div class="clearfix"></div> 
                            <p>
                                <?php

                                if(has_excerpt()){
                                  echo get_the_excerpt();
                                 }else{
                                  echo luzuk_excerpt( get_the_content() , 80 );
                                 } 
                                ?>
                            </p>
                        </div>
                    </div>
                </div> 
                           
                <div class="clearfix"></div>          
            </div>
            <script>
  jQuery.noConflict();
  $(function(){
    function featuredpostboxHeight(){
      var ht = 0;
      $('#innerpage-box .featured-post-box').each(function(i){
        var tHt = $(this).height();
        if(ht<tHt){
          ht=tHt;
        }
      });
      $('#innerpage-box .featured-post-box').height(ht+'px');
    }
    featuredpostboxHeight();
  });
  $( window ).resize(function(){
    featuredpostboxHeight();
  });
</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>
 * */

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('luzuk_test_npp_count', 2);
    $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) {
                $luzuk_test_designation = get_theme_mod('luzuk_test_designation' . $i);
            }
            $post = get_post();
            //designation
            $designation = get_post_meta($post->ID, 'designation', false);
            $luzuk_test_designation = !empty($designation[0]) ? $designation[0] : '';

            if (($postN % 3) == 0 && $isCustomizer == false) {
                ?>
                <div class="clearfix paddingBot20"></div>
            </div>
            <div class="row">
                <?php
            }
            ++$postN;
            ?>
            <div class="<?php echo $colCls; ?> ">
                <div class="ht-test-member wow fadeInRight testimonial-home-area">
                    <div class="test-contentbox">
                        <div class="test-content">
                            <?php
                                if (has_excerpt()) {
                                    echo get_the_excerpt();
                                } else {
                                    echo get_the_content();
                                }
                            ?>
                        </div> 
                        <div class="clearfix"></div>
                        <div class="text-designation"><?php
                            $name2 = get_post_meta($post->ID, 'testimonial_Sub_Title', false);
                            echo (!empty($name2[0])) ? $name2[0] : '';
                            ?>
                        </div> 
                        <h6 class="member-name"><?php the_title(); ?></h6>
                       
                    </div>
                     <div class="ht-test-member-image">
                          <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="clearfix"></div>
                </div>

                <div class="testimonial-inner-area">
                <div class="ht-test-member wow fadeInRight">
                     <div class="col-md-3 pd-0">
                         <div class="ht-test-member-image">
                              <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="col-md-9 pd-0">
                        <div class="test-contentbox">
                            <div class="test-content">
                                <?php
                                    if (has_excerpt()) {
                                        echo get_the_excerpt();
                                    } else {
                                        echo get_the_content();
                                    }
                                ?>
                            </div> 
                            <div class="clearfix"></div>
                            <div class="text-designation"><?php
                                $name2 = get_post_meta($post->ID, 'testimonial_Sub_Title', false);
                                echo (!empty($name2[0])) ? $name2[0] : '';
                                ?>
                            </div> 
                            <h6 class="member-name"><?php the_title(); ?></h6>
                           
                        </div>
                    </div>
                   
                    <div class="clearfix"></div>
                </div>
            </div>
            
            </div>

            

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


/*End Testimonials*/

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', 2);
        $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();
    // 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="col-md-12 faq-content padding0 wow fadeInLeft">
                    <h6 class="faq-title"><?php the_title(); ?></h6>
                    <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>
            <?php
        endwhile;
    }else{
        for($i=0; $i<$cols; $i++){
            ?>
            <div class="row">
                <div class="col-md-12 faq-content padding0">
                    <h6 class="faq-title">Lorem Ipsum is simply dummy text of the printing and typesetting?</h6>
                    <div class="faq-description">
                        <p><?php
                            if(!empty($isHome) && $isHome==1){
                                ?>
                                Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. Lorem Ipsum is simply dummy text of the printing  typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s. Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s.
                                <br>
                                <?php
                                // if(!empty($faqPageId)){
                                //     echo '<a href="'.get_permalink($faqPageId).'">Read More..</a>';
                                // }else{
                                //     echo '<a href="'.get_permalink($faqPageId).'">Read More..</a>';
                                // }
                            }else{
                                ?>
                                Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. Lorem Ipsum is simply dummy text of the printing  typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s. Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s.

                                Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. Lorem Ipsum is simply dummy text of the printing  typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s. Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s.
                                <?php
                            }?>
                        </p>
                    </div>  
                </div>
            </div>
            <?php
        }
    }
        echo '</div>';
        ?>

        <script>
            $(function(){
                $('.faq-description').hide();
                $('.faq-title').on('click', function(){
                    $('.faq-description.active').slideToggle(500).removeClass('active');
                    $(this).next().slideToggle(500).toggleClass('active');
                    
                });
            });
        </script>
        <?php
        $text = ob_get_contents();
        ob_clean();
        ob_end_flush();
    wp_reset_postdata();
    // echo $text;
    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('gallery_npp_count', 8);  
    ++$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';
        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();
            $luzuk_image = wp_get_attachment_image_src(get_post_thumbnail_id(), 'medium_large');

            $post = get_post();
          
            if (($postN % 4) == 0 && $isCustomizer == false) {
                ?>
                <div class="clearfix paddingBot20"></div>
                </div>
                <div class="row">
                    <?php
                }
                ++$postN;
                ?>
                
                <div class="<?php echo $colCls; ?> gallery-img lz-gallery-images slide-item wow fadeInRight">
                    <div class="ht-gallery-member">
                        <div class="ht-gallery-member-image">
                            <?php
                            if (has_post_thumbnail()) {
                                $image_url = $luzuk_image[0];
                            } else {
                                $image_url = get_template_directory_uri() . '/images/about1.jpg';
                            }
                            ?>
                            <a class="group1" 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="overlay"><i class="fa fa-search" aria-hidden="true"></i></div>  
                        </a>
                        </div>
                            
                        </div>
                </div>
                <?php
            endwhile;
            $text = ob_get_contents();
            ob_clean();
        endif;
        wp_reset_postdata();
        return $text;
}


   