function widget($args, $instance)
 {
     global $wpdb, $current_site, $post, $wiki_tree;
     extract($args);
     $instance = apply_filters('eab-widgets-upcoming-instance_read', $instance, $this);
     $options = wp_parse_args((array) $instance, $this->_defaults);
     $title = apply_filters('widget_title', empty($instance['title']) ? __('Upcoming', $this->translation_domain) : $instance['title'], $instance, $this->id_base);
     $query_args = array('posts_per_page' => $options['limit']);
     if ($options['category']) {
         $query_args['tax_query'] = array(array('taxonomy' => 'eab_events_category', 'field' => 'id', 'terms' => (int) $options['category']));
     }
     if ($options['lookahead'] && is_numeric($options['lookahead'])) {
         $lookahead_func = create_function('', 'return ' . $options['lookahead'] . ';');
         add_filter('eab-collection-upcoming_weeks-week_number', $lookahead_func);
     }
     $_events = Eab_CollectionFactory::get_upcoming_weeks_events(eab_current_time(), $query_args);
     if (!empty($lookahead_func)) {
         remove_filter('eab-collection-upcoming_weeks-week_number', $lookahead_func);
     }
     if (is_array($_events) && count($_events) > 0) {
         echo $before_widget;
         echo $before_title . $title . $after_title;
         echo '<div id="event-popular"><ul>';
         foreach ($_events as $_event) {
             $thumbnail = $excerpt = false;
             if ($options['thumbnail']) {
                 $raw = wp_get_attachment_image_src(get_post_thumbnail_id($_event->get_id()));
                 $thumbnail = $raw ? @$raw[0] : false;
             }
             $excerpt = false;
             if (!empty($options['excerpt'])) {
                 $words = (int) $options['excerpt_words_limit'] ? (int) $options['excerpt_words_limit'] : false;
                 $excerpt = eab_call_template('util_words_limit', $_event->get_excerpt_or_fallback(), $words);
             }
             echo '<li>';
             echo '<a href="' . get_permalink($_event->get_id()) . '" class="' . ($_event->get_id() == $post->ID ? 'current' : '') . '" >' . ($options['thumbnail'] && $thumbnail ? '<img src="' . $thumbnail . '" /><br />' : '') . $_event->get_title() . '</a>';
             if (!empty($options['dates'])) {
                 echo '<div class="wpmudevevents-date">' . Eab_Template::get_event_dates($_event) . '</div>';
             }
             if (!empty($options['excerpt']) && !empty($excerpt)) {
                 echo '<p>' . $excerpt . '</p>';
             }
             do_action('eab-widgets-upcoming-after_event', $options, $_event, $this);
             echo '</li>';
         }
         echo '</ul></div>';
         echo $after_widget;
     } else {
         echo $before_widget . $before_title . $title . $after_title . '<p class="eab-widget-no_events">' . __('No upcoming events.', Eab_EventsHub::TEXT_DOMAIN) . '</p>' . $after_widget;
     }
 }