<?php
       
//faq

/**
 * 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>
 * */
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('dinero_testimonials_npp_count', 4);
    $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();
            $dinero_testimonials_image = wp_get_attachment_image_src(get_post_thumbnail_id(), 'total-team-thumb');


     if ($isCustomizer === true) {
            $testimonial_area_designation = get_theme_mod('testimonial_area_designation' . $i);
        } else {
            $testimonial_area_designation = '';
        }

        $post = get_post();

            //designation
        $designation = get_post_meta($post->ID, 'designation', false);
        $testimonial_area_designation = !empty($designation[0]) ? $designation[0] : '';
            ?>
            <div class="item">
                <div class="dinero-testimonials-single <?php echo esc_attr(get_theme_mod('dinero_testimonials_box_onload_effects','wow zoomIn')); ?>" data-wow-duration="2s" style="text-align : <?php if(get_theme_mod('dinero_testimonials_box_align','Center') == 'Center'){ ?> center <?php } elseif(get_theme_mod('dinero_testimonials_box_align','Left') == 'Left'){ ?> left <?php } elseif(get_theme_mod('dinero_testimonials_box_align','Right') == 'Right'){ ?> right <?php } ?> ">
                    <div class="dinero-testimonials-image">
                        <img src="<?php echo (!empty($dinero_testimonials_image[0])) ? $dinero_testimonials_image[0] : get_template_directory_uri() . '/images/testimonial.jpg' ?>" class="img-responsive" alt="<?php the_title(); ?>" />
                    </div>      
                    <div class="dinero-testimonials-content">
                        <h4 class="dinero-testimonials-name" style="text-transform : <?php if(get_theme_mod('dinero_testimonials_title_case','Capitalize') == 'Capitalize'){ ?> capitalize <?php } elseif(get_theme_mod('dinero_testimonials_title_case','Lowercase') == 'Lowercase'){ ?> lowercase <?php } elseif(get_theme_mod('dinero_testimonials_title_case','Uppercase') == 'Uppercase'){ ?> uppercase <?php } ?> "><?php the_title(); ?></h4>
                        <h6 class="dinero-testimonials-designation"><?php echo ($testimonial_area_designation); ?></h6>              
                        <p><?php
                            if (has_excerpt()) {
                                echo get_the_excerpt();
                            } else {
                                echo get_the_content();
                            }
                            ?>                                
                        </p> 
                        <i class="fa fa-quote-right" aria-hidden="true"></i>
                        <div class="clearfix"></div>
                    </div>  
                 </div>
            </div>
        <?php
    endwhile;
    $text = ob_get_contents();
    ob_clean();
endif;
wp_reset_postdata();
return $text;
}

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('dinero_service_number',2);  
    ++$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:
        case 17:
        case 19:
        case 21:
        case 23:
        $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-project-thumb');
                $post = get_post();

                ?>
                <div class="<?php echo $colCls;?>">
                           <div  service-match-height="groupName" class="dinero-service-box <?php echo esc_attr(get_theme_mod('dinero_service_box_onload_effects','wow zoomIn')); ?>" data-wow-duration="2s">
                                 <div class="dinero-service-image">
                                    <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="dinero-service-img" src="<?php echo esc_url($image_url); ?>" alt="service" style="height: <?php echo esc_attr(get_theme_mod('dinero_services_post_image_height','200')) ?>px;" />
                                        <div class="overlay"></div>
                                    </a>
                                </div>
                                 <?php if( get_theme_mod('dinero_service_icon_enable',true) == true){ ?>
                                    <div class="dinero-service-icon">
                                        <i class="<?php echo esc_attr(get_theme_mod('dinero_service_icon' . $i, 'fa fa-bar-chart')); ?>"></i>
                                    </div>
                                    <?php }?>
                                <div class="dinero-service-content" style="text-align: <?php if(get_theme_mod('dinero_services_content_align','Left') == 'Left'){ ?> left <?php } elseif(get_theme_mod('dinero_services_content_align','Center') == 'Center'){ ?> center <?php } elseif(get_theme_mod('dinero_services_content_align','Right') == 'Right'){ ?> right <?php } ?> ">
                                    <h4><a href="<?php the_permalink(); ?>" style="text-transform : <?php if(get_theme_mod('dinero_service_title_case','Uppercase') == 'Uppercase'){ ?> uppercase <?php } elseif(get_theme_mod('dinero_service_title_case','Lowercase') == 'Lowercase'){ ?> lowercase <?php } elseif(get_theme_mod('dinero_service_title_case','Capitalize') == 'Capitalize'){ ?> capitalize <?php } ?> "><?php the_title(); ?></a></h4>
                                    <p><?php $dinero_excerpt = get_the_excerpt(); echo esc_html( dinero_string_limit_words( $dinero_excerpt, esc_attr(get_theme_mod('dinero_services_post_excerpt','20')) ) ); ?></p>
                                        <?php
                                             $dinero_service_button_text = get_theme_mod('dinero_service_button_text', 'READ MORE'); ?>
                                         <?php if( get_theme_mod('dinero_service_button_enable',true) == true){ ?>
                                            <a href="<?php the_permalink(); ?>" class="read-btn"><?php echo ($dinero_service_button_text );  ?><i class="fa fa-angle-double-right" aria-hidden="true"></i></a>

                                        <?php }?>


                                </div>
                            </div>                            
                  
      <script>
    var matchHeight = function () {
    
    function init() {
        eventListeners();
        matchHeight();
    }
    
    function eventListeners(){
        $(window).on('resize', function() {
            matchHeight();
        });
    }
    
    function matchHeight(){
        var groupName = $('[service-match-height]');
        var groupHeights = [];
        
        groupName.css('min-height', 'auto');
        
        groupName.each(function() {
            groupHeights.push($(this).outerHeight());
        });
        
        var maxHeight = Math.max.apply(null, groupHeights);
        groupName.css('min-height', maxHeight);
    };
    
    return {
        init: init
    };
    
} ();

