diff --git a/sfc-activity-feed-widget.php b/sfc-activity-feed-widget.php index a8f6af7..886144c 100644 --- a/sfc-activity-feed-widget.php +++ b/sfc-activity-feed-widget.php @@ -1,145 +1,145 @@ -=')) { - 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 "

"; -} - -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']); - ?> -

-

-

-

-

-

- =')) { + 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 "

"; +} + +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']); + ?> +

+

+

+

+

+

+ - -'.__('Settings', 'sfc').''; - $links[] = ''.__('Donate', 'sfc').''; - } - return $links; -} - -// action links -add_filter('plugin_action_links_'.plugin_basename(__FILE__), 'sfc_settings_link', 10, 1); -function sfc_settings_link($links) { - $links[] = ''.__('Settings', 'sfc').''; - 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 '

".sprintf(__('Simple Facebook Connect needs configuration information on its settings page.', 'sfc'), admin_url('options-general.php?page=sfc'))."

';" ) ); - } 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() { -?> -
-

-

-
- -
- - -
-

-

Simple Facebook Connect is developed and maintained by Otto.

-

He blogs at Nothing To See Here and Otto on WordPress, posts photos on Flickr, and chats on Twitter.

-

You can follow his site on either Facebook or Twitter, if you like.

-

If you'd like to buy him a beer, then he'd be perfectly happy to drink it.

-
- -
-

- 1, 'items' => 10) ); ?> -
-
-

- -

-
-
- - -

-

-
    -
  1. Facebook Application List', 'sfc'); ?>
  2. -
  3. -
- -

-
    -
  1. Facebook Connect Setup', 'sfc'); ?>
  2. -
  3. -
  4. -
  5. Facebook Application List page.', 'sfc'); ?>
  6. -
  7. -
-api_client->admin_getAppProperties(array('connect_url')); - } catch (Exception $e) { - // bad API key or secret or something - $error=true; - echo '

'.__('Facebook doesn\'t like your settings, it says:', 'sfc').' ' . $e->getMessage() . '.

'; - } - - 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 '

'; - 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 '.

'; - } - - if ($error) { -?> -

edit your applications settings and correct the values therein. The site will not work properly until the errors are corrected.', 'sfc'), $options['appid']); ?>

- "; - _e('(required)', 'sfc'); -} -function sfc_setting_app_secret() { - if (defined('SFC_APP_SECRET')) return; - $options = get_option('sfc_options'); - echo " "; - _e('(required)', 'sfc'); -} -function sfc_setting_appid() { - if (defined('SFC_APP_ID')) return; - $options = get_option('sfc_options'); - echo " "; - _e('(required)', 'sfc'); - if (!empty($options['appid'])) printf(__('

Here is a link to your applications wall. There you can give it a name, upload a profile picture, things like that. Look for the "Edit Application" link to modify the application.

', 'sfc'), $options['appid']); -} -function sfc_setting_fanpage() { - if (defined('SFC_FANPAGE')) return; - $options = get_option('sfc_options'); ?> - -

replace -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'); ?>

- -

Fan Page that you want to use for -your site, enter the ID of the page here. Most users should leave this blank.', 'sfc'); ?>

- -"; -} - -// 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']) { - ?> -' /> - - -get_queried_object_id() ) { - $link = get_permalink( $id ); - echo "\n"; - } - } else if (is_home()) { - $link = get_bloginfo('url'); - echo "\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; -} + + +'.__('Settings', 'sfc').''; + $links[] = ''.__('Donate', 'sfc').''; + } + return $links; +} + +// action links +add_filter('plugin_action_links_'.plugin_basename(__FILE__), 'sfc_settings_link', 10, 1); +function sfc_settings_link($links) { + $links[] = ''.__('Settings', 'sfc').''; + 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 '

".sprintf(__('Simple Facebook Connect needs configuration information on its settings page.', 'sfc'), admin_url('options-general.php?page=sfc'))."

';" ) ); + } 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() { +?> +
+

+

+
+ +
+ + +
+

+

Simple Facebook Connect is developed and maintained by Otto.

+

He blogs at Nothing To See Here and Otto on WordPress, posts photos on Flickr, and chats on Twitter.

+

You can follow his site on either Facebook or Twitter, if you like.

+

If you'd like to buy him a beer, then he'd be perfectly happy to drink it.

+
+ +
+

+ 1, 'items' => 10) ); ?> +
+
+

+ +

+
+
+ + +

+

+
    +
  1. Facebook Application List', 'sfc'); ?>
  2. +
  3. +
+ +

+
    +
  1. Facebook Connect Setup', 'sfc'); ?>
  2. +
  3. +
  4. +
  5. Facebook Application List page.', 'sfc'); ?>
  6. +
  7. +
+api_client->admin_getAppProperties(array('connect_url')); + } catch (Exception $e) { + // bad API key or secret or something + $error=true; + echo '

'.__('Facebook doesn\'t like your settings, it says:', 'sfc').' ' . $e->getMessage() . '.

'; + } + + 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 '

'; + 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 '.

'; + } + + if ($error) { +?> +

edit your applications settings and correct the values therein. The site will not work properly until the errors are corrected.', 'sfc'), $options['appid']); ?>

+ "; + _e('(required)', 'sfc'); +} +function sfc_setting_app_secret() { + if (defined('SFC_APP_SECRET')) return; + $options = get_option('sfc_options'); + echo " "; + _e('(required)', 'sfc'); +} +function sfc_setting_appid() { + if (defined('SFC_APP_ID')) return; + $options = get_option('sfc_options'); + echo " "; + _e('(required)', 'sfc'); + if (!empty($options['appid'])) printf(__('

Here is a link to your applications wall. There you can give it a name, upload a profile picture, things like that. Look for the "Edit Application" link to modify the application.

', 'sfc'), $options['appid']); +} +function sfc_setting_fanpage() { + if (defined('SFC_FANPAGE')) return; + $options = get_option('sfc_options'); ?> + +

replace +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'); ?>

+ +

Fan Page that you want to use for +your site, enter the ID of the page here. Most users should leave this blank.', 'sfc'); ?>

+ +"; +} + +// 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']) { + ?> +' /> + + +get_queried_object_id() ) { + $link = get_permalink( $id ); + echo "\n"; + } + } else if (is_home()) { + $link = get_bloginfo('url'); + echo "\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; +} diff --git a/sfc-bookmark-widget.php b/sfc-bookmark-widget.php index 9a0ebe1..98dfdf4 100644 --- a/sfc-bookmark-widget.php +++ b/sfc-bookmark-widget.php @@ -1,88 +1,88 @@ -=')) { - 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 ''; -} - -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']); - ?> - - - - - '') ); - $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']); - ?> -

- =')) { + 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 ''; +} + +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']); + ?> + + + + + '') ); + $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']); + ?> +

+ =')) { - 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) { -?> - - -
-

-

-
-
- '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']); - ?> - - - - - -

- =')) { + 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) { +?> + + +
+

+

+
+
+ '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']); + ?> + + + + + +

+ - - -3. Just below the last input (not the comment text area, just the name/email/url inputs, add this: - - -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('

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.

','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() { -?>

- - - -', ']]>', $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 '

'.__('Connect with Facebook', 'sfc').'

'; -} - -// 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 '
'; } - -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 '
'; } - -} - -// 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 '
'; } - -add_action('comment_form_after_fields', 'comment_user_details_end',20,0); -function comment_user_details_end() { echo '
'; } - -} - -// 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 ""; - } - - // 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 ""; - } - - 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; - } - } -} + + + +3. Just below the last input (not the comment text area, just the name/email/url inputs, add this: + + +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('

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.

','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() { +?>

+ + + +', ']]>', $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 '

'.__('Connect with Facebook', 'sfc').'

'; +} + +// 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 '
'; } + +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 '
'; } + +} + +// 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 '
'; } + +add_action('comment_form_after_fields', 'comment_user_details_end',20,0); +function comment_user_details_end() { echo '
'; } + +} + +// 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 ""; + } + + // 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 ""; + } + + 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; + } + } +} diff --git a/sfc-connect-widget.php b/sfc-connect-widget.php index 43cf0b7..d4984bf 100644 --- a/sfc-connect-widget.php +++ b/sfc-connect-widget.php @@ -1,94 +1,94 @@ -=')) { - 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_connect_widget_activation_check'); - -// Shortcode for putting it into pages or posts directly -// profile id is required. Won't work without it. -function sfc_connect_shortcode() { - $login =''.__('Connect with Facebook', 'sfc').''; - return $login; -} -add_shortcode('fb-connect', 'sfc_connect_shortcode'); - -class SFC_Connect_Widget extends WP_Widget { - function SFC_Connect_Widget() { - $widget_ops = array('classname' => 'widget_sfc-connect', 'description' => __('Facebook Connect', 'sfc')); - $this->WP_Widget('sfc-connect', __('Facebook Connect (SFC)', 'sfc'), $widget_ops); - } - - function widget($args, $instance) { - $options = get_option('sfc_options'); - extract( $args ); - $title = apply_filters('widget_title', $instance['title']); - $appid = $options['appid']; - $stream = isset($instance['stream']) ? $instance['stream'] : true; - $connections = intval($instance['connections']); - $width = intval($instance['width']); - ?> - - - - - '') ); - $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']); - ?> -

- =')) { + 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_connect_widget_activation_check'); + +// Shortcode for putting it into pages or posts directly +// profile id is required. Won't work without it. +function sfc_connect_shortcode() { + $login =''.__('Connect with Facebook', 'sfc').''; + return $login; +} +add_shortcode('fb-connect', 'sfc_connect_shortcode'); + +class SFC_Connect_Widget extends WP_Widget { + function SFC_Connect_Widget() { + $widget_ops = array('classname' => 'widget_sfc-connect', 'description' => __('Facebook Connect', 'sfc')); + $this->WP_Widget('sfc-connect', __('Facebook Connect (SFC)', 'sfc'), $widget_ops); + } + + function widget($args, $instance) { + $options = get_option('sfc_options'); + extract( $args ); + $title = apply_filters('widget_title', $instance['title']); + $appid = $options['appid']; + $stream = isset($instance['stream']) ? $instance['stream'] : true; + $connections = intval($instance['connections']); + $width = intval($instance['width']); + ?> + + + + + '') ); + $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']); + ?> +

