public function widget($args, $instance)
    {
        global $post;
        // setup_postdata not enough
        // set defaults
        $titles = $cats = $tax_tags = array();
        extract($args);
        extract($instance);
        // missing data?
        if (!count($titles) or !count($cats)) {
            _e('Recent tabs widget still need to be configured! Add tabs, add a title, and select type for each tab in widgets area.', 'bunyad-widgets');
            return;
        }
        $tabs = array();
        foreach ($titles as $key => $title) {
            // defaults missing?
            if (empty($tax_tags[$key])) {
                $tax_tags[$key] = '';
            }
            if (empty($cats[$key])) {
                $cats[$key] = '';
            }
            if (empty($posts[$key])) {
                $posts[$key] = !empty($number) ? $number : 0;
            }
            $tabs[$title] = array('cat_type' => $cats[$key], 'tag' => $tax_tags[$key], 'posts' => $posts[$key]);
        }
        // latest posts
        $posts = $this->get_posts($tabs);
        // do custom loop if available
        if (has_action('bunyad_widget_tabbed_recent_loop')) {
            $args['tabs'] = $tabs;
            do_action('bunyad_widget_tabbed_recent_loop', $args, $posts);
        } else {
            ?>
	
			<?php 
            echo $before_widget;
            ?>
	
			<ul class="tabs-list">
			
				<?php 
            $count = 0;
            foreach ($posts as $key => $val) {
                $count++;
                $active = $count == 1 ? 'active' : '';
                ?>
				
				<li class="<?php 
                echo $active;
                ?>
">
					<a href="#" data-tab="<?php 
                echo esc_attr($count);
                ?>
"><?php 
                echo $key;
                ?>
</a>
				</li>
				
				<?php 
            }
            ?>
				
			</ul>
			
			<div class="tabs-data">
				<?php 
            $i = 0;
            foreach ($posts as $tab => $tab_posts) {
                $i++;
                $active = $i == 1 ? 'active' : '';
                ?>
					
				<ul class="tab-posts <?php 
                echo $active;
                ?>
 posts-list" id="recent-tab-<?php 
                echo esc_attr($i);
                ?>
">
				
				<?php 
                if ($tabs[$tab] == 'comments') {
                    ?>
	
					<?php 
                    foreach ($tab_posts as $comment) {
                        ?>
					
					<li class="comment">
						
						<span class="author"><?php 
                        printf('%s said', get_comment_author_link($comment->comment_ID));
                        ?>
</span>
						
						<p class="text"><?php 
                        comment_excerpt($comment->comment_ID);
                        ?>
</p>
						
						<a href=""><?php 
                        echo get_the_title($comment->comment_post_ID);
                        ?>
</a>
					
					</li>
	
					<?php 
                    }
                    ?>
				
				
				<?php 
                } else {
                    ?>
				
					<?php 
                    while ($tab_posts->have_posts()) {
                        $tab_posts->the_post();
                        ?>
	
					<li>
					
						<a href="<?php 
                        the_permalink();
                        ?>
"><?php 
                        the_post_thumbnail('post-thumbnail', array('title' => strip_tags(get_the_title())));
                        ?>
	
						<?php 
                        if (class_exists('Bunyad') && Bunyad::options()->review_show_widgets) {
                            ?>
							<?php 
                            echo apply_filters('bunyad_review_main_snippet', '');
                            ?>
						<?php 
                        }
                        ?>
						
						</a>
						
						<div class="content">
						
							<?php 
                        echo Bunyad::blocks()->meta('above', 'tabbed-recent', array('type' => 'widget'));
                        ?>
						
							<a href="<?php 
                        the_permalink();
                        ?>
" title="<?php 
                        echo esc_attr(get_the_title() ? get_the_title() : get_the_ID());
                        ?>
">
								<?php 
                        if (get_the_title()) {
                            the_title();
                        } else {
                            the_ID();
                        }
                        ?>
</a>
								
							<?php 
                        echo Bunyad::blocks()->meta('below', 'tabbed-recent', array('type' => 'widget'));
                        ?>
								
							<?php 
                        if (class_exists('Bunyad') && Bunyad::options()->review_show_widgets) {
                            ?>
								<?php 
                            echo apply_filters('bunyad_review_main_snippet', '', 'stars');
                            ?>
							<?php 
                        }
                        ?>
																		
						</div>
					
					</li>
					
					<?php 
                    }
                    ?>
					
				<?php 
                }
                ?>
					
				</ul>
				<?php 
            }
            ?>
			
			</div>
			
			<?php 
            echo $after_widget;
            ?>
		
		<?php 
        }
        // end custom loop
        wp_reset_postdata();
        wp_reset_query();
    }
					<?php 
        echo Bunyad::blocks()->meta('above', 'related-posts', array('type' => 'widget'));
        ?>
					
					<h2><a href="<?php 
        the_permalink();
        ?>
