function widget($args, $instance)
 {
     global $wp_al2fb;
     $user_ID = isset($instance['al2fb_userid']) ? $instance['al2fb_userid'] : false;
     if (!$user_ID && !is_single() && !is_page()) {
         return;
     }
     // Get current post
     if (!empty($GLOBALS['post'])) {
         $post = $GLOBALS['post'];
     }
     if (empty($post->ID) && !empty($post['post_id'])) {
         $post = get_post($post['post_id']);
     }
     if (empty($post) || empty($post->ID)) {
         return;
     }
     // Excluded post types
     $ex_custom_types = explode(',', get_option(c_al2fb_option_exclude_type));
     if (in_array($post->post_type, $ex_custom_types)) {
         return;
     }
     // Get user
     if (!$user_ID) {
         $user_ID = $wp_al2fb->Get_user_ID($post);
     }
     // Check if widget should be displayed
     if (get_user_meta($user_ID, c_al2fb_meta_like_nohome, true) && is_home() || get_user_meta($user_ID, c_al2fb_meta_like_noposts, true) && is_single() || get_user_meta($user_ID, c_al2fb_meta_like_nopages, true) && is_page() || get_user_meta($user_ID, c_al2fb_meta_like_noarchives, true) && is_archive() || get_user_meta($user_ID, c_al2fb_meta_like_nocategories, true) && is_category() || get_post_meta($post->ID, c_al2fb_meta_nolike, true)) {
         return;
     }
     // Get settings
     $comments = isset($instance['al2fb_comments']) ? $instance['al2fb_comments'] : false;
     $comments_count = isset($instance['al2fb_comments_count']) ? $instance['al2fb_comments_count'] : false;
     $messages = isset($instance['al2fb_messages']) ? $instance['al2fb_messages'] : false;
     $messages_count = isset($instance['al2fb_messages_count']) ? $instance['al2fb_messages_count'] : false;
     $messages_comments = isset($instance['al2fb_messages_comments']) ? $instance['al2fb_messages_comments'] : false;
     $like_button = isset($instance['al2fb_like_button']) ? $instance['al2fb_like_button'] : false;
     $like_box = isset($instance['al2fb_like_box']) ? $instance['al2fb_like_box'] : false;
     $send_button = isset($instance['al2fb_send_button']) ? $instance['al2fb_send_button'] : false;
     $subscribe_button = isset($instance['al2fb_subscribe_button']) ? $instance['al2fb_subscribe_button'] : false;
     $comments_plugin = isset($instance['al2fb_comments_plugin']) ? $instance['al2fb_comments_plugin'] : false;
     $face_pile = isset($instance['al2fb_face_pile']) ? $instance['al2fb_face_pile'] : false;
     $profile = isset($instance['al2fb_profile']) ? $instance['al2fb_profile'] : false;
     $registration = isset($instance['al2fb_registration']) ? $instance['al2fb_registration'] : false;
     $login = isset($instance['al2fb_login']) ? $instance['al2fb_login'] : false;
     $activity = isset($instance['al2fb_activity']) ? $instance['al2fb_activity'] : false;
     // Logged in?
     $registration = $registration && !is_user_logged_in() && get_option('users_can_register');
     $login = $login && !is_user_logged_in();
     // More settings
     $charset = get_bloginfo('charset');
     $link_id = get_post_meta($post->ID, c_al2fb_meta_link_id, true);
     // Get link type
     $comments_nolink = get_user_meta($user_ID, c_al2fb_meta_fb_comments_nolink, true);
     if (empty($comments_nolink)) {
         $comments_nolink = 'author';
     } else {
         if ($comments_nolink == 'on') {
             $comments_nolink = 'none';
         }
     }
     // Get comments
     $fb_comments = false;
     if ($comments) {
         $fb_comments = WPAL2Int::Get_comments_or_likes($post, false);
     }
     // Get messages
     $fb_messages = false;
     if ($messages) {
         try {
             $fb_messages = WPAL2Int::Get_fb_feed_cached($user_ID);
         } catch (Exception $e) {
             if ($wp_al2fb->debug) {
                 print_r($e);
             }
         }
     }
     if ($fb_comments || $fb_messages || $like_button || $like_box || $send_button || $subscribe_button || $comments_plugin || $face_pile || $profile || $registration || $login || $activity) {
         // Get values
         extract($args);
         $title = apply_filters('widget_title', $instance['title']);
         // Build content
         echo $before_widget;
         if (empty($title)) {
             $title = 'Add Link to Facebook';
         }
         echo $before_title . $title . $after_title;
         // Comments
         if ($fb_comments) {
             echo '<div class="al2fb_widget_comments">';
             self::Render_fb_comments($fb_comments, $comments_nolink, $link_id, $comments_count);
             echo '</div>';
         }
         // Status messages
         if ($fb_messages) {
             echo '<div class="al2fb_widget_messages">';
             self::Render_fb_messages($fb_messages, $comments_nolink, $link_id, $messages_count, $messages_comments);
             echo '</div>';
         }
         // Facebook like button
         if ($like_button) {
             echo WPAL2Int::Get_like_button($post, false);
         }
         // Facebook like box
         if ($like_box) {
             echo WPAL2Int::Get_like_button($post, true);
         }
         // Facebook send button
         if ($send_button) {
             echo WPAL2Int::Get_send_button($post);
         }
         if ($subscribe_button) {
             echo WPAL2Int::Get_subscribe_button($post);
         }
         // Facebook comments plugins
         if ($comments_plugin) {
             echo WPAL2Int::Get_comments_plugin($post);
         }
         // Facebook Face pile
         if ($face_pile) {
             echo WPAL2Int::Get_face_pile($post);
         }
         // Facebook profile
         if ($profile) {
             echo WPAL2Int::Get_profile_link($post);
         }
         // Facebook registration
         if ($registration) {
             echo WPAL2Int::Get_registration($post);
         }
         // Facebook login
         if ($login) {
             echo WPAL2Int::Get_login($post);
         }
         // Facebook activity feed
         if ($activity) {
             echo WPAL2Int::Get_activity_feed($post);
         }
         echo $after_widget;
     }
 }
 function Shortcode_face_pile($atts)
 {
     extract(shortcode_atts(array('post_id' => null), $atts));
     if (empty($post_id)) {
         global $post;
     } else {
         $post = get_post($post_id);
     }
     if (isset($post)) {
         return WPAL2Int::Get_face_pile($post);
     } else {
         return '';
     }
 }
 function al2fb_face_pile($post_ID = null)
 {
     if (empty($post_ID)) {
         global $post;
     } else {
         $post = get_post($post_ID);
     }
     if (isset($post)) {
         echo WPAL2Int::Get_face_pile($post);
     }
 }