 <?php if  (of_get_option('aw_tabbed_pop') || of_get_option('aw_tabbed_recent') || of_get_option('aw_tabbed_comment') || of_get_option('aw_tabbed_tags') ) { ?> 
<div id="tabwidget"> 
  <ul id="tabnav"> 
  
 <?php if ( (of_get_option('aw_tabbed_pop')) !='' ) { ?> 
    <li><a href="#tab1" class="selected"><?php _e('Popular', 'awesome'); ?></a></li>
<?php } ?>	
<?php if ( (of_get_option('aw_tabbed_recent')) !='' ) { ?> 
    <li><a href="#tab2"><?php _e('Recent', 'awesome'); ?></a></li> 
<?php } ?>	
<?php if ( (of_get_option('aw_tabbed_comment')) !='' ) { ?> 
    <li><a href="#tab3"><?php _e('Comments', 'awesome'); ?></a></li>
<?php } ?>
<?php if ( (of_get_option('aw_tabbed_tags')) !='' ) { ?> 	
    <li><a href="#tab4"><?php _e('Tags', 'awesome'); ?></a></li> 
<?php } ?>	
  </ul> 
  
	<div id="tab-content">
	
	 <?php if ( (of_get_option('aw_tabbed_pop')) !='' ) { ?> 
		  <div id="tab1" style="display: block; ">
		  
			<ul class="recent-tab">
				<?php 
				$limit = of_get_option('aw_tabbed_pop_limit');
				$popularpost = new WP_Query( array( 'posts_per_page' => $limit, 'meta_key' => 'wpb_post_views_count', 'orderby' => 'wpb_post_views_count', 'order' => 'DESC'  ) );
				while ( $popularpost->have_posts() ) : $popularpost->the_post(); ?>
				
					<li>
						<?php if ( has_post_thumbnail() ) { ?>
						<?php $get_img_mini = wp_get_attachment_image_src( get_post_thumbnail_id(), 'post-thumb-mini');	?>
						<a href="<?php the_permalink(); ?>"><img src="<?php echo $get_img_mini[0]; ?>" alt="<?php the_title(); ?>" width="<?php echo $get_img_mini[1]; ?>" height="<?php echo $get_img_mini[2]; ?>" /></a>
						<?php } ?>							
						<a href="<?php the_permalink() ?>" title="Permanent Link to: <?php the_title_attribute(); ?>"><?php the_title(); ?></a> <br />
						<span class="side-meta">	

						<?php 
						printf(__('<span class="aside-date"><span>%1$s </span><span>%2$s</span></span>', 'awesome'),
							get_the_date( 'j' ),
							get_the_date( 'M Y' )
						);
						?>							
							
						
						</span>					
						
						<?php wpb_get_post_views(get_the_ID()); ?>
					</li>
						
				<?php endwhile;
				wp_reset_query();
				?>
			</ul>
			<!-- End most viewed post -->		  
		  
		  </div> 
		  
	<?php } ?>	
		 
	<?php if ( (of_get_option('aw_tabbed_recent')) !='' ) { ?> 	 
		  <div id="tab2" style="display: none; ">	
			
			<?php 
			$limit = of_get_option('aw_tabbed_recent_limit');
			rewind_posts(); ?>
			<?php 
			$the_query = new WP_Query( 'showposts='. $limit . '' ); 
			?>
			<?php while ($the_query -> have_posts()) : $the_query -> the_post(); ?>									
				
			<ul class="recent-tab">
			
			<li>
				<?php if ( has_post_thumbnail() ) { ?>
				<?php $get_img_mini = wp_get_attachment_image_src( get_post_thumbnail_id(), 'post-thumb-mini');	?>
				<a href="<?php the_permalink(); ?>"><img src="<?php echo $get_img_mini[0]; ?>" alt="<?php the_title(); ?>" width="<?php echo $get_img_mini[1]; ?>" height="<?php echo $get_img_mini[2]; ?>" /></a>
				<?php } ?>			
				<span><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></span><br />
				
					<span class="side-meta">	

					<?php 
					printf(__('<span class="aside-date"><span>%1$s </span><span>%2$s</span></span>', 'awesome'),
						get_the_date( 'j' ),
						get_the_date( 'M Y' )
					);
					?>							
					
					</span>				
					
			</li>
			<?php endwhile; wp_reset_query(); ?>			
		  
		  </ul> 
		  
		 </div> 
		  
	<?php } ?>	  
		  
	<?php if ( (of_get_option('aw_tabbed_comment')) !='' ) { ?> 		
		  <div id="tab3" style="display: none; ">
		  
				<?php
				global $wpdb;
				$limit = of_get_option('aw_tabbed_comment_limit');
				$sql = "SELECT DISTINCT ID, post_title, post_password, comment_ID,
				comment_post_ID, comment_author, comment_date_gmt, comment_approved,
				comment_type,comment_author_url,
				SUBSTRING(comment_content,1,30) AS com_excerpt
				FROM $wpdb->comments
				LEFT OUTER JOIN $wpdb->posts ON ($wpdb->comments.comment_post_ID =
				$wpdb->posts.ID)
				WHERE comment_approved = '1' AND comment_type = '' AND
				post_password = ''
				ORDER BY comment_date_gmt DESC
				LIMIT $limit";
				$comments = $wpdb->get_results($sql);
				$output = $pre_HTML;
				$output .= "\n<ul>";
				foreach ($comments as $comment) {
				$output .= "\n<li><span class=\"author\">".strip_tags($comment->comment_author)
				."</span> on " . "<a href=\"" . get_permalink($comment->ID) .
				"#comment-" . $comment->comment_ID . "\" title=\" View comment \">" . strip_tags($comment->com_excerpt)
				."</a></li>";
				}
				$output .= "\n</ul>";
				$output .= $post_HTML;
				echo $output;?>
		  
		  </div> 
	<?php } ?>	  
		  
	<?php if ( (of_get_option('aw_tabbed_tags')) !='' ) { ?> 		  
		  <div id="tab4" style="display: none; ">		  
			
		<?php if ( function_exists('wp_tag_cloud') ) : ?>		  
			<div class="tag-clouds-tab">
			<?php 
			  $limit = of_get_option('aw_tabbed_tags_limit');
			  $args = array(
				'taxonomy'  => array('post_tag'), 
				'smallest'  => 10,
				'largest'  => 10,
				'format' => 'flat',		
				'number' => $limit
			   ); 
			   
			  wp_tag_cloud($args);
			?>
			</div>
		<?php endif; ?>			
		  
		  </div>
		  
	<?php } ?>	  
		  
		  
	</div><!-- /#tab-content -->
 
</div><!-- /#usual1 --> 
<?php } else { echo "Not Found"; } ?>