" title="<?php 
        the_title_attribute();
        ?>
"><?php 
        the_title();
        ?>
</a></h2>
					
					<?php 
        echo Bunyad::blocks()->meta('below', 'related-posts', array('type' => 'widget'));
        ?>
					
				</article>
			</li>
			
		<?php 
    }
    wp_reset_postdata();
    ?>
		</ul>
	</section>

<?php 
}
        echo Bunyad::blocks()->meta('above', 'grid-overlay');
        ?>
					
					<h2 itemprop="name headline"><a href="<?php 
        the_permalink();
        ?>
" title="<?php 
        the_title_attribute();
        ?>
" itemprop="url"><?php 
        the_title();
        ?>
</a></h2>
					
					<?php 
        echo Bunyad::blocks()->meta('below', 'grid-overlay');
        ?>
					
				</div>
			
			</article>
		</div>
			
		<?php 
    }
    ?>
				
	</div>
	
	
	<?php 
    ?>
" title="<?php 
    echo esc_attr(get_the_title() ? get_the_title() : get_the_ID());
    ?>
">
						<?php 
    if (get_the_title()) {
        the_title();
    } else {
        the_ID();
    }
    ?>
</a>
						
					<?php 
    echo Bunyad::blocks()->meta('below', 'live-search', array('type' => 'widget'));
    ?>
						
					<?php 
    if (class_exists('Bunyad') && Bunyad::options()->review_show_widgets) {
        ?>
						<?php 
        echo apply_filters('bunyad_review_main_snippet', '', 'stars');
        ?>
					<?php 
    }
    ?>
																
				</div>
			
			</li>
    public function widget($args, $instance)
    {
        $cache = get_transient('bunyad_widget_latest_reviews');
        if (!is_array($cache)) {
            $cache = array();
        }
        if (!isset($args['widget_id'])) {
            $args['widget_id'] = $this->number;
        }
        // cache available
        if (isset($cache[$args['widget_id']])) {
            //echo $cache[ $args['widget_id'] ];
            //return;
        }
        ob_start();
        extract($args);
        extract($instance, EXTR_SKIP);
        $title = apply_filters('widget_title', empty($instance['title']) ? __('Recent Posts', 'bunyad-widgets') : $instance['title'], $instance, $this->id_base);
        if (empty($instance['number']) || !($number = absint($instance['number']))) {
            $number = 5;
        }
        $query_args = array('posts_per_page' => $number, 'post_status' => 'publish', 'ignore_sticky_posts' => 1, 'meta_key' => '_bunyad_review_overall');
        // order by rating?
        if (isset($order) && $order == 'rating') {
            $query_args['orderby'] = 'meta_value';
        } else {
            $query_args['orderby'] = 'date';
        }
        $r = new WP_Query(apply_filters('bunyad_widget_latest_reviews_query_args', $query_args));
        // do custom loop if available
        if (has_action('bunyad_widget_latest_review_loop')) {
            $args['title'] = $title;
            do_action('bunyad_widget_latest_review_loop', array_merge($args, $instance), $r);
        } elseif ($r->have_posts()) {
            ?>

			<?php 
            echo $before_widget;
            ?>
			
			<?php 
            if ($title) {
                ?>
				<?php 
                echo $before_title . $title . $after_title;
                ?>
			<?php 
            }
            ?>
			
			<ul class="posts-list">
			
			<?php 
            while ($r->have_posts()) {
                $r->the_post();
                global $post;
                ?>
				<li>
				
					<a href="<?php 
                the_permalink();
                ?>
"><?php 
                the_post_thumbnail('post-thumbnail', array('title' => strip_tags(get_the_title())));
                ?>
					
					<?php 
                if (class_exists('Bunyad') && Bunyad::options()->review_show_widgets) {
                    ?>
						<?php 
                    echo apply_filters('bunyad_review_main_snippet', '');
                    ?>
					<?php 
                }
                ?>
					
					</a>
					
					<div class="content">
					
						<?php 
                echo Bunyad::blocks()->meta('above', 'latest-reviews', array('type' => 'widget'));
                ?>
					
						<a href="<?php 
                the_permalink();
                ?>
" title="<?php 
                echo esc_attr(get_the_title() ? get_the_title() : get_the_ID());
                ?>
">
							<?php 
                if (get_the_title()) {
                    the_title();
                } else {
                    the_ID();
                }
                ?>
</a>
							
						<?php 
                echo Bunyad::blocks()->meta('below', 'latest-reviews', array('type' => 'widget'));
                ?>
							
						<?php 
                if (class_exists('Bunyad') && Bunyad::options()->review_show_widgets) {
                    ?>
							<?php 
                    echo apply_filters('bunyad_review_main_snippet', '', 'stars');
                    ?>
						<?php 
                }
                ?>

					</div>
				
				</li>
			<?php 
            }
            ?>
			</ul>
			
			<?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();
        set_transient('bunyad_widget_latest_reviews', $cache);
    }
        ?>
" title="<?php 
        echo esc_attr(get_the_title() ? get_the_title() : get_the_ID());
        ?>
">
							<?php 
        if (get_the_title()) {
            the_title();
        } else {
            the_ID();
        }
        ?>
</a>
							
						<?php 
        echo Bunyad::blocks()->meta('below', 'block-small');
        ?>
							
						<?php 
        echo apply_filters('bunyad_review_main_snippet', '', 'stars');
        ?>
						
					</div>
				
			<?php 
    } else {
        ?>
			
					<i class="fa fa-angle-right"></i>
					<a href="<?php 
        the_permalink();
        ?>
" title="<?php 
        echo esc_attr(get_the_title() ? get_the_title() : get_the_ID());
        ?>
" itemprop="name headline url">
						<?php 
        if (get_the_title()) {
            the_title();
        } else {
            the_ID();
        }
        ?>
</a>
						
					<?php 
        echo Bunyad::blocks()->meta('below', 'listing-alt');
        ?>
						
					<?php 
        echo apply_filters('bunyad_review_main_snippet', '', 'stars');
        ?>
					
					<div class="excerpt"><?php 
        echo Bunyad::posts()->excerpt(null, Bunyad::options()->excerpt_length_alt, array('force_more' => Bunyad::options()->read_more_alt));
        ?>
					</div>
					
				</div>
			
			
			</article>
				<div class="content">
				
					<?php 
    echo Bunyad::blocks()->meta('above', 'mega-menu', array('type' => 'widget'));
    ?>
									
					<a href="<?php 
    the_permalink();
    ?>
"><?php 
    the_title();
    ?>
</a>
					
					<?php 
    echo Bunyad::blocks()->meta('below', 'mega-menu', array('type' => 'widget'));
    ?>
																
				</div>
			</div>
			
			<?php 
}
wp_reset_postdata();
?>
			
		</div>
		
	</section>
	</div>
