<?php
       
//faq

//team
// ****
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_area_npp_count1', 15);
    $cols++;
    switch($cols){
        case 1:
        $colCls = 'col-lg-12 col-md-12 col-sm-12 col-xs-12';
        break;
        case 2: 
        $colCls = 'col-lg-6 col-md-6 col-sm-6 col-xs-6';
        break;
        case 3:
        case 5:
        case 6:
        case 9:
        case 11:
        case 13:
        case 15:
        $colCls = 'col-lg-3 col-md-6 col-sm-6 col-xs-6';
        break;
        default: 
        $colCls = 'col-lg-3 col-md-6 col-sm-6 col-xs-6';
        break;
    } 

    // } 
 $text = '';
 $query = new WP_Query($args);
 if ($query->have_posts()):
    $postN = 0;

    while ($query->have_posts()) : $query->the_post();
        $team_area_image = wp_get_attachment_image_src(get_post_thumbnail_id(), 'total-team-thumb');
        if ($isCustomizer === true) {
            $team_area_designation = get_theme_mod('team_area_designation' . $i);
            $team_area_facebook = get_theme_mod('team_area_facebook' . $i);
            $team_area_twitter = get_theme_mod('team_area_twitter' . $i);
           // $team_area_linkedin = get_theme_mod('team_area_linkedin' . $i);
            $team_area_instagram = get_theme_mod('team_area_instagram' . $i);
            $team_area_pinterest = get_theme_mod('team_area_pinterest' . $i);
        } else {
            $team_area_facebook = '';
            $team_area_twitter = '';
           // $team_area_linkedin = '';
            $team_area_instagram = '';
            $team_area_pinterest = '';
            $team_area_designation = '';
        }

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

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

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

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

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

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

        ?>
        <div class="<?php echo $colCls;?> single-team"> 
            <div class="our-team">
                <div class="single-team-img">
                    <?php
                        if (has_post_thumbnail()) {
                            $image_url = $team_area_image[0];
                        } else {
                            $image_url = get_template_directory_uri() . '/images/team-thumb.png';
                        }
                    ?>                  
                    <img src="<?php echo esc_url($image_url); ?>" alt="<?php the_title(); ?>" />     
                    <div class="t_oly"></div>          

                    <div class="team-text">
                        <h4 class="inner-area-title wow fadeInLeft" ><?php the_title(); ?></h4> 
                         <?php if($team_area_designation ){ ?>      
                        <div class="team-designation wow fadeInLeft"> <?php echo ($team_area_designation); ?> </div>
                        <?php }?>
                        <?php if ($team_area_facebook || $team_area_twitter || $team_area_instagram || $team_area_pinterest) { ?>
                            <div class="team-social-icon">
                                <?php if ($team_area_facebook) { ?>
                                <a target="_blank" href="<?php echo esc_url($team_area_facebook) ?>">
                                    <i class="fa fa-facebook"></i></a>
                                <?php } ?>
                                <?php if ($team_area_twitter) { ?>
                                <a target="_blank" href="<?php echo esc_url($team_area_twitter) ?>" ><i class="fa-brands fa-x-twitter"></i></a>
                                <?php } ?>
                                <?php if ($team_area_instagram) { ?>
                                <a target="_blank" href="<?php echo esc_url($team_area_instagram) ?>" ><i class="fa fa-instagram"></i></a> 
                                <?php } ?>
                               <?php if ($team_area_pinterest) { ?>
                                <a target="_blank" href="<?php echo esc_url($team_area_pinterest) ?>"><i class="fa fa-pinterest"></i></a>
                                <?php } ?>
                            </div>
                    <?php } ?>
                    </div>
                </div>
                <div class="clearfix"></div>
            </div> 
        </div>

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


//team Inner Page

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


