function form($instance)
 {
     $title = esc_attr($instance['title']);
     $feed_id = @$instance['feed_id'];
     $posts_limit = @$instance['posts_limit'];
     // Set defaults
     // ...
     $opts = new Wdgpo_Options();
     $gplus_feeds = $opts->get_option('gplus_import_ids');
     $gplus_feeds = $gplus_feeds ? array_filter($gplus_feeds) : array();
     $gplus_feeds[] = $opts->get_option('gplus_page_id');
     $gplus_feeds[] = $opts->get_option('gplus_profile_id');
     $posts_limit = $posts_limit ? $posts_limit : 10;
     $html = '<p>';
     $html .= '<label for="' . $this->get_field_id('title') . '">' . __('Title:', 'wdgpo') . '</label>';
     $html .= '<input type="text" name="' . $this->get_field_name('title') . '" id="' . $this->get_field_id('title') . '" class="widefat" value="' . $title . '"/>';
     $html .= '</p>';
     $html .= '<p>';
     $html .= '<label for="' . $this->get_field_id('feed_id') . '">' . __('Show items for this feed:', 'wdgpo') . '</label> ';
     $html .= '<select name="' . $this->get_field_name('feed_id') . '" id="' . $this->get_field_id('feed_id') . '">';
     foreach ($gplus_feeds as $key => $feed) {
         $selected = $feed == $feed_id ? 'selected="selected"' : '';
         $html .= "<option value='{$feed}' {$selected}>{$feed}&nbsp;</option>";
     }
     $html .= '</select>';
     $html .= '</p>';
     $html .= '<p>';
     $html .= '<label for="' . $this->get_field_id('posts_limit') . '">' . __('Show this many imported posts:', 'wdgpo') . '</label> ';
     $html .= '<select name="' . $this->get_field_name('posts_limit') . '" id="' . $this->get_field_id('posts_limit') . '">';
     for ($i = 1; $i < 21; $i++) {
         $selected = $i == $posts_limit ? 'selected="selected"' : '';
         $html .= "<option value='{$i}' {$selected}>{$i}</option>";
     }
     $html .= '</select>';
     $html .= '</p>';
     echo $html;
 }
 function _show_posts($limit)
 {
     $feed_id = Wdgpo_Options::get_option('gplus_page_id');
     $query = new WP_Query(array('post_type' => array('post', 'wdgpo_imported_post'), 'meta_key' => 'wdgpo_gplus_feed_id', 'meta_value' => $feed_id, 'posts_per_page' => (int) $limit));
     echo "<ul class='wdgpo_gplus_posts'>";
     foreach ($query->posts as $post) {
         $url = 'wdgpo_imported_post' == $post->post_type ? get_post_meta($post->ID, 'wdgpo_gplus_item_id', true) : get_permalink($post->ID);
         echo "<li>";
         echo '<a class="wdgpo_gplus_post_title" href="' . esc_url($url) . '">' . esc_html($post->post_title) . '</a>';
         echo "</li>";
     }
     echo "</ul>";
 }
 function process_gplus_page_code($args)
 {
     $args = shortcode_atts(array('appearance' => false, 'float' => false), $args);
     $appearance = $args['appearance'] ? $args['appearance'] : 'medium_icon';
     $float = in_array($args['float'], array('left', 'right')) ? "style='float:{$args['float']};'" : '';
     $data = new Wdgpo_Options();
     $page_id = $data->get_option('gplus_page_id');
     if (!$page_id) {
         return '';
     }
     $tpl = '<a href="https://plus.google.com/%s/?prsrc=3" style="text-decoration: none;"><img src="https://ssl.gstatic.com/images/icons/gplus-%d.png" width="%d" height="%d" style="border: 0;"></img></a>';
     $tpl = "<div class='wdgpo wdgpo_gplus_page wdgpo_gplus_page_{$appearance}' {$float}>{$tpl}</div>";
     $ret = '';
     switch ($appearance) {
         case "small_icon":
             $ret = sprintf($tpl, $page_id, 16, 16, 16);
             break;
         case "medium_icon":
             $ret = sprintf($tpl, $page_id, 32, 32, 32);
             break;
         case "large_icon":
             $ret = sprintf($tpl, $page_id, 64, 64, 64);
             break;
     }
     return $ret;
 }