</div>
    $cat = current(get_the_category());
    ?>
					
					<div class="col-6 item small-item">
					
						<a href="<?php 
    the_permalink();
    ?>
" class="image-link"><?php 
    the_post_thumbnail('grid-slider-small', array('alt' => esc_attr(get_the_title()), 'title' => ''));
    ?>
</a>
							
						<div class="caption caption-small">
							<?php 
    echo Bunyad::blocks()->cat_label();
    ?>
						
							<h3><a href="<?php 
    the_permalink();
    ?>
" class="item-heading heading-small"><?php 
    the_title();
    ?>
</a></h3>
							<time class="the-date" datetime="<?php 
    echo esc_attr(get_the_time(DATE_W3C));
    ?>
"><?php 
    echo esc_html(get_the_date());
    ?>
				<?php 
while ($query->have_posts()) {
    $query->the_post();
    ?>
					
					<li>
						<a href="<?php 
    the_permalink();
    ?>
" class="image-link"><?php 
    the_post_thumbnail(apply_filters('bunyad_featured_image', 'main-slider', 'slider'), array('alt' => esc_attr(get_the_title()), 'title' => ''));
    ?>
</a>					
	
						<?php 
    $cat = Bunyad::blocks()->get_primary_cat();
    ?>
						
						<a href="<?php 
    echo get_category_link($cat->term_id);
    ?>
" class="cat cat-title cat-<?php 
    echo $cat->cat_ID;
    ?>
"><?php 
    echo esc_html($cat->cat_name);
    ?>
</a>
						
						<div class="caption">
    public function widget($args, $instance)
    {
        extract($args);
        extract($instance);
        $title = apply_filters('widget_title', $instance['title'], $instance, $this->id_base);
        $type = empty($type) ? '' : $type;
        if ($type == 'jetpack') {
            // jetpack inactive?
            if (!$this->has_jetpack()) {
                _e('Please install Jetpack plugin and activate the WordPress.com Stats module.', 'bunyad-widgets');
                return;
            }
            /**
             * Get posts by views from Jetpack stat module (wordpress.com stats)
             */
            $post_views = stats_get_csv('postviews', array('days' => absint($days), 'limit' => 100));
            if (!$post_views) {
                $post_views = array();
            }
            $post_ids = array_filter(wp_list_pluck($post_views, 'post_id'));
            $query_args = array('offset' => 0, 'posts_per_page' => $number);
            // define posts to get if available
            if (count($post_ids)) {
                $query_args = array_merge($query_args, array('post__in' => $post_ids, 'orderby' => 'post__in'));
            }
            // get the local posts
            $r = new WP_Query(apply_filters('bunyad_widget_popular_posts_query_args', $query_args));
        }
        // if not jetpack or don't have any posts yet - fall-back to comments
        if ($type !== 'jetpack' && (!isset($r) or !$r->have_posts())) {
            $r = new WP_Query(apply_filters('bunyad_widget_popular_posts_query_args', array('posts_per_page' => $number, 'offset' => 0, 'orderby' => 'comment_count', 'ignore_sticky_posts' => 1)));
        }
        // do custom loop if available
        if (has_action('bunyad_widget_popular_posts_loop')) {
            $args['title'] = $title;
            do_action('bunyad_widget_popular_posts_loop', array_merge($args, $instance), $r);
        } elseif ($r->have_posts()) {
            ?>
			<?php 
            echo $before_widget;
            ?>
			<?php 
            echo $before_title . $title . $after_title;
            ?>
			
			<ul class="posts-list">
			<?php 
            while ($r->have_posts()) {
                $r->the_post();
                global $post;
                ?>
				<li>
				
					<a href="<?php 
                the_permalink();
                ?>
"><?php 
                the_post_thumbnail('post-thumbnail', array('title' => strip_tags(get_the_title())));
                ?>
					
					<?php 
                if (class_exists('Bunyad') && Bunyad::options()->review_show_widgets) {
                    ?>
						<?php 
                    echo apply_filters('bunyad_review_main_snippet', '');
                    ?>
					<?php 
                }
                ?>
					
					</a>
					
					<div class="content">
					
						<?php 
                echo Bunyad::blocks()->meta('above', 'popular-posts', array('type' => 'widget'));
                ?>
					
						<a href="<?php 
                the_permalink();
                ?>
" title="<?php 
                echo esc_attr(get_the_title() ? get_the_title() : get_the_ID());
                ?>
">
							<?php 
                if (get_the_title()) {
                    the_title();
                } else {
                    the_ID();
                }
                ?>
</a>
							
						<?php 
                echo Bunyad::blocks()->meta('below', 'popular-posts', array('type' => 'widget'));
                ?>
							
						<?php 
                if (class_exists('Bunyad') && Bunyad::options()->review_show_widgets) {
                    ?>
							<?php 
                    echo apply_filters('bunyad_review_main_snippet', '', 'stars');
                    ?>
						<?php 
                }
                ?>

					</div>
				
				</li>
			<?php 
            }
            ?>
			</ul>
			
			<?php 
            echo $after_widget;
            ?>
		
		<?php 
        }
        // reset global data
        wp_reset_postdata();
    }