Exemplo n.º 1
0
/**
 * 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 {
    }
}
Exemplo n.º 2
0
 /**
  * Provides the implementations of the inherited abstract
  * methods.  The implementation uses user meta to maintain
  * a store for authorization codes, user ids, CSRF states, and
  * access tokens.
  */
 protected function setPersistentData($key, $value)
 {
     if (!in_array($key, self::$kSupportedKeys)) {
         self::errorLog('Unsupported key passed to setPersistentData.');
         return;
     }
     //WP 3.0+
     fb_update_user_meta(get_current_user_id(), $key, $value);
 }