+ =')) { - 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_fan_box_activation_check'); - -function get_sfc_fanbox($args='') { - $options = get_option('sfc_options'); - $args = wp_parse_args($args, array( - 'stream' => 1, - 'connections' => 10, - 'width' => 200, - 'height' => 0, - 'logobar' => 1 - )); - extract($args); - - if ($options['fanpage']) $id = $options['fanpage']; - else $id = $options['appid']; - - $retvar = ' 1, - 'connections' => 10, - 'width' => 200, - 'height' => 0, - 'logobar' => 1, - ), $atts); - - return get_sfc_fanbox($args); -} -add_shortcode('fb-fanbox', 'sfc_fanbox_shortcode'); - -class SFC_Fan_Box_Widget extends WP_Widget { - function SFC_Fan_Box_Widget() { - $widget_ops = array('classname' => 'widget_sfc-fanbox', 'description' => __('Facebook Fan Box', 'sfc')); - $this->WP_Widget('sfc-fanbox', __('Facebook Fan Box (SFC)', 'sfc'), $widget_ops); - } - - function widget($args, $instance) { - extract( $args ); - $title = apply_filters('widget_title', $instance['title']); - $instance['stream'] = isset($instance['stream']) ? $instance['stream'] : 1; - $instance['logobar'] = isset($instance['logobar']) ? $instance['logobar'] : 1; - $instance['connections'] = intval($instance['connections']); - $instance['width'] = intval($instance['width']); - $instance['height'] = intval($instance['height']); - ?> - - - - - '', 'connections' => '0', 'logobar'=> 0, 'stream' => 0, 'width'=>200, 'height'=>0) ); - $instance['title'] = strip_tags($new_instance['title']); - $instance['connections'] = intval($new_instance['connections']); - $instance['width'] = intval($new_instance['width']); - $instance['height'] = intval($new_instance['height']); - $instance['stream'] = $new_instance['stream'] ? 1 : 0; - $instance['logobar'] = $new_instance['logobar'] ? 1 : 0; - return $instance; - } - - function form($instance) { - $instance = wp_parse_args( (array) $instance, array( 'title' => '', 'connections' => '0', 'logobar'=> 0, 'stream' => 0, 'width'=>200, 'height'=>0) ); - $title = strip_tags($instance['title']); - $connections = intval($instance['connections']); - $width = intval($instance['width']); - $height = intval($instance['height']); - $stream = $instance['stream'] ? true : false; - $logobar = $instance['logobar'] ? true : false; - ?> -

-

-

-

-

-

- '.__('Use this area to add any custom CSS you like to the Facebook Fan Box display.', 'sfc').'

'; -} - -function sfc_fanbox_css_callback() { - $options = get_option('sfc_options'); - if (!$options['fanbox_css']) $options['fanbox_css'] = ''; - /* good default CSS to use: - - .connect_widget .connect_widget_facebook_logo_menubar { - } - .fan_box .full_widget .connect_top { - } - .fan_box .full_widget .page_stream { - } - .fan_box .full_widget .connections { - } - */ - - ?> -

-=')) { + 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_fan_box_activation_check'); + +function get_sfc_fanbox($args='') { + $options = get_option('sfc_options'); + $args = wp_parse_args($args, array( + 'stream' => 1, + 'connections' => 10, + 'width' => 200, + 'height' => 0, + 'logobar' => 1 + )); + extract($args); + + if ($options['fanpage']) $id = $options['fanpage']; + else $id = $options['appid']; + + $retvar = ' 1, + 'connections' => 10, + 'width' => 200, + 'height' => 0, + 'logobar' => 1, + ), $atts); + + return get_sfc_fanbox($args); +} +add_shortcode('fb-fanbox', 'sfc_fanbox_shortcode'); + +class SFC_Fan_Box_Widget extends WP_Widget { + function SFC_Fan_Box_Widget() { + $widget_ops = array('classname' => 'widget_sfc-fanbox', 'description' => __('Facebook Fan Box', 'sfc')); + $this->WP_Widget('sfc-fanbox', __('Facebook Fan Box (SFC)', 'sfc'), $widget_ops); + } + + function widget($args, $instance) { + extract( $args ); + $title = apply_filters('widget_title', $instance['title']); + $instance['stream'] = isset($instance['stream']) ? $instance['stream'] : 1; + $instance['logobar'] = isset($instance['logobar']) ? $instance['logobar'] : 1; + $instance['connections'] = intval($instance['connections']); + $instance['width'] = intval($instance['width']); + $instance['height'] = intval($instance['height']); + ?> + + + + + '', 'connections' => '0', 'logobar'=> 0, 'stream' => 0, 'width'=>200, 'height'=>0) ); + $instance['title'] = strip_tags($new_instance['title']); + $instance['connections'] = intval($new_instance['connections']); + $instance['width'] = intval($new_instance['width']); + $instance['height'] = intval($new_instance['height']); + $instance['stream'] = $new_instance['stream'] ? 1 : 0; + $instance['logobar'] = $new_instance['logobar'] ? 1 : 0; + return $instance; + } + + function form($instance) { + $instance = wp_parse_args( (array) $instance, array( 'title' => '', 'connections' => '0', 'logobar'=> 0, 'stream' => 0, 'width'=>200, 'height'=>0) ); + $title = strip_tags($instance['title']); + $connections = intval($instance['connections']); + $width = intval($instance['width']); + $height = intval($instance['height']); + $stream = $instance['stream'] ? true : false; + $logobar = $instance['logobar'] ? true : false; + ?> +

+

+

+

+

+

+ '.__('Use this area to add any custom CSS you like to the Facebook Fan Box display.', 'sfc').'

'; +} + +function sfc_fanbox_css_callback() { + $options = get_option('sfc_options'); + if (!$options['fanbox_css']) $options['fanbox_css'] = ''; + /* good default CSS to use: + + .connect_widget .connect_widget_facebook_logo_menubar { + } + .fan_box .full_widget .connect_top { + } + .fan_box .full_widget .page_stream { + } + .fan_box .full_widget .connections { + } + */ + + ?> +

+=')) { - 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_find_widget_activation_check'); - -// Shortcode for putting it into pages or posts directly -// profile id is required. Wont work without it. -function sfc_find_shortcode() { - $options = get_option('sfc_options'); - if ($options['fanpage']) $fb_id = $options['fanpage']; - else $fb_id = $options['appid']; - - return ''; -} - -add_shortcode('fb-find', 'sfc_find_shortcode'); - -class SFC_Find_Widget extends WP_Widget { - function SFC_Find_Widget() { - $widget_ops = array('classname' => 'widget_sfc-find', 'description' => __('Find us on Facebook Button', 'sfc')); - $this->WP_Widget('sfc-find', __('Facebook Find Button (SFC)', 'sfc'), $widget_ops); - } - - function widget($args, $instance) { - extract( $args ); - $title = apply_filters('widget_title', $instance['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']); - ?> -

- =')) { + 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_find_widget_activation_check'); + +// Shortcode for putting it into pages or posts directly +// profile id is required. Wont work without it. +function sfc_find_shortcode() { + $options = get_option('sfc_options'); + if ($options['fanpage']) $fb_id = $options['fanpage']; + else $fb_id = $options['appid']; + + return ''; +} + +add_shortcode('fb-find', 'sfc_find_shortcode'); + +class SFC_Find_Widget extends WP_Widget { + function SFC_Find_Widget() { + $widget_ops = array('classname' => 'widget_sfc-find', 'description' => __('Find us on Facebook Button', 'sfc')); + $this->WP_Widget('sfc-find', __('Facebook Find Button (SFC)', 'sfc'), $widget_ops); + } + + function widget($args, $instance) { + extract( $args ); + $title = apply_filters('widget_title', $instance['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']); + ?> +

