<?php

function servicesShortCode($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('peccular_service_number',2);  
    ++$cols;
    switch ($cols) {
        case 1:
        $colCls = 'col-md-12 col-sm-12 col-xs-12';
        break;
        case 2: 
        $colCls = 'col-lg-6 col-md-6 col-sm-6 col-xs-12';
        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-lg-4 col-md-6 col-sm-6 col-xs-12';
        break;
        default: 
        $colCls = 'col-lg-4 col-md-6 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();
                $peccular_image = wp_get_attachment_image_src(get_post_thumbnail_id(), 'total-project-thumb');
                $post = get_post();

                ?>
                <?php
                 $peccular_service_page_icon_left = get_theme_mod('peccular_service_page_icon_left'.$i);
                 ?>
                <div class="item serbrdr pd-1 pb-5">
                            <!-- <div class="row md-1">   -->
                           <div  service-match-height="groupName" class="peccular-service-box <?php echo esc_attr(get_theme_mod('peccular_service_box_onload_effects','wow zoomIn')); ?>" data-wow-duration="2s">
                               
                                    <div class="peccular-service-image">
                                    <a href="<?php the_permalink();?>">     

                                    <!-- <img class="peccular-service-img" src="<//?php echo esc_url(get_template_directory_uri().'/images/serviceimg.jpg');?>" alt="service" style="height: <//?php echo esc_attr(get_theme_mod('peccular_services_post_image_height','auto')) ?>px;" />   -->

                                    <img class="peccular-service-img" src="<?php echo (!empty($peccular_image[0])) ? $peccular_image[0] : get_template_directory_uri() . '/serviceimg.jpg' ?>" class="img-responsive" alt="<?php the_title(); ?>"  style="height: <?php echo esc_attr(get_theme_mod('peccular_services_post_image_height','415')) ?>px;" alt=""/>  

                                          <div class="overlay simple-overlay-3"></div>                         
                                     </a>   
                                    
                                    </div><!-- div image-->                                
                                    
                                <div class="content-bor">
                                    <div class="peccular-service-content" style="text-align: <?php if(get_theme_mod('peccular_services_content_align','Left') == 'Left'){ ?> left <?php } elseif(get_theme_mod('peccular_services_content_align','Center') == 'Center'){ ?> center <?php } elseif(get_theme_mod('peccular_services_content_align','Right') == 'Right'){ ?> right <?php } ?> ">
                                        <div class="bg-icon">
                                            <i class="<?php echo $peccular_service_page_icon_left; ?>"></i>
                                        </div>
                                        <h4><a href="<?php the_permalink(); ?>" style="text-transform : <?php if(get_theme_mod('peccular_service_title_case','Capitalize') == 'Capitalize'){ ?> Capitalize <?php } elseif(get_theme_mod('peccular_service_title_case','Lowercase') == 'Lowercase'){ ?> lowercase <?php } elseif(get_theme_mod('peccular_service_title_case','Capitalize') == 'Capitalize'){ ?> capitalize <?php } elseif(get_theme_mod('peccular_service_title_case','Uppercase') == 'Uppercase'){ ?> uppercase <?php } ?> "><?php the_title(); ?></a>
                                        </h4>                                         
                                        <p><?php $peccular_excerpt = get_the_excerpt(); echo esc_html( peccular_string_limit_words( $peccular_excerpt, esc_attr(get_theme_mod('peccular_services_post_excerpt','8')) ) ); ?></p>

                                    <div class="clearfix"></div>
                                     <?php
                                        $peccular_service_button_text = get_theme_mod('peccular_service_button_text', 'Read more'); ?>
                                     <?php if( get_theme_mod('peccular_service_button_enable',true) == true){ ?>
                                        <a href="<?php the_permalink(); ?>" class="service-btn"><?php echo ($peccular_service_button_text );  ?></a>
 
                                    <?php }?>                           
                                             
                                <div class="clearfix"></div> 
                                </div>   
                                 </div>
                                
                            </div> 
                            <!-- </div>     -->                       
                        </div>
        <?php
    endwhile;
    $text = ob_get_contents();
    ob_clean();
endif;
wp_reset_postdata();
return $text;
}

function servicesInnerpgeShortCode($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('peccular_service_number',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:
        case 11:
        case 13:
        case 15:
        case 17:
        case 19:
        case 21:
        case 23:
        $colCls = 'col-lg-4 col-md-6 col-sm-6 col-xs-12';
        break;
        default: 
        $colCls = 'col-lg-4 col-md-6 col-sm-6 col-xs-12';
        break;
        }
    // }
        $text = '';
        $query = new WP_Query($args);
        if ($query->have_posts()):
            $postN = 0;
               ?> 
            <div class="row">
            <?php

                while ($query->have_posts()) : $query->the_post();
                $peccular_image = wp_get_attachment_image_src(get_post_thumbnail_id(), 'total-project-thumb');
                $post = get_post();       

                ?>
                 <?php
                 $peccular_service_innerpage_icon_left = get_theme_mod('peccular_service_innerpage_icon_left'.$i);
                 ?>
                <div class="<?php echo $colCls;?> serbrdr pd-1">
                 
                           <div  class="peccular-service-box <?php echo esc_attr(get_theme_mod('peccular_service_box_onload_effects','wow zoomIn')); ?>" data-wow-duration="2s">
                               <?php if(get_theme_mod('service_featured_img_on_off') != 'on' ){
                                    ?>
                                    <div class="peccular-service-image">
                                    <a href="<?php the_permalink();?>">  
                                     <?php
                                        if (has_post_thumbnail()) {
                                            $image_url = $peccular_image[0];
                                        } else {
                                            $image_url = get_template_directory_uri() . '/images/service1.jpg';
                                        }
                                        ?>                                          
                                      <img class="peccular-service-img" src="<?php echo esc_url($image_url); ?>" alt="service" style="height: <?php echo esc_attr(get_theme_mod('peccular_serviceinnerpage_post_image_height','435')) ?>px;" />       
                                          <div class="overlay simple-overlay-3"></div>                         
                                     </a>   
                                    
                                    </div><!-- div image-->      

                                     <?php }?>

                        <div class="content-bor">
                                    <div class="peccular-service-content" style="text-align: <?php if(get_theme_mod('peccular_services_content_align','Left') == 'Left'){ ?> left <?php } elseif(get_theme_mod('peccular_services_content_align','Center') == 'Center'){ ?> center <?php } elseif(get_theme_mod('peccular_services_content_align','Right') == 'Right'){ ?> right <?php } ?> ">
                                        <div class="bg-icon">
                                            <i class="<?php echo $peccular_service_innerpage_icon_left; ?>"></i>
                                        </div>
                                        <h4><a href="<?php the_permalink(); ?>" style="text-transform : <?php if(get_theme_mod('peccular_service_title_case','Capitalize') == 'Capitalize'){ ?> Capitalize <?php } elseif(get_theme_mod('peccular_service_title_case','Lowercase') == 'Lowercase'){ ?> lowercase <?php } elseif(get_theme_mod('peccular_service_title_case','Capitalize') == 'Capitalize'){ ?> capitalize <?php } elseif(get_theme_mod('peccular_service_title_case','Uppercase') == 'Uppercase'){ ?> uppercase <?php } ?> "><?php the_title(); ?></a>
                                        </h4>                                         
                                        <p><?php $peccular_excerpt = get_the_excerpt(); echo esc_html( peccular_string_limit_words( $peccular_excerpt, esc_attr(get_theme_mod('peccular_services_post_excerpt','8')) ) ); ?></p>

                                    <div class="clearfix"></div>
                                     <?php
                                        $peccular_service_button_text = get_theme_mod('peccular_service_button_text', 'Read more'); ?>
                                     <?php if( get_theme_mod('peccular_service_button_enable',true) == true){ ?>
                                        <a href="<?php the_permalink(); ?>" class="service-btn"><?php echo ($peccular_service_button_text );  ?></a>
 
                                    <?php }?>                           
                                             
                                <div class="clearfix"></div> 
                                </div>   
                                 </div>
                                
                            </div> 
                           
                    </div>   

 <?php
    endwhile;
    ?>
    <div class="clearfix"></div>
    </div>
    <?php
    $text = ob_get_contents();
    ob_clean();
endif;
wp_reset_postdata();
return $text;
}

add_shortcode('SERVICES', 'servicesInnerpgeShortCode');
