Example #1
0
    function widget($args, $instance)
    {
        $cache = wp_cache_get('kadence_testimonials_slider', 'widget');
        if (!is_array($cache)) {
            $cache = array();
        }
        if (!isset($args['widget_id'])) {
            $args['widget_id'] = $this->id;
        }
        if (isset($cache[$args['widget_id']])) {
            echo $cache[$args['widget_id']];
            return;
        }
        ob_start();
        extract($args);
        $carousel_rn = rand(10, 100);
        $title = apply_filters('widget_title', empty($instance['title']) ? __('Testimonials', 'virtue') : $instance['title'], $instance, $this->id_base);
        if (empty($instance['number']) || !($number = absint($instance['number']))) {
            $number = 10;
        }
        if (empty($instance['wordcount']) || !($wordcount = absint($instance['wordcount']))) {
            $wordcount = 25;
        }
        if (isset($instance['orderby'])) {
            $testorder = $instance['orderby'];
        } else {
            $testorder = 'rand';
        }
        if (isset($instance['columns'])) {
            $columns = $instance['columns'];
        } else {
            $columns = '1';
        }
        if (!empty($instance['speed'])) {
            $speed = $instance['speed'];
        } else {
            $speed = '9000';
        }
        if (!empty($instance['link'])) {
            $link = $instance['link'];
        } else {
            $link = false;
        }
        if (!empty($instance['linktext'])) {
            $linktext = $instance['linktext'];
        } else {
            $linktext = '';
        }
        if (!empty($instance['pagelink'])) {
            $pagelink = $instance['pagelink'];
        } else {
            $pagelink = '';
        }
        if (!empty($instance['full_content'])) {
            $full_content = $instance['full_content'];
        } else {
            $full_content = 'excerpt';
        }
        if (empty($instance['scroll']) || $instance['scroll'] == 1) {
            $scroll = 'items:1,';
        } else {
            $scroll = '';
        }
        if ($columns == '2') {
            $itemsize = 'tcol-lg-6 tcol-md-6 tcol-sm-6 tcol-xs-12 tcol-ss-12';
            $slidewidth = 560;
            $slideheight = 560;
            $md = 2;
            $sm = 2;
            $xs = 1;
            $ss = 1;
        } else {
            if ($columns == '1') {
                $itemsize = 'tcol-lg-12 tcol-md-12 tcol-sm-12 tcol-xs-12 tcol-ss-12';
                $slidewidth = 560;
                $slideheight = 560;
                $md = 1;
                $sm = 1;
                $xs = 1;
                $ss = 1;
            } else {
                if ($columns == '3') {
                    $itemsize = 'tcol-lg-4 tcol-md-4 tcol-sm-4 tcol-xs-6 tcol-ss-12';
                    $slidewidth = 366;
                    $slideheight = 366;
                    $md = 3;
                    $sm = 3;
                    $xs = 2;
                    $ss = 1;
                } else {
                    if ($columns == '6') {
                        $itemsize = 'tcol-lg-2 tcol-md-2 tcol-sm-3 tcol-xs-4 tcol-ss-6';
                        $slidewidth = 240;
                        $slideheight = 240;
                        $md = 6;
                        $sm = 4;
                        $xs = 3;
                        $ss = 2;
                    } else {
                        if ($columns == '5') {
                            $itemsize = 'tcol-lg-25 tcol-md-25 tcol-sm-3 tcol-xs-4 tcol-ss-6';
                            $slidewidth = 240;
                            $slideheight = 240;
                            $md = 5;
                            $sm = 4;
                            $xs = 3;
                            $ss = 2;
                        } else {
                            $itemsize = 'tcol-lg-3 tcol-md-3 tcol-sm-4 tcol-xs-6 tcol-ss-12';
                            $slidewidth = 269;
                            $slideheight = 269;
                            $md = 4;
                            $sm = 3;
                            $xs = 2;
                            $ss = 1;
                        }
                    }
                }
            }
        }
        $r = new WP_Query(apply_filters('widget_posts_args', array('post_type' => 'testimonial', 'testimonial-group' => $instance['thecat'], 'no_found_rows' => true, 'posts_per_page' => $number, 'orderby' => $testorder, 'post_status' => 'publish', 'ignore_sticky_posts' => true)));
        if ($r->have_posts()) {
            ?>
    <?php 
            echo $before_widget;
            ?>
    <?php 
            if ($title) {
                echo $before_title . $title . $after_title;
            }
            ?>
        <div class="fredcarousel">
          <div id="carouselcontainer-<?php 
            echo esc_attr($carousel_rn);
            ?>
" class="rowtight fadein-carousel">
          <div id="testimonial-carousel-<?php 
            echo esc_attr($carousel_rn);
            ?>
" class="kad-testimonial-carousel initcaroufedsel" data-carousel-container="#carouselcontainer-<?php 
            echo esc_attr($carousel_rn);
            ?>
" data-carousel-transition="700" data-carousel-scroll="<?php 
            echo esc_attr($scroll);
            ?>
" data-carousel-auto="true" data-carousel-speed="<?php 
            echo esc_attr($speed);
            ?>
" data-carousel-id="testimonial-carousel-<?php 
            echo esc_attr($carousel_rn);
            ?>
" data-carousel-md="<?php 
            echo esc_attr($md);
            ?>
" data-carousel-sm="<?php 
            echo esc_attr($sm);
            ?>
" data-carousel-xs="<?php 
            echo esc_attr($xs);
            ?>
" data-carousel-ss="<?php 
            echo esc_attr($ss);
            ?>
">
            <?php 
            while ($r->have_posts()) {
                $r->the_post();
                ?>
            <div class="<?php 
                echo esc_attr($itemsize);
                ?>
 t_item">
              <div class="grid_item testimonial_item all postclass">
                <div class="testimonialbox clearfix">
        <?php 
                global $post;
                if (has_post_thumbnail($post->ID)) {
                    $image_url = wp_get_attachment_image_src(get_post_thumbnail_id($post->ID), 'full');
                    $thumbnailURL = $image_url[0];
                    $image = aq_resize($thumbnailURL, 60, 60, true);
                    if (empty($image)) {
                        $image = $thumbnailURL;
                    }
                    ?>
                    <div class="alignleft testimonialimg">
                        <img src="<?php 
                    echo esc_attr($image);
                    ?>
" alt="<?php 
                    the_title();
                    ?>
" class="" style="display: block; max-width:60px;">
                    </div>
                    <?php 
                    $image = null;
                    $thumbnailURL = null;
                    ?>
                  <?php 
                } else {
                    ?>
                    <div class="alignleft testimonialimg">
                      <i class="icon-user2" style="font-size:60px"></i>
                    </div>
                  <?php 
                }
                ?>
                                 
                                 <?php 
                if ($full_content == "full_content") {
                    the_content();
                } else {
                    echo esc_attr(strip_tags(virtue_content($wordcount)));
                }
                if (isset($link) && $link == 'page') {
                    if (!empty($pagelink)) {
                        $thepagelink = $pagelink;
                    } else {
                        $thepagelink = get_the_permalink();
                    }
                    echo '<a href="' . $thepagelink . '" class="kadtestimoniallink testpagelink">';
                    if (!empty($linktext)) {
                        $thelinktext = $linktext;
                    } else {
                        $thelinktext = __('Read More', 'virtue');
                    }
                    echo $thelinktext;
                    echo '</a>';
                } else {
                    if (isset($link) && $link == 'post') {
                        echo '<a href="' . get_the_permalink() . '" class="kadtestimoniallink">';
                        if (!empty($linktext)) {
                            $thelinktext = $linktext;
                        } else {
                            $thelinktext = __('Read More', 'virtue');
                        }
                        echo $thelinktext;
                        echo '</a>';
                    }
                }
                ?>
                </div>
                <div class="testimonialbottom">
                            <div class="lipbg kad-arrow-down"></div>
                            <p><strong><?php 
                the_title();
                ?>
</strong>
                              <?php 
                global $post;
                $location = get_post_meta($post->ID, '_kad_testimonial_location', true);
                if ($location != '') {
                    echo ' - ' . $location;
                }
                ?>
                            </p>
                </div> <!--testimonial bottom -->
              </div> <!-- grid item -->
            </div> <!--itemsize -->
      <?php 
            }
            ?>
        </div>
      </div>
        <div class="clearfix"></div>
        <a class="prev icon-arrow-left test-prev" id="prevport-testimonial-carousel-<?php 
            echo esc_attr($carousel_rn);
            ?>
" href="#"></a>
        <a class="next icon-arrow-right test-next" id="nextport-testimonial-carousel-<?php 
            echo esc_attr($carousel_rn);
            ?>
" href="#"></a>
    </div>
      
    <?php 
            echo $after_widget;
            // Reset the global $the_post as this query will have stomped on it
            wp_reset_postdata();
        }
        $cache[$args['widget_id']] = ob_get_flush();
        wp_cache_set('kadence_testimonials_slider', $cache, 'widget');
    }
