<?php 
/*
 * 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>
 * */

/*services*/
function ctserviceShortCode($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('lz_fitness_ct_service_npp_count',7);  
    $lz_fitness_ct_service_icon1 = get_theme_mod('lz_fitness_ct_service_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: 
       $colCls = 'col-md-4 col-sm-6';
       break;
       case 4: 
       case 7:
       case 8:  
       case 10:
       case 11:
       case 12:
       $colCls = 'col-md-3 col-sm-6';
       break;
       default: 
       $colCls = 'col-md-4 col-sm-6';
       break;
   }
   $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();
        $lz_fitness_image = wp_get_attachment_image_src(get_post_thumbnail_id(), 'total-service-thumb');
        $post = get_post();
        ?>
        <div class="row">
            <div class="<?php echo $colCls; ?> padding10 complete-serbox">
                <div class="serviceBox blue">
                    <div class="service-icon padding0 wow slideInLeft">

                       <i class="<?php echo $lz_fitness_ct_service_icon1; ?>"></i>

                       <?php
                       if (has_post_thumbnail()) {
                        $image_url = $lz_fitness_image[0];
                    } else {
                        $image_url = get_template_directory_uri() . '/images/project.jpg';
                    }
                    ?>                                                          
                    <img class="secondry-bg img-responsive" src="<?php echo esc_url($image_url); ?>" alt="<?php the_title(); ?>" />

                </div>
                <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 lz_fitness_excerpt( get_the_content() , 60 );
                }
                ?></p> 
                <?php
                $Servicessectionbutton = get_theme_mod('lz_fitness_Servicessection_txt', 'read more '); 
                
                ?>
                <?php if( get_theme_mod('servicesusection_button_display','show' ) == 'show') :
                    ?>            
                    <a href="<?php the_permalink(); ?>" target="_blank" class="btn btn-lg red">
                        <?php echo ($Servicessectionbutton );  ?>

                    </a>
                <?php endif ?>
            </div>
            <div class="clearfix"></div>
            
            <!-- for inner page -->
 <div class="image-flip" ontouchstart="this.classList.toggle('hover');">
                    <div class="mainflip">
                        <div class="frontside">
                            <div class="card">
                                <div class="card-body text-center">
                                    <div class="serbx-imgbx"> 
                                        <?php
                 if (has_post_thumbnail()) {
                    $image_url = $lz_fitness_image[0];
                } else {
                    $image_url = get_template_directory_uri() . '/images/project.jpg';
                }
                ?> 
                <a href="<?php the_permalink(); ?>">
                <img class="secondry-bg img-responsive" src="<?php echo esc_url($image_url); ?>" alt="<?php the_title(); ?>" /></a>
                <div class="clearfix"></div>
         </div>
         <div class="service-innerpage-contentbox">
                                    <h4 class="card-title"><?php the_title(); ?></h4>
                                    <p class="card-text"><?php 
                  if(has_excerpt()){
                    echo get_the_excerpt();
                }else{
                    echo lz_fitness_excerpt( get_the_content() , 70 );
                }
                ?></p>
                                    <a href="<?php the_permalink(); ?>" class="btn btn-primary btn-sm"><i class="fa fa-plus"></i></a>
                                </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>

<script>
    jQuery.noConflict();
    $(function(){
        function serviceinnerpagecontentboxHeight(){
            var ht = 0;
            $('div#content-box .service-innerpage-contentbox').each(function(i){
                var tHt = $(this).height();
                if(ht<tHt){
                    ht=tHt;
                }
            });
            $('div#content-box .service-innerpage-contentbox').height(ht+'px');
        }
        serviceinnerpagecontentboxHeight();
    });
    $( window ).resize(function(){
     serviceinnerpagecontentboxHeight();
 });
</script>        
<!-- for inner page -->
</div>
<?php
endwhile;
$text = ob_get_contents();
ob_clean();
endif;
wp_reset_postdata();
return $text;
}
add_shortcode('SERVICES', 'ctserviceShortCode');