+ =')) { - 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_like_activation_check'); - -global $sfc_like_defaults; -$sfc_like_defaults = array( - 'id'=>0, - 'layout'=>'standard', // standard or button_count - 'showfaces'=>'true', // true or false - 'width'=>'260', - 'height'=>'26', - 'action'=>'like', // like or recommend - 'colorscheme'=>'light', // light or dark - 'font' => 'lucida+grande', // arial, lucida+grande, seqoe+ui, tahoma, trebuchet+ms, or verdana - ); - -function get_sfc_like_button($args='') { - global $sfc_like_defaults; - $args = wp_parse_args($args, $sfc_like_defaults); - extract($args); - - $url = get_permalink($id); - - // This wont work until I switch to the new libraries - //return ""; - - return "

"; -} - -function sfc_like_button($args='') { - echo get_sfc_like_button($args); -} - -function sfc_like_shortcode($atts) { - global $sfc_like_defaults; - $args = shortcode_atts($sfc_like_defaults, $atts); - - return get_sfc_like_button($args); -} -add_shortcode('fb-like', 'sfc_like_shortcode'); - -function sfc_like_button_automatic($content) { - $options = get_option('sfc_options'); - - $args = array( - 'layout'=>$options['like_layout'], - 'action'=>$options['like_action'], - ); - - $button = get_sfc_like_button($args); - switch ($options['like_position']) { - case "before": - $content = $button . $content; - break; - case "after": - $content = $content . $button; - break; - case "both": - $content = $button . $content . $button; - break; - case "manual": - default: - break; - } - return $content; -} -add_filter('the_content', 'sfc_like_button_automatic', 30); - -// add the admin sections to the sfc page -add_action('admin_init', 'sfc_like_admin_init'); -function sfc_like_admin_init() { - add_settings_section('sfc_like', __('Like Button Settings', 'sfc'), 'sfc_like_section_callback', 'sfc'); - add_settings_field('sfc_like_position', __('Like Button Position', 'sfc'), 'sfc_like_position', 'sfc', 'sfc_like'); - add_settings_field('sfc_like_layout', __('Like Button Layout', 'sfc'), 'sfc_like_layout', 'sfc', 'sfc_like'); - add_settings_field('sfc_like_action', __('Like Button Action', 'sfc'), 'sfc_like_action', 'sfc', 'sfc_like'); -} - -function sfc_like_section_callback() { - echo '

'.__('Choose where you want the like button added to your content.', 'sfc').'

'; -} - -function sfc_like_position() { - $options = get_option('sfc_options'); - if (!$options['like_position']) $options['like_position'] = 'manual'; - ?> -
    -
  • -
  • -
  • -
  • -
- -
    -
  • -
  • -
- -
    -
  • -
  • -
- - - -/', $content, $matches) ) { - foreach ( wp_kses_hair($matches[1], array('http')) as $attr) - $img[$attr['name']] = $attr['value']; - if ( isset($img['src']) ) { - if (!isset($img['class']) || - (isset($img['class']) && false === straipos($img['class'], apply_filters('sfc_img_exclude',array('wp-smiley')))) - ) { // ignore smilies -?> - - - - -=')) { + 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_like_activation_check'); + +global $sfc_like_defaults; +$sfc_like_defaults = array( + 'id'=>0, + 'layout'=>'standard', // standard or button_count + 'showfaces'=>'true', // true or false + 'width'=>'260', + 'height'=>'26', + 'action'=>'like', // like or recommend + 'colorscheme'=>'light', // light or dark + 'font' => 'lucida+grande', // arial, lucida+grande, seqoe+ui, tahoma, trebuchet+ms, or verdana + ); + +function get_sfc_like_button($args='') { + global $sfc_like_defaults; + $args = wp_parse_args($args, $sfc_like_defaults); + extract($args); + + $url = get_permalink($id); + + // This wont work until I switch to the new libraries + //return ""; + + return "

"; +} + +function sfc_like_button($args='') { + echo get_sfc_like_button($args); +} + +function sfc_like_shortcode($atts) { + global $sfc_like_defaults; + $args = shortcode_atts($sfc_like_defaults, $atts); + + return get_sfc_like_button($args); +} +add_shortcode('fb-like', 'sfc_like_shortcode'); + +function sfc_like_button_automatic($content) { + $options = get_option('sfc_options'); + + $args = array( + 'layout'=>$options['like_layout'], + 'action'=>$options['like_action'], + ); + + $button = get_sfc_like_button($args); + switch ($options['like_position']) { + case "before": + $content = $button . $content; + break; + case "after": + $content = $content . $button; + break; + case "both": + $content = $button . $content . $button; + break; + case "manual": + default: + break; + } + return $content; +} +add_filter('the_content', 'sfc_like_button_automatic', 30); + +// add the admin sections to the sfc page +add_action('admin_init', 'sfc_like_admin_init'); +function sfc_like_admin_init() { + add_settings_section('sfc_like', __('Like Button Settings', 'sfc'), 'sfc_like_section_callback', 'sfc'); + add_settings_field('sfc_like_position', __('Like Button Position', 'sfc'), 'sfc_like_position', 'sfc', 'sfc_like'); + add_settings_field('sfc_like_layout', __('Like Button Layout', 'sfc'), 'sfc_like_layout', 'sfc', 'sfc_like'); + add_settings_field('sfc_like_action', __('Like Button Action', 'sfc'), 'sfc_like_action', 'sfc', 'sfc_like'); +} + +function sfc_like_section_callback() { + echo '

'.__('Choose where you want the like button added to your content.', 'sfc').'

'; +} + +function sfc_like_position() { + $options = get_option('sfc_options'); + if (!$options['like_position']) $options['like_position'] = 'manual'; + ?> +
    +
  • +
  • +
  • +
  • +
+ +
    +
  • +
  • +
+ +
    +
  • +
  • +
+ + + +/', $content, $matches) ) { + foreach ( wp_kses_hair($matches[1], array('http')) as $attr) + $img[$attr['name']] = $attr['value']; + if ( isset($img['src']) ) { + if (!isset($img['class']) || + (isset($img['class']) && false === straipos($img['class'], apply_filters('sfc_img_exclude',array('wp-smiley')))) + ) { // ignore smilies +?> + + + + +=')) { - 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_live_stream_activation_check'); - -function get_sfc_livestream($args='') { - $args = wp_parse_args($args, array( - 'width' => '200', - 'height' => '400', - )); - extract($args); - - return ''; -} - -function sfc_livestream($args='') { - echo get_sfc_livestream($args); -} - -function sfc_live_stream_shortcode($atts) { - $args = shortcode_atts(array( - 'width' => '200', - 'height' => '400', - ), $atts); - - return get_sfc_livestream($args); -} -add_shortcode('fb-livestream', 'sfc_live_stream_shortcode'); - -class SFC_Live_Stream_Widget extends WP_Widget { - function SFC_Live_Stream_Widget() { - $widget_ops = array('classname' => 'widget_sfc-livestream', 'description' => __('Facebook Live Stream', 'sfc')); - $this->WP_Widget('sfc-livestream', __('Facebook Live Stream (SFC)', 'sfc'), $widget_ops); - } - - function widget($args, $instance) { - $options = get_option('sfc_options'); - extract( $args ); - $title = apply_filters('widget_title', $instance['title']); - $width = intval($instance['width']); - $height = intval($instance['height']); - ?> - - - - - '', 'width'=>200, 'height'=>400 ) ); - $instance['title'] = strip_tags($new_instance['title']); - $instance['width'] = intval($new_instance['width']); - if ($instance['width'] < 200) $instance['width'] = 200; - $instance['height'] = intval($new_instance['height']); - if ($instance['height'] < 400) $instance['height'] = 400; - return $instance; - } - - function form($instance) { - $instance = wp_parse_args( (array) $instance, array( 'title' => '', 'width'=>200, 'height'=>400 ) ); - $title = strip_tags($instance['title']); - $connections = intval($instance['connections']); - $width = intval($instance['width']); - $height = intval($instance['height']); - $stream = $instance['stream'] ? true : false; - ?> -

-

-

- - =')) { + 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_live_stream_activation_check'); + +function get_sfc_livestream($args='') { + $args = wp_parse_args($args, array( + 'width' => '200', + 'height' => '400', + )); + extract($args); + + return ''; +} + +function sfc_livestream($args='') { + echo get_sfc_livestream($args); +} + +function sfc_live_stream_shortcode($atts) { + $args = shortcode_atts(array( + 'width' => '200', + 'height' => '400', + ), $atts); + + return get_sfc_livestream($args); +} +add_shortcode('fb-livestream', 'sfc_live_stream_shortcode'); + +class SFC_Live_Stream_Widget extends WP_Widget { + function SFC_Live_Stream_Widget() { + $widget_ops = array('classname' => 'widget_sfc-livestream', 'description' => __('Facebook Live Stream', 'sfc')); + $this->WP_Widget('sfc-livestream', __('Facebook Live Stream (SFC)', 'sfc'), $widget_ops); + } + + function widget($args, $instance) { + $options = get_option('sfc_options'); + extract( $args ); + $title = apply_filters('widget_title', $instance['title']); + $width = intval($instance['width']); + $height = intval($instance['height']); + ?> + + + + + '', 'width'=>200, 'height'=>400 ) ); + $instance['title'] = strip_tags($new_instance['title']); + $instance['width'] = intval($new_instance['width']); + if ($instance['width'] < 200) $instance['width'] = 200; + $instance['height'] = intval($new_instance['height']); + if ($instance['height'] < 400) $instance['height'] = 400; + return $instance; + } + + function form($instance) { + $instance = wp_parse_args( (array) $instance, array( 'title' => '', 'width'=>200, 'height'=>400 ) ); + $title = strip_tags($instance['title']); + $connections = intval($instance['connections']); + $width = intval($instance['width']); + $height = intval($instance['height']); + $stream = $instance['stream'] ? true : false; + ?> +

+

+

+ + =')) { - 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_login_activation_check'); - -// add the section on the user profile page -add_action('profile_personal_options','sfc_login_profile_page'); - -function sfc_login_profile_page($profile) { - $options = get_option('sfc_options'); -?> - - - -ID, 'fbuid'); - if (empty($fbuid)) { - ?> - - -