$(document).ready(function() {
    matchHeight.init();
});
</script>

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

    /**
     * Use for the show the pricing at home page and in pricing 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('dinero_pricing_npp_count', 2);
      $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:
            $colCls = 'col-md-4 col-sm-6 col-xs-12';
            break;
            default: 
            $colCls = 'col-md-4 col-sm-6 col-xs-12';
            break;
    }

    $showStatic = true;
    for ($i = 1; $i <= $cols; $i++) {
        $dinero_PlanPageId = get_theme_mod('dinero_pricing_plan_page_' . $i);
        $dinero_pricing_page_icon = get_theme_mod('dinero_pricing_plan_page_icon_'.$i);
        $dinero_planTitle  = get_theme_mod('dinero_pricing_plan_name_' . $i, 'Easy Start');
        $dinero_plansubTitle  = get_theme_mod('dinero_pricing_plan_tagline_' . $i, '4 Hours of coaching');
        $dinero_planunit  = get_theme_mod('dinero_pricing_plan_unit_' . $i,'$');
        $dinero_planPrice  = get_theme_mod('dinero_pricing_plan_price_' . $i,'136');
        $dinero_planContent= get_theme_mod('dinero_pricing_plan_content_' . $i, '
            <li>Pre-Coaching Conversation</li>
            <li>4 Coaching Sessions</li>
            <li>Final Conversation</li>');

        $link = get_theme_mod('dinero_pricing_plan_url'.$i);
        $dinero_url = get_theme_mod('dinero_pricing_plan_url_'.$i, '#');

        if ($dinero_PlanPageId || $dinero_planTitle || $dinero_plansubTitle || $dinero_planunit || $dinero_planPrice || $dinero_planContent || $dinero_url ) {
          $showStatic = false;
          ?> 
          <div class="<?php echo $colCls; ?> pd-0">
            <div class="dinero-pricing-single <?php echo esc_attr(get_theme_mod('dinero_pricing_box_onload_effects','wow zoomIn')); ?>" data-wow-duration="1s" style="text-align : <?php if(get_theme_mod('dinero_pricing_box_align','Center') == 'Center'){ ?> center <?php } elseif(get_theme_mod('dinero_pricing_box_align','Left') == 'Left'){ ?> left <?php } elseif(get_theme_mod('dinero_pricing_box_align','Right') == 'Right'){ ?> right <?php } ?> ">

            <div class="dinero-pricing-box-head">
                <h4 class="dinero-pricing-title" href="#" style="text-transform : <?php if(get_theme_mod('dinero_pricing_title_case','Uppercase') == 'Uppercase'){ ?> uppercase <?php } elseif(get_theme_mod('dinero_pricing_title_case','Lowercase') == 'Lowercase'){ ?> lowercase <?php } elseif(get_theme_mod('dinero_pricing_title_case','Capitalize') == 'Capitalize'){ ?> capitalize <?php } ?>">
                    <?php echo ($dinero_planTitle); ?>
                </h4>
                <h6 class="dinero-pricing-subtitle">
                   <i class="fa fa-clock-o" aria-hidden="true"></i> <?php echo ($dinero_plansubTitle); ?>
                </h6>
                <div class="dinero-pricing-currency-price"><span><?php echo ($dinero_planunit); ?></span><?php echo ($dinero_planPrice); ?></div>
            </div>
            <ul class="dinero-pricing-list"> <?php echo ($dinero_planContent); ?></ul>
            
            <?php
            $dinero_pricing_page_id = get_theme_mod('dinero_pricing_page');           
            ?>
                <div class="dinero-pricing-btn">    
                    <a class="btn" href="<?php echo esc_url(!empty($dinero_url)?$dinero_url:'#');?>">
                       <i class="fa fa-long-arrow-right"></i>
                    </a>
                </div>
            <!--  <div class="clearfix"></div> -->
        </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, '#');

    ?>
    <div class="<?php echo $colCls; ?> plan">
      <div class="pricing-plans">

        <div class="price-box">
          <div class="price-bx">

            <div class="plan-cost">$30</div>
        </div>
        <div class="clearfix"></div>
        <h4 class="plan-title">STANDARD</h4>
        <div class="table-content">
        Excepteur sint occaecat cupidatat non proi dent sunt in culpa.
     </div>
     <div class="clearfix"></div>
     <div class="pri-table-link">
      <a class="btn" href="#">DETAILS</a>
  </div>
</div>
<!-- <div class="clearfix"></div> -->
</div>
</div>
<?php
}

}

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


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

    ob_start();

    $args = array('post_type' => 'our-project');
    if (!empty($pageId)) {
        $args['page_id'] = absint($pageId);
    }
    $args['posts_per_page'] = -1;
    $colCls = '';
    // if($isCustomizer == true){
    $cols = get_theme_mod('dinero_project_npp_count',2);  
    ++$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:
        case 17:
        case 19:
        case 21:
        case 23:
        $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-project-thumb');
                $post = get_post();

                ?>

                <div class="<?php echo $colCls;?> dinero-project-b">
                            <div project-match-height="groupName" class="dinero-project-single <?php echo esc_attr(get_theme_mod('dinero_project_box_onload_effects','wow zoomIn')); ?>" data-wow-duration="1s" style="text-align : <?php if(get_theme_mod('dinero_project_box_align','Center') == 'Center'){ ?> center <?php } elseif(get_theme_mod('dinero_project_box_align','Left') == 'Left'){ ?> left <?php } elseif(get_theme_mod('dinero_project_box_align','Right') == 'Right'){ ?> right <?php } ?> ">
                                <a href="<?php the_permalink(); ?>" class="picon">
                                    <div class="dinero-project-img">
                                         <?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="project" style="height: <?php echo esc_attr(get_theme_mod('dinero_project_post_image_height','500')) ?>px;" />
                                    </div>
                                </a>
                                <div class="dinero-project-content">
                                    <h4 class="dinero-project-title inner-area-title" style="text-transform : <?php if(get_theme_mod('dinero_project_title_case','Capitalize') == 'Capitalize'){ ?> capitalize <?php } elseif(get_theme_mod('dinero_project_title_case','Lowercase') == 'Lowercase'){ ?> lowercase <?php } elseif(get_theme_mod('dinero_project_title_case','Uppercase') == 'Uppercase'){ ?> uppercase <?php } ?>">
                                       <?php the_title(); ?>
                                    </h4>
                                    <?php if( get_theme_mod('dinero_project_button_enable','Yes') == 'Yes'){ ?>
                                        <a href="<?php the_permalink(); ?>" class="read-btn"><?php echo esc_html('Read More', 'dinero'); ?><i class="fa fa-angle-double-right" aria-hidden="true"></i></a>
                                    <?php }?>
                                   
                                    <div class="clearfix"></div>
                                </div>
                               
                            </div>
                            
                        </div>
        <?php
    endwhile;
    $text = ob_get_contents();
    ob_clean();
endif;
wp_reset_postdata();
return $text;
}


add_shortcode('TESTIMONIALS', 'testimonialinnerpageShortCode');
add_shortcode('PROJECT', 'projectinnerpageShortCode');
add_shortcode('SERVICES', 'servicesInnerpgeShortCode');
add_shortcode('FAQS', 'faqShortcode');