function kad_testimonial_shortcode_function($atts, $content)
{
    extract(shortcode_atts(array('orderby' => '', 'order' => '', 'cat' => '', 'id' => rand(10, 100), 'columns' => '', 'limit_text' => false, 'offset' => null, 'wordcount' => '25', 'link' => false, 'linktext' => __('Read More', 'virtue'), 'items' => '3'), $atts));
    if (empty($orderby)) {
        $orderby = 'menu_order';
    }
    if (!empty($order)) {
        $order = $order;
    } else {
        if ($orderby == 'menu_order') {
            $order = 'ASC';
        } else {
            $order = 'DESC';
        }
    }
    if (empty($cat)) {
        $cat = '';
    }
    if (empty($columns)) {
        $columns = '3';
    }
    if ($columns == '2') {
        $itemsize = 'tcol-md-6 tcol-sm-6 tcol-xs-12 tcol-ss-12';
    } else {
        if ($columns == '1') {
            $itemsize = 'tcol-md-12 tcol-sm-12 tcol-xs-12 tcol-ss-12';
        } else {
            if ($columns == '3') {
                $itemsize = 'tcol-md-4 tcol-sm-4 tcol-xs-6 tcol-ss-12';
            } else {
                if ($columns == '6') {
                    $itemsize = 'tcol-md-2 tcol-sm-3 tcol-xs-4 tcol-ss-6';
                } else {
                    if ($columns == '5') {
                        $itemsize = 'tcol-md-25 tcol-sm-3 tcol-xs-4 tcol-ss-6';
                    } else {
                        $itemsize = 'tcol-md-3 tcol-sm-4 tcol-xs-6 tcol-ss-12';
                    }
                }
            }
        }
    }
    global $virtue_premium;
    if (isset($virtue_premium['virtue_animate_in']) && $virtue_premium['virtue_animate_in'] == 1) {
        $animate = 1;
    } else {
        $animate = 0;
    }
    ob_start();
    ?>
	<div class="home-testimonial">
		<div id="testimonialwrapper-<?php 
    echo esc_attr($id);
    ?>
" class="rowtight init-isotope" data-fade-in="<?php 
    echo esc_attr($animate);
    ?>
" data-iso-selector=".t_item" data-iso-style="masonry" data-iso-filter="false"> 
            <?php 
    $wp_query = null;
    $wp_query = new WP_Query();
    $wp_query->query(array('orderby' => $orderby, 'order' => $order, 'offset' => $offset, 'post_type' => 'testimonial', 'testimonial-group' => $cat, 'posts_per_page' => $items));
    $count = 0;
    if ($wp_query) {
        while ($wp_query->have_posts()) {
            $wp_query->the_post();
            ?>
					<div class="<?php 
            echo esc_attr($itemsize);
            ?>
 t_item">
                		<div class="grid_item testimonial_item kad_testimonial_fade_in kt_item_fade_in postclass">
                			<div class="testimonialbox">
								<?php 
            global $post;
            if (has_post_thumbnail($post->ID)) {
                $image_url = wp_get_attachment_image_src(get_post_thumbnail_id($post->ID), 'full');
                $thumbnailURL = $image_url[0];
                $image = aq_resize($thumbnailURL, 60, 60, true);
                if (empty($image)) {
                    $image = $thumbnailURL;
                }
                ?>
									<div class="alignleft testimonialimg">
	                                       <img src="<?php 
                echo esc_url($image);
                ?>
" alt="<?php 
                the_title();
                ?>
" class="" style="display: block; max-width:60px;">
	                                </div>
                           				<?php 
                $image = null;
                $thumbnailURL = null;
                ?>
                                <?php 
            } else {
                ?>
                                	<div class="alignleft testimonialimg">
                                		<i class="icon-users" style="font-size:60px"></i>
                                	</div>
                                <?php 
            }
            ?>
			                            <?php 
            if ($limit_text) {
                echo esc_attr(strip_tags(virtue_content($wordcount)));
            } else {
                the_content();
            }
            if ($link) {
                echo '<a href="' . get_the_permalink() . '" class="kadtestimoniallink">';
                echo $linktext;
                echo '</a>';
            }
            ?>
			                    </div>
			                    <div class="testimonialbottom">
			                    	<div class="lipbg kad-arrow-down"></div>
			                    	<p><strong><?php 
            the_title();
            ?>
</strong>
			                    		<?php 
            $location = get_post_meta($post->ID, '_kad_testimonial_location', true);
            if ($location != '') {
                echo ' - ' . $location;
            }
            ?>
	      						</p>
			                </div>
			            </div>
                	</div>
					<?php 
        }
    } else {
        ?>
					<li class="error-not-found"><?php 
        _e('Sorry, no testimonial entries found.', 'virtue');
        ?>
</li>
				<?php 
    }
    ?>
                </div> <!-- testimonialwrapper -->
                    <?php 
    $wp_query = null;
    wp_reset_query();
    ?>
		</div><!-- /.home-testimonial -->
            		

	<?php 
    $output = ob_get_contents();
    ob_end_clean();
    return $output;
}
    function widget($args, $instance)
    {
        $cache = wp_cache_get('kadence_testimonials_slider', 'widget');
        if (!is_array($cache)) {
            $cache = array();
        }
        if (!isset($args['widget_id'])) {
            $args['widget_id'] = $this->id;
        }
        if (isset($cache[$args['widget_id']])) {
            echo $cache[$args['widget_id']];
            return;
        }
        ob_start();
        extract($args);
        $carousel_rn = rand(10, 100);
        $title = apply_filters('widget_title', empty($instance['title']) ? __('Testimonials', 'virtue') : $instance['title'], $instance, $this->id_base);
        if (empty($instance['number']) || !($number = absint($instance['number']))) {
            $number = 10;
        }
        if (empty($instance['wordcount']) || !($wordcount = absint($instance['wordcount']))) {
            $wordcount = 25;
        }
        if (isset($instance['orderby'])) {
            $testorder = $instance['orderby'];
        } else {
            $testorder = 'rand';
        }
        if (isset($instance['columns'])) {
            $columns = $instance['columns'];
        } else {
            $columns = '1';
        }
        if (!empty($instance['speed'])) {
            $speed = $instance['speed'];
        } else {
            $speed = '9000';
        }
        if (!empty($instance['link'])) {
            $link = $instance['link'];
        } else {
            $link = false;
        }
        if (!empty($instance['linktext'])) {
            $linktext = $instance['linktext'];
        } else {
            $linktext = '';
        }
        if (!empty($instance['pagelink'])) {
            $pagelink = $instance['pagelink'];
        } else {
            $pagelink = '';
        }
        if (empty($instance['scroll']) || $instance['scroll'] == 1) {
            $scroll = 'items:1,';
        } else {
            $scroll = '';
        }
        if ($columns == '2') {
            $itemsize = 'tcol-lg-6 tcol-md-6 tcol-sm-6 tcol-xs-12 tcol-ss-12';
            $slidewidth = 560;
            $slideheight = 560;
            $md = 2;
            $sm = 2;
            $xs = 1;
            $ss = 1;
        } else {
            if ($columns == '1') {
                $itemsize = 'tcol-lg-12 tcol-md-12 tcol-sm-12 tcol-xs-12 tcol-ss-12';
                $slidewidth = 560;
                $slideheight = 560;
                $md = 1;
                $sm = 1;
                $xs = 1;
                $ss = 1;
            } else {
                if ($columns == '3') {
                    $itemsize = 'tcol-lg-4 tcol-md-4 tcol-sm-4 tcol-xs-6 tcol-ss-12';
                    $slidewidth = 366;
                    $slideheight = 366;
                    $md = 3;
                    $sm = 3;
                    $xs = 2;
                    $ss = 1;
                } else {
                    if ($columns == '6') {
                        $itemsize = 'tcol-lg-2 tcol-md-2 tcol-sm-3 tcol-xs-4 tcol-ss-6';
                        $slidewidth = 240;
                        $slideheight = 240;
                        $md = 6;
                        $sm = 4;
                        $xs = 3;
                        $ss = 2;
                    } else {
                        if ($columns == '5') {
                            $itemsize = 'tcol-lg-25 tcol-md-25 tcol-sm-3 tcol-xs-4 tcol-ss-6';
                            $slidewidth = 240;
                            $slideheight = 240;
                            $md = 5;
                            $sm = 4;
                            $xs = 3;
                            $ss = 2;
                        } else {
                            $itemsize = 'tcol-lg-3 tcol-md-3 tcol-sm-4 tcol-xs-6 tcol-ss-12';
                            $slidewidth = 269;
                            $slideheight = 269;
                            $md = 4;
                            $sm = 3;
                            $xs = 2;
                            $ss = 1;
                        }
                    }
                }
            }
        }
        $r = new WP_Query(apply_filters('widget_posts_args', array('post_type' => 'testimonial', 'testimonial-group' => $instance['thecat'], 'no_found_rows' => true, 'posts_per_page' => $number, 'orderby' => $testorder, 'post_status' => 'publish', 'ignore_sticky_posts' => true)));
        if ($r->have_posts()) {
            ?>
    <?php 
            echo $before_widget;
            ?>
    <?php 
            if ($title) {
                echo $before_title . $title . $after_title;
            }
            ?>
        <div class="fredcarousel">
          <div id="carouselcontainer-<?php 
            echo $carousel_rn;
            ?>
" class="rowtight">
          <div id="testimonial-carousel-<?php 
            echo $carousel_rn;
            ?>
" class="kad-testimonial-carousel">
            <?php 
            while ($r->have_posts()) {
                $r->the_post();
                ?>
            <div class="<?php 
                echo $itemsize;
                ?>
 t_item">
              <div class="grid_item testimonial_item all postclass">
                <div class="testimonialbox clearfix">
        <?php 
                global $post;
                if (has_post_thumbnail($post->ID)) {
                    $image_url = wp_get_attachment_image_src(get_post_thumbnail_id($post->ID), 'full');
                    $thumbnailURL = $image_url[0];
                    $image = aq_resize($thumbnailURL, 60, 60, true);
                    if (empty($image)) {
                        $image = $thumbnailURL;
                    }
                    ?>
                    <div class="alignleft testimonialimg">
                        <img src="<?php 
                    echo $image;
                    ?>
" alt="<?php 
                    the_title();
                    ?>
" class="" style="display: block; max-width:60px;">
                    </div>
                    <?php 
                    $image = null;
                    $thumbnailURL = null;
                    ?>
                  <?php 
                } else {
                    ?>
                    <div class="alignleft testimonialimg">
                      <i class="icon-user2" style="font-size:60px"></i>
                    </div>
                  <?php 
                }
                ?>
                                 
                                 <?php 
                echo esc_attr(strip_tags(virtue_content($wordcount)));
                ?>
 
                                 <?php 
                if (isset($link) && $link == 'page') {
                    if (!empty($pagelink)) {
                        $thepagelink = $pagelink;
                    } else {
                        $thepagelink = get_the_permalink();
                    }
                    echo '<a href="' . $thepagelink . '" class="kadtestimoniallink testpagelink">';
                    if (!empty($linktext)) {
                        $thelinktext = $linktext;
                    } else {
                        $thelinktext = __('Read More', 'virtue');
                    }
                    echo $thelinktext;
                    echo '</a>';
                } else {
                    if (isset($link) && $link == 'post') {
                        echo '<a href="' . get_the_permalink() . '" class="kadtestimoniallink">';
                        if (!empty($linktext)) {
                            $thelinktext = $linktext;
                        } else {
                            $thelinktext = __('Read More', 'virtue');
                        }
                        echo $thelinktext;
                        echo '</a>';
                    }
                }
                ?>
                </div>
                <div class="testimonialbottom">
                            <div class="lipbg kad-arrow-down"></div>
                            <p><strong><?php 
                the_title();
                ?>
</strong>
                              <?php 
                global $post;
                $location = get_post_meta($post->ID, '_kad_testimonial_location', true);
                if ($location != '') {
                    echo ' - ' . $location;
                }
                ?>
                            </p>
                </div> <!--testimonial bottom -->
              </div> <!-- grid item -->
            </div> <!--itemsize -->
      <?php 
            }
            ?>
        </div>
      </div>
        <div class="clearfix"></div>
        <a class="prev icon-arrow-left test-prev" id="prevport-<?php 
            echo $carousel_rn;
            ?>
" href="#"></a>
        <a class="next icon-arrow-right test-next" id="nextport-<?php 
            echo $carousel_rn;
            ?>
" href="#"></a>
    </div>
    <script type="text/javascript"> jQuery( window ).load(function () {var $wcontainer = jQuery('#carouselcontainer-<?php 
            echo $carousel_rn;
            ?>
'); var $container = jQuery('#testimonial-carousel-<?php 
            echo $carousel_rn;
            ?>
');
          setWidths(); 
          function init_test_Carousel() {
              $container.carouFredSel({
                scroll: { <?php 
            echo $scroll;
            ?>
 easing: "swing", duration: 700, pauseOnHover : true}, auto: {play: true, timeoutDuration: <?php 
            echo $speed;
            ?>
},
                prev: '#prevport-<?php 
            echo $carousel_rn;
            ?>
', next: '#nextport-<?php 
            echo $carousel_rn;
            ?>
', pagination: false, swipe: true, items: {visible: null}
              });
            }
            init_test_Carousel();
            jQuery(window).on("debouncedresize", function( event ) {
              $container.trigger("destroy");
              setWidths();
             init_test_Carousel();
            });
          $wcontainer.animate({'opacity' : 1});
          function getUnitWidth() {var width;
          if(jQuery(window).width() <= 480) {
          width = $wcontainer.width() / <?php 
            echo $ss;
            ?>
;
          } else if(jQuery(window).width() <= 768) {
          width = $wcontainer.width() / <?php 
            echo $xs;
            ?>
;
          } else if(jQuery(window).width() <= 990) {
          width = $wcontainer.width() / <?php 
            echo $sm;
            ?>
;
          } else {
          width = $wcontainer.width() / <?php 
            echo $md;
            ?>
;
          }
          return width;
          }
          function setWidths() {
          var unitWidth = getUnitWidth() -1;
          $container.children().css({ width: unitWidth });
          } });
      </script>       
    <?php 
            echo $after_widget;
            // Reset the global $the_post as this query will have stomped on it
            wp_reset_postdata();
        }
        $cache[$args['widget_id']] = ob_get_flush();
        wp_cache_set('kadence_testimonials_slider', $cache, 'widget');
    }
Example #4
0
                           				<?php 
            $image = null;
            $thumbnailURL = null;
            ?>
                                <?php 
        } else {
            ?>
                                	<div class="alignleft testimonialimg">
                                		<i class="icon-user2" style="font-size:60px"></i>
                                	</div>
                                <?php 
        }
        ?>
                                <?php 
        if ($limit_text) {
            echo esc_attr(strip_tags(virtue_content($wordcount)));
        } else {
            the_content();
        }
        if ($postlink) {
            echo '<a href="' . get_the_permalink() . '" class="kadtestimoniallink">';
            echo $thelinktext;
            echo '</a>';
        }
        ?>

			                    </div>
			                    <div class="testimonialbottom">
			                    	<div class="lipbg kad-arrow-down"></div>
			                    	<p><strong><?php 
        the_title();