<?php

/**
 * Liting the team/trainer details 
 * @param : int $pageId default is null
 * @param : boolean $isCustomizer default is false, if set to true will get the data stored with customizer
 * @param : int $i default is null, it will used as a iteration for data with customizer, this will be used only if the $isCustomizer is set to true.
 * @return: Text $text
 */
    /**
     * 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 Parag Chaure <parag.radical@outlook.com>
     * */
    function testimonialShortCode($pageId = null, $isCustomizer = false, $i = null, $showStaticVals = false) {
        global $query;
        $args = array('post_type' => 'lz_fitness_testimoni');
        if (!empty($pageId)) {
            $args['page_id'] = absint($pageId);
        } else {
            $args['paged'] = max(1, get_query_var('paged'));
        }
        $i = !empty($i) ? $i : 0;
        $text = '';
        $query = new WP_Query($args);
        // print_r($query);
        if ($query->have_posts()):
            $cssCls = ($isCustomizer == false) ? 'col-sm-12' : 'col-sm-10 col-sm-offset-1';

            ob_start();
            while ($query->have_posts()) : $query->the_post();
                $post = get_post();
                $lz_fitness_image = wp_get_attachment_image_src(get_post_thumbnail_id(), 'total-team-thumb');
                ?>
                <?php if ($isCustomizer == false) { ?>
                <div class="item <?php if ($i == 0) { ?>active<?php } ?>">
                    <blockquote>
                        <div class="row">
                            <div class="<?php echo $cssCls; ?>">
                                <div class="page-testimonial-box">
                                    <div class="col-sm-3">
                                        <img src="<?php echo (!empty($lz_fitness_image[0])) ? $lz_fitness_image[0] : get_template_directory_uri() . '/images/team-thumb.png' ?>" class="img-responsive" alt="<?php the_title(); ?>" />
                                    </div>
                                    <div class="col-sm-9">
                                        <p><?php
                                        if (has_excerpt()) {
                                            echo get_the_excerpt();
                                        } else {
                                            echo lz_fitness_excerpt(get_the_content(), 250);
                                        }
                                        ?></p>
                                        <h6><?php the_title(); ?></h6>
                                        <div class="text-designation">
                                            <?php
                                            $name2 = get_post_meta($post->ID, 'testimonial_Sub_Title', false);
                                            echo (!empty($name2[0])) ? $name2[0] : '';
                                            ?>
                                        </div>
                                    </div>
                                    <div class="clearfix"></div>
                                </div>
                            </div>
                        </div>
                    </blockquote>
                </div>
                <?php }else{ ?>
						<div class="col-md-2 paddind5">
							<div id="item<?php echo ++$i;?>" class="item">
								<a class="thumb">
									<img src="<?php echo $lz_fitness_image[0]; ?>">
								</a>
								<div class="tooltip_description" style="display:none" title="">
								 <h3><?php the_title(); ?></h3>
                                    <?php
										if (has_excerpt()) {
											echo get_the_excerpt();
										} else {
											echo lz_fitness_excerpt(get_the_content(), 250);
										}
										?>
								</div>
							</div>
						</div>

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

    /**
     * Use for the show the gallery at home page and in the page where user add this the shortcode
     * @return void
     * @author Parag Chaure <parag.radical@outlook.com>
     * */
    function galleryShortcode($args = null) {
        $args['post_type'] = 'lz_fitness_gallary';
        $args['order'] = 'ASC';
        // print_r($args);
        $gallaryHtml = '';
        $args['posts_per_page'] = (!empty($args['posts_per_page'])) ? $args['posts_per_page'] : -1;
        $class = !empty($args['ishome']) && $args['ishome'] == true ? 'gallery' : 'portfolio';
        $class = 'gallery';
        ob_start();
        ?>
        <div class="ht-<?php echo $class; ?>-post-wrap <?php if (!empty($args['ishome']) && $args['ishome'] == true) {
            echo 'container';
        } ?>">
        <div class="ht-<?php echo $class; ?>-posts ht-clearfix">
            <?php
            if (!empty($pageId)) {
                $args['page_id'] = absint($pageId);
            }
            $text = '';
            $query = new WP_Query($args);
                // echo '<pre/>';print_r($query);
            if ($query->have_posts()) {
                while ($query->have_posts()) : $query->the_post();
                    $pageLink = '';
                    $slider_btn_link = get_post_meta($query->ID, 'slider_btn_link', false);
                    if (!empty($slider_btn_link) && is_array($slider_btn_link)) {
                        $pageLink = esc_url(get_permalink($slider_btn_link[0]));
                    }
                    if (has_post_thumbnail()) {
                        $image_url = get_template_directory_uri() . '/images/portfolio-small-blank.png';
                        $total_image = wp_get_attachment_image_src(get_post_thumbnail_id(), 'total-portfolio-thumb');
                        $total_image_large = wp_get_attachment_image_src(get_post_thumbnail_id(), 'large');
                    } else {
                        $image_url = get_template_directory_uri() . '/images/portfolio-small.png';
                        $total_image = "";
                    }
                        // echo '<pre/>';print_r($total_image);
                    ?>
                    <div class="ht-<?php echo $class; ?>">
                        <div class="ht-<?php echo $class; ?>-outer-wrap">
                            <div class="ht-<?php echo $class; ?>-wrap" style="background-image: url(<?php echo esc_url($total_image[0]) ?>);">
                                <img src="<?php echo esc_url($total_image[0]); ?>" alt="<?php esc_attr(get_the_title()); ?>">
                                <a class="ht-portfolio-image" data-lightbox-gallery="gallery1" href="<?php echo esc_url($total_image[0]) ?>"><i class="fa fa-search"></i></a>
                                <div class="ht-portfolio-caption">
                                    <h5><?php echo esc_attr(get_the_title()) ?></h5>
                                    <?php if (has_post_thumbnail()) { ?>
                                    <a class="ht-portfolio-image" data-lightbox-gallery="gallery1" href="<?php echo esc_url($total_image[0]) ?>"><i class="fa fa-search"></i></a>
                                    <?php } ?>
                                </div>
                            </div>
                        </div>
                    </div>
                    <?php
                endwhile;
                wp_reset_postdata();
            } else {
                $gallaryImage = array(
                    '/images/facility.jpg',
                    '/images/sleep.jpg',
                    '/images/man-461195_1280.jpg',
                    '/images/wellness-285588_1280.jpg',
                    '/images/about.jpg',
                    '/images/relax-1690338_1920.jpg',
                        // '/images/man-461195_1280.jpg',
                );
                for ($i = 0; $i < count($gallaryImage); $i++) {
                    ?>
                    <div class="ht-<?php echo $class; ?>">
                        <div class="ht-<?php echo $class; ?>-outer-wrap">
                            <div class="ht-<?php echo $class; ?>-wrap" style="background-image: url(<?php echo get_template_directory_uri() . $gallaryImage[$i]; ?>);">
                                <img src="<?php echo get_template_directory_uri() . $gallaryImage[$i]; ?>" alt="Gallary <?php echo $i + 1; ?>">
                                <a class="ht-portfolio-image" data-lightbox-gallery="gallery1" href="<?php echo get_template_directory_uri() . $gallaryImage[$i]; ?>"><i class="fa fa-search"></i></a>
                                <div class="ht-portfolio-caption">
                                    <h5>Gallary <?php echo $i + 1; ?></h5>
                                    <a class="ht-portfolio-image" data-lightbox-gallery="gallery1" href="<?php echo get_template_directory_uri() . $gallaryImage[$i]; ?>"><i class="fa fa-search"></i></a>
                                </div>
                            </div>
                        </div>
                    </div>
                    <?php }
                }
                ?>
            </div>
        </div>
        <?php
        $gallaryHtml = ob_get_contents();
        ob_clean();
        ob_end_flush();
        return $gallaryHtml;
    }

    /**
     * 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 Parag Chaure <parag.radical@outlook.com>
     * */
