Skip to content
Browse files

Removed windows nasty line feeds

  • Loading branch information...
1 parent 9831e52 commit 4a31c145f1bf50f839139f1f439402d22c2f221c @loxK committed
Showing with 3,254 additions and 3,254 deletions.
  1. +145 −145 sfc-activity-feed-widget.php
  2. +333 −333 sfc-base.php
  3. +88 −88 sfc-bookmark-widget.php
  4. +169 −169 sfc-chicklet.php
  5. +354 −354 sfc-comments.php
  6. +94 −94 sfc-connect-widget.php
  7. +193 −193 sfc-fan-box-widget.php
  8. +87 −87 sfc-find.php
  9. +220 −220 sfc-like.php
  10. +117 −117 sfc-live-stream-widget.php
  11. +273 −273 sfc-login.php
  12. +436 −436 sfc-publish.php
  13. +173 −173 sfc-register.php
  14. +279 −279 sfc-share.php
  15. +122 −122 sfc-upcoming-widget.php
  16. +105 −105 sfc-user-status-widget.php
  17. +62 −62 sfc.php
  18. +4 −4 uninstall.php
View
290 sfc-activity-feed-widget.php
@@ -1,145 +1,145 @@
-<?php
-/*
-Plugin Name: SFC - Activity Feed Widget
-Plugin URI: http://ottopress.com/wordpress-plugins/simple-facebook-connect/
-Description: Create an Activity Feed for your sites sidebar.
-Author: Otto
-Version: 0.22
-Author URI: http://ottodestruct.com
-License: GPL2
-
- Copyright 2009-2010 Samuel Wood (email : otto@ottodestruct.com)
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License version 2,
- as published by the Free Software Foundation.
-
- You may NOT assume that you can use any other version of the GPL.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- The license for this software can likely be found here:
- http://www.gnu.org/licenses/gpl-2.0.html
-
-*/
-
-
-// checks for sfc on activation
-function sfc_activity_feed_activation_check(){
- if (function_exists('sfc_version')) {
- if (version_compare(sfc_version(), '0.18', '>=')) {
- return;
- }
- }
- deactivate_plugins(basename(__FILE__)); // Deactivate ourself
- wp_die(__('The base SFC plugin must be activated before this plugin will run.', 'sfc'));
-}
-register_activation_hook(__FILE__, 'sfc_activity_feed_activation_check');
-
-function get_sfc_activity_feed($args) {
- $args = wp_parse_args($args, array(
- 'header'=>'true',
- 'site'=>'',
- 'bordercolor'=>'000000',
- 'width'=>'260',
- 'height'=>'400',
- 'font'=>'lucida+grande',
- 'colorscheme'=>'light'));
- extract($args);
-
- if (empty($site)) $site = get_bloginfo('url');
-
- return "<p class='fb-activity-feed'><iframe src='http://www.facebook.com/plugins/activity.php?site={$site}&amp;width={$width}&amp;height={$height}&amp;header={$header}&amp;colorscheme={$colorscheme}&amp;font={$font}&amp;border_color={$bordercolor}' scrolling='no' frameborder='0' allowTransparency='true' style='border:none; overflow:hidden; width:{$width}px; height:{$height}px'></iframe></p>";
-}
-
-function sfc_activity_feed($args='') {
- echo get_sfc_activity_feed($args);
-}
-
-function sfc_activity_feed_shortcode($atts) {
- $args = shortcode_atts(array(
- 'header'=>'true',
- 'site'=>'',
- 'bordercolor'=>'000000',
- 'width'=>'260',
- 'height'=>'400',
- 'font'=>'lucida+grande',
- 'colorscheme'=>'light'), $atts);
-
- return get_sfc_activity_feed($args);
-}
-add_shortcode('fb-activity', 'sfc_activity_feed_shortcode');
-
-class SFC_Activity_Feed_Widget extends WP_Widget {
- function SFC_Activity_Feed_Widget() {
- $widget_ops = array('classname' => 'widget_sfc-activity-feed', 'description' => __('Facebook Activity Feed', 'sfc'));
- $this->WP_Widget('sfc-activity', __('Facebook Activity Feed (SFC)', 'sfc'), $widget_ops);
- }
-
- function widget($args, $instance) {
- extract( $args );
- $title = apply_filters('widget_title', $instance['title']);
- echo $before_widget;
- if ( $title ) echo $before_title . $title . $after_title;
- sfc_activity_feed($instance);
- echo $after_widget;
- }
-
- function update($new_instance, $old_instance) {
- $instance = $old_instance;
- $new_instance = wp_parse_args( (array) $new_instance, array( 'title' => '', 'width'=>260, 'height'=>400, 'bordercolor'=>'000000', 'font'=>'lucida+grande', 'colorscheme'=>'light') );
- $instance['title'] = strip_tags($new_instance['title']);
- $instance['width'] = intval($new_instance['width']);
- $instance['height'] = intval($new_instance['height']);
- $instance['bordercolor'] = strip_tags($new_instance['bordercolor']);
- $instance['colorscheme'] = strip_tags($new_instance['colorscheme']);
- $instance['font'] = strip_tags($new_instance['font']);
- return $instance;
- }
-
- function form($instance) {
- $instance = wp_parse_args( (array) $instance, array( 'title' => '', 'width'=>260, 'height'=>400, 'bordercolor'=>'000000', 'font'=>'lucida+grande', 'colorscheme'=>'light' ) );
- $title = strip_tags($instance['title']);
- $width = intval($instance['width']);
- $height = intval($instance['height']);
- $bordercolor = strip_tags($instance['bordercolor']);
- if (empty($bordercolor)) $bordercolor = '000000';
- $colorscheme = strip_tags($instance['colorscheme']);
- $font = strip_tags($instance['font']);
- ?>
-<p><label for="<?php echo $this->get_field_id('title'); ?>"><?php _e('Title:'); ?>
-<input class="widefat" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" type="text" value="<?php echo $title; ?>" />
-</label></p>
-<p><label for="<?php echo $this->get_field_id('width'); ?>"><?php _e('Width of the widget in pixels:', 'sfc'); ?>
-<input class="widefat" id="<?php echo $this->get_field_id('width'); ?>" name="<?php echo $this->get_field_name('width'); ?>" type="text" value="<?php echo $width; ?>" />
-</label></p>
-<p><label for="<?php echo $this->get_field_id('height'); ?>"><?php _e('Height of the widget in pixels:', 'sfc'); ?>
-<input class="widefat" id="<?php echo $this->get_field_id('height'); ?>" name="<?php echo $this->get_field_name('height'); ?>" type="text" value="<?php echo $height; ?>" />
-</label></p>
-<p><label for="<?php echo $this->get_field_id('bordercolor'); ?>"><?php _e('Border color:', 'sfc'); ?>
-<input class="widefat" id="<?php echo $this->get_field_id('bordercolor'); ?>" name="<?php echo $this->get_field_name('bordercolor'); ?>" type="text" value="<?php echo $bordercolor; ?>" />
-</label></p>
-<p><label for="<?php echo $this->get_field_id('colorscheme'); ?>"><?php _e('Color scheme:', 'sfc'); ?>
-<select name="<?php echo $this->get_field_name('colorscheme'); ?>" id="<?php echo $this->get_field_id('colorscheme'); ?>">
-<option value="light" <?php selected('light', $colorscheme); ?>><?php _e('light', 'sfc'); ?></option>
-<option value="dark" <?php selected('dark', $colorscheme); ?>><?php _e('dark', 'sfc'); ?></option>
-</select>
-</label></p>
-<p><label for="<?php echo $this->get_field_id('font'); ?>"><?php _e('Font:', 'sfc'); ?>
-<select name="<?php echo $this->get_field_name('font'); ?>" id="<?php echo $this->get_field_id('font'); ?>">
-<option value="arial" <?php selected('arial', $font); ?>>arial</option>
-<option value="lucide+grande" <?php selected('lucide+grande', $font); ?>>lucide grande</option>
-<option value="segoe+ui" <?php selected('segoe+ui', $font); ?>>segoe ui</option>
-<option value="tahoma" <?php selected('tahoma', $font); ?>>tahoma</option>
-<option value="trebuchet+ms" <?php selected('trebuchet+ms', $font); ?>>trebuchet ms</option>
-<option value="verdana" <?php selected('verdana', $font); ?>>verdana</option>
-</select>
-</label></p>
- <?php
- }
-}
-add_action('widgets_init', create_function('', 'return register_widget("SFC_Activity_Feed_Widget");'));
-
+<?php
+/*
+Plugin Name: SFC - Activity Feed Widget
+Plugin URI: http://ottopress.com/wordpress-plugins/simple-facebook-connect/
+Description: Create an Activity Feed for your sites sidebar.
+Author: Otto
+Version: 0.22
+Author URI: http://ottodestruct.com
+License: GPL2
+
+ Copyright 2009-2010 Samuel Wood (email : otto@ottodestruct.com)
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License version 2,
+ as published by the Free Software Foundation.
+
+ You may NOT assume that you can use any other version of the GPL.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ The license for this software can likely be found here:
+ http://www.gnu.org/licenses/gpl-2.0.html
+
+*/
+
+
+// checks for sfc on activation
+function sfc_activity_feed_activation_check(){
+ if (function_exists('sfc_version')) {
+ if (version_compare(sfc_version(), '0.18', '>=')) {
+ return;
+ }
+ }
+ deactivate_plugins(basename(__FILE__)); // Deactivate ourself
+ wp_die(__('The base SFC plugin must be activated before this plugin will run.', 'sfc'));
+}
+register_activation_hook(__FILE__, 'sfc_activity_feed_activation_check');
+
+function get_sfc_activity_feed($args) {
+ $args = wp_parse_args($args, array(
+ 'header'=>'true',
+ 'site'=>'',
+ 'bordercolor'=>'000000',
+ 'width'=>'260',
+ 'height'=>'400',
+ 'font'=>'lucida+grande',
+ 'colorscheme'=>'light'));
+ extract($args);
+
+ if (empty($site)) $site = get_bloginfo('url');
+
+ return "<p class='fb-activity-feed'><iframe src='http://www.facebook.com/plugins/activity.php?site={$site}&amp;width={$width}&amp;height={$height}&amp;header={$header}&amp;colorscheme={$colorscheme}&amp;font={$font}&amp;border_color={$bordercolor}' scrolling='no' frameborder='0' allowTransparency='true' style='border:none; overflow:hidden; width:{$width}px; height:{$height}px'></iframe></p>";
+}
+
+function sfc_activity_feed($args='') {
+ echo get_sfc_activity_feed($args);
+}
+
+function sfc_activity_feed_shortcode($atts) {
+ $args = shortcode_atts(array(
+ 'header'=>'true',
+ 'site'=>'',
+ 'bordercolor'=>'000000',
+ 'width'=>'260',
+ 'height'=>'400',
+ 'font'=>'lucida+grande',
+ 'colorscheme'=>'light'), $atts);
+
+ return get_sfc_activity_feed($args);
+}
+add_shortcode('fb-activity', 'sfc_activity_feed_shortcode');
+
+class SFC_Activity_Feed_Widget extends WP_Widget {
+ function SFC_Activity_Feed_Widget() {
+ $widget_ops = array('classname' => 'widget_sfc-activity-feed', 'description' => __('Facebook Activity Feed', 'sfc'));
+ $this->WP_Widget('sfc-activity', __('Facebook Activity Feed (SFC)', 'sfc'), $widget_ops);
+ }
+
+ function widget($args, $instance) {
+ extract( $args );
+ $title = apply_filters('widget_title', $instance['title']);
+ echo $before_widget;
+ if ( $title ) echo $before_title . $title . $after_title;
+ sfc_activity_feed($instance);
+ echo $after_widget;
+ }
+
+ function update($new_instance, $old_instance) {
+ $instance = $old_instance;
+ $new_instance = wp_parse_args( (array) $new_instance, array( 'title' => '', 'width'=>260, 'height'=>400, 'bordercolor'=>'000000', 'font'=>'lucida+grande', 'colorscheme'=>'light') );
+ $instance['title'] = strip_tags($new_instance['title']);
+ $instance['width'] = intval($new_instance['width']);
+ $instance['height'] = intval($new_instance['height']);
+ $instance['bordercolor'] = strip_tags($new_instance['bordercolor']);
+ $instance['colorscheme'] = strip_tags($new_instance['colorscheme']);
+ $instance['font'] = strip_tags($new_instance['font']);
+ return $instance;
+ }
+
+ function form($instance) {
+ $instance = wp_parse_args( (array) $instance, array( 'title' => '', 'width'=>260, 'height'=>400, 'bordercolor'=>'000000', 'font'=>'lucida+grande', 'colorscheme'=>'light' ) );
+ $title = strip_tags($instance['title']);
+ $width = intval($instance['width']);
+ $height = intval($instance['height']);
+ $bordercolor = strip_tags($instance['bordercolor']);
+ if (empty($bordercolor)) $bordercolor = '000000';
+ $colorscheme = strip_tags($instance['colorscheme']);
+ $font = strip_tags($instance['font']);
+ ?>
+<p><label for="<?php echo $this->get_field_id('title'); ?>"><?php _e('Title:'); ?>
+<input class="widefat" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" type="text" value="<?php echo $title; ?>" />
+</label></p>
+<p><label for="<?php echo $this->get_field_id('width'); ?>"><?php _e('Width of the widget in pixels:', 'sfc'); ?>
+<input class="widefat" id="<?php echo $this->get_field_id('width'); ?>" name="<?php echo $this->get_field_name('width'); ?>" type="text" value="<?php echo $width; ?>" />
+</label></p>
+<p><label for="<?php echo $this->get_field_id('height'); ?>"><?php _e('Height of the widget in pixels:', 'sfc'); ?>
+<input class="widefat" id="<?php echo $this->get_field_id('height'); ?>" name="<?php echo $this->get_field_name('height'); ?>" type="text" value="<?php echo $height; ?>" />
+</label></p>
+<p><label for="<?php echo $this->get_field_id('bordercolor'); ?>"><?php _e('Border color:', 'sfc'); ?>
+<input class="widefat" id="<?php echo $this->get_field_id('bordercolor'); ?>" name="<?php echo $this->get_field_name('bordercolor'); ?>" type="text" value="<?php echo $bordercolor; ?>" />
+</label></p>
+<p><label for="<?php echo $this->get_field_id('colorscheme'); ?>"><?php _e('Color scheme:', 'sfc'); ?>
+<select name="<?php echo $this->get_field_name('colorscheme'); ?>" id="<?php echo $this->get_field_id('colorscheme'); ?>">
+<option value="light" <?php selected('light', $colorscheme); ?>><?php _e('light', 'sfc'); ?></option>
+<option value="dark" <?php selected('dark', $colorscheme); ?>><?php _e('dark', 'sfc'); ?></option>
+</select>
+</label></p>
+<p><label for="<?php echo $this->get_field_id('font'); ?>"><?php _e('Font:', 'sfc'); ?>
+<select name="<?php echo $this->get_field_name('font'); ?>" id="<?php echo $this->get_field_id('font'); ?>">
+<option value="arial" <?php selected('arial', $font); ?>>arial</option>
+<option value="lucide+grande" <?php selected('lucide+grande', $font); ?>>lucide grande</option>
+<option value="segoe+ui" <?php selected('segoe+ui', $font); ?>>segoe ui</option>
+<option value="tahoma" <?php selected('tahoma', $font); ?>>tahoma</option>
+<option value="trebuchet+ms" <?php selected('trebuchet+ms', $font); ?>>trebuchet ms</option>
+<option value="verdana" <?php selected('verdana', $font); ?>>verdana</option>
+</select>
+</label></p>
+ <?php
+ }
+}
+add_action('widgets_init', create_function('', 'return register_widget("SFC_Activity_Feed_Widget");'));
+
View
666 sfc-base.php
@@ -1,333 +1,333 @@
-<?php
-/*
- * This is the main code for the SFC Base system. It's included by the main "Simple Facebook Connect" plugin.
- */
-
-// Load the textdomain
-load_plugin_textdomain('sfc', false, dirname(plugin_basename(__FILE__)));
-
-// load the FB script into the head
-add_action('wp_enqueue_scripts','sfc_featureloader');
-function sfc_featureloader() {
- if ($_SERVER['HTTPS'] == 'on')
- wp_enqueue_script( 'fb-featureloader', 'https://ssl.connect.facebook.com/js/api_lib/v0.4/FeatureLoader.js.php/'.get_locale(), array(), '0.4', false);
- else
- wp_enqueue_script( 'fb-featureloader', 'http://static.ak.connect.facebook.com/js/api_lib/v0.4/FeatureLoader.js.php/'.get_locale(), array(), '0.4', false);
-
- //wp_enqueue_script( 'fb-all', 'http://connect.facebook.net/en_US/all.js', array(), '1', false);
-}
-
-// fix up the html tag to have the FBML extensions
-add_filter('language_attributes','sfc_lang_atts');
-function sfc_lang_atts($lang) {
- return ' xmlns:fb="http://www.facebook.com/2008/fbml" xmlns:og="http://opengraphprotocol.org/schema/" '.$lang;
-}
-
-// basic XFBML load into footer
-add_action('wp_footer','sfc_add_base_js',20); // 20, to put it at the end of the footer insertions. sub-plugins should use 30 for their code
-function sfc_add_base_js() {
- $options = get_option('sfc_options');
- sfc_load_api($options['api_key']);
-};
-
-function sfc_load_api($key) {
-$reload = apply_filters('sfc_reload_state_change',false);
-
-$sets['permsToRequestOnConnect']='email';
-if ($reload) $sets['reloadIfSessionStateChanged'] = true;
-?>
-<script type="text/javascript">
-FB_RequireFeatures(["XFBML"], function() {
- FB.init("<?php echo $key; ?>", "<?php bloginfo('url'); ?>/?xd_receiver=1", <?php echo json_encode($sets); ?>);
-});
-</script>
-<?php
-}
-
-// plugin row links
-add_filter('plugin_row_meta', 'sfc_donate_link', 10, 2);
-function sfc_donate_link($links, $file) {
- if ($file == plugin_basename(__FILE__)) {
- $links[] = '<a href="'.admin_url('options-general.php?page=sfc').'">'.__('Settings', 'sfc').'</a>';
- $links[] = '<a href="https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=otto%40ottodestruct%2ecom">'.__('Donate', 'sfc').'</a>';
- }
- return $links;
-}
-
-// action links
-add_filter('plugin_action_links_'.plugin_basename(__FILE__), 'sfc_settings_link', 10, 1);
-function sfc_settings_link($links) {
- $links[] = '<a href="'.admin_url('options-general.php?page=sfc').'">'.__('Settings', 'sfc').'</a>';
- return $links;
-}
-
-// add the admin settings and such
-add_action('admin_init', 'sfc_admin_init',9); // 9 to force it first, subplugins should use default
-function sfc_admin_init(){
- $options = get_option('sfc_options');
- if (empty($options['api_key']) || empty($options['app_secret']) || empty($options['appid'])) {
- add_action('admin_notices', create_function( '', "echo '<div class=\"error\"><p>".sprintf(__('Simple Facebook Connect needs configuration information on its <a href="%s">settings</a> page.', 'sfc'), admin_url('options-general.php?page=sfc'))."</p></div>';" ) );
- } else {
- sfc_featureloader();
- add_action('admin_footer','sfc_add_base_js',20);
- }
- wp_enqueue_script('jquery');
- register_setting( 'sfc_options', 'sfc_options', 'sfc_options_validate' );
- add_settings_section('sfc_main', __('Main Settings', 'sfc'), 'sfc_section_text', 'sfc');
- if (!defined('SFC_API_KEY')) add_settings_field('sfc_api_key', __('Facebook API Key', 'sfc'), 'sfc_setting_api_key', 'sfc', 'sfc_main');
- if (!defined('SFC_APP_SECRET')) add_settings_field('sfc_app_secret', __('Facebook Application Secret', 'sfc'), 'sfc_setting_app_secret', 'sfc', 'sfc_main');
- if (!defined('SFC_APP_ID')) add_settings_field('sfc_appid', __('Facebook Application ID', 'sfc'), 'sfc_setting_appid', 'sfc', 'sfc_main');
- if (!defined('SFC_FANPAGE')) add_settings_field('sfc_fanpage', __('Facebook Fan Page', 'sfc'), 'sfc_setting_fanpage', 'sfc', 'sfc_main');
-}
-
-// add the admin options page
-add_action('admin_menu', 'sfc_admin_add_page');
-function sfc_admin_add_page() {
- $mypage = add_options_page(__('Simple Facebook Connect', 'sfc'), __('Simple Facebook Connect', 'sfc'), 'manage_options', 'sfc', 'sfc_options_page');
-}
-
-// display the admin options page
-function sfc_options_page() {
-?>
- <div class="wrap">
- <h2><?php _e('Simple Facebook Connect', 'sfc'); ?></h2>
- <p><?php _e('Options relating to the Simple Facebook Connect plugins.', 'sfc'); ?> </p>
- <form method="post" action="options.php">
- <?php settings_fields('sfc_options'); ?>
- <table><tr><td>
- <?php do_settings_sections('sfc'); ?>
- </td><td style='vertical-align:top;'>
- <div style='width:20em; float:right; background: #ffc; border: 1px solid #333; margin: 2px; padding: 5px'>
- <h3 align='center'><?php _e('About the Author', 'sfc'); ?></h3>
- <p><a href="http://ottopress.com/blog/wordpress-plugins/simple-facebook-connect/">Simple Facebook Connect</a> is developed and maintained by <a href="http://ottodestruct.com">Otto</a>.</p>
- <p>He blogs at <a href="http://ottodestruct.com">Nothing To See Here</a> and <a href="http://ottopress.com">Otto on WordPress</a>, posts photos on <a href="http://www.flickr.com/photos/otto42/">Flickr</a>, and chats on <a href="http://twitter.com/otto42">Twitter</a>.</p>
- <p>You can follow his site on either <a href="http://www.facebook.com/apps/application.php?id=116002660893">Facebook</a> or <a href="http://twitter.com/ottodestruct">Twitter</a>, if you like.</p>
- <p>If you'd like to <a href="https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=otto%40ottodestruct%2ecom">buy him a beer</a>, then he'd be perfectly happy to drink it.</p>
- </div>
-
- <div style='width:20em; float:right; background: #fff; border: 1px solid #333; margin: 2px; padding: 5px'>
- <h3 align='center'><?php _e('Facebook Platform Status', 'sfc'); ?></h3>
- <?php @wp_widget_rss_output('http://www.facebook.com/feeds/api_messages.php',array('show_date' => 1, 'items' => 10) ); ?>
- </div>
- </td></tr></table>
- <p class="submit">
- <input type="submit" name="Submit" class="button-primary" value="<?php esc_attr_e('Save Changes') ?>" />
- </p>
- </form>
- </div>
-
-<?php
-}
-
-function sfc_section_text() {
- $options = get_option('sfc_options');
- if (empty($options['api_key']) || empty($options['app_secret']) || empty($options['appid'])) {
-?>
-<p><?php _e('To connect your site to Facebook, you will need a Facebook Application.
-If you have already created one, please insert your API key, Application Secret, and Application ID below.', 'sfc'); ?></p>
-<p><strong><?php _e('Can\'t find your key?', 'sfc'); ?></strong></p>
-<ol>
-<li><?php _e('Get a list of your applications from here: <a target="_blank" href="http://www.facebook.com/developers/apps.php">Facebook Application List</a>', 'sfc'); ?></li>
-<li><?php _e('Select the application you want, then copy and paste the API key, Application Secret, and Application ID from there.', 'sfc'); ?></li>
-</ol>
-
-<p><strong><?php _e('Haven\'t created an application yet?', 'sfc'); ?></strong> <?php _e('Don\'t worry, it\'s easy!', 'sfc'); ?></p>
-<ol>
-<li><?php _e('Go to this link to create your application: <a target="_blank" href="http://developers.facebook.com/setup.php">Facebook Connect Setup</a>', 'sfc'); ?></li>
-<li><?php _e('When it tells you to "Upload a file" on step 2, just hit the "Upload Later" button. This plugin takes care of that part for you!', 'sfc'); ?></li>
-<li><?php _e('On the final screen, there will be an API Key field, in the yellow box. Copy and paste that information into here.', 'sfc'); ?></li>
-<li><?php _e('You can get the rest of the information from the application on the
-<a target="_blank" href="http://www.facebook.com/developers/apps.php">Facebook Application List</a> page.', 'sfc'); ?></li>
-<li><?php _e('Select the application you want, then copy and paste the API key, Application Secret, and Application ID from there.', 'sfc'); ?></li>
-</ol>
-<?php
- // look for an FBFoundations key if we dont have one of our own,
- // to better facilitate switching from that plugin to this one.
- $fbfoundations_settings = get_option('fbfoundations_settings');
- if (isset($fbfoundations_settings['api_key']) && !empty($fbfoundations_settings['api_key'])) {
- $options['api_key'] = $fbfoundations_settings['api_key'];
- }
- } else {
-
- // load facebook platform
- include_once 'facebook-platform/facebook.php';
- $fb=new Facebook($options['api_key'], $options['app_secret']);
-
- $error = false;
-
- try {
- $a = $fb->api_client->admin_getAppProperties(array('connect_url'));
- } catch (Exception $e) {
- // bad API key or secret or something
- $error=true;
- echo '<p class="error">'.__('Facebook doesn\'t like your settings, it says:', 'sfc').' ' . $e->getMessage() . '.</p>';
- }
-
- if (is_array($a)) {
- $connecturl = $a['connect_url'];
- } else if (is_object($a)) { // seems to happen on some setups.. dunno why.
- $connecturl = $a->connect_url;
- }
-
- if (!SFC_IGNORE_ERRORS && !empty($connecturl)) {
- $siteurl = trailingslashit(get_option('siteurl'));
- if (@strpos($siteurl, $connecturl) === false) {
- $error = true;
- echo '<p class="error">';
- sprintf(__('Your Facebook Application\'s "Connect URL" is configured incorrectly. It is currently set to %1$s when it should be set to "%2$s"', 'sfc'), $connecturl, $siteurl);
- echo '.</p>';
- }
-
- if ($error) {
-?>
-<p class="error"><?php sprintf(__('To correct these errors, you may need to <a href="http://www.facebook.com/developers/editapp.php?app_id=%s">edit your applications settings</a> and correct the values therein. The site will not work properly until the errors are corrected.', 'sfc'), $options['appid']); ?></p>
-<?php
- }
- }
- }
-}
-
-// this will override all the main options if they are pre-defined
-function sfc_override_options($options) {
- if (defined('SFC_API_KEY')) $options['api_key'] = SFC_API_KEY;
- if (defined('SFC_APP_SECRET')) $options['app_secret'] = SFC_APP_SECRET;
- if (defined('SFC_APP_ID')) $options['appid'] = SFC_APP_ID;
- if (defined('SFC_FANPAGE')) $options['fanpage'] = SFC_FANPAGE;
- return $options;
-}
-add_filter('option_sfc_options', 'sfc_override_options');
-
-function sfc_setting_api_key() {
- if (defined('SFC_API_KEY')) return;
- $options = get_option('sfc_options');
- echo "<input type='text' id='sfcapikey' name='sfc_options[api_key]' value='{$options['api_key']}' size='40' /> ";
- _e('(required)', 'sfc');
-}
-function sfc_setting_app_secret() {
- if (defined('SFC_APP_SECRET')) return;
- $options = get_option('sfc_options');
- echo "<input type='text' id='sfcappsecret' name='sfc_options[app_secret]' value='{$options['app_secret']}' size='40' /> ";
- _e('(required)', 'sfc');
-}
-function sfc_setting_appid() {
- if (defined('SFC_APP_ID')) return;
- $options = get_option('sfc_options');
- echo "<input type='text' id='sfcappid' name='sfc_options[appid]' value='{$options['appid']}' size='40' /> ";
- _e('(required)', 'sfc');
- if (!empty($options['appid'])) printf(__('<p>Here is a <a href=\'http://www.facebook.com/apps/application.php?id=%s&amp;v=wall\'>link to your applications wall</a>. There you can give it a name, upload a profile picture, things like that. Look for the "Edit Application" link to modify the application.</p>', 'sfc'), $options['appid']);
-}
-function sfc_setting_fanpage() {
- if (defined('SFC_FANPAGE')) return;
- $options = get_option('sfc_options'); ?>
-
-<p><?php _e('Some sites use Fan Pages on Facebook to connect with their users. The Application wall acts as a
-Fan Page in all respects, however some sites have been using Fan Pages previously, and already have
-communities and content built around them. Facebook offers no way to migrate these, so the option to
-use an existing Fan Page is offered for people with this situation. Note that this doesn\'t <em>replace</em>
-the application, as that is not optional. However, you can use a Fan Page for specific parts of the
-SFC plugin, such as the Fan Box, the Publisher, and the Chicklet.', 'sfc'); ?></p>
-
-<p><?php _e('If you have a <a href="http://www.facebook.com/pages/manage/">Fan Page</a> that you want to use for
-your site, enter the ID of the page here. Most users should leave this blank.', 'sfc'); ?></p>
-
-<?php
- echo "<input type='text' id='sfcfanpage' name='sfc_options[fanpage]' value='{$options['fanpage']}' size='40' />";
-}
-
-// validate our options
-function sfc_options_validate($input) {
- if (!defined('SFC_API_KEY')) {
- // api keys are 32 bytes long and made of hex values
- $input['api_key'] = trim($input['api_key']);
- if(! preg_match('/^[a-f0-9]{32}$/i', $input['api_key'])) {
- $input['api_key'] = '';
- }
- }
-
- if (!defined('SFC_APP_SECRET')) {
- // api keys are 32 bytes long and made of hex values
- $input['app_secret'] = trim($input['app_secret']);
- if(! preg_match('/^[a-f0-9]{32}$/i', $input['app_secret'])) {
- $input['app_secret'] = '';
- }
- }
-
- if (!defined('SFC_APP_ID')) {
- // app ids are big integers
- $input['appid'] = trim($input['appid']);
- if(! preg_match('/^[0-9]+$/i', $input['appid'])) {
- $input['appid'] = '';
- }
- }
-
- if (!defined('SFC_FANPAGE')) {
- // fanpage ids are big integers
- $input['fanpage'] = trim($input['fanpage']);
- if(! preg_match('/^[0-9]+$/i', $input['fanpage'])) {
- $input['fanpage'] = '';
- }
- }
-
- $input = apply_filters('sfc_validate_options',$input); // filter to let sub-plugins validate their options too
- return $input;
-}
-
-
-// this adds the app id to allow you to use Facebook Insights on your domain, linked to your application.
-add_action('wp_head','sfc_meta_head');
-function sfc_meta_head() {
- $options = get_option('sfc_options');
-
- if ($options['appid']) {
- ?>
-<meta property='fb:app_id' content='<?php echo $options['appid']; ?>' />
-<?php
- }
- ?>
-<meta property="og:site_name" content="<?php bloginfo('name'); ?>" />
-<?php
- if ( is_singular() ) {
- global $wp_the_query;
- if ( $id = $wp_the_query->get_queried_object_id() ) {
- $link = get_permalink( $id );
- echo "<meta property='og:url' content='{$link}' />\n";
- }
- } else if (is_home()) {
- $link = get_bloginfo('url');
- echo "<meta property='og:url' content='{$link}' />\n";
- }
-}
-
-
-// this function checks if the current FB user is a fan of your page.
-// Returns true if they are, false otherwise.
-function sfc_is_fan($pageid='0') {
- $options = get_option('sfc_options');
-
- if ($pageid == '0') {
- if ($options['fanpage']) $pageid = $options['fanpage'];
- else $pageid = $options['appid'];
- }
-
- include_once 'facebook-platform/facebook.php';
- $fb=new Facebook($options['api_key'], $options['app_secret']);
-
- $fbuid=$fb->get_loggedin_user();
-
- if (!$fbuid) return false;
-
- if ($fb->api_client->pages_isFan($pageid) ) {
- return true;
- } else {
- return false;
- }
-}
-
-// get the current facebook user number (0 if the user is not connected to this site)
-function sfc_get_user() {
- $options = get_option('sfc_options');
- include_once 'facebook-platform/facebook.php';
- $fb=new Facebook($options['api_key'], $options['app_secret']);
- $fbuid=$fb->get_loggedin_user();
- return $fbuid;
-}
+<?php
+/*
+ * This is the main code for the SFC Base system. It's included by the main "Simple Facebook Connect" plugin.
+ */
+
+// Load the textdomain
+load_plugin_textdomain('sfc', false, dirname(plugin_basename(__FILE__)));
+
+// load the FB script into the head
+add_action('wp_enqueue_scripts','sfc_featureloader');
+function sfc_featureloader() {
+ if ($_SERVER['HTTPS'] == 'on')
+ wp_enqueue_script( 'fb-featureloader', 'https://ssl.connect.facebook.com/js/api_lib/v0.4/FeatureLoader.js.php/'.get_locale(), array(), '0.4', false);
+ else
+ wp_enqueue_script( 'fb-featureloader', 'http://static.ak.connect.facebook.com/js/api_lib/v0.4/FeatureLoader.js.php/'.get_locale(), array(), '0.4', false);
+
+ //wp_enqueue_script( 'fb-all', 'http://connect.facebook.net/en_US/all.js', array(), '1', false);
+}
+
+// fix up the html tag to have the FBML extensions
+add_filter('language_attributes','sfc_lang_atts');
+function sfc_lang_atts($lang) {
+ return ' xmlns:fb="http://www.facebook.com/2008/fbml" xmlns:og="http://opengraphprotocol.org/schema/" '.$lang;
+}
+
+// basic XFBML load into footer
+add_action('wp_footer','sfc_add_base_js',20); // 20, to put it at the end of the footer insertions. sub-plugins should use 30 for their code
+function sfc_add_base_js() {
+ $options = get_option('sfc_options');
+ sfc_load_api($options['api_key']);
+};
+
+function sfc_load_api($key) {
+$reload = apply_filters('sfc_reload_state_change',false);
+
+$sets['permsToRequestOnConnect']='email';
+if ($reload) $sets['reloadIfSessionStateChanged'] = true;
+?>
+<script type="text/javascript">
+FB_RequireFeatures(["XFBML"], function() {
+ FB.init("<?php echo $key; ?>", "<?php bloginfo('url'); ?>/?xd_receiver=1", <?php echo json_encode($sets); ?>);
+});
+</script>
+<?php
+}
+
+// plugin row links
+add_filter('plugin_row_meta', 'sfc_donate_link', 10, 2);
+function sfc_donate_link($links, $file) {
+ if ($file == plugin_basename(__FILE__)) {
+ $links[] = '<a href="'.admin_url('options-general.php?page=sfc').'">'.__('Settings', 'sfc').'</a>';
+ $links[] = '<a href="https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=otto%40ottodestruct%2ecom">'.__('Donate', 'sfc').'</a>';
+ }
+ return $links;
+}
+
+// action links
+add_filter('plugin_action_links_'.plugin_basename(__FILE__), 'sfc_settings_link', 10, 1);
+function sfc_settings_link($links) {
+ $links[] = '<a href="'.admin_url('options-general.php?page=sfc').'">'.__('Settings', 'sfc').'</a>';
+ return $links;
+}
+
+// add the admin settings and such
+add_action('admin_init', 'sfc_admin_init',9); // 9 to force it first, subplugins should use default
+function sfc_admin_init(){
+ $options = get_option('sfc_options');
+ if (empty($options['api_key']) || empty($options['app_secret']) || empty($options['appid'])) {
+ add_action('admin_notices', create_function( '', "echo '<div class=\"error\"><p>".sprintf(__('Simple Facebook Connect needs configuration information on its <a href="%s">settings</a> page.', 'sfc'), admin_url('options-general.php?page=sfc'))."</p></div>';" ) );
+ } else {
+ sfc_featureloader();
+ add_action('admin_footer','sfc_add_base_js',20);
+ }
+ wp_enqueue_script('jquery');
+ register_setting( 'sfc_options', 'sfc_options', 'sfc_options_validate' );
+ add_settings_section('sfc_main', __('Main Settings', 'sfc'), 'sfc_section_text', 'sfc');
+ if (!defined('SFC_API_KEY')) add_settings_field('sfc_api_key', __('Facebook API Key', 'sfc'), 'sfc_setting_api_key', 'sfc', 'sfc_main');
+ if (!defined('SFC_APP_SECRET')) add_settings_field('sfc_app_secret', __('Facebook Application Secret', 'sfc'), 'sfc_setting_app_secret', 'sfc', 'sfc_main');
+ if (!defined('SFC_APP_ID')) add_settings_field('sfc_appid', __('Facebook Application ID', 'sfc'), 'sfc_setting_appid', 'sfc', 'sfc_main');
+ if (!defined('SFC_FANPAGE')) add_settings_field('sfc_fanpage', __('Facebook Fan Page', 'sfc'), 'sfc_setting_fanpage', 'sfc', 'sfc_main');
+}
+
+// add the admin options page
+add_action('admin_menu', 'sfc_admin_add_page');
+function sfc_admin_add_page() {
+ $mypage = add_options_page(__('Simple Facebook Connect', 'sfc'), __('Simple Facebook Connect', 'sfc'), 'manage_options', 'sfc', 'sfc_options_page');
+}
+
+// display the admin options page
+function sfc_options_page() {
+?>
+ <div class="wrap">
+ <h2><?php _e('Simple Facebook Connect', 'sfc'); ?></h2>
+ <p><?php _e('Options relating to the Simple Facebook Connect plugins.', 'sfc'); ?> </p>
+ <form method="post" action="options.php">
+ <?php settings_fields('sfc_options'); ?>
+ <table><tr><td>
+ <?php do_settings_sections('sfc'); ?>
+ </td><td style='vertical-align:top;'>
+ <div style='width:20em; float:right; background: #ffc; border: 1px solid #333; margin: 2px; padding: 5px'>
+ <h3 align='center'><?php _e('About the Author', 'sfc'); ?></h3>
+ <p><a href="http://ottopress.com/blog/wordpress-plugins/simple-facebook-connect/">Simple Facebook Connect</a> is developed and maintained by <a href="http://ottodestruct.com">Otto</a>.</p>
+ <p>He blogs at <a href="http://ottodestruct.com">Nothing To See Here</a> and <a href="http://ottopress.com">Otto on WordPress</a>, posts photos on <a href="http://www.flickr.com/photos/otto42/">Flickr</a>, and chats on <a href="http://twitter.com/otto42">Twitter</a>.</p>
+ <p>You can follow his site on either <a href="http://www.facebook.com/apps/application.php?id=116002660893">Facebook</a> or <a href="http://twitter.com/ottodestruct">Twitter</a>, if you like.</p>
+ <p>If you'd like to <a href="https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=otto%40ottodestruct%2ecom">buy him a beer</a>, then he'd be perfectly happy to drink it.</p>
+ </div>
+
+ <div style='width:20em; float:right; background: #fff; border: 1px solid #333; margin: 2px; padding: 5px'>
+ <h3 align='center'><?php _e('Facebook Platform Status', 'sfc'); ?></h3>
+ <?php @wp_widget_rss_output('http://www.facebook.com/feeds/api_messages.php',array('show_date' => 1, 'items' => 10) ); ?>
+ </div>
+ </td></tr></table>
+ <p class="submit">
+ <input type="submit" name="Submit" class="button-primary" value="<?php esc_attr_e('Save Changes') ?>" />
+ </p>
+ </form>
+ </div>
+
+<?php
+}
+
+function sfc_section_text() {
+ $options = get_option('sfc_options');
+ if (empty($options['api_key']) || empty($options['app_secret']) || empty($options['appid'])) {
+?>
+<p><?php _e('To connect your site to Facebook, you will need a Facebook Application.
+If you have already created one, please insert your API key, Application Secret, and Application ID below.', 'sfc'); ?></p>
+<p><strong><?php _e('Can\'t find your key?', 'sfc'); ?></strong></p>
+<ol>
+<li><?php _e('Get a list of your applications from here: <a target="_blank" href="http://www.facebook.com/developers/apps.php">Facebook Application List</a>', 'sfc'); ?></li>
+<li><?php _e('Select the application you want, then copy and paste the API key, Application Secret, and Application ID from there.', 'sfc'); ?></li>
+</ol>
+
+<p><strong><?php _e('Haven\'t created an application yet?', 'sfc'); ?></strong> <?php _e('Don\'t worry, it\'s easy!', 'sfc'); ?></p>
+<ol>
+<li><?php _e('Go to this link to create your application: <a target="_blank" href="http://developers.facebook.com/setup.php">Facebook Connect Setup</a>', 'sfc'); ?></li>
+<li><?php _e('When it tells you to "Upload a file" on step 2, just hit the "Upload Later" button. This plugin takes care of that part for you!', 'sfc'); ?></li>
+<li><?php _e('On the final screen, there will be an API Key field, in the yellow box. Copy and paste that information into here.', 'sfc'); ?></li>
+<li><?php _e('You can get the rest of the information from the application on the
+<a target="_blank" href="http://www.facebook.com/developers/apps.php">Facebook Application List</a> page.', 'sfc'); ?></li>
+<li><?php _e('Select the application you want, then copy and paste the API key, Application Secret, and Application ID from there.', 'sfc'); ?></li>
+</ol>
+<?php
+ // look for an FBFoundations key if we dont have one of our own,
+ // to better facilitate switching from that plugin to this one.
+ $fbfoundations_settings = get_option('fbfoundations_settings');
+ if (isset($fbfoundations_settings['api_key']) && !empty($fbfoundations_settings['api_key'])) {
+ $options['api_key'] = $fbfoundations_settings['api_key'];
+ }
+ } else {
+
+ // load facebook platform
+ include_once 'facebook-platform/facebook.php';
+ $fb=new Facebook($options['api_key'], $options['app_secret']);
+
+ $error = false;
+
+ try {
+ $a = $fb->api_client->admin_getAppProperties(array('connect_url'));
+ } catch (Exception $e) {
+ // bad API key or secret or something
+ $error=true;
+ echo '<p class="error">'.__('Facebook doesn\'t like your settings, it says:', 'sfc').' ' . $e->getMessage() . '.</p>';
+ }
+
+ if (is_array($a)) {
+ $connecturl = $a['connect_url'];
+ } else if (is_object($a)) { // seems to happen on some setups.. dunno why.
+ $connecturl = $a->connect_url;
+ }
+
+ if (!SFC_IGNORE_ERRORS && !empty($connecturl)) {
+ $siteurl = trailingslashit(get_option('siteurl'));
+ if (@strpos($siteurl, $connecturl) === false) {
+ $error = true;
+ echo '<p class="error">';
+ sprintf(__('Your Facebook Application\'s "Connect URL" is configured incorrectly. It is currently set to %1$s when it should be set to "%2$s"', 'sfc'), $connecturl, $siteurl);
+ echo '.</p>';
+ }
+
+ if ($error) {
+?>
+<p class="error"><?php sprintf(__('To correct these errors, you may need to <a href="http://www.facebook.com/developers/editapp.php?app_id=%s">edit your applications settings</a> and correct the values therein. The site will not work properly until the errors are corrected.', 'sfc'), $options['appid']); ?></p>
+<?php
+ }
+ }
+ }
+}
+
+// this will override all the main options if they are pre-defined
+function sfc_override_options($options) {
+ if (defined('SFC_API_KEY')) $options['api_key'] = SFC_API_KEY;
+ if (defined('SFC_APP_SECRET')) $options['app_secret'] = SFC_APP_SECRET;
+ if (defined('SFC_APP_ID')) $options['appid'] = SFC_APP_ID;
+ if (defined('SFC_FANPAGE')) $options['fanpage'] = SFC_FANPAGE;
+ return $options;
+}
+add_filter('option_sfc_options', 'sfc_override_options');
+
+function sfc_setting_api_key() {
+ if (defined('SFC_API_KEY')) return;
+ $options = get_option('sfc_options');
+ echo "<input type='text' id='sfcapikey' name='sfc_options[api_key]' value='{$options['api_key']}' size='40' /> ";
+ _e('(required)', 'sfc');
+}
+function sfc_setting_app_secret() {
+ if (defined('SFC_APP_SECRET')) return;
+ $options = get_option('sfc_options');
+ echo "<input type='text' id='sfcappsecret' name='sfc_options[app_secret]' value='{$options['app_secret']}' size='40' /> ";
+ _e('(required)', 'sfc');
+}
+function sfc_setting_appid() {
+ if (defined('SFC_APP_ID')) return;
+ $options = get_option('sfc_options');
+ echo "<input type='text' id='sfcappid' name='sfc_options[appid]' value='{$options['appid']}' size='40' /> ";
+ _e('(required)', 'sfc');
+ if (!empty($options['appid'])) printf(__('<p>Here is a <a href=\'http://www.facebook.com/apps/application.php?id=%s&amp;v=wall\'>link to your applications wall</a>. There you can give it a name, upload a profile picture, things like that. Look for the "Edit Application" link to modify the application.</p>', 'sfc'), $options['appid']);
+}
+function sfc_setting_fanpage() {
+ if (defined('SFC_FANPAGE')) return;
+ $options = get_option('sfc_options'); ?>
+
+<p><?php _e('Some sites use Fan Pages on Facebook to connect with their users. The Application wall acts as a
+Fan Page in all respects, however some sites have been using Fan Pages previously, and already have
+communities and content built around them. Facebook offers no way to migrate these, so the option to
+use an existing Fan Page is offered for people with this situation. Note that this doesn\'t <em>replace</em>
+the application, as that is not optional. However, you can use a Fan Page for specific parts of the
+SFC plugin, such as the Fan Box, the Publisher, and the Chicklet.', 'sfc'); ?></p>
+
+<p><?php _e('If you have a <a href="http://www.facebook.com/pages/manage/">Fan Page</a> that you want to use for
+your site, enter the ID of the page here. Most users should leave this blank.', 'sfc'); ?></p>
+
+<?php
+ echo "<input type='text' id='sfcfanpage' name='sfc_options[fanpage]' value='{$options['fanpage']}' size='40' />";
+}
+
+// validate our options
+function sfc_options_validate($input) {
+ if (!defined('SFC_API_KEY')) {
+ // api keys are 32 bytes long and made of hex values
+ $input['api_key'] = trim($input['api_key']);
+ if(! preg_match('/^[a-f0-9]{32}$/i', $input['api_key'])) {
+ $input['api_key'] = '';
+ }
+ }
+
+ if (!defined('SFC_APP_SECRET')) {
+ // api keys are 32 bytes long and made of hex values
+ $input['app_secret'] = trim($input['app_secret']);
+ if(! preg_match('/^[a-f0-9]{32}$/i', $input['app_secret'])) {
+ $input['app_secret'] = '';
+ }
+ }
+
+ if (!defined('SFC_APP_ID')) {
+ // app ids are big integers
+ $input['appid'] = trim($input['appid']);
+ if(! preg_match('/^[0-9]+$/i', $input['appid'])) {
+ $input['appid'] = '';
+ }
+ }
+
+ if (!defined('SFC_FANPAGE')) {
+ // fanpage ids are big integers
+ $input['fanpage'] = trim($input['fanpage']);
+ if(! preg_match('/^[0-9]+$/i', $input['fanpage'])) {
+ $input['fanpage'] = '';
+ }
+ }
+
+ $input = apply_filters('sfc_validate_options',$input); // filter to let sub-plugins validate their options too
+ return $input;
+}
+
+
+// this adds the app id to allow you to use Facebook Insights on your domain, linked to your application.
+add_action('wp_head','sfc_meta_head');
+function sfc_meta_head() {
+ $options = get_option('sfc_options');
+
+ if ($options['appid']) {
+ ?>
+<meta property='fb:app_id' content='<?php echo $options['appid']; ?>' />
+<?php
+ }
+ ?>
+<meta property="og:site_name" content="<?php bloginfo('name'); ?>" />
+<?php
+ if ( is_singular() ) {
+ global $wp_the_query;
+ if ( $id = $wp_the_query->get_queried_object_id() ) {
+ $link = get_permalink( $id );
+ echo "<meta property='og:url' content='{$link}' />\n";
+ }
+ } else if (is_home()) {
+ $link = get_bloginfo('url');
+ echo "<meta property='og:url' content='{$link}' />\n";
+ }
+}
+
+
+// this function checks if the current FB user is a fan of your page.
+// Returns true if they are, false otherwise.
+function sfc_is_fan($pageid='0') {
+ $options = get_option('sfc_options');
+
+ if ($pageid == '0') {
+ if ($options['fanpage']) $pageid = $options['fanpage'];
+ else $pageid = $options['appid'];
+ }
+
+ include_once 'facebook-platform/facebook.php';
+ $fb=new Facebook($options['api_key'], $options['app_secret']);
+
+ $fbuid=$fb->get_loggedin_user();
+
+ if (!$fbuid) return false;
+
+ if ($fb->api_client->pages_isFan($pageid) ) {
+ return true;
+ } else {
+ return false;
+ }
+}
+
+// get the current facebook user number (0 if the user is not connected to this site)
+function sfc_get_user() {
+ $options = get_option('sfc_options');
+ include_once 'facebook-platform/facebook.php';
+ $fb=new Facebook($options['api_key'], $options['app_secret']);
+ $fbuid=$fb->get_loggedin_user();
+ return $fbuid;
+}
View
176 sfc-bookmark-widget.php
@@ -1,88 +1,88 @@
-<?php
-/*
-Plugin Name: SFC - Bookmark Widget
-Plugin URI: http://ottopress.com/wordpress-plugins/simple-facebook-connect/
-Description: Shows a "Add Bookmark" button in the sidebar which allows users to add the site to their bookmark bar in Facebook.
-Author: Otto
-Version: 0.22
-Author URI: http://ottodestruct.com
-License: GPL2
-
- Copyright 2009-2010 Samuel Wood (email : otto@ottodestruct.com)
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License version 2,
- as published by the Free Software Foundation.
-
- You may NOT assume that you can use any other version of the GPL.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- The license for this software can likely be found here:
- http://www.gnu.org/licenses/gpl-2.0.html
-
-*/
-
-// checks for sfc on activation
-function sfc_bookmark_widget_activation_check(){
- if (function_exists('sfc_version')) {
- if (version_compare(sfc_version(), '0.4', '>=')) {
- return;
- }
- }
- deactivate_plugins(basename(__FILE__)); // Deactivate ourself
- wp_die(__('The base SFC plugin must be activated before this plugin will run.', 'sfc'));
-}
-register_activation_hook(__FILE__, 'sfc_bookmark_widget_activation_check');
-
-function get_sfc_bookmark($args='') {
- return '<fb:bookmark type="off-facebook"></fb:bookmark>';
-}
-
-function sfc_bookmark($args='') {
- echo get_sfc_bookmark();
-}
-
-function sfc_bookmark_shortcode($atts) {
- return get_sfc_bookmark();
-}
-add_shortcode('fb-bookmark', 'sfc_bookmark_shortcode');
-
-class SFC_Bookmark_Widget extends WP_Widget {
- function SFC_Bookmark_Widget() {
- $widget_ops = array('classname' => 'widget_sfc-bookmark', 'description' => __('Facebook Bookmark', 'sfc'));
- $this->WP_Widget('sfc-bookmark', __('Facebook Bookmark (SFC)', 'sfc'), $widget_ops);
- }
-
- function widget($args, $instance) {
- extract( $args );
- $title = apply_filters('widget_title', $instance['title']);
- ?>
- <?php echo $before_widget; ?>
- <?php if ( $title ) echo $before_title . $title . $after_title; ?>
- <?php sfc_bookmark(); ?>
- <?php echo $after_widget; ?>
- <?php
- }
-
- function update($new_instance, $old_instance) {
- $instance = $old_instance;
- $new_instance = wp_parse_args( (array) $new_instance, array( 'title' => '') );
- $instance['title'] = strip_tags($new_instance['title']);
- return $instance;
- }
-
- function form($instance) {
- $instance = wp_parse_args( (array) $instance, array( 'title' => '') );
- $title = strip_tags($instance['title']);
- ?>
-<p><label for="<?php echo $this->get_field_id('title'); ?>"><?php _e('Title:'); ?>
-<input class="widefat" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" type="text" value="<?php echo $title; ?>" />
-</label></p>
- <?php
- }
-}
-add_action('widgets_init', create_function('', 'return register_widget("SFC_Bookmark_Widget");'));
+<?php
+/*
+Plugin Name: SFC - Bookmark Widget
+Plugin URI: http://ottopress.com/wordpress-plugins/simple-facebook-connect/
+Description: Shows a "Add Bookmark" button in the sidebar which allows users to add the site to their bookmark bar in Facebook.
+Author: Otto
+Version: 0.22
+Author URI: http://ottodestruct.com
+License: GPL2
+
+ Copyright 2009-2010 Samuel Wood (email : otto@ottodestruct.com)
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License version 2,
+ as published by the Free Software Foundation.
+
+ You may NOT assume that you can use any other version of the GPL.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ The license for this software can likely be found here:
+ http://www.gnu.org/licenses/gpl-2.0.html
+
+*/
+
+// checks for sfc on activation
+function sfc_bookmark_widget_activation_check(){
+ if (function_exists('sfc_version')) {
+ if (version_compare(sfc_version(), '0.4', '>=')) {
+ return;
+ }
+ }
+ deactivate_plugins(basename(__FILE__)); // Deactivate ourself
+ wp_die(__('The base SFC plugin must be activated before this plugin will run.', 'sfc'));
+}
+register_activation_hook(__FILE__, 'sfc_bookmark_widget_activation_check');
+
+function get_sfc_bookmark($args='') {
+ return '<fb:bookmark type="off-facebook"></fb:bookmark>';
+}
+
+function sfc_bookmark($args='') {
+ echo get_sfc_bookmark();
+}
+
+function sfc_bookmark_shortcode($atts) {
+ return get_sfc_bookmark();
+}
+add_shortcode('fb-bookmark', 'sfc_bookmark_shortcode');
+
+class SFC_Bookmark_Widget extends WP_Widget {
+ function SFC_Bookmark_Widget() {
+ $widget_ops = array('classname' => 'widget_sfc-bookmark', 'description' => __('Facebook Bookmark', 'sfc'));
+ $this->WP_Widget('sfc-bookmark', __('Facebook Bookmark (SFC)', 'sfc'), $widget_ops);
+ }
+
+ function widget($args, $instance) {
+ extract( $args );
+ $title = apply_filters('widget_title', $instance['title']);
+ ?>
+ <?php echo $before_widget; ?>
+ <?php if ( $title ) echo $before_title . $title . $after_title; ?>
+ <?php sfc_bookmark(); ?>
+ <?php echo $after_widget; ?>
+ <?php
+ }
+
+ function update($new_instance, $old_instance) {
+ $instance = $old_instance;
+ $new_instance = wp_parse_args( (array) $new_instance, array( 'title' => '') );
+ $instance['title'] = strip_tags($new_instance['title']);
+ return $instance;
+ }
+
+ function form($instance) {
+ $instance = wp_parse_args( (array) $instance, array( 'title' => '') );
+ $title = strip_tags($instance['title']);
+ ?>
+<p><label for="<?php echo $this->get_field_id('title'); ?>"><?php _e('Title:'); ?>
+<input class="widefat" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" type="text" value="<?php echo $title; ?>" />
+</label></p>
+ <?php
+ }
+}
+add_action('widgets_init', create_function('', 'return register_widget("SFC_Bookmark_Widget");'));
View
338 sfc-chicklet.php
@@ -1,169 +1,169 @@
-<?php
-/*
-Plugin Name: SFC - Chicklet
-Plugin URI: http://ottopress.com/wordpress-plugins/simple-facebook-connect/
-Description: Creates a chicklet for showing fan count of your app/page on FB.
-Author: Otto
-Version: 0.22
-Author URI: http://ottodestruct.com
-License: GPL2
-
- Copyright 2009-2010 Samuel Wood (email : otto@ottodestruct.com)
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License version 2,
- as published by the Free Software Foundation.
-
- You may NOT assume that you can use any other version of the GPL.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- The license for this software can likely be found here:
- http://www.gnu.org/licenses/gpl-2.0.html
-
-*/
-
-define('SFC_FANCOUNT_CACHE',60*60); // 1 hour caching
-
-// checks for sfc on activation
-function sfc_chicklet_activation_check(){
- if (function_exists('sfc_version')) {
- if (version_compare(sfc_version(), '0.8', '>=')) {
- return;
- }
- }
- deactivate_plugins(basename(__FILE__)); // Deactivate ourself
- wp_die(__('The base SFC plugin must be activated before this plugin will run.', 'sfc'));
-}
-register_activation_hook(__FILE__, 'sfc_chicklet_activation_check');
-
-function sfc_chicklet($id = 0) {
- $options = get_option('sfc_options');
-
- if ($id == 0) {
- if ($options['fanpage']) $id = $options['fanpage'];
- else $id = $options['appid'];
- }
-
- $sfc_chicklet_fancount = get_transient('sfc_chicklet_fancount');
-
- if (!isset($sfc_chicklet_fancount[$id])) {
- include_once 'facebook-platform/facebook.php';
- $fb=new Facebook($options['api_key'], $options['app_secret']);
- $result = $fb->api_client->fql_query("SELECT fan_count, page_url FROM page WHERE page_id={$id}");
- if ($result) {
- $sfc_chicklet_fancount[$id] = $result[0];
- set_transient('sfc_chicklet_fancount',$sfc_chicklet_fancount,SFC_FANCOUNT_CACHE);
- }
- }
-
- if ($sfc_chicklet_fancount) {
- $fancount = $sfc_chicklet_fancount[$id]['fan_count'];
- $pageurl = $sfc_chicklet_fancount[$id]['page_url'];
- }
-
- global $sfc_chicklet_no_style;
- if (!$sfc_chicklet_no_style) {
-?>
-<style>
-.fanBoxChicklet {
- width:88px;
- height:17px;
- overflow:auto;
- background-color:#94bfbf;
- border-top: 1px solid #cefdfd;
- border-left: 1px solid #cefdfd;
- border-right: 1px solid #5f8586;
- border-bottom: 1px solid #5f8586;
- font: 11px/normal monospace, courier new, sans-serif;
- color:#59564f;
- margin: 0;
- padding: 0;
- text-align:right;
-}
-
-.fanBoxChicklet .quantity {
- width:auto;
- height:13px;
- min-width:40px;
- background-color:#cefdfd;
- border-top: 1px solid #8a8a8a;
- border-left: 1px solid #8a8a8a;
- border-right: 1px solid #fefffe;
- border-bottom: 1px solid #fefffe;
- padding: 2px;
- float: left;
- text-align: center;
- overflow: hidden;
- margin:1px 5px 0 0;
- padding:0;
-}
-
-.fanBoxChicklet .readerCaption {
- width:auto;
- float: left;
- text-align: center;
- vertical-align: middle;
- margin: 2px 0 0 0;
- padding: 0;
-}
-
-.fanBoxChicklet .feedCountLink {
- color:#59564f;
- text-decoration:none;
- margin:0;
- padding:0;
-}
-
-.fanBoxBy {
- width:88px;
- height:9px;
- font: 9px/normal monospace, courier new, sans-serif;
- color:#59564f;
-}
-</style>
-<?php } ?>
-<div class="fanBoxChicklet fanBoxChicklet-<?php echo $id; ?>">
-<p class="quantity"><?php echo $fancount; ?></p>
-<p class="readerCaption"><a href="<?php echo $pageurl; ?>" class="feedCountLink" target="_blank"><?php _e('Fans', 'sfc'); ?></a></p>
-</div>
-<div class="fanBoxBy"><?php _e('ON FACEBOOK', 'sfc'); ?></div>
-<?php
-}
-
-
-class SFC_Chicklet_Widget extends WP_Widget {
- function SFC_Chicklet_Widget() {
- $widget_ops = array('classname' => 'widget_sfc-chicklet', 'description' => __('Facebook Chicklet', 'sfc'));
- $this->WP_Widget('sfc-chicklet', __('Facebook Chicklet', 'sfc'), $widget_ops);
- }
-
- function widget($args, $instance) {
- extract( $args );
- $title = apply_filters('widget_title', $instance['title']);
- ?>
- <?php echo $before_widget; ?>
- <?php if ( $title ) echo $before_title . $title . $after_title; ?>
- <?php sfc_chicklet(); ?>
- <?php echo $after_widget; ?>
- <?php
- }
-
- function update($new_instance, $old_instance) {
- return $new_instance;
- }
-
- function form($instance) {
- $title = esc_attr($instance['title']);
- ?>
-<p><label for="<?php echo $this->get_field_id('title'); ?>"><?php _e('Title:'); ?>
-<input class="widefat" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" type="text" value="<?php echo $title; ?>" />
-</label></p>
- <?php
- }
-}
-add_action('widgets_init', create_function('', 'return register_widget("SFC_Chicklet_Widget");'));
-
+<?php
+/*
+Plugin Name: SFC - Chicklet
+Plugin URI: http://ottopress.com/wordpress-plugins/simple-facebook-connect/
+Description: Creates a chicklet for showing fan count of your app/page on FB.
+Author: Otto
+Version: 0.22
+Author URI: http://ottodestruct.com
+License: GPL2
+
+ Copyright 2009-2010 Samuel Wood (email : otto@ottodestruct.com)
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License version 2,
+ as published by the Free Software Foundation.
+
+ You may NOT assume that you can use any other version of the GPL.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ The license for this software can likely be found here:
+ http://www.gnu.org/licenses/gpl-2.0.html
+
+*/
+
+define('SFC_FANCOUNT_CACHE',60*60); // 1 hour caching
+
+// checks for sfc on activation
+function sfc_chicklet_activation_check(){
+ if (function_exists('sfc_version')) {
+ if (version_compare(sfc_version(), '0.8', '>=')) {
+ return;
+ }
+ }
+ deactivate_plugins(basename(__FILE__)); // Deactivate ourself
+ wp_die(__('The base SFC plugin must be activated before this plugin will run.', 'sfc'));
+}
+register_activation_hook(__FILE__, 'sfc_chicklet_activation_check');
+
+function sfc_chicklet($id = 0) {
+ $options = get_option('sfc_options');
+
+ if ($id == 0) {
+ if ($options['fanpage']) $id = $options['fanpage'];
+ else $id = $options['appid'];
+ }
+
+ $sfc_chicklet_fancount = get_transient('sfc_chicklet_fancount');
+
+ if (!isset($sfc_chicklet_fancount[$id])) {
+ include_once 'facebook-platform/facebook.php';
+ $fb=new Facebook($options['api_key'], $options['app_secret']);
+ $result = $fb->api_client->fql_query("SELECT fan_count, page_url FROM page WHERE page_id={$id}");
+ if ($result) {
+ $sfc_chicklet_fancount[$id] = $result[0];
+ set_transient('sfc_chicklet_fancount',$sfc_chicklet_fancount,SFC_FANCOUNT_CACHE);
+ }
+ }
+
+ if ($sfc_chicklet_fancount) {
+ $fancount = $sfc_chicklet_fancount[$id]['fan_count'];
+ $pageurl = $sfc_chicklet_fancount[$id]['page_url'];
+ }
+
+ global $sfc_chicklet_no_style;
+ if (!$sfc_chicklet_no_style) {
+?>
+<style>
+.fanBoxChicklet {
+ width:88px;
+ height:17px;
+ overflow:auto;
+ background-color:#94bfbf;
+ border-top: 1px solid #cefdfd;
+ border-left: 1px solid #cefdfd;
+ border-right: 1px solid #5f8586;
+ border-bottom: 1px solid #5f8586;
+ font: 11px/normal monospace, courier new, sans-serif;
+ color:#59564f;
+ margin: 0;
+ padding: 0;
+ text-align:right;
+}
+
+.fanBoxChicklet .quantity {
+ width:auto;
+ height:13px;
+ min-width:40px;
+ background-color:#cefdfd;
+ border-top: 1px solid #8a8a8a;
+ border-left: 1px solid #8a8a8a;
+ border-right: 1px solid #fefffe;
+ border-bottom: 1px solid #fefffe;
+ padding: 2px;
+ float: left;
+ text-align: center;
+ overflow: hidden;
+ margin:1px 5px 0 0;
+ padding:0;
+}
+
+.fanBoxChicklet .readerCaption {
+ width:auto;
+ float: left;
+ text-align: center;
+ vertical-align: middle;
+ margin: 2px 0 0 0;
+ padding: 0;
+}
+
+.fanBoxChicklet .feedCountLink {
+ color:#59564f;
+ text-decoration:none;
+ margin:0;
+ padding:0;
+}
+
+.fanBoxBy {
+ width:88px;
+ height:9px;
+ font: 9px/normal monospace, courier new, sans-serif;
+ color:#59564f;
+}
+</style>
+<?php } ?>
+<div class="fanBoxChicklet fanBoxChicklet-<?php echo $id; ?>">
+<p class="quantity"><?php echo $fancount; ?></p>
+<p class="readerCaption"><a href="<?php echo $pageurl; ?>" class="feedCountLink" target="_blank"><?php _e('Fans', 'sfc'); ?></a></p>
+</div>
+<div class="fanBoxBy"><?php _e('ON FACEBOOK', 'sfc'); ?></div>
+<?php
+}
+
+
+class SFC_Chicklet_Widget extends WP_Widget {
+ function SFC_Chicklet_Widget() {
+ $widget_ops = array('classname' => 'widget_sfc-chicklet', 'description' => __('Facebook Chicklet', 'sfc'));
+ $this->WP_Widget('sfc-chicklet', __('Facebook Chicklet', 'sfc'), $widget_ops);
+ }
+
+ function widget($args, $instance) {
+ extract( $args );
+ $title = apply_filters('widget_title', $instance['title']);
+ ?>
+ <?php echo $before_widget; ?>
+ <?php if ( $title ) echo $before_title . $title . $after_title; ?>
+ <?php sfc_chicklet(); ?>
+ <?php echo $after_widget; ?>
+ <?php
+ }
+
+ function update($new_instance, $old_instance) {
+ return $new_instance;
+ }
+
+ function form($instance) {
+ $title = esc_attr($instance['title']);
+ ?>
+<p><label for="<?php echo $this->get_field_id('title'); ?>"><?php _e('Title:'); ?>
+<input class="widefat" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" type="text" value="<?php echo $title; ?>" />
+</label></p>
+ <?php
+ }
+}
+add_action('widgets_init', create_function('', 'return register_widget("SFC_Chicklet_Widget");'));
+
View
708 sfc-comments.php
@@ -1,354 +1,354 @@
-<?php
-/*
-Plugin Name: SFC - Comments
-Plugin URI: http://ottopress.com/wordpress-plugins/simple-facebook-connect/
-Description: Allow users to leave comments using their Facebook info (without their logging into WordPress itself).
-Author: Otto
-Version: 0.22
-Author URI: http://ottodestruct.com
-License: GPL2
-
- Copyright 2009-2010 Samuel Wood (email : otto@ottodestruct.com)
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License version 2,
- as published by the Free Software Foundation.
-
- You may NOT assume that you can use any other version of the GPL.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- The license for this software can likely be found here:
- http://www.gnu.org/licenses/gpl-2.0.html
-
-Usage Note: You have to modify your theme to use this plugin.
-
-In your comments.php file (or wherever your comments form is), you need to do the following.
-
-1. Find the three inputs for the name, email, and url.
-
-2. Just before the first input, add this code:
-<div id="comment-user-details">
-<?php do_action('alt_comment_login'); ?>
-
-3. Just below the last input (not the comment text area, just the name/email/url inputs, add this:
-</div>
-
-That will add the necessary pieces to allow the script to work.
-
-Hopefully, a future version of WordPress will make this simpler.
-
-*/
-
-add_action('admin_init','sfc_comm_error_check');
-function sfc_comm_error_check() {
- if ( get_option( 'comment_registration' ) ) {
- add_action('admin_notices', create_function( '', "_e('<div class=\"error\"><p>SFC-Comments doesn\'t work with sites that require registration to comment. Use SFC-Login and SFC-Register to allow users to register on your site.</p></div>','sfc');" ) );
- }
-}
-
-// if you don't want the plugin to ask for email permission, ever, then define this to true in your wp-config
-if ( !defined('SFC_DISABLE_EMAIL_PERMISSION') )
- define( 'SFC_DISABLE_EMAIL_PERMISSION', false );
-
-
-// checks for sfc on activation
-function sfc_comm_activation_check(){
- if (function_exists('sfc_version')) {
- if (version_compare(sfc_version(), '0.1', '>=')) {
- return;
- }
- }
- deactivate_plugins(basename(__FILE__)); // Deactivate ourself
- wp_die(__('The base SFC plugin must be activated before this plugin will run.', 'sfc'));
-}
-register_activation_hook(__FILE__, 'sfc_comm_activation_check');
-
-// force load jQuery (we need it later anyway)
-add_action('wp_enqueue_scripts','sfc_comm_jquery');
-function sfc_comm_jquery() {
- wp_enqueue_script('jquery');
-}
-
-// set a variable to know when we are showing comments (no point in adding js to other pages)
-add_action('comment_form','sfc_comm_comments_enable');
-function sfc_comm_comments_enable() {
- global $sfc_comm_comments_form;
- $sfc_comm_comments_form = true;
-}
-
-// add placeholder for sending comment to Facebook checkbox
-add_action('comment_form','sfc_comm_send_place');
-function sfc_comm_send_place() {
-?><p id="sfc_comm_send"></p><?php
-}
-
-// hook to the footer to add our scripting
-add_action('wp_footer','sfc_comm_footer_script',30); // 30 to ensure we happen after sfc base
-function sfc_comm_footer_script() {
- global $sfc_comm_comments_form;
- if ($sfc_comm_comments_form != true) return; // nothing to do, not showing comments
-
- if ( is_user_logged_in() ) return; // don't bother with this stuff for logged in users
-
- $options = get_option('sfc_options');
-?>
-<style type="text/css">
-#fb-user { border: 1px dotted #C0C0C0; padding: 5px; display: block; height: 96px; }
-#fb-user .fb_profile_pic_rendered { margin-right: 5px; }
-#fb-user a.FB_Link img { float: left; }
-</style>
-
-<script type="text/javascript">
-var fb_connect_user = false;
-
-function sfc_update_user_details() {
- fb_connect_user = true;
-
- // Show their FB details TODO this should be configurable, or at least prettier...
- if (!jQuery('#fb-user').length) {
- jQuery('#comment-user-details').hide().after("<span id='fb-user'>" +
- "<fb:profile-pic uid='loggedinuser' facebook-logo='true' size='normal' height='96'></fb:profile-pic>" +
- "<span id='fb-msg'><strong><fb:intl><?php echo addslashes(__('Hi', 'sfc')); ?></fb:intl> <fb:name uid='loggedinuser' useyou='false'></fb:name>!</strong><br /><fb:intl><?php echo addslashes(__('You are connected with your Facebook account.', 'sfc')); ?></fb:intl>" +
- "<a href='#' onclick='FB.Connect.logoutAndRedirect(\"<?php the_permalink() ?>\"); return false;'> <?php echo addslashes(__('Logout', 'sfc')); ?></a>" +
- "</span></span>");
- jQuery('#sfc_comm_send').html('<input style="width: auto;" type="checkbox" id="sfc_comm_share" /><label for="sfc_comm_send"><fb:intl><?php echo addslashes(__('Share Comment on Facebook', 'sfc')); ?></fb:intl></label>');
- }
-
- // Refresh the DOM
- FB.XFBML.Host.parseDomTree();
-}
-
-jQuery("#commentform").bind('submit',sfc_handle_submit_share);
-function sfc_handle_submit_share() {
- if (jQuery('#sfc_comm_share:checked').val() == 'on') {
- sfc_setCookie('sfc_share', 'yes');
- }
- return true;
-}
-
-<?php if (get_option('require_name_email') && !SFC_DISABLE_EMAIL_PERMISSION) { ?>
-// first, check if we already have email permission
-var sfc_comm_email_perm = false;
-FB.ensureInit ( function () {
- FB.Facebook.apiClient.users_hasAppPermission('email',function(res,ex){
- if (res == 0) {
- // no permission, ask for it on submit
- jQuery("#commentform").bind('submit',sfc_get_email_perms);
- } else {
- // we have permission, no special handler needed
- sfc_comm_email_perm = true;
- }
- });
-});
-
-// ask for email permission
-function sfc_get_email_perms() {
- if (sfc_comm_email_perm) return true;
- if (fb_connect_user) {
- FB.Facebook.apiClient.users_hasAppPermission('email',function(res,ex){
- if (res == 0) {
- FB.Connect.showPermissionDialog("email", function(perms) {
- if (perms.match("email")) {
- sfc_commentform_submit();
- } else {
- var dialog = FB.UI.FBMLPopupDialog('<?php echo addslashes(__('Email required', 'sfc')); ?>', '');
- var fbml='\
-<div id="fb_dialog_content" class="fb_dialog_content">\
- <div class="fb_confirmation_stripes"></div>\
- <div class="fb_confirmation_content"><p><?php echo addslashes(__('This site requires permission to get your email address for you to leave a comment. You can not leave a comment without granting that permission.', 'sfc')); ?></p></div>\
-</div>';
- dialog.setFBMLContent(fbml);
- dialog.setContentWidth(540);
- dialog.setContentHeight(65);
- dialog.set_placement(FB.UI.PopupPlacement.topCenter);
- dialog.show();
- setTimeout ( function() { dialog.close(); }, 5000 );
- }
- });
- } else {
- sfc_commentform_submit();
- }
- });
- return false;
- } else {
- return true;
- }
-}
-
-// submit the form
-function sfc_commentform_submit() {
- jQuery("#commentform").unbind('submit',sfc_get_email_perms);
- jQuery("#commentform :submit").click();
-}
-<?php } ?>
-
-function sfc_setCookie(c_name,value,expiredays) {
- var exdate=new Date();
- exdate.setDate(exdate.getDate()+expiredays);
- document.cookie=c_name+ "=" +escape(value)+((expiredays==null) ? "" : ";expires="+exdate.toGMTString());
-}
-
-function sfc_getCookie(c_name) {
- if (document.cookie.length>0) {
- c_start=document.cookie.indexOf(c_name + "=");
- if (c_start!=-1) {
- c_start=c_start + c_name.length+1;
- c_end=document.cookie.indexOf(";",c_start);
- if (c_end==-1) c_end=document.cookie.length;
- return unescape(document.cookie.substring(c_start,c_end));
- }
- }
- return "";
-}
-
-FB.ensureInit ( function () {
- FB.Connect.ifUserConnected(sfc_update_user_details);
- if (sfc_getCookie('sfc_share') == 'yes') {
- sfc_setCookie('sfc_share', null);
- <?php
- global $post;
- // build the attachment
- $permalink = get_permalink($post->ID);
- $attachment['name'] = get_the_title();
- $attachment['href'] = get_permalink();
- $attachment['description'] = sfc_comm_make_excerpt($post->post_content);
- $attachment['caption'] = '{*actor*} left a comment on '.get_the_title();
- $attachment['comments_xid'] = urlencode(get_permalink());
-
- $action_links[0]['text'] = 'Read Post';
- $action_links[0]['href'] = get_permalink();
- ?>
-
- FB.Connect.streamPublish(null,
- <?php echo json_encode($attachment); ?>,
- <?php echo json_encode($action_links); ?>
- );
- }
-});
-</script>
-<?php
-}
-
-// I wish wp_trim_excerpt was easier to use separately...
-function sfc_comm_make_excerpt($text) {
- $text = strip_shortcodes( $text );
- remove_filter( 'the_content', 'wptexturize' );
- $text = apply_filters('the_content', $text);
- add_filter( 'the_content', 'wptexturize' );
- $text = str_replace(']]>', ']]&gt;', $text);
- $text = wp_strip_all_tags($text);
- $text = str_replace(array("\r\n","\r","\n"),' ',$text);
- $excerpt_length = apply_filters('excerpt_length', 55);
- $excerpt_more = apply_filters('excerpt_more', '[...]');
- $words = explode(' ', $text, $excerpt_length + 1);
- if (count($words) > $excerpt_length) {
- array_pop($words);
- array_push($words, $excerpt_more);
- $text = implode(' ', $words);
- }
- return $text;
-}
-
-// this bit is to allow the user to add the relevant comments login button to the comments form easily
-// user need only stick a do_action('alt_comment_login'); wherever he wants the button to display
-add_action('alt_comment_login','sfc_comm_login_button');
-add_action('comment_form_before_fields', 'sfc_comm_login_button',10,0); // WP 3.0 support
-
-function sfc_comm_login_button() {
- echo '<p><fb:login-button v="2" perms="email" onlogin="sfc_update_user_details();"><fb:intl>'.__('Connect with Facebook', 'sfc').'</fb:intl></fb:login-button></p>';
-}
-
-// this exists so that other plugins can hook into the same place to add their login buttons
-if (!function_exists('alt_login_method_div')) {
-
-add_action('alt_comment_login','alt_login_method_div',5,0);
-add_action('comment_form_before_fields', 'alt_login_method_div',5,0); // WP 3.0 support
-
-function alt_login_method_div() { echo '<div id="alt-login-methods">'; }
-
-add_action('alt_comment_login','alt_login_method_div_close',20,0);
-add_action('comment_form_before_fields', 'alt_login_method_div_close',20,0); // WP 3.0 support
-
-function alt_login_method_div_close() { echo '</div>'; }
-
-}
-
-// WP 3.0 support
-if (!function_exists('comment_user_details_begin')) {
-
-add_action('comment_form_before_fields', 'comment_user_details_begin',1,0);
-function comment_user_details_begin() { echo '<div id="comment-user-details">'; }
-
-add_action('comment_form_after_fields', 'comment_user_details_end',20,0);
-function comment_user_details_end() { echo '</div>'; }
-
-}
-
-// generate facebook avatar code for FB user comments
-add_filter('get_avatar','sfc_comm_avatar', 10, 5);
-function sfc_comm_avatar($avatar, $id_or_email, $size = '96', $default = '', $alt = false) {
- // check to be sure this is for a comment
- if ( !is_object($id_or_email) || !isset($id_or_email->comment_ID) || $id_or_email->user_id)
- return $avatar;
-
- // check for fbuid comment meta
- $fbuid = get_comment_meta($id_or_email->comment_ID, 'fbuid', true);
- if ($fbuid) {
- // return the avatar code
- return "<img width='{$size}' height='{$size}' class='avatar avatar-{$size} fbavatar' src='http://graph.facebook.com/{$fbuid}/picture?type=square' />";
- }
-
- // check for number@facebook.com email address (deprecated, auto-converts to new meta data)
- if (preg_match('|(\d+)\@facebook\.com|', $id_or_email->comment_author_email, $m)) {
- // save the fbuid as meta data
- update_comment_meta($id_or_email->comment_ID, 'fbuid', $m[1]);
-
- // return the avatar code
- return "<img width='{$size}' height='{$size}' class='avatar avatar-{$size} fbavatar' src='http://graph.facebook.com/{$m[1]}/picture?type=square' />";
- }
-
- return $avatar;
-}
-
-// store the FB user ID as comment meta data ('fbuid')
-add_action('comment_post','sfc_comm_add_meta', 10, 1);
-function sfc_comm_add_meta($comment_id) {
- $options = get_option('sfc_options');
- include_once 'facebook-platform/facebook.php';
- $fb=new Facebook($options['api_key'], $options['app_secret']);
- $fbuid=$fb->get_loggedin_user();
- if ($fbuid) {
- update_comment_meta($comment_id, 'fbuid', $fbuid);
- }
-}
-
-// Add user fields for FB commenters
-add_filter('pre_comment_on_post','sfc_comm_fill_in_fields');
-function sfc_comm_fill_in_fields($comment_post_ID) {
- if (is_user_logged_in()) return; // do nothing to WP users
-
- $options = get_option('sfc_options');
- include_once 'facebook-platform/facebook.php';
- $fb=new Facebook($options['api_key'], $options['app_secret']);
- $fbuid=$fb->get_loggedin_user();
-
- // this is a facebook user, override the sent values with FB info
- if ($fbuid) {
- $user_details = $fb->api_client->users_getInfo($fbuid, 'name, profile_url');
- if (is_array($user_details)) {
- $_POST['author'] = $user_details[0]['name'];
- $_POST['url'] = $user_details[0]['profile_url'];
- }
-
- $query = "SELECT email FROM user WHERE uid=\"{$fbuid}\"";
- $email = $fb->api_client->fql_query($query);
- if (is_array($email)) {
- $email = $email[0]['email'];
- $_POST['email'] = $email;
- }
- }
-}
+<?php
+/*
+Plugin Name: SFC - Comments
+Plugin URI: http://ottopress.com/wordpress-plugins/simple-facebook-connect/
+Description: Allow users to leave comments using their Facebook info (without their logging into WordPress itself).
+Author: Otto
+Version: 0.22
+Author URI: http://ottodestruct.com
+License: GPL2
+
+ Copyright 2009-2010 Samuel Wood (email : otto@ottodestruct.com)
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License version 2,
+ as published by the Free Software Foundation.
+
+ You may NOT assume that you can use any other version of the GPL.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ The license for this software can likely be found here:
+ http://www.gnu.org/licenses/gpl-2.0.html
+
+Usage Note: You have to modify your theme to use this plugin.
+
+In your comments.php file (or wherever your comments form is), you need to do the following.
+
+1. Find the three inputs for the name, email, and url.
+
+2. Just before the first input, add this code:
+<div id="comment-user-details">
+<?php do_action('alt_comment_login'); ?>
+
+3. Just below the last input (not the comment text area, just the name/email/url inputs, add this:
+</div>
+
+That will add the necessary pieces to allow the script to work.
+
+Hopefully, a future version of WordPress will make this simpler.
+
+*/
+
+add_action('admin_init','sfc_comm_error_check');
+function sfc_comm_error_check() {
+ if ( get_option( 'comment_registration' ) ) {
+ add_action('admin_notices', create_function( '', "_e('<div class=\"error\"><p>SFC-Comments doesn\'t work with sites that require registration to comment. Use SFC-Login and SFC-Register to allow users to register on your site.</p></div>','sfc');" ) );
+ }
+}
+
+// if you don't want the plugin to ask for email permission, ever, then define this to true in your wp-config
+if ( !defined('SFC_DISABLE_EMAIL_PERMISSION') )
+ define( 'SFC_DISABLE_EMAIL_PERMISSION', false );
+
+
+// checks for sfc on activation
+function sfc_comm_activation_check(){
+ if (function_exists('sfc_version')) {
+ if (version_compare(sfc_version(), '0.1', '>=')) {
+ return;
+ }
+ }
+ deactivate_plugins(basename(__FILE__)); // Deactivate ourself
+ wp_die(__('The base SFC plugin must be activated before this plugin will run.', 'sfc'));
+}
+register_activation_hook(__FILE__, 'sfc_comm_activation_check');
+
+// force load jQuery (we need it later anyway)
+add_action('wp_enqueue_scripts','sfc_comm_jquery');
+function sfc_comm_jquery() {
+ wp_enqueue_script('jquery');
+}
+
+// set a variable to know when we are showing comments (no point in adding js to other pages)
+add_action('comment_form','sfc_comm_comments_enable');
+function sfc_comm_comments_enable() {
+ global $sfc_comm_comments_form;
+ $sfc_comm_comments_form = true;
+}
+
+// add placeholder for sending comment to Facebook checkbox
+add_action('comment_form','sfc_comm_send_place');
+function sfc_comm_send_place() {
+?><p id="sfc_comm_send"></p><?php
+}
+
+// hook to the footer to add our scripting
+add_action('wp_footer','sfc_comm_footer_script',30); // 30 to ensure we happen after sfc base
+function sfc_comm_footer_script() {
+ global $sfc_comm_comments_form;
+ if ($sfc_comm_comments_form != true) return; // nothing to do, not showing comments
+
+ if ( is_user_logged_in() ) return; // don't bother with this stuff for logged in users
+
+ $options = get_option('sfc_options');
+?>
+<style type="text/css">
+#fb-user { border: 1px