<?php
//Services shortcode  
function featuredShortCode($pageId = null, $isCustomizer = false, $i = null) {

    ob_start();

    $args = array('post_type' => 'feature');
    if (!empty($pageId)) {
        $args['page_id'] = absint($pageId);
    }
    $args['posts_per_page'] = -1;
    $colCls = '';
    // if($isCustomizer == true){
    $cols = get_theme_mod('services_npp_count',7);  
    ++$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-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();
            $lz_fitness_image = wp_get_attachment_image_src(get_post_thumbnail_id(), 'total-service-thumb');
            $post = get_post();
if (($postN % 4) == 0 && $isCustomizer == false) {
                ?>
                <div class="clearfix paddingBot20"></div>
            </div>
            <div class="row">
                <?php
            }
            ++$postN;
           
            ?>
            <div class="row">
            <div class="<?php echo $colCls; ?> padding10">
                <div class="services-post">
                    <div class="service_img">
                        <?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>
                    <div class="services-data">  
                       
                            <h3 class="post-title"><?php the_title(); ?></h3>                     
                       
                          <p class="description"><?php
                          if (has_excerpt()) {
                            echo get_the_excerpt();
                        } else {
                            echo lz_fitness_excerpt(get_the_content(), 130);
                        }
                        ?>
                    </p>
                    <?php if( get_theme_mod('servicesall_button_display','show' ) == 'show') :
                            ?>
                   <div class="servicess-button">
                     <button><a href="<?php echo esc_url(get_permalink()); ?>"><i class="fa fa-angle-right" aria-hidden="true"></i></a></button>
                 </div>
                 <?php endif ?>
              
           </div>
         
           
       </div>
   </div>
   <?php
endwhile;
$text = ob_get_contents();
ob_clean();
endif;
wp_reset_postdata();
return $text;
}



//Events shortcode  
function featuredeventsShortCode($pageId = null, $isCustomizer = false, $i = null) {
    ob_start();

    $args = array('post_type' => 'events');
    if (!empty($pageId)) {
        $args['page_id'] = absint($pageId);
    }
    $args['posts_per_page'] = -1;
    $colCls = '';
    // if($isCustomizer == true){
    $cols = get_theme_mod('events_npp_count',7);  
    ++$cols;
    switch ($cols) {
        case 1:
                $colCls = 'col-md-12 col-sm-12';
                break;
            case 2:
            case 3:
            case 4: 
            case 5:
            case 6: 
            case 7: 
            case 8: 
            case 9:
            case 10:
            case 11:
            case 12: 
            case 13: 
            case 14: 
            case 15:
            case 16: 
              
                $colCls = 'col-md-6 col-sm-6';
                break;
            
            default: 
                $colCls = '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();
            $lz_fitness_image = wp_get_attachment_image_src(get_post_thumbnail_id(), 'total-event-thumb');
            $post = get_post();
if (($postN % 4) == 0 && $isCustomizer == false) {
                ?>
                <div class="clearfix paddingBot20"></div>
            </div>
            <div class="row">
                <?php
            }
            ++$postN;
           
            ?>
            <div class="row">
            <div class="<?php echo $colCls; ?> padding10">
                <div class="events-post ">
                    <div class="event_img">
                        <?php
                        if (has_post_thumbnail()) {
                            $image_url = $lz_fitness_image[0];
                        } else {
                            $image_url = get_template_directory_uri() . '/images/default.png';
                        }
                        ?>                                                          
                        <img class="secondry-bg img-responsive" src="<?php echo esc_url($image_url); ?>" alt="<?php the_title(); ?>" />
                   </div>
                    <div class="events-data">  
                       
                            <h3 class="post-title"><?php the_title(); ?></h3>                     
                       
                          <p class="description"><?php
                          if (has_excerpt()) {
                            echo get_the_excerpt();
                        } else {
                            echo lz_fitness_excerpt(get_the_content(), 150);
                        }
                        ?>
                    </p>
                    <?php if( get_theme_mod('eventsall_button_display','show' ) == 'show') :
                            ?>
                   <div class="eventss-button">
                     <button><a href="<?php echo esc_url(get_permalink()); ?>">Read More</a></button>
                 </div>
                 <?php endif ?>
              
           </div>
         
           
       </div>
   </div>
   <?php
endwhile;
$text = ob_get_contents();
ob_clean();
endif;
wp_reset_postdata();
return $text;
}

add_shortcode('SERVICES', 'featuredShortCode');