/** * Check to see if the active admin has authenticated with Facebook * If not, display a warning message * * @since 1.0 */ function fb_check_connected_accounts() { $current_user = wp_get_current_user(); global $facebook; if (!isset($facebook)) { return; } $options = get_option('fb_options'); // check if we have enough info to handle the authFacebook function if (!$options || empty($options['app_id']) || empty($options['app_secret'])) { return; } //see if they have connected their account to facebook $fb_data = fb_get_user_meta($current_user->ID, 'fb_data', true); //if no, show message prompting to connect if (empty($fb_data['fb_uid']) && isset($options['social_publisher']) && isset($options['social_publisher']['enabled'])) { $fb_user = fb_get_current_user(); if ($fb_user) { $perms = $facebook->api('/me/permissions', 'GET', array('ref' => 'fbwpp')); } if ($fb_user && isset($perms['data'][0]['manage_pages']) && isset($perms['data'][0]['publish_actions']) && isset($perms['data'][0]['publish_stream'])) { $fb_user_data = array('fb_uid' => $fb_user['id'], 'username' => $fb_user['username'], 'activation_time' => time()); fb_update_user_meta($current_user->ID, 'fb_data', $fb_user_data); } else { fb_admin_dialog(sprintf(__('Facebook social publishing is enabled. %sLink your Facebook account to your WordPress account</a> to get full functionality, including adding new Posts to your Timeline.', 'facebook'), '<a href="#" onclick="authFacebook(); return false;">'), true); } } else { } }
function fb_subscribe_button_automatic($content) { $options = get_option('fb_options'); global $post; if (isset($post)) { if (isset($options['subscribe']['show_on_homepage'])) { $options['subscribe']['href'] = get_permalink($post->ID); } $fb_data = fb_get_user_meta(get_the_author_meta('ID'), 'fb_data', true); if (!$fb_data) { return $content; } $options['subscribe']['href'] = 'http://www.facebook.com/' . $fb_data['username']; $new_content = ''; if (isset($fb_data['username'])) { switch ($options['subscribe']['position']) { case 'top': $new_content = fb_get_subscribe_button($options['subscribe']) . $content; break; case 'bottom': $new_content = $content . fb_get_subscribe_button($options['subscribe']); break; case 'both': $new_content = fb_get_subscribe_button($options['subscribe']) . $content; $new_content .= fb_get_subscribe_button($options['subscribe']); break; } } $show_indiv = get_post_meta($post->ID, 'fb_social_plugin_settings_box_subscribe', true); if (is_home() && isset($options['subscribe']['show_on_homepage'])) { $content = $new_content; } elseif (('default' == $show_indiv || empty($show_indiv)) && isset($options['subscribe']['show_on'])) { if (is_page() && ($options['subscribe']['show_on'] == 'all pages' || $options['subscribe']['show_on'] == 'all posts and pages')) { $content = $new_content; } elseif (is_single() && ($options['subscribe']['show_on'] == 'all posts' || $options['subscribe']['show_on'] == 'all posts and pages')) { $content = $new_content; } } elseif ('show' == $show_indiv) { $content = $new_content; } } return $content; }
protected function getPersistentData($key, $default = false) { if (!in_array($key, self::$kSupportedKeys)) { self::errorLog('Unsupported key passed to getPersistentData.'); return $default; } return $usermeta = fb_get_user_meta(get_current_user_id(), $key, true); }