<?php
       
/*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-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 wow zoomIn">
                   
                    <div class="single-service">

                         <div class="service-icon">
                             <a href="<?php the_permalink(); ?>">
                           <i class="<?php echo $services_page_icon1; ?>"></i>
                            </a>
                             <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(); ?>" />
                                 </a>
                            </div>
                        <h4 class="post-title inner-area-title wow fadeInDown"><?php the_title(); ?></h4>
                        <p class="section-area-text">
                            <?php

                            if(has_excerpt()){
                              echo get_the_excerpt();
                             }else{
                              echo luzuk_excerpt( get_the_content() , 100 );
                             } 
                            ?>
                        </p>
                    </div>


                </div>
                 <div class="col-md-4 col-sm-6 col-xs-12 inn-single-service-bx">
                 <div class="singleinner-service">

                         <div class="service_inbox">
                              <div class="service_inimg">
                           <?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>
                            <div class="service_inbox-content">
                                <h3 class="title"> <a href="<?php the_permalink(); ?>"><?php the_title(); ?> </a></h3>
                                <p class="description"><?php
                                    if(has_excerpt()){
                                      echo get_the_excerpt();
                                     }else{
                                      echo luzuk_excerpt( get_the_content() , 90 );
                                     } 
                                    ?>
                                </p>
                            </div>
                             <?php if( get_theme_mod('servicesinn_button_display','show' ) == 'show') :
                                ?>
                                <?php
                                    $ct_service_page_id = get_theme_mod('ct_service_page'); 
                                    $servicesbutn_text = get_theme_mod('servicesbutninn_text', 'Read More');
                                    ?>

                                <div class="servicesbtn"><a href="<?php the_permalink(); ?>"><span class="button-text"><?php echo $servicesbutn_text; ?></span><span class="button-arrow"></span></a>
                                </div>
                                <?php endif ?>
                        </div>
                    </div>
                </div>

                    <script>
                        jQuery.noConflict();
                        $(function(){
                            function singleserviceHeight(){
                                var ht = 0;
                                $('#innerpage-box .service_inbox-content').each(function(i){
                                    var tHt = $(this).height();
                                    if(ht<tHt){
                                        ht=tHt;
                                    }
                                });
                                $('#innerpage-box .service_inbox-content').height(ht+'px');
                            }
                            singleserviceHeight();
                        });
                        $( window ).resize(function(){
                            singleserviceHeight();
                        });
                    </script>

                <?php
            endwhile;
            $text = ob_get_contents();
            ob_clean();
        endif;
        wp_reset_postdata();
        return $text;
    }
add_shortcode('SERVICES', 'serviceShortCode');

