__('List posts, comments, and/or tags with or without tabs.', 'hueman'), 'classname' => 'widget_hu_tabs' ) ); } public function hu_get_defaults() { return array( 'title' => '', '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', ); } /* 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' => 'far fa-clock', 'popular' => 'fas fa-star', 'comments' => 'far fa-comments', 'tags' => 'fas fa-tags' ); $output = sprintf(''; return $output; } /* Widget /* ------------------------------------ */ public function widget($args, $instance) { extract( $args ); $defaults = $this -> hu_get_defaults(); $instance = wp_parse_args( (array) $instance, $defaults ); $title = apply_filters('widget_title',$instance['title']); $title = empty( $title ) ? '' : $title; $output = $before_widget."\n"; if( $title || ! empty( $before_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); } ?>
array( 'post' ), 'showposts' => $instance["recent_num"], 'cat' => $instance['recent_cat_id'], 'ignore_sticky_posts' => true ) ); $recent = new WP_Query( is_array( $recent_query_params ) ? $recent_query_params : array() ); ?> 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'], ), ), ) ); $popular = new WP_Query( is_array( $popular_query_params ) ? $popular_query_params : array() ); ?> $instance["comments_num"],'status'=>'approve','post_status'=>'publish')); ?>
hu_get_defaults(); $instance = wp_parse_args( (array) $instance, $defaults ); ?>

" />

Recent Posts

>

>

" name="get_field_name("recent_num") ); ?>" type="text" value="" size='3' />

$this->get_field_name("recent_cat_id"), 'selected' => $instance["recent_cat_id"], 'show_option_all' => 'All', 'show_count' => true ) ); ?>


Most Popular

>

>

" name="get_field_name("popular_num") ); ?>" type="text" value="" size='3' />

$this->get_field_name("popular_cat_id"), 'selected' => $instance["popular_cat_id"], 'show_option_all' => 'All', 'show_count' => true ) ); ?>


Recent Comments

>

>

" name="get_field_name("comments_num") ); ?>" type="text" value="" size='3' />


Tags

>


Tab Order

" name="get_field_name("order_recent") ); ?>" value="" />

" name="get_field_name("order_popular") ); ?>" value="" />

" name="get_field_name("order_comments") ); ?>" value="" />

" name="get_field_name("order_tags") ); ?>" value="" />


Tab Info

>

>