main_file = str_replace('-class', '', __FILE__); // Get plugin url $this->plugin_url = WP_PLUGIN_URL . '/' . basename(dirname($this->main_file)); if (strpos($this->plugin_url, 'http') === 0 && is_ssl()) $this->plugin_url = str_replace('http://', 'https://', $this->plugin_url); // Log $this->debug = get_option(c_al2fb_option_debug); // Get site & blog id if (is_multisite()) { $current_site = get_current_site(); $this->site_id = $current_site->id; global $blog_id; $this->blog_id = $blog_id; } // register activation actions //register_activation_hook($this->main_file, array(&$this, 'Activate')); register_deactivation_hook($this->main_file, array(&$this, 'Deactivate')); // Register actions add_action('init', array(&$this, 'Init'), 0); if (is_admin()) { add_action('admin_menu', array(&$this, 'Admin_menu')); add_filter('plugin_action_links', array(&$this, 'Plugin_action_links'), 10, 2); add_action('admin_notices', array(&$this, 'Admin_notices')); add_action('post_submitbox_misc_actions', array(&$this, 'Post_submitbox_misc_actions')); add_filter('manage_posts_columns', array(&$this, 'Manage_posts_columns')); add_action('manage_posts_custom_column', array(&$this, 'Manage_posts_custom_column'), 10, 2); add_filter('manage_pages_columns', array(&$this, 'Manage_posts_columns')); add_action('manage_pages_custom_column', array(&$this, 'Manage_posts_custom_column'), 10, 2); add_action('add_meta_boxes', array(&$this, 'Add_meta_boxes')); add_action('save_post', array(&$this, 'Save_post')); add_action('personal_options', array(&$this, 'Personal_options')); add_action('personal_options_update', array(&$this, 'Personal_options_update')); add_action('edit_user_profile_update', array(&$this, 'Personal_options_update')); } add_action('transition_post_status', array(&$this, 'Transition_post_status'), 10, 3); add_action('xmlrpc_publish_post', array(&$this, 'Remote_publish')); add_action('app_publish_post', array(&$this, 'Remote_publish')); add_action('future_to_publish', array(&$this, 'Future_to_publish')); add_action('al2fb_publish', array(&$this, 'Remote_publish')); if (get_option(c_al2fb_option_use_pp)) add_action('publish_post', array(&$this, 'Remote_publish')); add_action('comment_post', array(&$this, 'Comment_post')); add_action('comment_unapproved_to_approved', array(&$this, 'Comment_approved')); add_action('comment_approved_to_unapproved', array(&$this, 'Comment_unapproved')); // Content add_action('wp_head', array(&$this, 'WP_head')); add_filter('the_content', array(&$this, 'The_content'), 999); add_filter('comments_array', array(&$this, 'Comments_array'), 10, 2); add_filter('get_comments_number', array(&$this, 'Get_comments_number'), 10, 2); add_filter('comment_class', array(&$this, 'Comment_class')); add_filter('get_avatar', array(&$this, 'Get_avatar'), 10, 5); // Shortcodes add_shortcode('al2fb_likers', array(&$this, 'Shortcode_likers')); add_shortcode('al2fb_like_count', array(&$this, 'Shortcode_like_count')); add_shortcode('al2fb_like_button', array(&$this, 'Shortcode_like_button')); add_shortcode('al2fb_like_box', array(&$this, 'Shortcode_like_box')); add_shortcode('al2fb_send_button', array(&$this, 'Shortcode_send_button')); add_shortcode('al2fb_comments_plugin', array(&$this, 'Shortcode_comments_plugin')); add_shortcode('al2fb_face_pile', array(&$this, 'Shortcode_face_pile')); add_shortcode('al2fb_profile_link', array(&$this, 'Shortcode_profile_link')); add_shortcode('al2fb_registration', array(&$this, 'Shortcode_registration')); add_shortcode('al2fb_login', array(&$this, 'Shortcode_login')); add_shortcode('al2fb_activity_feed', array(&$this, 'Shortcode_activity_feed')); if (get_option(c_al2fb_option_shortcode_widget)) add_filter('widget_text', 'do_shortcode'); // Custom filters add_filter('al2fb_excerpt', array(&$this, 'Filter_excerpt'), 10, 2); add_filter('al2fb_content', array(&$this, 'Filter_content'), 10, 2); // Widget add_action('widgets_init', create_function('', 'return register_widget("AL2FB_Widget");')); if (!is_admin()) add_action('wp_print_styles', array(&$this, 'WP_print_styles')); } // Handle plugin activation function Activate() { global $wpdb; $version = get_option(c_al2fb_option_version); if (empty($version)) update_option(c_al2fb_option_siteurl, true); if ($version <= 1) { delete_option(c_al2fb_meta_client_id); delete_option(c_al2fb_meta_app_secret); delete_option(c_al2fb_meta_access_token); delete_option(c_al2fb_meta_picture_type); delete_option(c_al2fb_meta_picture); delete_option(c_al2fb_meta_page); delete_option(c_al2fb_meta_clean); delete_option(c_al2fb_meta_donated); } if ($version <= 2) { $rows = $wpdb->get_results("SELECT user_id, meta_value FROM " . $wpdb->usermeta . " WHERE meta_key='al2fb_integrate'"); foreach ($rows as $row) { update_user_meta($row->user_id, c_al2fb_meta_fb_comments, $row->meta_value); update_user_meta($row->user_id, c_al2fb_meta_fb_likes, $row->meta_value); delete_user_meta($row->user_id, 'al2fb_integrate'); } } if ($version <= 3) { global $wpdb; $rows = $wpdb->get_results("SELECT ID FROM " . $wpdb->users); foreach ($rows as $row) update_user_meta($row->ID, c_al2fb_meta_like_faces, true); } if ($version <= 4) { $rows = $wpdb->get_results("SELECT user_id, meta_value FROM " . $wpdb->usermeta . " WHERE meta_key='" . c_al2fb_meta_trailer . "'"); foreach ($rows as $row) { $value = get_user_meta($row->user_id, c_al2fb_meta_trailer, true); update_user_meta($row->user_id, c_al2fb_meta_trailer, ' ' . $value); } } if ($version <= 5) { if (!get_option(c_al2fb_option_css)) update_option(c_al2fb_option_css, '.al2fb_widget_comments { } .al2fb_widget_comments li { } .al2fb_widget_picture { width: 32px; height: 32px; } .al2fb_widget_name { } .al2fb_widget_comment { } .al2fb_widget_date { font-size: smaller; } '); } if ($version < 6) update_option(c_al2fb_option_version, 6); } // Handle plugin deactivation function Deactivate() { global $user_ID; get_currentuserinfo(); // Cleanup if requested if (get_user_meta($user_ID, c_al2fb_meta_clean, true)) { delete_user_meta($user_ID, c_al2fb_meta_client_id); delete_user_meta($user_ID, c_al2fb_meta_app_secret); delete_user_meta($user_ID, c_al2fb_meta_access_token); delete_user_meta($user_ID, c_al2fb_meta_picture_type); delete_user_meta($user_ID, c_al2fb_meta_picture); delete_user_meta($user_ID, c_al2fb_meta_picture_default); delete_user_meta($user_ID, c_al2fb_meta_page); delete_user_meta($user_ID, c_al2fb_meta_page_owner); delete_user_meta($user_ID, c_al2fb_meta_use_groups); delete_user_meta($user_ID, c_al2fb_meta_group); delete_user_meta($user_ID, c_al2fb_meta_caption); delete_user_meta($user_ID, c_al2fb_meta_msg); delete_user_meta($user_ID, c_al2fb_meta_shortlink); delete_user_meta($user_ID, c_al2fb_meta_add_new_page); delete_user_meta($user_ID, c_al2fb_meta_trailer); delete_user_meta($user_ID, c_al2fb_meta_hyperlink); delete_user_meta($user_ID, c_al2fb_meta_share_link); delete_user_meta($user_ID, c_al2fb_meta_fb_comments); delete_user_meta($user_ID, c_al2fb_meta_fb_comments_postback); delete_user_meta($user_ID, c_al2fb_meta_fb_comments_copy); delete_user_meta($user_ID, c_al2fb_meta_fb_comments_nolink); delete_user_meta($user_ID, c_al2fb_meta_fb_likes); delete_user_meta($user_ID, c_al2fb_meta_post_likers); delete_user_meta($user_ID, c_al2fb_meta_post_like_button); delete_user_meta($user_ID, c_al2fb_meta_like_nohome); delete_user_meta($user_ID, c_al2fb_meta_like_noposts); delete_user_meta($user_ID, c_al2fb_meta_like_nopages); delete_user_meta($user_ID, c_al2fb_meta_like_noarchives); delete_user_meta($user_ID, c_al2fb_meta_like_nocategories); delete_user_meta($user_ID, c_al2fb_meta_like_layout); delete_user_meta($user_ID, c_al2fb_meta_like_faces); delete_user_meta($user_ID, c_al2fb_meta_like_width); delete_user_meta($user_ID, c_al2fb_meta_like_action); delete_user_meta($user_ID, c_al2fb_meta_like_font); delete_user_meta($user_ID, c_al2fb_meta_like_colorscheme); delete_user_meta($user_ID, c_al2fb_meta_like_link); delete_user_meta($user_ID, c_al2fb_meta_like_top); delete_user_meta($user_ID, c_al2fb_meta_like_iframe); delete_user_meta($user_ID, c_al2fb_meta_post_send_button); delete_user_meta($user_ID, c_al2fb_meta_post_combine_buttons); delete_user_meta($user_ID, c_al2fb_meta_like_box_width); delete_user_meta($user_ID, c_al2fb_meta_like_box_border); delete_user_meta($user_ID, c_al2fb_meta_like_box_noheader); delete_user_meta($user_ID, c_al2fb_meta_like_box_nostream); delete_user_meta($user_ID, c_al2fb_meta_comments_posts); delete_user_meta($user_ID, c_al2fb_meta_comments_width); delete_user_meta($user_ID, c_al2fb_meta_pile_size); delete_user_meta($user_ID, c_al2fb_meta_pile_width); delete_user_meta($user_ID, c_al2fb_meta_pile_rows); delete_user_meta($user_ID, c_al2fb_meta_reg_width); delete_user_meta($user_ID, c_al2fb_meta_login_width); delete_user_meta($user_ID, c_al2fb_meta_login_regurl); delete_user_meta($user_ID, c_al2fb_meta_login_redir); delete_user_meta($user_ID, c_al2fb_meta_login_html); delete_user_meta($user_ID, c_al2fb_meta_act_width); delete_user_meta($user_ID, c_al2fb_meta_act_height); delete_user_meta($user_ID, c_al2fb_meta_act_header); delete_user_meta($user_ID, c_al2fb_meta_act_recommend); delete_user_meta($user_ID, c_al2fb_meta_open_graph); delete_user_meta($user_ID, c_al2fb_meta_open_graph_type); delete_user_meta($user_ID, c_al2fb_meta_open_graph_admins); delete_user_meta($user_ID, c_al2fb_meta_exclude_default); delete_user_meta($user_ID, c_al2fb_meta_not_post_list); delete_user_meta($user_ID, c_al2fb_meta_fb_encoding); delete_user_meta($user_ID, c_al2fb_meta_fb_locale); delete_user_meta($user_ID, c_al2fb_meta_clean); delete_user_meta($user_ID, c_al2fb_meta_donated); delete_user_meta($user_ID, c_al2fb_meta_rated); delete_user_meta($user_ID, c_al2fb_meta_nospsn); delete_user_meta($user_ID, c_al2fb_meta_service); } } // Initialization function Init() { // I18n load_plugin_textdomain(c_al2fb_text_domain, false, dirname(plugin_basename(__FILE__)) . '/language/'); // Image request if (isset($_GET['al2fb_image'])) { $img = dirname(__FILE__) . '/wp-blue-s.png'; header('Content-type: image/png'); readfile($img); exit(); } // Facebook registration if (isset($_REQUEST['al2fb_reg'])) { self::Facebook_registration(); exit(); } // Facebook login if (isset($_REQUEST['al2fb_login'])) { self::Facebook_login(); exit(); } // Set default capability if (!get_option(c_al2fb_option_min_cap)) update_option(c_al2fb_option_min_cap, 'edit_posts'); // Disable shorcodes if Mingle forum is used $mingle = 'mingle-forum/wpf-main.php'; $plugins = get_option('active_plugins'); if (in_array($mingle, $plugins)) update_option(c_al2fb_option_noshortcode, true); // Enqueue style sheet if (is_admin()) { $css_name = $this->Change_extension(basename($this->main_file), '-admin.css'); $css_url = $this->plugin_url . '/' . $css_name; wp_register_style('al2fb_style_admin', $css_url); wp_enqueue_style('al2fb_style_admin'); } else { $upload_dir = wp_upload_dir(); $css_name = $this->Change_extension(basename($this->main_file), '.css'); if (file_exists($upload_dir['basedir'] . '/' . $css_name)) $css_url = $upload_dir['baseurl'] . '/' . $css_name; else if (file_exists(TEMPLATEPATH . '/' . $css_name)) $css_url = get_bloginfo('template_directory') . '/' . $css_name; else $css_url = $this->plugin_url . '/' . $css_name; wp_register_style('al2fb_style', $css_url); wp_enqueue_style('al2fb_style'); } // Check user capability if (current_user_can(get_option(c_al2fb_option_min_cap))) { if (is_admin()) { // Initiate Facebook authorization if (isset($_REQUEST['al2fb_action']) && $_REQUEST['al2fb_action'] == 'init') { // Debug info update_option(c_al2fb_log_redir_init, date('c')); // Get current user global $user_ID; get_currentuserinfo(); // Redirect $auth_url = self::Authorize_url($user_ID); try { // Check if (ini_get('safe_mode') || ini_get('open_basedir')) update_option(c_al2fb_log_redir_check, 'No'); else { $response = self::Request($auth_url, '', 'GET'); update_option(c_al2fb_log_redir_check, date('c')); } // Redirect wp_redirect($auth_url); exit(); } catch (Exception $e) { // Register error update_option(c_al2fb_log_redir_check, $e->getMessage()); update_option(c_al2fb_last_error, $e->getMessage()); update_option(c_al2fb_last_error_time, date('c')); // Redirect $error_url = admin_url('tools.php?page=' . plugin_basename($this->main_file)); $error_url .= '&al2fb_action=error'; $error_url .= '&error=' . urlencode($e->getMessage()); wp_redirect($error_url); exit(); } } } // Handle Facebook authorization self::Authorize(); } } // Display admin messages function Admin_notices() { // Check user capability if (current_user_can(get_option(c_al2fb_option_min_cap))) { // Get current user global $user_ID; get_currentuserinfo(); // Check actions if (isset($_REQUEST['al2fb_action'])) { // Configuration if ($_REQUEST['al2fb_action'] == 'config') self::Action_config(); // Authorization else if ($_REQUEST['al2fb_action'] == 'authorize') self::Action_authorize(); // Mail debug info else if ($_REQUEST['al2fb_action'] == 'mail') self::Action_mail(); else if ($_REQUEST['al2fb_action'] == 'service') self::Action_service(); } self::Check_config(); } } // Save settings function Action_config() { // Security check check_admin_referer(c_al2fb_nonce_form); // Get current user global $user_ID; get_currentuserinfo(); // Default values if (empty($_POST[c_al2fb_meta_picture_type])) $_POST[c_al2fb_meta_picture_type] = 'post'; if (empty($_POST[c_al2fb_meta_page])) $_POST[c_al2fb_meta_page] = null; if (empty($_POST[c_al2fb_meta_page_owner])) $_POST[c_al2fb_meta_page_owner] = null; if (empty($_POST[c_al2fb_meta_use_groups])) $_POST[c_al2fb_meta_use_groups] = null; if (empty($_POST[c_al2fb_meta_group])) $_POST[c_al2fb_meta_group] = null; if (empty($_POST[c_al2fb_meta_caption])) $_POST[c_al2fb_meta_caption] = null; if (empty($_POST[c_al2fb_meta_msg])) $_POST[c_al2fb_meta_msg] = null; if (empty($_POST[c_al2fb_meta_shortlink])) $_POST[c_al2fb_meta_shortlink] = null; if (empty($_POST[c_al2fb_meta_add_new_page])) $_POST[c_al2fb_meta_add_new_page] = null; if (empty($_POST[c_al2fb_meta_trailer])) $_POST[c_al2fb_meta_trailer] = null; if (empty($_POST[c_al2fb_meta_hyperlink])) $_POST[c_al2fb_meta_hyperlink] = null; if (empty($_POST[c_al2fb_meta_share_link])) $_POST[c_al2fb_meta_share_link] = null; if (empty($_POST[c_al2fb_meta_fb_comments])) $_POST[c_al2fb_meta_fb_comments] = null; if (empty($_POST[c_al2fb_meta_fb_comments_postback])) $_POST[c_al2fb_meta_fb_comments_postback] = null; if (empty($_POST[c_al2fb_meta_fb_comments_copy])) $_POST[c_al2fb_meta_fb_comments_copy] = null; if (empty($_POST[c_al2fb_meta_fb_comments_nolink])) $_POST[c_al2fb_meta_fb_comments_nolink] = null; if (empty($_POST[c_al2fb_meta_fb_likes])) $_POST[c_al2fb_meta_fb_likes] = null; if (empty($_POST[c_al2fb_meta_post_likers])) $_POST[c_al2fb_meta_post_likers] = null; if (empty($_POST[c_al2fb_meta_post_like_button])) $_POST[c_al2fb_meta_post_like_button] = null; if (empty($_POST[c_al2fb_meta_like_nohome])) $_POST[c_al2fb_meta_like_nohome] = null; if (empty($_POST[c_al2fb_meta_like_noposts])) $_POST[c_al2fb_meta_like_noposts] = null; if (empty($_POST[c_al2fb_meta_like_nopages])) $_POST[c_al2fb_meta_like_nopages] = null; if (empty($_POST[c_al2fb_meta_like_noarchives])) $_POST[c_al2fb_meta_like_noarchives] = null; if (empty($_POST[c_al2fb_meta_like_nocategories])) $_POST[c_al2fb_meta_like_nocategories] = null; if (empty($_POST[c_al2fb_meta_like_layout])) $_POST[c_al2fb_meta_like_layout] = null; if (empty($_POST[c_al2fb_meta_like_faces])) $_POST[c_al2fb_meta_like_faces] = null; if (empty($_POST[c_al2fb_meta_like_action])) $_POST[c_al2fb_meta_like_action] = null; if (empty($_POST[c_al2fb_meta_like_font])) $_POST[c_al2fb_meta_like_font] = null; if (empty($_POST[c_al2fb_meta_like_colorscheme])) $_POST[c_al2fb_meta_like_colorscheme] = null; if (empty($_POST[c_al2fb_meta_like_top])) $_POST[c_al2fb_meta_like_top] = null; if (empty($_POST[c_al2fb_meta_post_send_button])) $_POST[c_al2fb_meta_post_send_button] = null; if (empty($_POST[c_al2fb_meta_post_combine_buttons])) $_POST[c_al2fb_meta_post_combine_buttons] = null; if (empty($_POST[c_al2fb_meta_like_box_noheader])) $_POST[c_al2fb_meta_like_box_noheader] = null; if (empty($_POST[c_al2fb_meta_like_box_nostream])) $_POST[c_al2fb_meta_like_box_nostream] = null; if (empty($_POST[c_al2fb_meta_pile_size])) $_POST[c_al2fb_meta_pile_size] = null; if (empty($_POST[c_al2fb_meta_act_header])) $_POST[c_al2fb_meta_act_header] = null; if (empty($_POST[c_al2fb_meta_act_recommend])) $_POST[c_al2fb_meta_act_recommend] = null; if (empty($_POST[c_al2fb_meta_open_graph])) $_POST[c_al2fb_meta_open_graph] = null; if (empty($_POST[c_al2fb_meta_exclude_default])) $_POST[c_al2fb_meta_exclude_default] = null; if (empty($_POST[c_al2fb_meta_not_post_list])) $_POST[c_al2fb_meta_not_post_list] = null; if (empty($_POST[c_al2fb_meta_clean])) $_POST[c_al2fb_meta_clean] = null; if (empty($_POST[c_al2fb_meta_donated])) $_POST[c_al2fb_meta_donated] = null; if (empty($_POST[c_al2fb_meta_rated])) $_POST[c_al2fb_meta_rated] = null; if (empty($_POST[c_al2fb_meta_nospsn])) $_POST[c_al2fb_meta_nospsn] = null; $_POST[c_al2fb_meta_client_id] = trim($_POST[c_al2fb_meta_client_id]); $_POST[c_al2fb_meta_app_secret] = trim($_POST[c_al2fb_meta_app_secret]); $_POST[c_al2fb_meta_picture] = trim(stripslashes($_POST[c_al2fb_meta_picture])); $_POST[c_al2fb_meta_picture_default] = trim(stripslashes($_POST[c_al2fb_meta_picture_default])); $_POST[c_al2fb_meta_trailer] = rtrim(html_entity_decode(stripslashes($_POST[c_al2fb_meta_trailer]), ENT_QUOTES, get_bloginfo('charset'))); $_POST[c_al2fb_meta_like_width] = trim($_POST[c_al2fb_meta_like_width]); $_POST[c_al2fb_meta_like_link] = trim($_POST[c_al2fb_meta_like_link]); $_POST[c_al2fb_meta_like_box_width] = trim($_POST[c_al2fb_meta_like_box_width]); $_POST[c_al2fb_meta_like_box_border] = trim($_POST[c_al2fb_meta_like_box_border]); $_POST[c_al2fb_meta_comments_posts] = trim($_POST[c_al2fb_meta_comments_posts]); $_POST[c_al2fb_meta_comments_width] = trim($_POST[c_al2fb_meta_comments_width]); $_POST[c_al2fb_meta_pile_width] = trim($_POST[c_al2fb_meta_pile_width]); $_POST[c_al2fb_meta_pile_rows] = trim($_POST[c_al2fb_meta_pile_rows]); $_POST[c_al2fb_meta_reg_width] = trim($_POST[c_al2fb_meta_reg_width]); $_POST[c_al2fb_meta_login_width] = trim($_POST[c_al2fb_meta_login_width]); $_POST[c_al2fb_meta_login_regurl] = trim($_POST[c_al2fb_meta_login_regurl]); $_POST[c_al2fb_meta_login_redir] = trim($_POST[c_al2fb_meta_login_redir]); $_POST[c_al2fb_meta_login_html] = trim($_POST[c_al2fb_meta_login_html]); $_POST[c_al2fb_meta_act_width] = trim($_POST[c_al2fb_meta_act_width]); $_POST[c_al2fb_meta_act_height] = trim($_POST[c_al2fb_meta_act_height]); $_POST[c_al2fb_meta_open_graph_type] = trim($_POST[c_al2fb_meta_open_graph_type]); $_POST[c_al2fb_meta_open_graph_admins] = trim($_POST[c_al2fb_meta_open_graph_admins]); $_POST[c_al2fb_meta_fb_encoding] = trim($_POST[c_al2fb_meta_fb_encoding]); $_POST[c_al2fb_meta_fb_locale] = trim($_POST[c_al2fb_meta_fb_locale]); // Prevent losing selected page if (!self::Is_authorized($user_ID) || (get_user_meta($user_ID, c_al2fb_meta_use_groups, true) && get_user_meta($user_ID, c_al2fb_meta_group, true))) $_POST[c_al2fb_meta_page] = get_user_meta($user_ID, c_al2fb_meta_page, true); // Prevent losing selected group if (!self::Is_authorized($user_ID) || !get_user_meta($user_ID, c_al2fb_meta_use_groups, true)) $_POST[c_al2fb_meta_group] = get_user_meta($user_ID, c_al2fb_meta_group, true); // App ID or secret changed if (get_user_meta($user_ID, c_al2fb_meta_client_id, true) != $_POST[c_al2fb_meta_client_id] || get_user_meta($user_ID, c_al2fb_meta_app_secret, true) != $_POST[c_al2fb_meta_app_secret]) delete_user_meta($user_ID, c_al2fb_meta_access_token); // Page owner changed if ($_POST[c_al2fb_meta_page_owner] && !get_user_meta($user_ID, c_al2fb_meta_page_owner, true)) delete_user_meta($user_ID, c_al2fb_meta_access_token); // Use groups changed if ($_POST[c_al2fb_meta_use_groups] && !get_user_meta($user_ID, c_al2fb_meta_use_groups, true)) if (!get_user_meta($user_ID, c_al2fb_meta_group, true)) delete_user_meta($user_ID, c_al2fb_meta_access_token); // Like or send button enabled if ((!get_user_meta($user_ID, c_al2fb_meta_post_like_button, true) && !empty($_POST[c_al2fb_meta_post_like_button])) || (!get_user_meta($user_ID, c_al2fb_meta_post_send_button, true) && !empty($_POST[c_al2fb_meta_post_send_button]))) $_POST[c_al2fb_meta_open_graph] = true; // Update user options update_user_meta($user_ID, c_al2fb_meta_client_id, $_POST[c_al2fb_meta_client_id]); update_user_meta($user_ID, c_al2fb_meta_app_secret, $_POST[c_al2fb_meta_app_secret]); update_user_meta($user_ID, c_al2fb_meta_picture_type, $_POST[c_al2fb_meta_picture_type]); update_user_meta($user_ID, c_al2fb_meta_picture, $_POST[c_al2fb_meta_picture]); update_user_meta($user_ID, c_al2fb_meta_picture_default, $_POST[c_al2fb_meta_picture_default]); update_user_meta($user_ID, c_al2fb_meta_page, $_POST[c_al2fb_meta_page]); update_user_meta($user_ID, c_al2fb_meta_page_owner, $_POST[c_al2fb_meta_page_owner]); update_user_meta($user_ID, c_al2fb_meta_use_groups, $_POST[c_al2fb_meta_use_groups]); update_user_meta($user_ID, c_al2fb_meta_group, $_POST[c_al2fb_meta_group]); update_user_meta($user_ID, c_al2fb_meta_caption, $_POST[c_al2fb_meta_caption]); update_user_meta($user_ID, c_al2fb_meta_msg, $_POST[c_al2fb_meta_msg]); update_user_meta($user_ID, c_al2fb_meta_shortlink, $_POST[c_al2fb_meta_shortlink]); update_user_meta($user_ID, c_al2fb_meta_add_new_page, $_POST[c_al2fb_meta_add_new_page]); update_user_meta($user_ID, c_al2fb_meta_trailer, $_POST[c_al2fb_meta_trailer]); update_user_meta($user_ID, c_al2fb_meta_hyperlink, $_POST[c_al2fb_meta_hyperlink]); update_user_meta($user_ID, c_al2fb_meta_share_link, $_POST[c_al2fb_meta_share_link]); update_user_meta($user_ID, c_al2fb_meta_fb_comments, $_POST[c_al2fb_meta_fb_comments]); update_user_meta($user_ID, c_al2fb_meta_fb_comments_postback, $_POST[c_al2fb_meta_fb_comments_postback]); update_user_meta($user_ID, c_al2fb_meta_fb_comments_copy, $_POST[c_al2fb_meta_fb_comments_copy]); update_user_meta($user_ID, c_al2fb_meta_fb_comments_nolink, $_POST[c_al2fb_meta_fb_comments_nolink]); update_user_meta($user_ID, c_al2fb_meta_fb_likes, $_POST[c_al2fb_meta_fb_likes]); update_user_meta($user_ID, c_al2fb_meta_post_likers, $_POST[c_al2fb_meta_post_likers]); update_user_meta($user_ID, c_al2fb_meta_post_like_button, $_POST[c_al2fb_meta_post_like_button]); update_user_meta($user_ID, c_al2fb_meta_like_nohome, $_POST[c_al2fb_meta_like_nohome]); update_user_meta($user_ID, c_al2fb_meta_like_noposts, $_POST[c_al2fb_meta_like_noposts]); update_user_meta($user_ID, c_al2fb_meta_like_nopages, $_POST[c_al2fb_meta_like_nopages]); update_user_meta($user_ID, c_al2fb_meta_like_noarchives, $_POST[c_al2fb_meta_like_noarchives]); update_user_meta($user_ID, c_al2fb_meta_like_nocategories, $_POST[c_al2fb_meta_like_nocategories]); update_user_meta($user_ID, c_al2fb_meta_like_layout, $_POST[c_al2fb_meta_like_layout]); update_user_meta($user_ID, c_al2fb_meta_like_faces, $_POST[c_al2fb_meta_like_faces]); update_user_meta($user_ID, c_al2fb_meta_like_width, $_POST[c_al2fb_meta_like_width]); update_user_meta($user_ID, c_al2fb_meta_like_action, $_POST[c_al2fb_meta_like_action]); update_user_meta($user_ID, c_al2fb_meta_like_font, $_POST[c_al2fb_meta_like_font]); update_user_meta($user_ID, c_al2fb_meta_like_colorscheme, $_POST[c_al2fb_meta_like_colorscheme]); update_user_meta($user_ID, c_al2fb_meta_like_link, $_POST[c_al2fb_meta_like_link]); update_user_meta($user_ID, c_al2fb_meta_like_top, $_POST[c_al2fb_meta_like_top]); update_user_meta($user_ID, c_al2fb_meta_post_send_button, $_POST[c_al2fb_meta_post_send_button]); update_user_meta($user_ID, c_al2fb_meta_post_combine_buttons, $_POST[c_al2fb_meta_post_combine_buttons]); update_user_meta($user_ID, c_al2fb_meta_like_box_width, $_POST[c_al2fb_meta_like_box_width]); update_user_meta($user_ID, c_al2fb_meta_like_box_border, $_POST[c_al2fb_meta_like_box_border]); update_user_meta($user_ID, c_al2fb_meta_like_box_noheader, $_POST[c_al2fb_meta_like_box_noheader]); update_user_meta($user_ID, c_al2fb_meta_like_box_nostream, $_POST[c_al2fb_meta_like_box_nostream]); update_user_meta($user_ID, c_al2fb_meta_comments_posts, $_POST[c_al2fb_meta_comments_posts]); update_user_meta($user_ID, c_al2fb_meta_comments_width, $_POST[c_al2fb_meta_comments_width]); update_user_meta($user_ID, c_al2fb_meta_pile_size, $_POST[c_al2fb_meta_pile_size]); update_user_meta($user_ID, c_al2fb_meta_pile_width, $_POST[c_al2fb_meta_pile_width]); update_user_meta($user_ID, c_al2fb_meta_pile_rows, $_POST[c_al2fb_meta_pile_rows]); update_user_meta($user_ID, c_al2fb_meta_reg_width, $_POST[c_al2fb_meta_reg_width]); update_user_meta($user_ID, c_al2fb_meta_login_width, $_POST[c_al2fb_meta_login_width]); update_user_meta($user_ID, c_al2fb_meta_login_regurl, $_POST[c_al2fb_meta_login_regurl]); update_user_meta($user_ID, c_al2fb_meta_login_redir, $_POST[c_al2fb_meta_login_redir]); update_user_meta($user_ID, c_al2fb_meta_login_html, $_POST[c_al2fb_meta_login_html]); update_user_meta($user_ID, c_al2fb_meta_act_width, $_POST[c_al2fb_meta_act_width]); update_user_meta($user_ID, c_al2fb_meta_act_height, $_POST[c_al2fb_meta_act_height]); update_user_meta($user_ID, c_al2fb_meta_act_header, $_POST[c_al2fb_meta_act_header]); update_user_meta($user_ID, c_al2fb_meta_act_recommend, $_POST[c_al2fb_meta_act_recommend]); update_user_meta($user_ID, c_al2fb_meta_open_graph, $_POST[c_al2fb_meta_open_graph]); update_user_meta($user_ID, c_al2fb_meta_open_graph_type, $_POST[c_al2fb_meta_open_graph_type]); update_user_meta($user_ID, c_al2fb_meta_open_graph_admins, $_POST[c_al2fb_meta_open_graph_admins]); update_user_meta($user_ID, c_al2fb_meta_exclude_default, $_POST[c_al2fb_meta_exclude_default]); update_user_meta($user_ID, c_al2fb_meta_not_post_list, $_POST[c_al2fb_meta_not_post_list]); update_user_meta($user_ID, c_al2fb_meta_fb_encoding, $_POST[c_al2fb_meta_fb_encoding]); update_user_meta($user_ID, c_al2fb_meta_fb_locale, $_POST[c_al2fb_meta_fb_locale]); update_user_meta($user_ID, c_al2fb_meta_clean, $_POST[c_al2fb_meta_clean]); update_user_meta($user_ID, c_al2fb_meta_donated, $_POST[c_al2fb_meta_donated]); update_user_meta($user_ID, c_al2fb_meta_rated, $_POST[c_al2fb_meta_rated]); update_user_meta($user_ID, c_al2fb_meta_nospsn, $_POST[c_al2fb_meta_nospsn]); if (isset($_REQUEST['debug'])) { if (empty($_POST[c_al2fb_meta_access_token])) $_POST[c_al2fb_meta_access_token] = null; $_POST[c_al2fb_meta_access_token] = trim($_POST[c_al2fb_meta_access_token]); update_user_meta($user_ID, c_al2fb_meta_access_token, $_POST[c_al2fb_meta_access_token]); } // Update admin options if (current_user_can('manage_options')) { if (empty($_POST[c_al2fb_option_app_share])) $_POST[c_al2fb_option_app_share] = null; else $_POST[c_al2fb_option_app_share] = $user_ID; if (is_multisite()) update_site_option(c_al2fb_option_app_share, $_POST[c_al2fb_option_app_share]); else update_option(c_al2fb_option_app_share, $_POST[c_al2fb_option_app_share]); if (empty($_POST[c_al2fb_option_timeout])) $_POST[c_al2fb_option_timeout] = null; if (empty($_POST[c_al2fb_option_nonotice])) $_POST[c_al2fb_option_nonotice] = null; if (empty($_POST[c_al2fb_option_min_cap])) $_POST[c_al2fb_option_min_cap] = null; if (empty($_POST[c_al2fb_option_noverifypeer])) $_POST[c_al2fb_option_noverifypeer] = null; if (empty($_POST[c_al2fb_option_shortcode_widget])) $_POST[c_al2fb_option_shortcode_widget] = null; if (empty($_POST[c_al2fb_option_noshortcode])) $_POST[c_al2fb_option_noshortcode] = null; if (empty($_POST[c_al2fb_option_optout])) $_POST[c_al2fb_option_optout] = null; $_POST[c_al2fb_option_msg_refresh] = trim($_POST[c_al2fb_option_msg_refresh]); $_POST[c_al2fb_option_max_descr] = trim($_POST[c_al2fb_option_max_descr]); $_POST[c_al2fb_option_max_text] = trim($_POST[c_al2fb_option_max_text]); $_POST[c_al2fb_option_exclude_type] = trim($_POST[c_al2fb_option_exclude_type]); $_POST[c_al2fb_option_exclude_cat] = trim($_POST[c_al2fb_option_exclude_cat]); $_POST[c_al2fb_option_css] = trim($_POST[c_al2fb_option_css]); update_option(c_al2fb_option_timeout, $_POST[c_al2fb_option_timeout]); update_option(c_al2fb_option_nonotice, $_POST[c_al2fb_option_nonotice]); update_option(c_al2fb_option_min_cap, $_POST[c_al2fb_option_min_cap]); update_option(c_al2fb_option_msg_refresh, $_POST[c_al2fb_option_msg_refresh]); update_option(c_al2fb_option_max_descr, $_POST[c_al2fb_option_max_descr]); update_option(c_al2fb_option_max_text, $_POST[c_al2fb_option_max_text]); update_option(c_al2fb_option_exclude_type, $_POST[c_al2fb_option_exclude_type]); update_option(c_al2fb_option_exclude_cat, $_POST[c_al2fb_option_exclude_cat]); update_option(c_al2fb_option_noverifypeer, $_POST[c_al2fb_option_noverifypeer]); update_option(c_al2fb_option_shortcode_widget, $_POST[c_al2fb_option_shortcode_widget]); update_option(c_al2fb_option_noshortcode, $_POST[c_al2fb_option_noshortcode]); update_option(c_al2fb_option_optout, $_POST[c_al2fb_option_optout]); update_option(c_al2fb_option_css, $_POST[c_al2fb_option_css]); if (isset($_REQUEST['debug'])) { if (empty($_POST[c_al2fb_option_siteurl])) $_POST[c_al2fb_option_siteurl] = null; if (empty($_POST[c_al2fb_option_nocurl])) $_POST[c_al2fb_option_nocurl] = null; if (empty($_POST[c_al2fb_option_use_pp])) $_POST[c_al2fb_option_use_pp] = null; if (empty($_POST[c_al2fb_option_debug])) $_POST[c_al2fb_option_debug] = null; update_option(c_al2fb_option_siteurl, $_POST[c_al2fb_option_siteurl]); update_option(c_al2fb_option_nocurl, $_POST[c_al2fb_option_nocurl]); update_option(c_al2fb_option_use_pp, $_POST[c_al2fb_option_use_pp]); update_option(c_al2fb_option_debug, $_POST[c_al2fb_option_debug]); } } // Show result echo '
' . __('Settings updated', c_al2fb_text_domain) . '
' . __('Authorized, go posting!', c_al2fb_text_domain) . '
' . htmlspecialchars($e->getMessage(), ENT_QUOTES, get_bloginfo('charset')) . '
' . htmlspecialchars($msg, ENT_QUOTES, get_bloginfo('charset')) . '
' . nl2br(htmlspecialchars(stripslashes($_POST[c_al2fb_mail_msg]), ENT_QUOTES, get_bloginfo('charset'))) . '
'; $message .= '' . __('Debug information sent', c_al2fb_text_domain) . '
' . __('Sending debug information failed', c_al2fb_text_domain) . '
' . $text . '
'; _e('Add Link to Facebook', c_al2fb_text_domain); echo ' ' . $notice . '
' . $msg . '
'; echo __('Add Link to Facebook', c_al2fb_text_domain) . ' - '; edit_post_link(get_the_title($posts->post->ID), null, null, $posts->post->ID); echo ': ' . htmlspecialchars($error, ENT_QUOTES, get_bloginfo('charset')) . '
';
$msg = __('If you like the Add Link to Facebook plugin, please rate it on wordpress.org.
If the average rating is low, it makes no sense to support this plugin any longer.
You can disable this notice by checking the option "I have rated this plugin" on the settings page.', c_al2fb_text_domain);
$msg = str_replace('[wordpress]', 'http://wordpress.org/extend/plugins/add-link-to-facebook/', $msg);
$msg = str_replace('[settings]', $url, $msg);
echo $msg . '
'; echo __('Only this user can access the settings:', c_al2fb_text_domain); echo ' ' . $userdata->user_login . ' (id=' . $shared_user_ID . ')
' . __('Your server may not allow external connections', c_al2fb_text_domain) . '
|
/>
"" | |
| /> | |
|
| |
|
/>
| |
| /> Experimental! | |
|
/>
| |
| /> |
| /> | |
| /> | |
|
/>
| |
|
> > > | |
| /> | |
| /> |
|
/>
| |
|
> > > | |
|
> > | |
| /> | |
|
/>
| |
| /> |
| /> | |
| /> |
|
| ||
|
| ||
|
| ||
| /> | |
| /> |
| /> | |
| /> | |
| /> | |
| /> | |
| /> | |
| /> | |
|
> > | |
|
| |
|
/>
| |
|
| |
|
|
| /> | |
| /> | |
|
| |
|
() | |
|
/>
| |
| /> | |
| /> | |
| /> |
|
| ||
|
/>
| ||
|
| ||
|
| ||
|
| ||
|
| ||
|
| ||
|
/>
| ||
| /> | ||
| /> | ||
| /> | ||
|
| ||
| /> | |
| /> | |
| /> | |
| /> |
]*class="wp-caption-text"[^>]*>[^<]*<\/p>/i', '', $text); // Get plain texts $text = preg_replace('/<[^>]*>/', '', $text); // Truncate text if (!empty($text)) { $maxtext = get_option(c_al2fb_option_max_text); if (!$maxtext) $maxtext = 10000; $text = substr($text, 0, $maxtext); } return $text; } // Convert charset function Convert_encoding($user_ID, $text) { $blog_encoding = get_option('blog_charset'); $fb_encoding = get_user_meta($user_ID, c_al2fb_meta_fb_encoding, true); if (empty($fb_encoding)) $fb_encoding = 'UTF-8'; if ($blog_encoding != $fb_encoding && function_exists('mb_convert_encoding')) return @mb_convert_encoding($text, $fb_encoding, $blog_encoding); else return $text; } // Add Link to Facebook function Add_fb_link($post) { // Get url $user_ID = self::Get_user_ID($post); if (get_user_meta($user_ID, c_al2fb_meta_shortlink, true)) $link = wp_get_shortlink($post->ID); if (empty($link)) $link = get_permalink($post->ID); $link = apply_filters('al2fb_link', $link, $post); // Get processed texts $texts = self::Get_texts($post); $excerpt = $texts['excerpt']; $content = $texts['content']; $description = $texts['description']; // Get name $name = self::Convert_encoding($user_ID, get_the_title($post->ID)); $name = apply_filters('al2fb_name', $name, $post); // Get caption $caption = ''; if (get_user_meta($user_ID, c_al2fb_meta_caption, true)) { $caption = html_entity_decode(get_bloginfo('title'), ENT_QUOTES, get_bloginfo('charset')); $caption = self::Convert_encoding($user_ID, $caption); $caption = apply_filters('al2fb_caption', $caption, $post); } // Get link picture $picture_info = self::Get_link_picture($post, $user_ID); $picture = $picture_info['picture']; $picture_type = $picture_info['picture_type']; $picture = apply_filters('al2fb_picture', $picture, $post); // Get user note $message = ''; if (get_user_meta($user_ID, c_al2fb_meta_msg, true)) $message = $excerpt; // Do not disturb WordPress try { // Build request if (get_user_meta($user_ID, c_al2fb_meta_use_groups, true)) $page_id = get_user_meta($user_ID, c_al2fb_meta_group, true); if (empty($page_id)) $page_id = get_user_meta($user_ID, c_al2fb_meta_page, true); if (empty($page_id)) $page_id = 'me'; $url = 'https://graph.facebook.com/' . $page_id . '/feed'; $query_array = array( 'access_token' => self::Get_access_token_by_post($post), 'link' => $link, 'name' => $name, 'caption' => $caption, 'description' => $description, 'picture' => $picture, 'message' => $message ); // Add share link if (get_user_meta($user_ID, c_al2fb_meta_share_link, true)) { // http://forum.developers.facebook.net/viewtopic.php?id=50049 // http://bugs.developers.facebook.net/show_bug.cgi?id=9075 $actions = array( 'name' => __('Share', c_al2fb_text_domain), 'link' => 'http://www.facebook.com/share.php?u=' . urlencode($link) . '&t=' . urlencode(get_the_title($post->ID)) ); $query_array['actions'] = json_encode($actions); } // Build request $query = http_build_query($query_array, '', '&'); // Log request if ($this->debug) add_post_meta($post->ID, c_al2fb_meta_log, 'request=' . $query); // Execute request $response = self::Request($url, $query, 'POST'); // Log response if ($this->debug) add_post_meta($post->ID, c_al2fb_meta_log, 'response=' . $response); // Decode response $fb_link = json_decode($response); // Register link/date add_post_meta($post->ID, c_al2fb_meta_link_id, $fb_link->id); update_post_meta($post->ID, c_al2fb_meta_link_time, date('c')); update_post_meta($post->ID, c_al2fb_meta_link_picture, $picture_type . '=' . $picture); delete_post_meta($post->ID, c_al2fb_meta_error); // Update stats $this->Update_statistics('add', $post); } catch (Exception $e) { add_post_meta($post->ID, c_al2fb_meta_error, $e->getMessage()); update_post_meta($post->ID, c_al2fb_meta_link_time, date('c')); update_post_meta($post->ID, c_al2fb_meta_link_picture, $picture_type . '=' . $picture); } } // Delete Link from Facebook function Delete_fb_link($post) { // Do not disturb WordPress try { // Build request // http://developers.facebook.com/docs/reference/api/link/ $link_id = get_post_meta($post->ID, c_al2fb_meta_link_id, true); $url = 'https://graph.facebook.com/' . $link_id; $query = http_build_query(array( 'access_token' => self::Get_access_token_by_post($post), 'method' => 'delete' ), '', '&'); // Execute request $response = self::Request($url, $query, 'POST'); // Delete meta data delete_post_meta($post->ID, c_al2fb_meta_link_id); delete_post_meta($post->ID, c_al2fb_meta_link_time); delete_post_meta($post->ID, c_al2fb_meta_link_picture); delete_post_meta($post->ID, c_al2fb_meta_error); // Update stats $this->Update_statistics('del', $post); } catch (Exception $e) { add_post_meta($post->ID, c_al2fb_meta_error, $e->getMessage()); update_post_meta($post->ID, c_al2fb_meta_link_time, date('c')); } } // Delete Link from Facebook function Delete_fb_link_comment($comment) { // Get data $fb_comment_id = get_comment_meta($comment->comment_ID, c_al2fb_meta_fb_comment_id, true); if (empty($fb_comment_id)) return; $post = get_post($comment->comment_post_ID); if (empty($post)) return; // Do not disturb WordPress try { // Build request $url = 'https://graph.facebook.com/' . $fb_comment_id; $query = http_build_query(array( 'access_token' => self::Get_access_token_by_post($post), 'method' => 'delete' ), '', '&'); // Execute request $response = self::Request($url, $query, 'POST'); // Delete meta data delete_comment_meta($comment->comment_ID, c_al2fb_meta_fb_comment_id); } catch (Exception $e) { add_post_meta($post->ID, c_al2fb_meta_error, $e->getMessage()); } } // New comment function Comment_post($comment_ID) { $comment = get_comment($comment_ID); if ($comment->comment_approved == '1') self::Add_fb_link_comment($comment); } // Approved comment function Comment_approved($comment) { self::Add_fb_link_comment($comment); } // Disapproved comment function Comment_unapproved($comment) { self::Delete_fb_link_comment($comment); } // Add comment to link function Add_fb_link_comment($comment) { // Get data $fb_comment_id = get_comment_meta($comment->comment_ID, c_al2fb_meta_fb_comment_id, true); if (!empty($fb_comment_id)) return; $post = get_post($comment->comment_post_ID); if (empty($post)) return; $link_id = get_post_meta($post->ID, c_al2fb_meta_link_id, true); if (empty($link_id)) return; if (get_post_meta($post->ID, c_al2fb_meta_nointegrate, true)) return; $user_ID = self::Get_user_ID($post); if (!get_user_meta($user_ID, c_al2fb_meta_fb_comments_postback, true)) return; // Build message $message = $comment->comment_author . ' ' . __('commented on', c_al2fb_text_domain) . ' '; $message .= html_entity_decode(get_bloginfo('title'), ENT_QUOTES, get_bloginfo('charset')) . ":\n\n"; $message .= $comment->comment_content; $message = apply_filters('al2fb_comment', $message, $comment, $post); $message = self::Convert_encoding($user_ID, $message); // Do not disturb WordPress try { $url = 'https://graph.facebook.com/' . $link_id . '/comments'; $query_array = array( 'access_token' => self::Get_access_token_by_post($post), 'message' => $message ); // http://developers.facebook.com/docs/reference/api/Comment/ $query = http_build_query($query_array, '', '&'); // Execute request $response = self::Request($url, $query, 'POST'); // Process response $fb_comment = json_decode($response); add_comment_meta($comment->comment_ID, c_al2fb_meta_fb_comment_id, $fb_comment->id); } catch (Exception $e) { add_post_meta($post->ID, c_al2fb_meta_error, $e->getMessage()); } } function Is_authorized($user_ID) { return get_user_meta($user_ID, c_al2fb_meta_access_token, true); } // Get correct access for post function Get_access_token_by_post($post) { $user_ID = self::Get_user_ID($post); $page_id = get_user_meta($user_ID, c_al2fb_meta_page, true); return self::Get_access_token_by_page($user_ID, $page_id); } // Get access token for page function Get_access_token_by_page($user_ID, $page_id) { $access_token = get_user_meta($user_ID, c_al2fb_meta_access_token, true); if ($page_id && $page_id != 'me' && get_user_meta($user_ID, c_al2fb_meta_page_owner, true)) { $found = false; $pages = self::Get_fb_pages($user_ID); if ($pages->data) foreach ($pages->data as $page) if ($page->id == $page_id) { $found = true; $access_token = $page->access_token; } } return $access_token; } // HTML header function WP_head() { if (is_single() || is_page()) { global $post; $user_ID = self::Get_user_ID($post); if (get_user_meta($user_ID, c_al2fb_meta_open_graph, true)) { $charset = get_bloginfo('charset'); $title = html_entity_decode(get_bloginfo('title'), ENT_QUOTES, get_bloginfo('charset')); // Get link picture $link_picture = get_post_meta($post->ID, c_al2fb_meta_link_picture, true); if (empty($link_picture)) { $picture_info = self::Get_link_picture($post, $user_ID); $picture = $picture_info['picture']; if (empty($picture)) $picture = self::Redirect_uri() . '?al2fb_image=1'; } else $picture = substr($link_picture, strpos($link_picture, '=') + 1); // Get type $ogp_type = get_user_meta($user_ID, c_al2fb_meta_open_graph_type, true); if (empty($ogp_type)) $ogp_type = 'article'; // Generate meta tags echo '' . PHP_EOL; echo '' . PHP_EOL; echo '' . PHP_EOL; echo '' . PHP_EOL; echo '' . PHP_EOL; $texts = self::Get_texts($post); $maxlen = get_option(c_al2fb_option_max_descr); $description = substr($texts['description'], 0, $maxlen ? $maxlen : 256); echo '' . PHP_EOL; $appid = get_user_meta($user_ID, c_al2fb_meta_client_id, true); if (!empty($appid)) echo '' . PHP_EOL; $admins = get_user_meta($user_ID, c_al2fb_meta_open_graph_admins, true); if (!empty($admins)) echo '' . PHP_EOL; } } else if (is_home()) { // Check if any user has enabled the OGP global $wpdb; $opg = false; $rows = $wpdb->get_results("SELECT meta_value FROM " . $wpdb->usermeta . " WHERE meta_key='" . c_al2fb_meta_open_graph . "'"); foreach ($rows as $row) if ($row->meta_value) { $opg = true; break; } // Generate meta tags if ($opg) { $charset = get_bloginfo('charset'); $title = html_entity_decode(get_bloginfo('title'), ENT_QUOTES, get_bloginfo('charset')); echo '' . PHP_EOL; echo '' . PHP_EOL; echo '' . PHP_EOL; } } } // Additional styles function WP_print_styles() { $css = get_option(c_al2fb_option_css); if (!empty($css)) { echo '' . PHP_EOL; } } // Post content function The_content($content = '') { global $post; // Excluded post types $ex_custom_types = explode(',', get_option(c_al2fb_option_exclude_type)); if (in_array($post->post_type, $ex_custom_types)) return $content; $user_ID = self::Get_user_ID($post); 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())) { // Show likers if (get_user_meta($user_ID, c_al2fb_meta_post_likers, true)) { $likers = self::Get_likers($post); if (!empty($likers)) if (get_user_meta($user_ID, c_al2fb_meta_like_top, true)) $content = $likers . $content; else $content .= $likers; } // Show like button if (!get_post_meta($post->ID, c_al2fb_meta_nolike, true)) { if (get_user_meta($user_ID, c_al2fb_meta_post_like_button, true)) $button = self::Get_like_button($post, false); if (get_user_meta($user_ID, c_al2fb_meta_post_send_button, true) && !get_user_meta($user_ID, c_al2fb_meta_post_combine_buttons, true)) $button .= self::Get_send_button($post); } if (!empty($button)) if (get_user_meta($user_ID, c_al2fb_meta_like_top, true)) $content = $button . $content; else $content .= $button; } return $content; } // Shortcode likers names function Shortcode_likers($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 self::Get_likers($post); else return ''; } // Shortcode like count function Shortcode_like_count($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 self::Get_like_count($post); else return ''; } // Shortcode like button function Shortcode_like_button($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 self::Get_like_button($post, false); else return ''; } // Shortcode like box function Shortcode_like_box($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 self::Get_like_button($post, true); else return ''; } // Shortcode send button function Shortcode_send_button($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 self::Get_send_button($post); else return ''; } // Shortcode comments plugin function Shortcode_comments_plugin($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 self::Get_comments_plugin($post); else return ''; } // Shortcode face pile 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 self::Get_face_pile($post); else return ''; } // Shortcode profile link function Shortcode_profile_link($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 self::Get_profile_link($post); else return ''; } // Shortcode Facebook registration function Shortcode_registration($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 self::Get_registration($post); else return ''; } // Shortcode Facebook login function Shortcode_login($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 self::Get_login($post); else return ''; } // Shortcode Facebook activity feed function Shortcode_activity_feed($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 self::Get_activity_feed($post); else return ''; } // Get HTML for likers function Get_likers($post) { $user_ID = self::Get_user_ID($post); $likers = ''; $charset = get_bloginfo('charset'); $fb_likes = self::Get_comments_or_likes($post, true); if ($fb_likes) foreach ($fb_likes->data as $fb_like) { if (!empty($likers)) $likers .= ', '; if (get_user_meta($user_ID, c_al2fb_meta_fb_comments_nolink, true) == 'author') { $link = self::Get_fb_profilelink($fb_like->id); $likers .= '' . htmlspecialchars($fb_like->name, ENT_QUOTES, $charset) . ''; } else $likers .= htmlspecialchars($fb_like->name, ENT_QUOTES, $charset); } if (!empty($likers)) { $likers .= ' ' . _n('liked this post', 'liked this post', count($fb_likes->data), c_al2fb_text_domain) . ''; $likers = '
| Time: | ' . date('c') . ' |
| Server software: | ' . htmlspecialchars($_SERVER['SERVER_SOFTWARE'], ENT_QUOTES, $charset) . ' |
| SAPI: | ' . htmlspecialchars(php_sapi_name(), ENT_QUOTES, $charset) . ' |
| PHP version: | ' . PHP_VERSION . ' |
| safe_mode: | ' . (ini_get('safe_mode') ? 'Yes' : 'No') . ' |
| open_basedir: | ' . ini_get('open_basedir') . ' |
| User agent: | ' . htmlspecialchars($_SERVER['HTTP_USER_AGENT'], ENT_QUOTES, $charset) . ' |
| WordPress version: | ' . $wp_version . ' |
| Theme name: | ' . '' . htmlspecialchars($theme_data['Name'], ENT_QUOTES, $charset) . '' . ' |
| Theme version: | ' . htmlspecialchars($theme_data['Version'], ENT_QUOTES, $charset) . ' |
| Active plugin: | ' . htmlspecialchars($plugin_data['Name'], ENT_QUOTES, $charset) . ' |
| Plugin version: | ' . $plugin_version . ' |
| Settings version: | ' . get_option(c_al2fb_option_version) . ' |
| Multi site: | ' . (is_multisite() ? 'Yes' : 'No') . ' |
| Site id: | ' . $this->site_id . ' |
| Blog id: | ' . $this->blog_id . ' |
| Number of users: | ' . $users . ' |
| Blog address (home): | ' . htmlspecialchars(get_home_url(), ENT_QUOTES, $charset) . ' |
| WordPress address (site): | ' . htmlspecialchars(get_site_url(), ENT_QUOTES, $charset) . ' |
| Redirect URI: | ' . htmlspecialchars(self::Redirect_uri(), ENT_QUOTES, $charset) . ' |
| Authorize URL: | ' . htmlspecialchars(self::Authorize_url($user_ID), ENT_QUOTES, $charset) . ' |
| Authorization init: | ' . htmlspecialchars(get_option(c_al2fb_log_redir_init), ENT_QUOTES, $charset) . ' |
| Authorization check: | ' . htmlspecialchars(get_option(c_al2fb_log_redir_check), ENT_QUOTES, $charset) . ' |
| Redirect time: | ' . htmlspecialchars(get_option(c_al2fb_log_redir_time), ENT_QUOTES, $charset) . ' |
| Redirect referer: | ' . htmlspecialchars(get_option(c_al2fb_log_redir_ref), ENT_QUOTES, $charset) . ' |
| Redirect from: | ' . htmlspecialchars(get_option(c_al2fb_log_redir_from), ENT_QUOTES, $charset) . ' |
| Redirect to: | ' . htmlspecialchars(get_option(c_al2fb_log_redir_to), ENT_QUOTES, $charset) . ' |
| Authorized: | ' . (self::Is_authorized($user_ID) ? 'Yes' : 'No') . ' |
| Authorized time: | ' . get_option(c_al2fb_log_auth_time) . ' |
| allow_url_fopen: | ' . (ini_get('allow_url_fopen') ? 'Yes' : 'No') . ' |
| cURL: | ' . (function_exists('curl_init') ? 'Yes' : 'No') . ' |
| SSL: | ' . (function_exists('openssl_sign') ? 'Yes' : 'No') . ' |
| Encoding: | ' . htmlspecialchars(get_option('blog_charset'), ENT_QUOTES, $charset) . ' |
| Facebook: | ' . htmlspecialchars(get_user_meta($user_ID, c_al2fb_meta_fb_encoding, true), ENT_QUOTES, $charset) . ' |
| Locale: | ' . htmlspecialchars(WPLANG, ENT_QUOTES, $charset) . ' |
| Facebook: | ' . htmlspecialchars(self::Get_locale($user_ID), ENT_QUOTES, $charset) . ' |
| mb_convert_encoding: | ' . (function_exists('mb_convert_encoding') ? 'Yes' : 'No') . ' |
| Application: | ' . $app . ' |
| Shared user ID: | ' . $shared_user_ID . ' |
| Picture type: | ' . get_user_meta($user_ID, c_al2fb_meta_picture_type, true) . ' |
| Custom picture URL: | ' . $picture . ' |
| Default picture URL: | ' . $picture_default . ' |
| Page: | ' . $page . ' |
| Page owner: | ' . (get_user_meta($user_ID, c_al2fb_meta_page_owner, true) ? 'Yes' : 'No') . ' |
| Use groups: | ' . (get_user_meta($user_ID, c_al2fb_meta_use_groups, true) ? 'Yes' : 'No') . ' |
| Group: | ' . get_user_meta($user_ID, c_al2fb_meta_group, true) . ' |
| Caption: | ' . (get_user_meta($user_ID, c_al2fb_meta_caption, true) ? 'Yes' : 'No') . ' |
| Excerpt: | ' . (get_user_meta($user_ID, c_al2fb_meta_msg, true) ? 'Yes' : 'No') . ' |
| Trailer: | ' . htmlspecialchars(get_user_meta($user_ID, c_al2fb_meta_trailer, true), ENT_QUOTES, $charset) . ' |
| Hyperlink: | ' . (get_user_meta($user_ID, c_al2fb_meta_hyperlink, true) ? 'Yes' : 'No') . ' |
| Share link: | ' . (get_user_meta($user_ID, c_al2fb_meta_share_link, true) ? 'Yes' : 'No') . ' |
| Shortlink: | ' . (get_user_meta($user_ID, c_al2fb_meta_shortlink, true) ? 'Yes' : 'No') . ' |
| Page link: | ' . (get_user_meta($user_ID, c_al2fb_meta_add_new_page, true) ? 'Yes' : 'No') . ' |
| FB comments: | ' . (get_user_meta($user_ID, c_al2fb_meta_fb_comments, true) ? 'Yes' : 'No') . ' |
| FB comments postback: | ' . (get_user_meta($user_ID, c_al2fb_meta_fb_comments_postback, true) ? 'Yes' : 'No') . ' |
| FB comments copy: | ' . (get_user_meta($user_ID, c_al2fb_meta_fb_comments_copy, true) ? 'Yes' : 'No') . ' |
| FB comments no link: | ' . get_user_meta($user_ID, c_al2fb_meta_fb_comments_nolink, true) . ' |
| FB likes: | ' . (get_user_meta($user_ID, c_al2fb_meta_fb_likes, true) ? 'Yes' : 'No') . ' |
| Post likers: | ' . (get_user_meta($user_ID, c_al2fb_meta_post_likers, true) ? 'Yes' : 'No') . ' |
| Post like button: | ' . (get_user_meta($user_ID, c_al2fb_meta_post_like_button, true) ? 'Yes' : 'No') . ' |
| Not home page: | ' . (get_user_meta($user_ID, c_al2fb_meta_like_nohome, true) ? 'Yes' : 'No') . ' |
| Not posts: | ' . (get_user_meta($user_ID, c_al2fb_meta_like_noposts, true) ? 'Yes' : 'No') . ' |
| Not pages: | ' . (get_user_meta($user_ID, c_al2fb_meta_like_nopages, true) ? 'Yes' : 'No') . ' |
| Not archives: | ' . (get_user_meta($user_ID, c_al2fb_meta_like_noarchives, true) ? 'Yes' : 'No') . ' |
| Not categories: | ' . (get_user_meta($user_ID, c_al2fb_meta_like_nocategories, true) ? 'Yes' : 'No') . ' |
| Like layout: | ' . get_user_meta($user_ID, c_al2fb_meta_like_layout, true) . ' |
| Like faces: | ' . (get_user_meta($user_ID, c_al2fb_meta_like_faces, true) ? 'Yes' : 'No') . ' |
| Like width: | ' . get_user_meta($user_ID, c_al2fb_meta_like_width, true) . ' |
| Like action: | ' . get_user_meta($user_ID, c_al2fb_meta_like_action, true) . ' |
| Like font: | ' . get_user_meta($user_ID, c_al2fb_meta_like_font, true) . ' |
| Like color scheme: | ' . get_user_meta($user_ID, c_al2fb_meta_like_colorscheme, true) . ' |
| Like link: | ' . get_user_meta($user_ID, c_al2fb_meta_like_link, true) . ' |
| Like top: | ' . (get_user_meta($user_ID, c_al2fb_meta_like_top, true) ? 'Yes' : 'No') . ' |
| Send button: | ' . (get_user_meta($user_ID, c_al2fb_meta_post_send_button, true) ? 'Yes' : 'No') . ' |
| Combine buttons: | ' . (get_user_meta($user_ID, c_al2fb_meta_post_combine_buttons, true) ? 'Yes' : 'No') . ' |
| Like box width: | ' . get_user_meta($user_ID, c_al2fb_meta_like_box_width, true) . ' |
| Like box border: | ' . get_user_meta($user_ID, c_al2fb_meta_like_box_border, true) . ' |
| Like box no header: | ' . (get_user_meta($user_ID, c_al2fb_meta_like_box_noheader, true) ? 'Yes' : 'No') . ' |
| Like box no stream: | ' . (get_user_meta($user_ID, c_al2fb_meta_like_box_nostream, true) ? 'Yes' : 'No') . ' |
| Comments posts: | ' . get_user_meta($user_ID, c_al2fb_meta_comments_posts, true) . ' |
| Comments width: | ' . get_user_meta($user_ID, c_al2fb_meta_comments_width, true) . ' |
| Facepile size: | ' . get_user_meta($user_ID, c_al2fb_meta_pile_size, true) . ' |
| Facepile width: | ' . get_user_meta($user_ID, c_al2fb_meta_pile_width, true) . ' |
| Facepile rows: | ' . get_user_meta($user_ID, c_al2fb_meta_pile_rows, true) . ' |
| Registration width: | ' . get_user_meta($user_ID, c_al2fb_meta_reg_width, true) . ' |
| Login width: | ' . get_user_meta($user_ID, c_al2fb_meta_login_width, true) . ' |
| Registration URL: | Link |
| Redir URL: | Link |
| Login text/HTML: | Link |
| Activity width: | ' . get_user_meta($user_ID, c_al2fb_meta_act_width, true) . ' |
| Activity height: | ' . get_user_meta($user_ID, c_al2fb_meta_act_height, true) . ' |
| Activity header: | ' . (get_user_meta($user_ID, c_al2fb_meta_act_header, true) ? 'Yes' : 'No') . ' |
| Activity recommend: | ' . (get_user_meta($user_ID, c_al2fb_meta_act_recommend, true) ? 'Yes' : 'No') . ' |
| Facebook ID: | ' . $fid . ' |
| OGP: | ' . (get_user_meta($user_ID, c_al2fb_meta_open_graph, true) ? 'Yes' : 'No') . ' |
| OGP type: | ' . get_user_meta($user_ID, c_al2fb_meta_open_graph_type, true) . ' |
| OGP admins: | ' . get_user_meta($user_ID, c_al2fb_meta_open_graph_admins, true) . ' |
| Timeout: | ' . htmlspecialchars(get_option(c_al2fb_option_timeout), ENT_QUOTES, $charset) . ' |
| No notices: | ' . (get_option(c_al2fb_option_nonotice) ? 'Yes' : 'No') . ' |
| Min. capability: | ' . htmlspecialchars(get_option(c_al2fb_option_min_cap), ENT_QUOTES, $charset) . ' |
| Refresh comments: | ' . htmlspecialchars(get_option(c_al2fb_option_msg_refresh), ENT_QUOTES, $charset) . ' |
| Max. length: | ' . htmlspecialchars(get_option(c_al2fb_option_max_descr), ENT_QUOTES, $charset) . ' |
| Max. text length: | ' . htmlspecialchars(get_option(c_al2fb_option_max_text), ENT_QUOTES, $charset) . ' |
| Exclude post types: | ' . htmlspecialchars(get_option(c_al2fb_option_exclude_type), ENT_QUOTES, $charset) . ' |
| Exclude categories: | ' . htmlspecialchars(get_option(c_al2fb_option_exclude_cat), ENT_QUOTES, $charset) . ' |
| No verify peer: | ' . (get_option(c_al2fb_option_noverifypeer) ? 'Yes' : 'No') . ' |
| Shortcode/widget: | ' . (get_option(c_al2fb_option_shortcode_widget) ? 'Yes' : 'No') . ' |
| No shortcode: | ' . (get_option(c_al2fb_option_noshortcode) ? 'Yes' : 'No') . ' |
| No statistics: | ' . (get_option(c_al2fb_option_optout) ? 'Yes' : 'No') . ' |
| Site URL: | ' . htmlspecialchars(get_option(c_al2fb_option_siteurl), ENT_QUOTES, $charset) . ' |
| Do not use cURL: | ' . (get_option(c_al2fb_option_nocurl) ? 'Yes' : 'No') . ' |
| Use publish_post: | ' . (get_option(c_al2fb_option_use_pp) ? 'Yes' : 'No') . ' |
| Debug: | ' . (get_option(c_al2fb_option_debug) ? 'Yes' : 'No') . ' |
| CSS: | ' . htmlspecialchars(get_option(c_al2fb_option_css), ENT_QUOTES, $charset) . ' |
| wp_get_attachment_thumb_url: | ' . (function_exists('wp_get_attachment_thumb_url') ? 'Yes' : 'No') . ' |
| wp_get_attachment_image_src: | ' . (function_exists('wp_get_attachment_image_src') ? 'Yes' : 'No') . ' |
| theme - post-thumbnails: | ' . (current_theme_supports('post-thumbnails') ? 'Yes' : 'No') . ' |
| get_post_thumbnail_id: | ' . (function_exists('get_post_thumbnail_id') ? 'Yes' : 'No') . ' |
| wp_get_attachment_image_src: | ' . (function_exists('wp_get_attachment_image_src') ? 'Yes' : 'No') . ' |
| Post #' . $posts->post->ID . ': | '; $info .= '' . htmlspecialchars(get_the_title($posts->post->ID), ENT_QUOTES, $charset) . ''; $info .= ' by ' . htmlspecialchars($userdata->user_login, ENT_QUOTES, $charset); $info .= ' @ ' . $posts->post->post_date; $info .= ' ' . $picture['picture_type'] . ''; if (!empty($selected_picture)) $info .= ' selected'; if (!empty($attached_picture)) $info .= ' attached'; if (!empty($featured_picture)) $info .= ' featured'; if (!empty($post_picture)) $info .= ' post'; if (!empty($avatar_picture)) $info .= ' avatar'; if (!empty($link_id)) $info .= ' Facebook'; $info .= ' |
| Link picture #' . $posts->post->ID . ': | '; $info .= '' . htmlspecialchars(get_the_title($posts->post->ID), ENT_QUOTES, $charset) . ''; $info .= ' ' . htmlspecialchars($link_picture, ENT_QUOTES, $charset); $info .= ' @ ' . $posts->post->post_date . ' |
| Error: | '; $info .= '' . htmlspecialchars($error, ENT_QUOTES, $charset) . ' |
| Error time: | '; $info .= '' . htmlspecialchars(get_post_meta($posts->post->ID, c_al2fb_meta_link_time, true), ENT_QUOTES, $charset) . ' |
| Error post: | '; $info .= '' . htmlspecialchars(get_the_title($posts->post->ID), ENT_QUOTES, $charset) . ' |
| Last error: | ' . htmlspecialchars(get_option(c_al2fb_last_error), ENT_QUOTES, $charset) . ' |
| Last error time: | ' . htmlspecialchars(get_option(c_al2fb_last_error_time), ENT_QUOTES, $charset) . ' |
' . print_r($_SERVER, true) . ''; return $info; } // Update usage statistics function Update_statistics($action, $post) { if (get_option(c_al2fb_option_optout)) return; try { $uri = self::Redirect_uri(); $title = html_entity_decode(get_bloginfo('title'), ENT_QUOTES, get_bloginfo('charset')); // Get plugin version if (!function_exists('get_plugins')) require_once(ABSPATH . 'wp-admin/includes/plugin.php'); $plugin_folder = get_plugins('/' . plugin_basename(dirname(__FILE__))); $plugin_version = $plugin_folder[basename($this->main_file)]['Version']; // Security $hash = md5(AUTH_KEY ? AUTH_KEY : get_bloginfo('url')); // Update $query = http_build_query(array( 'action' => $action, 'api' => 1, 'url' => $uri, 'userid' => self::Get_user_ID($post), 'charset' => get_bloginfo('charset'), 'lang' => get_bloginfo('language'), 'dir' => get_bloginfo('text_direction'), 'zone' => get_option('gmt_offset'), 'ver' => $plugin_version, 'title' => $title, 'hash' => $hash ), '', '&'); $response = self::Request('http://al2fb.bokhorst.biz/', $query, 'POST'); $service = json_decode($response, true); if (isset($service->id)) { $user_ID = self::Get_user_ID($post); // Delete existing messages $msgs = get_user_meta($user_ID, c_al2fb_meta_service, false); if ($msgs) foreach ($msgs as $msg) if (is_object($msg) ? $msg->id == $service['id'] : $msg['id'] == $service['id']) delete_user_meta($user_ID, c_al2fb_meta_service, $msg); // Add new message add_user_meta($user_ID, c_al2fb_meta_service, $service); } } catch (Exception $e) { if ($this->debug) print_r($e); } } // Check environment function Check_prerequisites() { // Check WordPress version global $wp_version; if (version_compare($wp_version, '3.0') < 0) die('Add Link to Facebook requires at least WordPress 3.0'); // Check basic prerequisities self::Check_function('add_action'); self::Check_function('add_filter'); self::Check_function('wp_register_style'); self::Check_function('wp_enqueue_style'); self::Check_function('file_get_contents'); self::Check_function('json_decode'); self::Check_function('md5'); } function Check_function($name) { if (!function_exists($name)) die('Required WordPress function "' . $name . '" does not exist'); } // Change file extension function Change_extension($filename, $new_extension) { return preg_replace('/\..+$/', $new_extension, $filename); } } } class AL2FB_Widget extends WP_Widget { function AL2FB_Widget() { $widget_ops = array('classname' => 'widget_al2fb', 'description' => ''); $this->WP_Widget('AL2FB_Widget', 'Add Link to Facebook', $widget_ops); } function widget($args, $instance) { global $wp_al2fb; if (!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 $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; $messages = isset($instance['al2fb_messages']) ? $instance['al2fb_messages'] : 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; $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 time zone offset $tz_off = get_option('gmt_offset'); if (empty($tz_off)) $tz_off = 0; else $tz_off = $tz_off * 3600; // Get comments $fb_comments = false; if ($comments) $fb_comments = $wp_al2fb->Get_comments_or_likes($post, false); // Get messages $fb_messages = false; if ($messages) try { $fb_messages = $wp_al2fb->Get_fb_feed($user_ID); } catch (Exception $e) { } if ($fb_comments || $fb_messages || $like_button || $like_box || $send_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 ''; } // Messages if ($fb_messages) { echo ''; } // Facebook like button if ($like_button) echo $wp_al2fb->Get_like_button($post, false); // Facebook like box if ($like_box) echo $wp_al2fb->Get_like_button($post, true); // Facebook send button if ($send_button) echo $wp_al2fb->Get_send_button($post); // Facebook comments plugins if ($comments_plugin) echo $wp_al2fb->Get_comments_plugin($post); // Facebook Face pile if ($face_pile) echo $wp_al2fb->Get_face_pile($post); // Facebook profile if ($profile) echo $wp_al2fb->Get_profile_link($post); // Facebook registration if ($registration) echo $wp_al2fb->Get_registration($post); // Facebook login if ($login) echo $wp_al2fb->Get_login($post); // Facebook activity feed if ($activity) echo $wp_al2fb->Get_activity_feed($post); echo $after_widget; } } // Helper render Facebook comments function Render_fb_comments($fb_comments, $comments_nolink, $link_id) { global $wp_al2fb; $charset = get_bloginfo('charset'); // Get time zone offset $tz_off = get_option('gmt_offset'); if (empty($tz_off)) $tz_off = 0; else $tz_off = $tz_off * 3600; echo '
id="get_field_id('al2fb_comments'); ?>" name="get_field_name('al2fb_comments'); ?>" />
id="get_field_id('al2fb_messages'); ?>" name="get_field_name('al2fb_messages'); ?>" />
id="get_field_id('al2fb_messages_comments'); ?>" name="get_field_name('al2fb_messages_comments'); ?>" />
id="get_field_id('al2fb_like_button'); ?>" name="get_field_name('al2fb_like_button'); ?>" />
id="get_field_id('al2fb_like_box'); ?>" name="get_field_name('al2fb_like_box'); ?>" />
id="get_field_id('al2fb_send_button'); ?>" name="get_field_name('al2fb_send_button'); ?>" />
id="get_field_id('al2fb_comments_plugin'); ?>" name="get_field_name('al2fb_comments_plugin'); ?>" />
id="get_field_id('al2fb_face_pile'); ?>" name="get_field_name('al2fb_face_pile'); ?>" />
id="get_field_id('al2fb_profile'); ?>" name="get_field_name('al2fb_profile'); ?>" />
id="get_field_id('al2fb_registration'); ?>" name="get_field_name('al2fb_registration'); ?>" />
id="get_field_id('al2fb_login'); ?>" name="get_field_name('al2fb_login'); ?>" />
id="get_field_id('al2fb_activity'); ?>" name="get_field_name('al2fb_activity'); ?>" />