- -

- - . - - - -

- - - - - - user_email); - - // load facebook platform - include_once 'facebook-platform/facebook.php'; - $fb=new Facebook($options['api_key'], $options['app_secret']); - - // user ids can be bigger than 32 bits, but are all digits - $fbuid = trim($_POST['fbuid']); - if(!preg_match('/^[0-9]+$/i', $fbuid)) { - $fbuid = 0; - } - if ($fbuid) { - // verify that users WP email address is a match to the FB email address (for security reasons) - $aa[0]['email_hash'] = $hash; - $aa[0]['account_id'] = $user->ID; - - $ret = $fb->api_client->connect_registerUsers(json_encode($aa)); - if (empty($ret)) { - // return value is empty, not good - _e('Facebook did not know your email address.', 'sfc'); - exit(); - } else { - // now we check to see if that user gives the email_hash back to us - $user_details = $fb->api_client->users_getInfo($fbuid, array('email_hashes')); - if (!empty($user_details[0]['email_hashes'])) { - - // go through the hashes returned by getInfo, make sure the one we want is in them - $valid = false; - foreach($user_details[0]['email_hashes'] as $check) { - if ($check == $hash) $valid = true; - } - - if (!$valid) { - // no good - _e('Facebook could not confirm your email address.', 'sfc'); - exit(); - } - } - } - } else { - if (!SFC_ALLOW_DISCONNECT) { - // disconnect not allowed - echo 1; - exit(); - } - // user disconnecting, so disconnect them in FB too - $aa[0] = $hash; - $ret = $fb->api_client->connect_unregisterUsers(json_encode($aa)); - - // we could check here, but why bother? just assume it worked. - } - - update_usermeta($user->ID, 'fbuid', $fbuid); - echo 1; - exit(); -} - -// computes facebook's email hash thingy. See http://wiki.developers.facebook.com/index.php/Connect.registerUsers -function sfc_login_fb_hash_email($email) { - $email = strtolower(trim($email)); - $c = crc32($email); - $m = md5($email); - $fbhash = sprintf('%u_%s',$c,$m); - return $fbhash; -} - -add_action('login_form','sfc_login_add_login_button'); -function sfc_login_add_login_button() { - global $action; - ?> - -


'; -} - -add_filter('authenticate','sfc_login_check',90); -function sfc_login_check($user) { - if ( is_a($user, 'WP_User') ) { return $user; } // check if user is already logged in, skip FB stuff - - $options = get_option('sfc_options'); - - // load facebook platform - include_once 'facebook-platform/facebook.php'; - - $fb=new Facebook($options['api_key'], $options['app_secret']); - $fbuid=$fb->get_loggedin_user(); - - if($fbuid): - try { - $test = $fb->api_client->fql_query('SELECT uid, pic_square, first_name FROM user WHERE uid = ' . $fbuid); - if ($test) { - global $wpdb; - $user_id = $wpdb->get_var( $wpdb->prepare("SELECT user_id FROM $wpdb->usermeta WHERE meta_key = 'fbuid' AND meta_value = %s", $fbuid) ); - - if ($user_id) { - $user = new WP_User($user_id); - } else { - do_action('sfc_login_new_fb_user',$fb); // hook for creating new users if desired - global $error; - $error = ''.__('ERROR', 'sfc').': '.__('Facebook user not recognized.', 'sfc'); - } - } - - } catch (Exception $ex) { - $fb->clear_cookie_state(); - } - - endif; - - return $user; -} - -add_action('wp_logout','sfc_login_logout'); -function sfc_login_logout() { - $options = get_option('sfc_options'); - - // load facebook platform - include_once 'facebook-platform/facebook.php'; - - $fb=new Facebook($options['api_key'], $options['app_secret']); - $fbuid=$fb->get_loggedin_user(); - if ($fbuid) { - $fb->logout(wp_login_url().'?loggedout=true'); - } -} - -add_action('login_head','sfc_login_featureloader'); -function sfc_login_featureloader() { - if ($_SERVER['HTTPS'] == 'on') - echo ""; - else - echo ""; -} - -add_action('login_form','sfc_add_base_js'); - -/* -// generate facebook avatar code for users who login with Facebook -// NOTE: This overrides Gravatar if you use it. -// -add_filter('get_avatar','sfc_login_avatar', 10, 5); -function sfc_login_avatar($avatar, $id_or_email, $size = '96', $default = '', $alt = false) { - // check to be sure this is for a user id - if ( !is_numeric($id_or_email) ) return $avatar; - $fbuid = get_usermeta( $id_or_email, 'fbuid'); - if ($fbuid) { - // return the avatar code - return ""; - } - return $avatar; -} -*/ +=')) { + 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_login_activation_check'); + +// add the section on the user profile page +add_action('profile_personal_options','sfc_login_profile_page'); + +function sfc_login_profile_page($profile) { + $options = get_option('sfc_options'); +?> + + + +ID, 'fbuid'); + if (empty($fbuid)) { + ?> + + +

+ +

+ + . + + + +

+ + + + + + user_email); + + // load facebook platform + include_once 'facebook-platform/facebook.php'; + $fb=new Facebook($options['api_key'], $options['app_secret']); + + // user ids can be bigger than 32 bits, but are all digits + $fbuid = trim($_POST['fbuid']); + if(!preg_match('/^[0-9]+$/i', $fbuid)) { + $fbuid = 0; + } + if ($fbuid) { + // verify that users WP email address is a match to the FB email address (for security reasons) + $aa[0]['email_hash'] = $hash; + $aa[0]['account_id'] = $user->ID; + + $ret = $fb->api_client->connect_registerUsers(json_encode($aa)); + if (empty($ret)) { + // return value is empty, not good + _e('Facebook did not know your email address.', 'sfc'); + exit(); + } else { + // now we check to see if that user gives the email_hash back to us + $user_details = $fb->api_client->users_getInfo($fbuid, array('email_hashes')); + if (!empty($user_details[0]['email_hashes'])) { + + // go through the hashes returned by getInfo, make sure the one we want is in them + $valid = false; + foreach($user_details[0]['email_hashes'] as $check) { + if ($check == $hash) $valid = true; + } + + if (!$valid) { + // no good + _e('Facebook could not confirm your email address.', 'sfc'); + exit(); + } + } + } + } else { + if (!SFC_ALLOW_DISCONNECT) { + // disconnect not allowed + echo 1; + exit(); + } + // user disconnecting, so disconnect them in FB too + $aa[0] = $hash; + $ret = $fb->api_client->connect_unregisterUsers(json_encode($aa)); + + // we could check here, but why bother? just assume it worked. + } + + update_usermeta($user->ID, 'fbuid', $fbuid); + echo 1; + exit(); +} + +// computes facebook's email hash thingy. See http://wiki.developers.facebook.com/index.php/Connect.registerUsers +function sfc_login_fb_hash_email($email) { + $email = strtolower(trim($email)); + $c = crc32($email); + $m = md5($email); + $fbhash = sprintf('%u_%s',$c,$m); + return $fbhash; +} + +add_action('login_form','sfc_login_add_login_button'); +function sfc_login_add_login_button() { + global $action; + ?> + +


