'List posts, comments, and/or tags with or without tabs.', 'classname' => 'widget_alx_tabs') );;
}
/* Create tabs-nav
/* ------------------------------------ */
private function _create_tabs($tabs,$count) {
// Borrowed from Jermaine Maree, thanks mate!
$titles = array(
'recent' => __('Recent Posts','hueman'),
'popular' => __('Popular Posts','hueman'),
'comments' => __('Recent Comments','hueman'),
'tags' => __('Tags','hueman')
);
$icons = array(
'recent' => 'fa fa-clock-o',
'popular' => 'fa fa-star',
'comments' => 'fa fa-comments-o',
'tags' => 'fa fa-tags'
);
$output = sprintf('
', $count);
foreach ( $tabs as $tab ) {
$output .= sprintf('- %4$s
',$tab, $tab, $icons[$tab], $titles[$tab]);
}
$output .= '
';
return $output;
}
/* Widget
/* ------------------------------------ */
public function widget($args, $instance) {
extract( $args );
$instance['title']?NULL:$instance['title']='';
$title = apply_filters('widget_title',$instance['title']);
$output = $before_widget."\n";
if($title)
$output .= $before_title.$title.$after_title;
ob_start();
/* Set tabs-nav order & output it
/* ------------------------------------ */
$tabs = array();
$count = 0;
$order = array(
'recent' => $instance['order_recent'],
'popular' => $instance['order_popular'],
'comments' => $instance['order_comments'],
'tags' => $instance['order_tags']
);
asort($order);
foreach ( $order as $key => $value ) {
if ( $instance[$key.'_enable'] ) {
$tabs[] = $key;
$count++;
}
}
if ( $tabs && ($count > 1) ) { $output .= $this->_create_tabs($tabs,$count); }
?>
query('showposts='.$instance["recent_num"].'&cat='.$instance["recent_cat_id"].'&ignore_sticky_posts=1');?>
have_posts()): $recent->the_post(); ?>
-
array( 'post' ),
'showposts' => $instance['popular_num'],
'cat' => $instance['popular_cat_id'],
'ignore_sticky_posts' => true,
'orderby' => 'comment_count',
'order' => 'dsc',
'date_query' => array(
array(
'after' => $instance['popular_time'],
),
),
) );
?>
have_posts() ): $popular->the_post(); ?>
-
$instance["comments_num"],'status'=>'approve','post_status'=>'publish')); ?>
'',
'tabs_category' => 1,
'tabs_date' => 1,
// Recent posts
'recent_enable' => 1,
'recent_thumbs' => 1,
'recent_cat_id' => '0',
'recent_num' => '5',
// Popular posts
'popular_enable' => 1,
'popular_thumbs' => 1,
'popular_cat_id' => '0',
'popular_time' => '0',
'popular_num' => '5',
// Recent comments
'comments_enable' => 1,
'comments_avatars' => 1,
'comments_num' => '5',
// Tags
'tags_enable' => 1,
// Order
'order_recent' => '1',
'order_popular' => '2',
'order_comments' => '3',
'order_tags' => '4',
);
$instance = wp_parse_args( (array) $instance, $defaults );
?>