function Get_avatar($avatar, $id_or_email, $size, $default)
 {
     $fb_picture_url = null;
     if (is_object($id_or_email)) {
         $comment = $id_or_email;
         if ($comment->comment_agent == 'AL2FB' && ($comment->comment_type == '' || $comment->comment_type == 'comment')) {
             // Get picture url
             $id = explode('id/', str_replace('id=', 'id/', $comment->comment_author_url));
             if (count($id) == 2) {
                 $fb_picture_url = WPAL2Int::Get_fb_picture_url_cached($id[1], 'normal');
             }
         }
     } else {
         if (stripos($id_or_email, '@facebook.com') !== false) {
             $id_or_email = strtolower($id_or_email);
             // Get picture url
             $id = explode('@facebook.com', $id_or_email);
             if (count($id) == 2) {
                 $fb_picture_url = WPAL2Int::Get_fb_picture_url_cached($id[0], 'normal');
             }
         }
     }
     // Build avatar image
     if ($fb_picture_url) {
         $avatar = '<img alt="' . esc_attr($comment->comment_author) . '"';
         $avatar .= ' src="' . $fb_picture_url . '"';
         $avatar .= ' class="avatar avatar-' . $size . ' photo al2fb"';
         $avatar .= ' height="' . $size . '"';
         $avatar .= ' width="' . $size . '"';
         $avatar .= ' />';
     }
     return $avatar;
 }
 function Render_fb_messages($fb_messages, $comments_nolink, $link_id, $max_count, $messages_comments)
 {
     $charset = get_bloginfo('charset');
     // Get time zone offset
     $tz_off = get_option('gmt_offset');
     if (empty($tz_off)) {
         $tz_off = 0;
     }
     $tz_off = apply_filters('al2fb_gmt_offset', $tz_off);
     $tz_off = $tz_off * 3600;
     $count = 0;
     echo '<ul>';
     if ($fb_messages->data) {
         foreach ($fb_messages->data as $fb_message) {
             if (isset($fb_message->message)) {
                 if ($max_count && ++$count > $max_count) {
                     break;
                 }
                 echo '<li>';
                 // Picture
                 if ($comments_nolink == 'author') {
                     echo '<img class="al2fb_widget_picture" alt="' . htmlspecialchars($fb_message->from->name, ENT_QUOTES, $charset) . '" src="' . WPAL2Int::Get_fb_picture_url_cached($fb_message->from->id, 'small') . '" />';
                 }
                 // Author
                 if ($comments_nolink == 'link') {
                     echo '<a href="' . WPAL2Int::Get_fb_permalink($fb_message->id) . '" class="al2fb_widget_name">' . htmlspecialchars($fb_message->from->name, ENT_QUOTES, $charset) . '</a>';
                 } else {
                     if ($comments_nolink == 'author') {
                         echo '<a href="' . WPAL2Int::Get_fb_profilelink($fb_message->from->id) . '" class="al2fb_widget_name">' . htmlspecialchars($fb_message->from->name, ENT_QUOTES, $charset) . '</a>';
                     } else {
                         echo '<span class="al2fb_widget_name">' . htmlspecialchars($fb_message->from->name, ENT_QUOTES, $charset) . '</span>';
                     }
                 }
                 // Message
                 echo ' ';
                 echo '<span class="al2fb_widget_message">' . htmlspecialchars($fb_message->message, ENT_QUOTES, $charset) . '</span>';
                 // Time
                 echo ' ';
                 $fb_time = strtotime($fb_message->created_time) + $tz_off;
                 echo '<span class="al2fb_widget_date">' . date(get_option('date_format') . ' ' . get_option('time_format'), $fb_time) . '</span>';
                 // Comments on message
                 if ($messages_comments) {
                     try {
                         $fb_message_comments = WPAL2Int::Get_fb_comments_cached($user_ID, $fb_message->id);
                         if ($fb_message_comments) {
                             self::Render_fb_comments($fb_message_comments, $comments_nolink, $fb_message->id, $messages_comments);
                         }
                     } catch (Exception $e) {
                         $error = $e->getMessage();
                     }
                 }
                 echo '</li>';
             }
         }
     }
     echo '</ul>';
 }