'; +} + +add_filter('authenticate','sfc_login_check',90); +function sfc_login_check($user) { + if ( is_a($user, 'WP_User') ) { return $user; } // check if user is already logged in, skip FB stuff + + $options = get_option('sfc_options'); + + // load facebook platform + include_once 'facebook-platform/facebook.php'; + + $fb=new Facebook($options['api_key'], $options['app_secret']); + $fbuid=$fb->get_loggedin_user(); + + if($fbuid): + try { + $test = $fb->api_client->fql_query('SELECT uid, pic_square, first_name FROM user WHERE uid = ' . $fbuid); + if ($test) { + global $wpdb; + $user_id = $wpdb->get_var( $wpdb->prepare("SELECT user_id FROM $wpdb->usermeta WHERE meta_key = 'fbuid' AND meta_value = %s", $fbuid) ); + + if ($user_id) { + $user = new WP_User($user_id); + } else { + do_action('sfc_login_new_fb_user',$fb); // hook for creating new users if desired + global $error; + $error = ''.__('ERROR', 'sfc').': '.__('Facebook user not recognized.', 'sfc'); + } + } + + } catch (Exception $ex) { + $fb->clear_cookie_state(); + } + + endif; + + return $user; +} + +add_action('wp_logout','sfc_login_logout'); +function sfc_login_logout() { + $options = get_option('sfc_options'); + + // load facebook platform + include_once 'facebook-platform/facebook.php'; + + $fb=new Facebook($options['api_key'], $options['app_secret']); + $fbuid=$fb->get_loggedin_user(); + if ($fbuid) { + $fb->logout(wp_login_url().'?loggedout=true'); + } +} + +add_action('login_head','sfc_login_featureloader'); +function sfc_login_featureloader() { + if ($_SERVER['HTTPS'] == 'on') + echo ""; + else + echo ""; +} + +add_action('login_form','sfc_add_base_js'); + +/* +// generate facebook avatar code for users who login with Facebook +// NOTE: This overrides Gravatar if you use it. +// +add_filter('get_avatar','sfc_login_avatar', 10, 5); +function sfc_login_avatar($avatar, $id_or_email, $size = '96', $default = '', $alt = false) { + // check to be sure this is for a user id + if ( !is_numeric($id_or_email) ) return $avatar; + $fbuid = get_usermeta( $id_or_email, 'fbuid'); + if ($fbuid) { + // return the avatar code + return ""; + } + return $avatar; +} +*/ diff --git a/sfc-publish.php b/sfc-publish.php index 4cec6ed..7b3a5ea 100644 --- a/sfc-publish.php +++ b/sfc-publish.php @@ -1,437 +1,437 @@ -=')) { - 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_publish_activation_check'); - -// add the meta boxes -add_action('admin_menu', 'sfc_publish_meta_box_add'); -function sfc_publish_meta_box_add() { - add_meta_box('sfc-publish-div', __('Facebook Publisher', 'sfc'), 'sfc_publish_meta_box', 'post', 'side'); - add_meta_box('sfc-publish-div', __('Facebook Publisher', 'sfc'), 'sfc_publish_meta_box', 'page', 'side'); -} - -// add the admin sections to the sfc page -add_action('admin_init', 'sfc_publish_admin_init'); -function sfc_publish_admin_init() { - add_settings_section('sfc_publish', __('Publish Settings', 'sfc'), 'sfc_publish_section_callback', 'sfc'); - add_settings_field('sfc_publish_flags', __('Automatic Publishing', 'sfc'), 'sfc_publish_auto_callback', 'sfc', 'sfc_publish'); - add_settings_field('sfc_publish_extended_permissions', __('Extended Permissions', 'sfc'), 'sfc_publish_extended_callback', 'sfc', 'sfc_publish'); - wp_enqueue_script('jquery'); -} - -function sfc_publish_section_callback() { - echo "

".__('Settings for the SFC-Publish plugin. The manual Facebook Publishing buttons can be found on the Edit Post or Edit Page screen, after you publish a post. If you can\'t find them, try scrolling down or seeing if you have the box disabled in the Options dropdown.', 'sfc')."

"; -} - -function sfc_publish_auto_callback() { - $options = get_option('sfc_options'); - if (!$options['autopublish_app']) $options['autopublish_app'] = false; - if (!$options['autopublish_profile']) $options['autopublish_profile'] = false; - ?> -

- Facebook bug.)', 'sfc'); ?> -

-

-

-
    -

  • -

  • - -

  • - -
-

- -', ']]>', $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); - } - $text = html_entity_decode($text); // added to try to fix annoying &entity; stuff - return $text; -} - -function sfc_publish_meta_box( $post ) { - $options = get_option('sfc_options'); - - if ($post->post_status == 'private') { - echo '

'.__('Why would you put private posts on Facebook, for all to see?', 'sfc').'

'; - return; - } - - if ($post->post_status !== 'publish') { - echo '

'.__('After publishing the post, you can send it to Facebook from here.', 'sfc').'

'; - return; - } - - // apply the content filters, in case some plugin is doing weird image stuff - $content = apply_filters('the_content', $post->post_content); - - // look for the images to add with image_src - $images = array(); - - // get the post thumbnail, put it first in the image list - if (current_theme_supports('post-thumbnails')) { - if ( has_post_thumbnail($post->ID) ) { - $thumbid = get_post_thumbnail_id($post->ID); - $att = wp_get_attachment_image_src($thumbid, 'full'); - if (!empty($att[0])) $images[] = $att[0]; - } - } - - // look for any images in the content - if ( preg_match_all('//', $content, $matches) ) { - foreach ($matches[1] as $match) { - foreach ( wp_kses_hair($match, array('http')) as $attr) - $img[$attr['name']] = $attr['value']; - if ( isset($img['src']) ) { - if (!isset($img['class']) || - (isset($img['class']) && false === straipos($img['class'], apply_filters('sfc_img_exclude',array('wp-smiley')))) - ) { // ignore smilies - $images[] = $img['src']; - } - } - } - } - - // build the attachment - $permalink = apply_filters('sfc_publish_permalink',get_permalink($post->ID),$post->ID); - $attachment['name'] = $post->post_title; - $attachment['href'] = $permalink; - $attachment['description'] = sfc_publish_make_excerpt($post->post_content); - $attachment['comments_xid'] = urlencode($permalink); - - // image attachments (up to 5, as that's all FB allows) - $count=0; - foreach ($images as $image) { - $attachment['media'][$count]['type'] = 'image'; - $attachment['media'][$count]['src'] = $image; - $attachment['media'][$count]['href'] = $permalink; - $count++; if ($count==5) break; - } - - // Share link - $action_links[0]['text'] = 'Share'; - $action_links[0]['href'] = 'http://www.facebook.com/share.php?u='.urlencode($permalink); - ?> - -

- ID, $post); - } -} - -function sfc_publish_automatic($id, $post) { - - // check to make sure post is published - if ($post->post_status !== 'publish') return; - - // check options to see if we need to send to FB at all - $options = get_option('sfc_options'); - if (!$options['autopublish_app'] && !$options['autopublish_profile']) - return; - - // load facebook platform - include_once 'facebook-platform/facebook.php'; - $fb=new Facebook($options['api_key'], $options['app_secret']); - - // to do this autopublish, we might need to switch users - if ($options['user'] && $options['session_key']) { - $tempuser = $fb->user; - $tempkey = $fb->api_client->session_key = $session_key; - $fb->set_user($options['user'], $options['session_key']); - } else { - return; // safety net: if we don't have a user and session key, we can't publish properly. - } - - // build the post to send to FB - - // apply the content filters, in case some plugin is doing weird image stuff - $content = apply_filters('the_content', $post->post_content); - - // look for the images to add with image_src - $images = array(); - - // get the post thumbnail, put it first in the image list - if (current_theme_supports('post-thumbnails')) { - if ( has_post_thumbnail($post->ID) ) { - $thumbid = get_post_thumbnail_id($post->ID); - $att = wp_get_attachment_image_src($thumbid, 'full'); - if (!empty($att[0])) $images[] = $att[0]; - } - } - - // look for any images in the content - if ( preg_match_all('//', $content, $matches) ) { - foreach ($matches[1] as $match) { - foreach ( wp_kses_hair($match, array('http')) as $attr) - $img[$attr['name']] = $attr['value']; - if ( isset($img['src']) ) { - if ( isset( $img['class'] ) && false === straipos( $img['class'], apply_filters('sfc_img_exclude',array('wp-smiley')) ) ) { // ignore smilies - $images[] = $img['src']; - } - } - } - } - - // build the attachment - $permalink = apply_filters('sfc_publish_permalink',get_permalink($post->ID), $post->ID); - $attachment['name'] = $post->post_title; - $attachment['href'] = $permalink; - $attachment['description'] = sfc_publish_make_excerpt($post->post_content); - $attachment['comments_xid'] = urlencode($permalink); - - // image attachments (up to 5, as that's all FB allows) - $count=0; - foreach ($images as $image) { - $attachment['media'][$count]['type'] = 'image'; - $attachment['media'][$count]['src'] = $image; - $attachment['media'][$count]['href'] = $permalink; - $count++; if ($count==5) break; - } - - // Share link - $action_links[0]['text'] = 'Share'; - $action_links[0]['href'] = 'http://www.facebook.com/share.php?u='.urlencode($permalink); - - // publish to page - if ($options['autopublish_app'] && !get_post_meta($id,'_fb_post_id_app',true) - && $options['fanpage'] // TODO eliminate this when Facebook fixes the bug - ) { - - if ($options['fanpage']) $who = $options['fanpage']; - else $who = $options['appid']; - - // check to see if we can send to FB at all - $result = $fb->api_client->users_hasAppPermission('publish_stream', $who); - if (!$result) break; - - $fb_post_id = $fb->api_client->stream_publish(null, json_encode($attachment), json_encode($action_links), null, $who); - - if ($fb_post_id) { - // update the post id so as to prevent automatically posting it twice - update_post_meta($id,'_fb_post_id_app',$fb_post_id); - } - } - - // publish to profile - if ($options['autopublish_profile'] && !get_post_meta($id,'_fb_post_id_profile',true)) { - - // check to see if we can send to FB at all - $result = $fb->api_client->users_hasAppPermission('publish_stream'); - if (!$result) break; - - $fb_post_prof_id = $fb->api_client->stream_publish(null, json_encode($attachment), json_encode($action_links)); - - if ($fb_post_prof_id) { - // update the post id so as to prevent automatically posting it twice - update_post_meta($id,'_fb_post_id_profile',$fb_post_prof_id); - } - } - - // switch users back, just in case - if ($tempuser) { - $fb->set_user($tempuser, $tempkey); - } -} - -add_filter('sfc_validate_options','sfc_publish_validate_options'); -function sfc_publish_validate_options($input) { - $options = get_option('sfc_options'); - - if ($input['autopublish_app'] != 1) $input['autopublish_app'] = 0; - if ($input['autopublish_profile'] != 1) $input['autopublish_profile'] = 0; - - // find the infinite session key and save it if it's there - if ($_COOKIE[$options['api_key'].'_expires'] == 0) { - // save the user and session key - $input['user'] = $_COOKIE[$options['api_key'].'_user']; - $input['session_key'] = $_COOKIE[$options['api_key'].'_session_key']; - } - - return $input; -} - -// finds a item from an array in a string -if (!function_exists('straipos')) : -function straipos($haystack,$array,$offset=0) -{ - $occ = array(); - for ($i = 0;$i=')) { + 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_publish_activation_check'); + +// add the meta boxes +add_action('admin_menu', 'sfc_publish_meta_box_add'); +function sfc_publish_meta_box_add() { + add_meta_box('sfc-publish-div', __('Facebook Publisher', 'sfc'), 'sfc_publish_meta_box', 'post', 'side'); + add_meta_box('sfc-publish-div', __('Facebook Publisher', 'sfc'), 'sfc_publish_meta_box', 'page', 'side'); +} + +// add the admin sections to the sfc page +add_action('admin_init', 'sfc_publish_admin_init'); +function sfc_publish_admin_init() { + add_settings_section('sfc_publish', __('Publish Settings', 'sfc'), 'sfc_publish_section_callback', 'sfc'); + add_settings_field('sfc_publish_flags', __('Automatic Publishing', 'sfc'), 'sfc_publish_auto_callback', 'sfc', 'sfc_publish'); + add_settings_field('sfc_publish_extended_permissions', __('Extended Permissions', 'sfc'), 'sfc_publish_extended_callback', 'sfc', 'sfc_publish'); + wp_enqueue_script('jquery'); +} + +function sfc_publish_section_callback() { + echo "

".__('Settings for the SFC-Publish plugin. The manual Facebook Publishing buttons can be found on the Edit Post or Edit Page screen, after you publish a post. If you can\'t find them, try scrolling down or seeing if you have the box disabled in the Options dropdown.', 'sfc')."

"; +} + +function sfc_publish_auto_callback() { + $options = get_option('sfc_options'); + if (!$options['autopublish_app']) $options['autopublish_app'] = false; + if (!$options['autopublish_profile']) $options['autopublish_profile'] = false; + ?> +

+ Facebook bug.)', 'sfc'); ?> +