// testimonial img
function testimonialimgShortCode($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('test_npp_count', 5);
    $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');
        $post = get_post();

            if (($postN % 3) == 0 && $isCustomizer == false) {
                ?>
                <!-- <div class="clearfix"></div> -->
            <!-- </div> -->
            <!-- <div class="row"> -->
                <?php
            }
            ++$postN;
            ?>
            <div class="card" data-id="content<?php echo $i; ?>">
               <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>
    
        <?php
    endwhile;
    $text = ob_get_contents();
    ob_clean();
endif;
wp_reset_postdata();
return $text;
}

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('test_npp_count', 5);
    $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');
        $post = get_post();

            if (($postN % 3) == 0 && $isCustomizer == false) {
                ?>
                <!-- <div class="clearfix"></div> -->
            <!-- </div> -->
            <!-- <div class="row"> -->
                <?php
            }
            ++$postN;
            ?>
             <!-- <div class="contentBox " id="content</?php echo $i; ?>"> -->
        <div class="item items innertest-item ">
            <div class="ts-area-single ">
                <div class="tsarea-inn">
                    <div class="ts-area-thumb">
                        <div class="row">
                            <div class="testiimgbx">
                                <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="ts-area-bx">
                                <h3 class="ts-area-title"><?php the_title(); ?></h3>
                                <div class="text-designation">
                                    <?php
                                        $name2 = get_post_meta($post->ID, 'testimonial_Sub_Title', false);
                                        echo (!empty($name2[0])) ? $name2[0] : '';
                                    ?> 
                                </div>
                            </div>
                        </div>
                    </div>
                    <div class="ts-area-content">
                        <div class="ts-area-c">   
                        <p><?php
                            if (has_excerpt()) {
                                echo get_the_excerpt();
                            } else {
                                echo get_the_content();
                            }
                            ?>   
                        </p>  
                    </div>
                </div>
            </div>
        </div>
    </div>
    
        <?php
    endwhile;
    $text = ob_get_contents();
    ob_clean();
endif;
wp_reset_postdata();
return $text;
}


// **************************
/*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-lg-12 col-md-12 col-sm-12';
        break;
        case 2: 
        $colCls = 'col-lg-6 col-md-6 col-sm-6';
        break;
        case 3:
        case 5:
        case 6:
        case 9:
        case 11:
        case 13:
        case 15:
        $colCls = 'col-lg-4 col-md-4 col-sm-6';
        break;
        default: 
        $colCls = 'col-lg-4 col-md-4 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();

        $service_icon = get_post_meta(get_the_ID(), '_service_icon', true);
        
        ?>
        <div class="<?php echo $colCls; ?> single-service-bx "> 
        <!-- <div class="item single-service-bx ">  -->
            <div class="single-service" >
                <div class="service-icon">
                    <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 class="sertxbx">                      
                        <div class="icn"> 
                            <a href="<?php the_permalink(); ?>">
                                <i class="<?php echo $service_icon; ?>"></i>    
                            </a>        
                        </div>     
                        <a href="<?php the_permalink(); ?>">                     
                            <h4 class="post-title inner-area-title "><?php the_title(); ?></h4>
                        </a>
                        <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> 
        </div>
            <?php
        endwhile;
        $text = ob_get_contents();
        ob_clean();
    endif;
    wp_reset_postdata();
    return $text;
}

// service innerpage {shortcode}
/*services*/

