/**
  * Format the output for this widget.
  *
  * @return string
  * @author Huu Ha
  */
 public function output($args, $instance)
 {
     extract($args);
     $html = $before_widget;
     $class = 'wplb-widget-post-featured ';
     if (!empty($instance['class'])) {
         $class .= $instance['class'];
     }
     $html .= '<div class="' . $class . '">';
     if (!empty($instance['title'])) {
         $html .= $before_title;
         $html .= $instance['title'];
         $html .= $after_title;
     }
     $post_type = 'post';
     $taxonomy = '';
     $term_id = '';
     if (!empty($instance['post_and_term'])) {
         $json_value = json_decode($instance['post_and_term']);
         $json_value = (array) $json_value[0];
         if (isset($json_value['post_type']) && !empty($json_value['post_type'])) {
             $post_type = $json_value['post_type'];
         }
         if (isset($json_value['taxonomy']) && !empty($json_value['taxonomy'])) {
             $taxonomy = $json_value['taxonomy'];
         }
         if (isset($json_value['term']) && !empty($json_value['term'])) {
             $term_id = $json_value['term'];
         }
     }
     $query_args = array('post_type' => $post_type, 'posts_per_page' => $instance['posts_num'] ? $instance['posts_num'] : 10, 'post__not_in' => $instance['exclude'] ? $instance['exclude'] : '', 'orderby' => $instance['orderby'], 'order' => $instance['order'], 'featured' => 'yes');
     if ($taxonomy != 'all' && $term_id != 'all') {
         $query_args['tax_query'] = array(array('taxonomy' => $taxonomy, 'field' => 'id', 'terms' => $term_id));
     }
     $wplb_query = new WP_Query($query_args);
     $counter = 0;
     $html .= '<ul class="wplb-listing">';
     while ($wplb_query->have_posts()) {
         $wplb_query->the_post();
         $image = wplb_get_image(array('format' => 'html', 'size' => $instance['image_size'], 'context' => 'featured-post-widget'));
         $html .= '<li class="wplb-item">';
         if (isset($instance['show_image']) && !empty($image)) {
             $html .= '<a href="' . get_permalink() . '">';
             $html .= '<div class="wplb-thumbnail">';
             $html .= $image;
             $html .= '</div>';
             $html .= '</a>';
         }
         if ($instance['show_title']) {
             $html .= '<h3 class="wplb-title"><a href="' . get_permalink() . '">' . get_the_title() . '</a></h3>';
         }
         $html .= '<p class="wplb-meta">';
         if (!empty($instance['show_gravatar'])) {
             $html .= '<span class="wplb-gravatar">';
             $html .= get_avatar(get_the_author_meta('ID'), $instance['gravatar_size']);
             $html .= '</span>';
         }
         if ($instance['show_meta_date'] || $instance['show_meta_cat']) {
             $html .= '<span class="wplb-post-meta">';
             if ($instance['show_meta_date']) {
                 $html .= wplb_get_time() . ' ';
             }
             if ($instance['show_meta_cat']) {
                 $html . get_the_category_list(', ');
             }
             $html .= '</span>';
         }
         $html .= '</p>';
         if (!empty($instance['show_content'])) {
             $html .= '<p class="wplb-entry-content">';
             if ('excerpt' == $instance['show_content']) {
                 $html .= get_the_excerpt();
             } elseif ('content-limit' == $instance['show_content']) {
                 $html .= wplb_get_the_content_limit((int) $instance['content_limit'], esc_html($instance['more_text']));
             } else {
                 global $more;
                 $orig_more = $more;
                 $more = 0;
                 $html .= get_the_content(esc_html($instance['more_text']));
                 $more = $orig_more;
             }
             $html .= '</p>';
         }
         $html .= '</li>';
     }
     $html .= '</ul>';
     wp_reset_query();
     $html .= '</div>';
     $html .= $after_widget;
     return apply_filters('wplb-widget-featured', $html, $args, $instance);
 }
 function wplb_the_content_limit($max_characters, $more_link_text = '(more...)', $stripteaser = false)
 {
     $content = wplb_get_the_content_limit($max_characters, $more_link_text, $stripteaser);
     echo apply_filters('wplb_the_content_limit', $content);
 }