+

+

+
    +

  • +

  • + +

  • + +
+

+ +', ']]>', $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); + } + $text = html_entity_decode($text); // added to try to fix annoying &entity; stuff + return $text; +} + +function sfc_publish_meta_box( $post ) { + $options = get_option('sfc_options'); + + if ($post->post_status == 'private') { + echo '

'.__('Why would you put private posts on Facebook, for all to see?', 'sfc').'

'; + return; + } + + if ($post->post_status !== 'publish') { + echo '

'.__('After publishing the post, you can send it to Facebook from here.', 'sfc').'

'; + return; + } + + // apply the content filters, in case some plugin is doing weird image stuff + $content = apply_filters('the_content', $post->post_content); + + // look for the images to add with image_src + $images = array(); + + // get the post thumbnail, put it first in the image list + if (current_theme_supports('post-thumbnails')) { + if ( has_post_thumbnail($post->ID) ) { + $thumbid = get_post_thumbnail_id($post->ID); + $att = wp_get_attachment_image_src($thumbid, 'full'); + if (!empty($att[0])) $images[] = $att[0]; + } + } + + // look for any images in the content + if ( preg_match_all('//', $content, $matches) ) { + foreach ($matches[1] as $match) { + foreach ( wp_kses_hair($match, array('http')) as $attr) + $img[$attr['name']] = $attr['value']; + if ( isset($img['src']) ) { + if (!isset($img['class']) || + (isset($img['class']) && false === straipos($img['class'], apply_filters('sfc_img_exclude',array('wp-smiley')))) + ) { // ignore smilies + $images[] = $img['src']; + } + } + } + } + + // build the attachment + $permalink = apply_filters('sfc_publish_permalink',get_permalink($post->ID),$post->ID); + $attachment['name'] = $post->post_title; + $attachment['href'] = $permalink; + $attachment['description'] = sfc_publish_make_excerpt($post->post_content); + $attachment['comments_xid'] = urlencode($permalink); + + // image attachments (up to 5, as that's all FB allows) + $count=0; + foreach ($images as $image) { + $attachment['media'][$count]['type'] = 'image'; + $attachment['media'][$count]['src'] = $image; + $attachment['media'][$count]['href'] = $permalink; + $count++; if ($count==5) break; + } + + // Share link + $action_links[0]['text'] = 'Share'; + $action_links[0]['href'] = 'http://www.facebook.com/share.php?u='.urlencode($permalink); + ?> + +

