/**
  * Display Widget
  *
  * @since 0.1.0
  */
 function widget($args, $instance)
 {
     extract($args);
     // Check for missing feed id.
     if (empty($instance['feed_id'])) {
         echo __('No Twitter feed ID given.', 'tweeple');
         return;
     }
     // Get new Twitter feed, or cached result
     $feed = tweeple_get_feed($instance['feed_id']);
     // Get Tweets
     $tweets = tweeple_get_tweets($feed);
     // @todo Could incorporate feed merging in the future here. tweeple_get_tweets( array( $feed1, $feed2, $feed3 ) )
     // Display widget
     echo $before_widget;
     $title = apply_filters('widget_title', $instance['title']);
     if (!empty($title)) {
         echo $before_title . $title . $after_title;
     }
     echo '<div class="tweeple tweeple-feed tweeple-feed-widget">';
     echo '<div class="tweeple-inner">';
     if (!tweeple_error($feed)) {
         // We are a go! Display widget.
         do_action('tweeple_display_widget', $tweets, $feed['options'], $feed['info']);
     } else {
         // Display error
         printf('<p>%s</p>', tweeple_error($feed));
     }
     echo '</div><!-- .tweeple-inner (end) -->';
     echo '</div><!-- .tweeple-feed-widget (end) -->';
     echo $after_widget;
 }
 /**
  * Display Tweet element of the Layout Builder.
  *
  * @since 0.4.0
  */
 public function tweet_element($id, $options)
 {
     // Get Twitter Feed
     $feed = tweeple_get_feed($options['feed_id']);
     $tweets = tweeple_get_tweets($feed);
     if (!tweeple_error($feed)) {
         do_action('tweeple_display_tweet_element', $tweets, $feed['options'], $options, $id);
     } else {
         printf('<p>%s</p>', tweeple_error($feed));
     }
 }
 /**
  * Setup feed shortcode
  *
  * @since 0.1.0
  */
 public function feed_shortcode($atts)
 {
     // Check for missing feed id.
     if (empty($atts['id'])) {
         return __('No Twitter feed ID given.', 'tweeple');
     }
     $atts['id'] = str_replace(' ', '', $atts['id']);
     $ids = explode(',', $atts['id']);
     $feeds = array();
     foreach ($ids as $id) {
         $feeds[] = tweeple_get_feed($id);
     }
     // Get Tweets
     $tweets = tweeple_get_tweets($feeds);
     // Start output
     $output = '<div class="tweeple tweeple-feed tweeple-feed-shortcode">';
     $output .= '<div class="tweeple-inner">';
     // Errror checking
     $error = '';
     foreach ($feeds as $feed) {
         if (tweeple_error($feed)) {
             $error = sprintf('<p>%s</p>', tweeple_error($feed));
         }
     }
     if (!$error) {
         // We are a go! Display shortcode.
         ob_start();
         do_action('tweeple_display_shortcode', $tweets, $feed['options'], $feed['info']);
         $output .= ob_get_clean();
     }
     $output .= '</div><!-- .tweeple-inner (end) -->';
     $output .= '</div><!-- .tweeple-feed-shortcode (end) -->';
     return apply_filters('tweeple_feed_shortcode', $output, $atts['id'], $feed);
 }