Ejemplo n.º 1
0
 * Remove data written by the Facebook plugin for WordPress after an administrative user clicks "Delete" from the plugin management page in the WordPress administrative interface (wp-admin).
 *
 * @since 1.1
 *
 * @todo post meta data
 */
// only execute as part of an uninstall script
if (!defined('WP_UNINSTALL_PLUGIN')) {
    exit;
}
// Facebook user helpers
if (!class_exists('Facebook_User')) {
    require_once dirname(__FILE__) . '/facebook-user.php';
}
// user data
$__user_id = get_current_user_id();
foreach (array('state', 'code', 'access_token', 'user_id', 'fb_data', 'facebook_timeline_disabled') as $meta_key) {
    Facebook_User::delete_user_meta($__user_id, $meta_key);
}
unset($__user_id);
// site options
$__options = array('fb_options', 'facebook_application', 'facebook_comments', 'facebook_comments_enabled', 'facebook_kid_directed_site', 'facebook_like_button', 'facebook_recommendations_bar', 'facebook_send_button', 'facebook_mentions', 'facebook_publish_page', 'facebook_follow_button', 'facebook_home_features', 'facebook_archive_features', 'facebook_migration_10', 'facebook_migration_115', 'facebook_migration_118');
$__public_post_types = get_post_types(array('public' => true));
foreach ($__public_post_types as $post_type) {
    $__options[] = 'facebook_' . $post_type . '_features';
}
unset($__public_post_types);
foreach ($__options as $option_name) {
    delete_option($option_name);
}
unset($__options);
 /**
  * Save custom user information
  *
  * @since 1.2
  * @param int $wordpress_user_id WordPress user identifier
  */
 public static function save_data($wordpress_user_id)
 {
     remove_filter('user_contactmethods', array('Facebook_User_Profile', 'user_contactmethods'), 1, 2);
     if (!($wordpress_user_id && current_user_can('edit_user', $wordpress_user_id))) {
         return;
     }
     if (isset($_POST['facebook_timeline']) && $_POST['facebook_timeline'] == '1') {
         if (!class_exists('Facebook_User')) {
             require_once dirname(dirname(__FILE__)) . '/facebook-user.php';
         }
         Facebook_User::delete_user_meta($wordpress_user_id, 'facebook_timeline_disabled');
         // delete if stored
     } else {
         if (!class_exists('Facebook_User')) {
             require_once dirname(dirname(__FILE__)) . '/facebook-user.php';
         }
         Facebook_User::update_user_meta($wordpress_user_id, 'facebook_timeline_disabled', '1');
     }
 }