+ ID, $post); + } +} + +function sfc_publish_automatic($id, $post) { + + // check to make sure post is published + if ($post->post_status !== 'publish') return; + + // check options to see if we need to send to FB at all + $options = get_option('sfc_options'); + if (!$options['autopublish_app'] && !$options['autopublish_profile']) + return; + + // load facebook platform + include_once 'facebook-platform/facebook.php'; + $fb=new Facebook($options['api_key'], $options['app_secret']); + + // to do this autopublish, we might need to switch users + if ($options['user'] && $options['session_key']) { + $tempuser = $fb->user; + $tempkey = $fb->api_client->session_key = $session_key; + $fb->set_user($options['user'], $options['session_key']); + } else { + return; // safety net: if we don't have a user and session key, we can't publish properly. + } + + // build the post to send to FB + + // apply the content filters, in case some plugin is doing weird image stuff + $content = apply_filters('the_content', $post->post_content); + + // look for the images to add with image_src + $images = array(); + + // get the post thumbnail, put it first in the image list + if (current_theme_supports('post-thumbnails')) { + if ( has_post_thumbnail($post->ID) ) { + $thumbid = get_post_thumbnail_id($post->ID); + $att = wp_get_attachment_image_src($thumbid, 'full'); + if (!empty($att[0])) $images[] = $att[0]; + } + } + + // look for any images in the content + if ( preg_match_all('//', $content, $matches) ) { + foreach ($matches[1] as $match) { + foreach ( wp_kses_hair($match, array('http')) as $attr) + $img[$attr['name']] = $attr['value']; + if ( isset($img['src']) ) { + if ( isset( $img['class'] ) && false === straipos( $img['class'], apply_filters('sfc_img_exclude',array('wp-smiley')) ) ) { // ignore smilies + $images[] = $img['src']; + } + } + } + } + + // build the attachment + $permalink = apply_filters('sfc_publish_permalink',get_permalink($post->ID), $post->ID); + $attachment['name'] = $post->post_title; + $attachment['href'] = $permalink; + $attachment['description'] = sfc_publish_make_excerpt($post->post_content); + $attachment['comments_xid'] = urlencode($permalink); + + // image attachments (up to 5, as that's all FB allows) + $count=0; + foreach ($images as $image) { + $attachment['media'][$count]['type'] = 'image'; + $attachment['media'][$count]['src'] = $image; + $attachment['media'][$count]['href'] = $permalink; + $count++; if ($count==5) break; + } + + // Share link + $action_links[0]['text'] = 'Share'; + $action_links[0]['href'] = 'http://www.facebook.com/share.php?u='.urlencode($permalink); + + // publish to page + if ($options['autopublish_app'] && !get_post_meta($id,'_fb_post_id_app',true) + && $options['fanpage'] // TODO eliminate this when Facebook fixes the bug + ) { + + if ($options['fanpage']) $who = $options['fanpage']; + else $who = $options['appid']; + + // check to see if we can send to FB at all + $result = $fb->api_client->users_hasAppPermission('publish_stream', $who); + if (!$result) break; + + $fb_post_id = $fb->api_client->stream_publish(null, json_encode($attachment), json_encode($action_links), null, $who); + + if ($fb_post_id) { + // update the post id so as to prevent automatically posting it twice + update_post_meta($id,'_fb_post_id_app',$fb_post_id); + } + } + + // publish to profile + if ($options['autopublish_profile'] && !get_post_meta($id,'_fb_post_id_profile',true)) { + + // check to see if we can send to FB at all + $result = $fb->api_client->users_hasAppPermission('publish_stream'); + if (!$result) break; + + $fb_post_prof_id = $fb->api_client->stream_publish(null, json_encode($attachment), json_encode($action_links)); + + if ($fb_post_prof_id) { + // update the post id so as to prevent automatically posting it twice + update_post_meta($id,'_fb_post_id_profile',$fb_post_prof_id); + } + } + + // switch users back, just in case + if ($tempuser) { + $fb->set_user($tempuser, $tempkey); + } +} + +add_filter('sfc_validate_options','sfc_publish_validate_options'); +function sfc_publish_validate_options($input) { + $options = get_option('sfc_options'); + + if ($input['autopublish_app'] != 1) $input['autopublish_app'] = 0; + if ($input['autopublish_profile'] != 1) $input['autopublish_profile'] = 0; + + // find the infinite session key and save it if it's there + if ($_COOKIE[$options['api_key'].'_expires'] == 0) { + // save the user and session key + $input['user'] = $_COOKIE[$options['api_key'].'_user']; + $input['session_key'] = $_COOKIE[$options['api_key'].'_session_key']; + } + + return $input; +} + +// finds a item from an array in a string +if (!function_exists('straipos')) : +function straipos($haystack,$array,$offset=0) +{ + $occ = array(); + for ($i = 0;$i=')) { - 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_register_activation_check'); - -// force a registration redirect if user is unknown -add_action('sfc_login_new_fb_user','sfc_register_redirect'); -function sfc_register_redirect($fb) { - if (SFC_REGISTER_TRANSPARENT) { - $fbuid=$fb->get_loggedin_user(); - - // this is a facebook user, get the info - if ($fbuid) { - $user_details = $fb->api_client->users_getInfo($fbuid, 'name, proxied_email'); - if (is_array($user_details)) { - $fbname = $user_details[0]['name']; - $fbemail = $fbemail[0]['proxied_email']; - } - - $query = "SELECT email FROM user WHERE uid=\"{$fbuid}\""; - $fbemail = $fb->api_client->fql_query($query); - if (is_array($fbemail)) { - $fbemail = $fbemail[0]['email']; - } - } - - // force create the user instantly - require_once( ABSPATH . WPINC . '/registration.php'); - $errors = register_new_user($fbname, $fbemail); - - if ( !is_wp_error($errors) ) { - wp_redirect('wp-login.php?checkemail=registered'); - exit(); - } - } - wp_redirect('wp-login.php?action=register'); - exit(); -} - -// we need jquery on the register form -add_action('login_head','sfc_register_jquery'); -function sfc_register_jquery() { - echo ""; -} - -// add init code -add_action('register_form','sfc_add_base_js'); - -// add javascript to fill in the reg form automagically for fb users -add_action('register_form','sfc_register_form'); -function sfc_register_form() { - $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, get the info - if ($fbuid) { - $user_details = $fb->api_client->users_getInfo($fbuid, 'name, proxied_email'); - if (is_array($user_details)) { - $fbname = $user_details[0]['name']; - } - - $query = "SELECT email FROM user WHERE uid=\"{$fbuid}\""; - $fbemail = $fb->api_client->fql_query($query); - if (is_array($fbemail)) { - $fbemail = $fbemail[0]['email']; - } - } -?> - -
- -get_loggedin_user(); - - // this is a facebook user, get the info - if ($fbuid) { - $user_details = $fb->api_client->users_getInfo($fbuid, 'first_name, last_name, profile_url, about_me'); - if ($user_details) { - $user['ID'] = $user_id; - $user['user_url'] = $user_details[0]['profile_url']; - wp_update_user($user); - - update_usermeta( $user_id, 'fbuid', $fbuid); - update_usermeta( $user_id, 'first_name', $user_details[0]['first_name'] ); - update_usermeta( $user_id, 'last_name', $user_details[0]['last_name']); - update_usermeta( $user_id, 'description', $user_details[0]['about_me'] ); - } - } -} +=')) { + 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_register_activation_check'); + +// force a registration redirect if user is unknown +add_action('sfc_login_new_fb_user','sfc_register_redirect'); +function sfc_register_redirect($fb) { + if (SFC_REGISTER_TRANSPARENT) { + $fbuid=$fb->get_loggedin_user(); + + // this is a facebook user, get the info + if ($fbuid) { + $user_details = $fb->api_client->users_getInfo($fbuid, 'name, proxied_email'); + if (is_array($user_details)) { + $fbname = $user_details[0]['name']; + $fbemail = $fbemail[0]['proxied_email']; + } + + $query = "SELECT email FROM user WHERE uid=\"{$fbuid}\""; + $fbemail = $fb->api_client->fql_query($query); + if (is_array($fbemail)) { + $fbemail = $fbemail[0]['email']; + } + } + + // force create the user instantly + require_once( ABSPATH . WPINC . '/registration.php'); + $errors = register_new_user($fbname, $fbemail); + + if ( !is_wp_error($errors) ) { + wp_redirect('wp-login.php?checkemail=registered'); + exit(); + } + } + wp_redirect('wp-login.php?action=register'); + exit(); +} + +// we need jquery on the register form +add_action('login_head','sfc_register_jquery'); +function sfc_register_jquery() { + echo ""; +} + +// add init code +add_action('register_form','sfc_add_base_js'); + +// add javascript to fill in the reg form automagically for fb users +add_action('register_form','sfc_register_form'); +function sfc_register_form() { + $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, get the info + if ($fbuid) { + $user_details = $fb->api_client->users_getInfo($fbuid, 'name, proxied_email'); + if (is_array($user_details)) { + $fbname = $user_details[0]['name']; + } + + $query = "SELECT email FROM user WHERE uid=\"{$fbuid}\""; + $fbemail = $fb->api_client->fql_query($query); + if (is_array($fbemail)) { + $fbemail = $fbemail[0]['email']; + } + } +?> + +
+ +get_loggedin_user(); + + // this is a facebook user, get the info + if ($fbuid) { + $user_details = $fb->api_client->users_getInfo($fbuid, 'first_name, last_name, profile_url, about_me'); + if ($user_details) { + $user['ID'] = $user_id; + $user['user_url'] = $user_details[0]['profile_url']; + wp_update_user($user); + + update_usermeta( $user_id, 'fbuid', $fbuid); + update_usermeta( $user_id, 'first_name', $user_details[0]['first_name'] ); + update_usermeta( $user_id, 'last_name', $user_details[0]['last_name']); + update_usermeta( $user_id, 'description', $user_details[0]['about_me'] ); + } + } +} diff --git a/sfc-share.php b/sfc-share.php index df9180c..7508d50 100644 --- a/sfc-share.php +++ b/sfc-share.php @@ -1,280 +1,280 @@ -=')) { - 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_share_activation_check'); - -if (!SFC_SHARE_USE_XFBML) { - // add the script to do this the non-connect way - add_action('wp_enqueue_scripts','sfc_share_enqueue'); - function sfc_share_enqueue() { - wp_enqueue_script( 'fb-share', 'http://static.ak.fbcdn.net/connect.php/js/FB.Share', array(), '1', true); - } -} - -/** - * Simple share button - * - * See http://wiki.developers.facebook.com/index.php/Fb:share-button for more info - * - * @param string $type box_count, button_count, button, icon, or icon_link - * @param int $post_id An optional post ID. - */ -function get_sfc_share_button($type = '', $id = 0) { - if (empty($type)) { - $options = get_option('sfc_options'); - $type = $options['share_type']; - } - - if (SFC_SHARE_USE_XFBML) { - return ''; - } else { - return ""; - } -} - -function sfc_share_button($type = '', $id = 0) { - echo get_sfc_share_button($type,$id); -} - -/** - * Simple share button as a shortcode - * - * See http://wiki.developers.facebook.com/index.php/Fb:share-button for more info - * - * Example use: [fb-share type="button"] or [fb-share id="123"] - */ -function sfcshare_shortcode($atts) { - $options = get_option('sfc_options'); - extract(shortcode_atts(array( - 'type' => $options['share_type'], - 'id' => 0, - ), $atts)); - - return get_sfc_share_button($type,$id); -} - -add_shortcode('fb-share', 'sfcshare_shortcode'); -add_shortcode('fbshare', 'sfcshare_shortcode'); // FB Foundations Share uses this shortcode. This is compatible with it. - -function sfc_share_button_automatic($content) { - $options = get_option('sfc_options'); - $button = get_sfc_share_button(); - switch ($options['share_position']) { - case "before": - $content = $button . $content; - break; - case "after": - $content = $content . $button; - break; - case "both": - $content = $button . $content . $button; - break; - case "manual": - default: - break; - } - return $content; -} -add_filter('the_content', 'sfc_share_button_automatic', 30); - -// add the admin sections to the sfc page -add_action('admin_init', 'sfc_share_admin_init'); -function sfc_share_admin_init() { - add_settings_section('sfc_share', __('Share Button Settings', 'sfc'), 'sfc_share_section_callback', 'sfc'); - add_settings_field('sfc_share_position', __('Share Button Position', 'sfc'), 'sfc_share_position', 'sfc', 'sfc_share'); - add_settings_field('sfc_share_type', __('Share Button Type', 'sfc'), 'sfc_share_type', 'sfc', 'sfc_share'); -} - -function sfc_share_section_callback() { - echo '

'.__('Choose where you want the share button to add the button in your content.', 'sfc').'

'; -} - -function sfc_share_position() { - $options = get_option('sfc_options'); - if (!$options['share_position']) $options['share_position'] = 'manual'; - ?> -

-

-

-

- - -
-
- -
-
- -
-

- - - -" /> -" /> - -/', $content, $matches) ) { - foreach ( wp_kses_hair($matches[1], array('http')) as $attr) - $img[$attr['name']] = $attr['value']; - if ( isset($img['src']) ) { - if (!isset($img['class']) || - (isset($img['class']) && false === straipos($img['class'], apply_filters('sfc_img_exclude',array('wp-smiley')))) - ) { // ignore smilies -?> -/', $content, $matches) ) { - foreach ( wp_kses_hair($matches[1], array('http')) as $attr) - $embed[$attr['name']] = $attr['value']; - if ( isset($embed['src']) ) { -?> - - - -=')) { + 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_share_activation_check'); + +if (!SFC_SHARE_USE_XFBML) { + // add the script to do this the non-connect way + add_action('wp_enqueue_scripts','sfc_share_enqueue'); + function sfc_share_enqueue() { + wp_enqueue_script( 'fb-share', 'http://static.ak.fbcdn.net/connect.php/js/FB.Share', array(), '1', true); + } +} + +/** + * Simple share button + * + * See http://wiki.developers.facebook.com/index.php/Fb:share-button for more info + * + * @param string $type box_count, button_count, button, icon, or icon_link + * @param int $post_id An optional post ID. + */ +function get_sfc_share_button($type = '', $id = 0) { + if (empty($type)) { + $options = get_option('sfc_options'); + $type = $options['share_type']; + } + + if (SFC_SHARE_USE_XFBML) { + return ''; + } else { + return ""; + } +} + +function sfc_share_button($type = '', $id = 0) { + echo get_sfc_share_button($type,$id); +} + +/** + * Simple share button as a shortcode + * + * See http://wiki.developers.facebook.com/index.php/Fb:share-button for more info + * + * Example use: [fb-share type="button"] or [fb-share id="123"] + */ +function sfcshare_shortcode($atts) { + $options = get_option('sfc_options'); + extract(shortcode_atts(array( + 'type' => $options['share_type'], + 'id' => 0, + ), $atts)); + + return get_sfc_share_button($type,$id); +} + +add_shortcode('fb-share', 'sfcshare_shortcode'); +add_shortcode('fbshare', 'sfcshare_shortcode'); // FB Foundations Share uses this shortcode. This is compatible with it. + +function sfc_share_button_automatic($content) { + $options = get_option('sfc_options'); + $button = get_sfc_share_button(); + switch ($options['share_position']) { + case "before": + $content = $button . $content; + break; + case "after": + $content = $content . $button; + break; + case "both": + $content = $button . $content . $button; + break; + case "manual": + default: + break; + } + return $content; +} +add_filter('the_content', 'sfc_share_button_automatic', 30); + +// add the admin sections to the sfc page +add_action('admin_init', 'sfc_share_admin_init'); +function sfc_share_admin_init() { + add_settings_section('sfc_share', __('Share Button Settings', 'sfc'), 'sfc_share_section_callback', 'sfc'); + add_settings_field('sfc_share_position', __('Share Button Position', 'sfc'), 'sfc_share_position', 'sfc', 'sfc_share'); + add_settings_field('sfc_share_type', __('Share Button Type', 'sfc'), 'sfc_share_type', 'sfc', 'sfc_share'); +} + +function sfc_share_section_callback() { + echo '

'.__('Choose where you want the share button to add the button in your content.', 'sfc').'

'; +} + +function sfc_share_position() { + $options = get_option('sfc_options'); + if (!$options['share_position']) $options['share_position'] = 'manual'; + ?> +

+

+

+

+ + +
+
+ +
+
+ +
+

+ + + +" /> +" /> + +/', $content, $matches) ) { + foreach ( wp_kses_hair($matches[1], array('http')) as $attr) + $img[$attr['name']] = $attr['value']; + if ( isset($img['src']) ) { + if (!isset($img['class']) || + (isset($img['class']) && false === straipos($img['class'], apply_filters('sfc_img_exclude',array('wp-smiley')))) + ) { // ignore smilies +?> +/', $content, $matches) ) { + foreach ( wp_kses_hair($matches[1], array('http')) as $attr) + $embed[$attr['name']] = $attr['value']; + if ( isset($embed['src']) ) { +?> + + + +=')) { - 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_upcoming_widget_activation_check'); - -// produce a list of upcoming events for a given facebook user -function sfc_upcoming_events($uid) { - if (!$uid) return; - - $options = get_option('sfc_options'); - - // load facebook platform - include_once 'facebook-platform/facebook.php'; - $fb=new Facebook($options['api_key'], $options['app_secret']); - - try { - $events = $fb->api_client->events_get($uid, null, time()); - } catch (Exception $e) { } - - if (!$events) return; - - $events_sorted = sfc_upcoming_sort($events, 'start_time'); - - foreach ($events_sorted as $event) { - do_action('sfc_upcoming_event',$event); - } -} - -function sfc_upcoming_event_output($event) { - echo date_i18n('F jS', $event["start_time"]); -?> - - "> -
- 'widget_sfc-upcoming', 'description' => __('Facebook Upcoming Events', 'sfc')); - $this->WP_Widget('sfc-upcoming', __('Facebook Upcoming Events (SFC)', 'sfc'), $widget_ops); - } - - function widget($args, $instance) { - extract( $args ); - $title = apply_filters('widget_title', $instance['title']); - $appid = $options['appid']; - $id = $instance['id']; - ?> - - - - - '') ); - $instance['title'] = strip_tags($new_instance['title']); - $instance['id'] = strip_tags($new_instance['id']); - return $instance; - } - - function form($instance) { - $instance = wp_parse_args( (array) $instance, array( 'title' => '') ); - $title = strip_tags($instance['title']); - $id = strip_tags($instance['id']); - ?> -

-

-

()

- =')) { + 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_upcoming_widget_activation_check'); + +// produce a list of upcoming events for a given facebook user +function sfc_upcoming_events($uid) { + if (!$uid) return; + + $options = get_option('sfc_options'); + + // load facebook platform + include_once 'facebook-platform/facebook.php'; + $fb=new Facebook($options['api_key'], $options['app_secret']); + + try { + $events = $fb->api_client->events_get($uid, null, time()); + } catch (Exception $e) { } + + if (!$events) return; + + $events_sorted = sfc_upcoming_sort($events, 'start_time'); + + foreach ($events_sorted as $event) { + do_action('sfc_upcoming_event',$event); + } +} + +function sfc_upcoming_event_output($event) { + echo date_i18n('F jS', $event["start_time"]); +?> + - "> +
+ 'widget_sfc-upcoming', 'description' => __('Facebook Upcoming Events', 'sfc')); + $this->WP_Widget('sfc-upcoming', __('Facebook Upcoming Events (SFC)', 'sfc'), $widget_ops); + } + + function widget($args, $instance) { + extract( $args ); + $title = apply_filters('widget_title', $instance['title']); + $appid = $options['appid']; + $id = $instance['id']; + ?> + + + + + '') ); + $instance['title'] = strip_tags($new_instance['title']); + $instance['id'] = strip_tags($new_instance['id']); + return $instance; + } + + function form($instance) { + $instance = wp_parse_args( (array) $instance, array( 'title' => '') ); + $title = strip_tags($instance['title']); + $id = strip_tags($instance['id']); + ?> +

+

+

()

+ =')) { - 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_user_status_activation_check'); - -function get_sfc_userstatus($args='') { - $args = wp_parse_args($args, array( - 'profileid' => '', - 'linked' => 'true' - )); - extract($args); - - return ""; -} - -function sfc_userstatus($args='') { - echo get_sfc_userstatus($args); -} - -function sfc_userstatus_shortcode($atts) { - $args = shortcode_atts(array( - 'profileid' => '', - 'linked' => 'true' - ), $atts); - - return get_sfc_userstatus($args); -} -add_shortcode('fb-userstatus', 'sfc_userstatus_shortcode'); - -class SFC_User_Status_Widget extends WP_Widget { - function SFC_User_Status_Widget() { - $widget_ops = array('classname' => 'widget_sfc-status', 'description' => __('Facebook User Status (needs user profile number)', 'sfc') ); - $this->WP_Widget('sfc-userstatus', __('Facebook Status (SFC)', 'sfc'), $widget_ops); - } - - function widget($args, $instance) { - extract( $args ); - $title = apply_filters('widget_title', $instance['title']); - $profileid = $instance['profileid']; - ?> - - - - - -

-

- -

- =')) { + 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_user_status_activation_check'); + +function get_sfc_userstatus($args='') { + $args = wp_parse_args($args, array( + 'profileid' => '', + 'linked' => 'true' + )); + extract($args); + + return ""; +} + +function sfc_userstatus($args='') { + echo get_sfc_userstatus($args); +} + +function sfc_userstatus_shortcode($atts) { + $args = shortcode_atts(array( + 'profileid' => '', + 'linked' => 'true' + ), $atts); + + return get_sfc_userstatus($args); +} +add_shortcode('fb-userstatus', 'sfc_userstatus_shortcode'); + +class SFC_User_Status_Widget extends WP_Widget { + function SFC_User_Status_Widget() { + $widget_ops = array('classname' => 'widget_sfc-status', 'description' => __('Facebook User Status (needs user profile number)', 'sfc') ); + $this->WP_Widget('sfc-userstatus', __('Facebook Status (SFC)', 'sfc'), $widget_ops); + } + + function widget($args, $instance) { + extract( $args ); + $title = apply_filters('widget_title', $instance['title']); + $profileid = $instance['profileid']; + ?> + + + + + +

+

+ +

+ - - -xd - -'; -else - echo ''; -?> - - - + + +xd + +'; +else + echo ''; +?> + + +