public function widget($args, $instance) { extract($args); $title = apply_filters('widget_title', $instance['title']); $count = $instance['count']; echo $before_widget; if ($title) { echo $before_title . $title . $after_title; } $instagram = new Simple_Instagram(); $feed = $instagram->get_popular_media($count); if (!$feed || 0 == count($feed)) { echo ''; return; } $return = '<div class="si_feed_widget">'; $return .= '<ul class="si_feed_list">'; foreach ($feed as $image) { if ($image->images != NULL) { $url = $image->images->standard_resolution->url; $url = str_replace('http://', '//', $url); $return .= '<li class="si_item">'; $return .= '<a href="' . $image->link . '" target="_blank">'; $image_caption = is_object($image->caption) ? $image->caption->text : ''; $return .= '<img alt="' . $image_caption . '" src="' . $url . '">'; $return .= '</a>'; $return .= '</li>'; } } $return .= '</ul>'; $return .= '</div>'; echo $return; echo $after_widget; }
/** * SI Popular - Enables and returns formatted HTML for * the [si_popular] shortcode * * @param array $atts - The Array of provided attributes * @return str $return - The formatted HTML */ public function si_popular($atts) { $defaults = shortcode_atts(array('limit' => 16, 'size' => 'medium', 'wrapper' => 'div', 'link' => 'true', 'width' => 'auto'), $atts); foreach ($defaults as $key => $value) { ${$key} = $value; } $instagram = new Simple_Instagram(); $feed = $instagram->get_popular_media($limit); if (!$feed || 0 == count($feed)) { return ''; } $feed = $this->check_count($feed, $limit); $return = $this->get_image_markup($feed, $width, $size, $wrapper, $link); return $return; }