Ejemplo n.º 3
0
 /**
  * Save custom user information.
  *
  * @since 1.2
  *
  * @uses current_user_can() current user must be able to edit the passed WordPress user ID
  * @param int $wordpress_user_id WordPress user identifier
  * @return void
  */
 public static function save_data($wordpress_user_id)
 {
     if (!($wordpress_user_id && current_user_can('edit_user', $wordpress_user_id))) {
         return;
     }
     // allow decoupling of a WordPress account and a Facebook account
     if (isset($_POST['facebook_remove'])) {
         // WordPress Facebook User helper functions
         if (!class_exists('Facebook_User')) {
             require_once dirname(dirname(__FILE__)) . '/facebook-user.php';
         }
         $facebook_user_id = Facebook_User::get_facebook_profile_id($wordpress_user_id);
         if ($facebook_user_id) {
             // delete mapped FBID and other data
             Facebook_User::delete_user_meta($wordpress_user_id, 'fb_data');
             // delete post to Timeline opt-in if stored
             Facebook_User::delete_user_meta($wordpress_user_id, 'facebook_timeline_disabled');
             // Load WP HTTP helpers
             if (!class_exists('Facebook_WP_Extend')) {
                 require_once dirname(dirname(__FILE__)) . '/includes/facebook-php-sdk/class-facebook-wp.php';
             }
             // Revoke connection to app and all permissions
             Facebook_WP_Extend::graph_api_with_app_access_token($facebook_user_id . '/permissions', 'DELETE');
         }
         unset($facebook_user_id);
         // no need to store any other Facebook data
         return;
     }
     if (isset($_POST['facebook_fbid']) && ctype_digit($_POST['facebook_fbid'])) {
         // WordPress Facebook User helper functions
         if (!class_exists('Facebook_User')) {
             require_once dirname(dirname(__FILE__)) . '/facebook-user.php';
         }
         try {
             $facebook_user = Facebook_User::get_facebook_user($_POST['facebook_fbid'], array('fields' => array('id', 'username', 'link', 'third_party_id')));
             if (isset($facebook_user['id'])) {
                 $facebook_user_data = array('fb_uid' => $facebook_user['id'], 'activation_time' => time());
                 if (!empty($facebook_user['username'])) {
                     $facebook_user_data['username'] = $facebook_user['username'];
                 }
                 if (!empty($facebook_user['link'])) {
                     $facebook_user_data['link'] = $facebook_user['link'];
                 }
                 if (!empty($facebook_user['third_party_id'])) {
                     $facebook_user_data['third_party_id'] = $facebook_user['third_party_id'];
                 }
                 Facebook_User::update_user_meta($wordpress_user_id, 'fb_data', $facebook_user_data);
                 unset($facebook_user_data);
             }
             unset($facebook_user);
         } catch (Exception $e) {
         }
     }
     if (isset($_POST['facebook_timeline']) && $_POST['facebook_timeline'] == '1') {
         // WordPress Facebook User helper functions
         if (!class_exists('Facebook_User')) {
             require_once dirname(dirname(__FILE__)) . '/facebook-user.php';
         }
         Facebook_User::delete_user_meta($wordpress_user_id, 'facebook_timeline_disabled');
         // delete if stored
     } else {
         // WordPress Facebook User helper functions
         if (!class_exists('Facebook_User')) {
             require_once dirname(dirname(__FILE__)) . '/facebook-user.php';
         }
         Facebook_User::update_user_meta($wordpress_user_id, 'facebook_timeline_disabled', '1');
     }
 }
 /**
  * Delete data persisted by the Facebook PHP SDK using WordPress-specific access method
  *
  * @since 1.0
  */
 protected function clearPersistentData($key)
 {
     if (!in_array($key, self::$kSupportedKeys)) {
         self::errorLog('Unsupported key passed to clearPersistentData.');
         return;
     }
     // load user functions
     if (!class_exists('Facebook_User')) {
         require_once dirname(dirname(dirname(__FILE__))) . '/facebook-user.php';
     }
     Facebook_User::delete_user_meta(get_current_user_id(), $key);
 }
Ejemplo n.º 5
0
 /**
  * Set the appropriate settings for each form component
  *
  * @since 1.1
  * @param array $options social publisher options
  * @return array clean option sets.
  */
 public static function sanitize_publish_options($options)
 {
     global $facebook;
     if (!is_array($options) || empty($options)) {
         return array();
     }
     if (!class_exists('Facebook_User')) {
         require_once dirname(dirname(__FILE__)) . '/facebook-user.php';
     }
     // publish to timeline is really a per-user setting, not a per-site setting
     // handle the special user case
     $user_meta_key = 'facebook_timeline_disabled';
     $current_user = wp_get_current_user();
     if (isset($options['author_timeline']) && $options['author_timeline'] == 1) {
         Facebook_User::delete_user_meta($current_user->ID, $user_meta_key);
     } else {
         Facebook_User::update_user_meta($current_user->ID, $user_meta_key, '1');
     }
     // is a new page chosen?
     // if the same page selected on new_page_timeline as currently stored don't overwrite the access token
     // it is possible multiple users can create content from the page but should not overwrite each other when editing the page without changing the target page
     if (isset($options['new_page_timeline'])) {
         $page_id = trim($options['new_page_timeline']);
         if (!$page_id && isset($options['page_timeline']['id'])) {
             delete_option(self::OPTION_PUBLISH_TO_PAGE);
         } else {
             if ($page_id && !(isset($options['page_timeline']['id']) && $options['page_timeline']['id'] == $options['new_page_timeline'])) {
                 $pages_for_current_user = self::get_publishable_pages_for_current_user();
                 foreach ($pages_for_current_user as $page) {
                     if (isset($page['id']) && $page['id'] === $page_id) {
                         self::update_publish_to_page($page);
                         break;
                     }
                 }
             }
         }
     }
     return false;
 }