/**
  * SI Profile - Enables and returns formatted HTML for
  * the [si_profile] shortcode
  *
  * @param array $atts - The Array of provided attributes
  * @return str $return - The formatted HTML
  */
 function si_profile($atts)
 {
     $defaults = shortcode_atts(array('username' => 'true', 'profile_picture' => 'true', 'bio' => 'true', 'website' => 'true', 'full_name' => 'true', 'themed' => 'false'), $atts);
     foreach ($defaults as $key => $value) {
         ${$key} = $value;
     }
     $instagram = new Simple_Instagram();
     $user = $instagram->get_user();
     if (!$user) {
         return '';
     }
     $class = $themed == 'true' ? 'si_profile themed' : 'si_profile';
     $return = '<div class="' . $class . '">';
     if ('true' == $profile_picture && $user->profile_picture != '') {
         $return .= '<div class="si_profile_picture">';
         $return .= '<img src="' . $user->profile_picture . '">';
         $return .= '</div>';
     }
     if ('true' == $username && $user->username != '') {
         $return .= '<div class="si_username">' . $user->username . '</div>';
     }
     if ('true' == $full_name && $user->full_name != '') {
         $return .= '<div class="si_full_name">' . $user->full_name . '</div>';
     }
     if ('true' == $bio && $user->bio != '') {
         $return .= '<div class="si_bio">' . $user->bio . '</div>';
     }
     if ('true' == $website && $user->website != '') {
         $return .= '<div class="si_website"><a href="' . $user->website . '">View Website</a></div>';
     }
     $return .= '</div>';
     return $return;
 }
 public function widget($args, $instance)
 {
     extract($args);
     $title = apply_filters('widget_title', $instance['title']);
     $count = $instance['count'];
     $user = isset($instance['user']) ? $instance['user'] : '';
     $user = $user == '' ? 'self' : $user;
     echo $before_widget;
     if ($title) {
         echo $before_title . $title . $after_title;
     }
     $instagram = new Simple_Instagram();
     $feed = $instagram->get_user_media($user, $count);
     $return = '';
     if ($feed && count($feed) > 0) {
         $return = '<div class="si_feed_widget">';
         $return .= '<ul class="si_feed_list">';
         foreach ($feed as $image) {
             $url = $image->images->standard_resolution->url;
             // Fix https
             $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;
 }
 function widget($args, $instance)
 {
     extract($args);
     $title = apply_filters('widget_title', $instance['title']);
     $profile_picture = $instance['profile_picture'];
     $username = $instance['username'];
     $full_name = $instance['full_name'];
     $bio = $instance['bio'];
     $website = $instance['website'];
     echo $before_widget;
     if ($title) {
         echo $before_title . $title . $after_title;
     }
     $instagram = new Simple_Instagram();
     $user = $instagram->get_user();
     $return = '<div class="si_profile_widget">';
     if ('true' == $profile_picture && $user->profile_picture != '') {
         $url = str_replace('http://', '//', $user->profile_picture);
         $return .= '<div class="si_profile_picture">';
         $return .= '<img src="' . $url . '">';
         $return .= '</div>';
     }
     $return .= $username == 'true' && $user->username != '' ? '<div class="si_username">' . $user->username . '</div>' : null;
     $return .= $full_name == 'true' && $user->full_name != '' ? '<div class="si_full_name">' . $user->full_name . '</div>' : null;
     $return .= $bio == 'true' && $user->bio != '' ? '<div class="si_bio">' . $user->bio . '</div>' : null;
     $return .= $website == 'true' && $user->website != '' ? '<div class="si_website"><a href="' . $user->website . '">View Website</a></div>' : null;
     $return .= '</div>';
     echo $return;
     echo $after_widget;
 }
 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;
 }
예제 #5
0
    /**
     * Search Users - Handles AJAX call to search for a User
     * by their username
     *
     * @return str - The HTML list of users
     */
    public function search_users()
    {
        if (!isset($_POST['user']) || $_POST['user'] == '') {
            echo '';
            exit;
        }
        $username = sanitize_text_field($_POST['user']);
        $instagram = new Simple_Instagram();
        $users = $instagram->get_user_id($username);
        if (!$users || 0 == count($users)) {
            echo '';
            exit;
        }
        foreach ($users as $result) {
            ?>
            <div class="si_sr">
                <div class="si_sr_user_image">
                    <img src="<?php 
            echo esc_attr($result->profile_picture);
            ?>
">
                </div>
                <div class="si_sr_user_info">
                    <div class="si_sr_user_name">
                        <strong>username: </strong><?php 
            echo $result->username;
            ?>
                    </div>
                    <div class="si_sr_user_id">
                        <strong>user ID: </strong><?php 
            echo $result->id;
            ?>
                    </div>
                </div>
            </div>
        <?php 
        }
        exit;
    }