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>';
 }
 static function Get_comments_or_likes($post, $likes, $cached = true)
 {
     $user_ID = WPAL2Facebook::Get_user_ID($post);
     $link_id = get_post_meta($post->ID, c_al2fb_meta_link_id, true);
     if ($link_id) {
         try {
             if ($likes) {
                 $result = WPAL2Int::Get_fb_likes_cached($user_ID, $link_id, $cached);
             } else {
                 $result = WPAL2Int::Get_fb_comments_cached($user_ID, $link_id, $cached);
             }
             // Remove previous errors
             $error = get_post_meta($post->ID, c_al2fb_meta_error, true);
             if (strpos($error, 'Import comment: ') !== false) {
                 delete_post_meta($post->ID, c_al2fb_meta_error, $error);
                 delete_post_meta($post->ID, c_al2fb_meta_error_time);
             }
             return $result;
         } catch (Exception $e) {
             update_post_meta($post->ID, c_al2fb_meta_error, 'Import comment: ' . $e->getMessage());
             update_post_meta($post->ID, c_al2fb_meta_error_time, date('c'));
             return null;
         }
     }
     return null;
 }