/**
 * 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 void
 * @author luzuk <support@luzuk.com>
 * */
    function pricingShortcode() {
      ob_start();
      $cols = get_theme_mod('pricing_npp_count', 3);
      $cols++;
      switch ($cols) {
        case 1:
            $colCls = 'col-lg-12 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:
            $colCls = 'col-lg-3 col-md-6 col-sm-6 col-xs-12';
            break;
            default: 
            $colCls = 'col-lg-3 col-md-6 col-sm-6 col-xs-12';
            break;
    }

    $showStatic = true;
    for ($i = 1; $i <= $cols; $i++) {
        $PlanPageId = get_theme_mod('pricing_plan_page_' . $i);
        $pricing_page_icon = get_theme_mod('pricing_plan_page_icon_'.$i);
        $planTitle  = get_theme_mod('pricing_plan_name_' . $i, 'Premium Package ');
        $planPrice  = get_theme_mod('pricing_plan_price_' . $i,'$ 99.00');  
        $planContent= get_theme_mod('pricing_plan_content_' . $i, '
            <li>Appliance & Fixture</li>
            <li>Annual Electrical Inspection</li>
            <li>Ceiling Fan Installation</li>
            <li>24-hour Response</li>');

        $link = get_theme_mod('pricing_plan_url'.$i);
        $url = get_theme_mod('pricing_plan_url_'.$i, '#');

        if ($PlanPageId || $planTitle || $planContent || $url || $pricing_page_icon || $planPrice ) {
          $showStatic = false;
          ?>
          
<?php
    $pricing_page_id = get_theme_mod('pricing_page');
    $pricing_page_button_title = get_theme_mod('pricing_page_button_title_'.$i, 'Book Now');
?>
        <div class="<?php echo $colCls; ?> sm-bx">
            <div class="single-pricing  ">
                
                <?php if($pricing_page_button_title){ ?>
                    <div class="pc-btn " data-wow-duration="4s">    
                        <a class="btn btn-lg" href="<?php echo esc_url(!empty($url)?$url:'#');?>">
                           <?php echo ($pricing_page_button_title);  ?>
                        </a>
                    </div>
                <?php } ?>
                <div class="pr-s-area">
                    <h2 class="currency-price"><?php echo ($planPrice); ?></h2>
                </div>
                <ul class="pricing-list "> <?php echo ($planContent); ?></ul>
                <?php if($planTitle){ ?>
                    <h4 class="plan-title inner-area-title" > <?php echo ($planTitle); ?> </h4>
                 <?php } ?> 
            </div>
        </div>
    <?php
}
}
if ($showStatic === true) {
  for ($i = 1; $i <= $cols; $i++) {
    $link = get_theme_mod('pricing_plan_url'.$i);
    $url = get_theme_mod('pricing_plan_url_'.$i, '#');

    ?>

<?php
}

}

$pricingHtml = ob_get_contents();
        // echo $pricingHtml;
ob_flush();
ob_clean();
}


// **************************
// ======projects =========
// **************************

function projectShortCode($pageId = null, $isCustomizer = false, $i = null) {

    ob_start();
     global $post;
    $args = array('post_type' => 'our-projects');
    if (!empty($pageId)) {
        $args['page_id'] = absint($pageId);
    }
    $args['posts_per_page'] = -1;
    $colCls = '';
    // if($isCustomizer == true){
    $cols = get_theme_mod('project_npp_count',3);  
    $projects_page_icon1 = get_theme_mod('projects_page_icon1'.$i);

    ++$cols;
    switch ($cols) {
        case 1:
        $colCls = 'col-lg-12 col-md-12 col-sm-12';
        break;
        case 2: 
        $colCls = 'col-lg-6 col-md-6 col-sm-6';
        break;
        case 3:
        case 5:
        case 6:
        case 9:
        case 11:
        case 13:
        case 15:
        $colCls = 'col-lg-4 col-md-4 col-sm-6';
        break;
        default: 
        $colCls = 'col-lg-3 col-md-4 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-project-thumb');
               global $post;

                $image_id  = get_post_meta( $post->ID, 'second_featured_image', true );
                $image_src = wp_get_attachment_url( $image_id );
              
                //   if ($isCustomizer === true) {
                //         $projtsubttle = get_theme_mod('projtsubttle' . $i);
                //     } else {
                //         $projtsubttle = '';
                //     }
                // $post = get_post();
                // $projtsubttle = get_post_meta($post->ID, 'projtsubttle', false);
                //echo the_post_thumbnail( 'project-featured-thumbnail' );
                // $projt_area = !empty($projtsubttle[0]) ? $projtsubttle[0] : '';
                // $projectsNum = get_post_meta($post->ID, 'projectsNum', false);
                //$projects_Num = !empty($projectsNum[0]) ? $projectsNum[0] : '';
            ?>
                 
                
        <!-- <div class="<?php echo $colCls;?> single-project-bx"> -->
        <div class=" swiper-slide">
            <div class="single-project-bx">
                <div class="single-project ">
                    <div class="project-icon">
                       <?php
                            if (has_post_thumbnail()) {
                                $image_url = $luzuk_image[0];
                            } else {
                                $image_url = get_template_directory_uri() . '/images/project.png';
                            }
                        ?>
                                
                        <a href="<?php the_permalink(); ?>">
                            <div class="project-img">    
                                <img class="img-responsive" src="<?php echo esc_url($image_url); ?>" alt="<?php the_title(); ?>" />
                                <div class="pj_conbx">
                                    <div class="pj_con">
                                        <h3 class="title"><?php the_title(); ?></h3>                                   
                                        <div class="txt">
                                        <?php
                                            if(has_excerpt()){
                                              echo get_the_excerpt();
                                             }else{
                                              echo luzuk_excerpt( get_the_content() , 40 );
                                            } 
                                        ?>       
                                        </div>
                                        <?php
                                            $proj_button1 = get_theme_mod('proj_button1', 'Installation');
                                        ?> 
                                        <?php if( $proj_button1 ){ ?>
                                        <div class="bttn">
                                            <div class="icn">
                                               <?php echo $proj_button1 ?> <i class="fa fa-long-arrow-right"></i>
                                            </div>
                                        </div>
                                        <?php }?>
                                    </div>
                                        
                                    
                                </div>                   
                            </div> 
                        </a>     
                    </div>
                    <div class="clearfix"></div>
                </div>  
            </div>  
        </div>

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



//projectpage

// ==========================
/*********gallery************/ 
// ==========================

function galleryShortCode($pageId = null, $isCustomizer = false, $i = null) {
    ob_start();

    $args = array(
        'post_type' => 'our-gallery',
        'posts_per_page' => -1,
    );

    if (!empty($pageId)) {
        $args['page_id'] = absint($pageId);
    }

    $query = new WP_Query($args);
    if ($query->have_posts()):

    ?>
        
    <div class="gallery-items gallery-sec">
        <?php 
        while ($query->have_posts()): 
            $query->the_post();
            
            // Get terms of the current post
            $terms = wp_get_post_terms(get_the_ID(), 'gallery_category');
            $term_ids = wp_list_pluck($terms, 'term_id'); // Get array of term IDs

            // Generate classes for the gallery item based on its categories
            $class_list = '';
            foreach ($term_ids as $id) {
                $class_list .= 'category-' . esc_attr($id) . ' ';
            }

            // Check if the post has a featured image
            if (has_post_thumbnail()) {
                $image_url = wp_get_attachment_image_src(get_post_thumbnail_id(), 'total-service-thumb')[0];
            } else {
                // Fallback image URL if no featured image is set
                $image_url = get_template_directory_uri() . '/images/about1.jpg';
            }
        ?>
        <div class="lz-gallery-images">
            <figure class="spa-gall">
                <div class="gallery-item <?php echo trim($class_list); ?>">
                    <a data-fancybox="gallery" href="<?php echo esc_url($image_url); ?>" title="<?php the_title(); ?>">  
                        <img class="img-responsive" src="<?php echo esc_url($image_url); ?>" alt="<?php the_title(); ?>" />
                        <figcaption></figcaption>
                    </a>
                </div>
            </figure>
        </div>
        <?php endwhile; ?>
    </div>
        
    <?php
    wp_reset_postdata();
    endif;

    $text = ob_get_clean();
    return $text;
}


