To connect your site to Facebook, you will need a Facebook Application.
If you have already created one, please insert your Application Secret and Application ID below.
Select the application you created, then copy and paste the Application Secret, and Application ID from there.
SFC-Plugins
Each separate plugin can be enabled or disabled using the checkboxes below. Only enable the plugins you want to use, and the rest will not run at all! Here's a quick description of each plugin:
Login - The Login plugin allows your users to login using their Facebook Credentials. To do this,
it adds a Facebook button on the Login screen. There is also a button on the Users' profile screen to allow them
to connect or disconnect their account from Facebook. The User's Facebook ID number will be stored as usermeta
and can be used for many things.
Register - The Register plugin changes the normal WordPress user registration mechanism into the
Facebook Register plugin mechanism. This lets users easily register using their Facebook credentials, or to
register without having any credentials. Users who register with FB credentials will automatically be able to
Login using their FB credentials in the Login plugin. As an added bonus, FB Register adds a CAPTCHA to the
registration process, helping to eliminate spam registrations.
Like - The Like plugin will let you automatically or manually add Like and Send buttons to all
the Posts and Pages on your site.
Share - The Share plugin will let you automatically add a second Like button to all the Posts and
Pages on your site. This is styled to look similar to the older, now removed, \"Share\" feature Facebook used
to offer, but it doesn't have the same kind of popup dialog any longer.
Publish - The Publish plugin will let you automatically send new posts and pages to either your
site's main Facebook Page or your personal Facebook Profile. Automatically posted entries also get metadata
about the Facebook post saved about them, for use by other plugins.
Widgets - The Widgets plugin adds several widgets that can be used by your site's sidebar (or
any other widget areas in your theme). Most of these come from the
Facebook Social Plugins.
Comments - The Comments plugin will let your users use Facebook credentials to make comments, and
offer those users an option to share their comments, and your post, on Facebook. This basically eliminates the
need for users to type in their Names and Email addresses. Note that some themes do checking for these \"required\"
elements via Javascript. Because Facebook Comments get these fields filled on the back end, the theme may need to
be modified to both display the button or to eliminate the javascript requirements checks.
Integrate Comments - The Comment Integration plugin will interact with the saved data from the
automatic publishing plugin, and periodically poll Facebook for new comments made to your auto-published stories.
Comments will then be pulled from Facebook and integrated into the normally displayed comments stream.
Photos - The Photos plugin adds a new tab to the Media Uploader on the Edit Post pages, which will
show your Facebook photo albums and let you easily embed pictures from Facebook into your posts.
{$home} in as the Connect URL on the Connect Tab.", 'sfc'); ?>
Facebook Application List page.', 'sfc'); ?>
How to Setup Your Facebook Application', 'sfc'); ?>
";
_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'); ?>
";
}
function sfc_plugins_text() {
?>
$value) {
if ($key != 'sig') {
$payload .= $key . '=' . $value;
}
}
if (md5($payload . $options['app_secret']) != $args['sig']) {
return null;
}
return $args;
}
function sfc_base64_url_decode($input) {
return base64_decode(strtr($input, '-_', '+/'));
}
/*
// 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;
}
*/
function sfc_remote($obj, $connection='', $args=array(), $type = 'GET') {
$type = strtoupper($type);
if (empty($obj)) return null;
if (empty($args['access_token'])) {
$cookie = sfc_cookie_parse();
if (!empty($cookie['access_token'])) {
$args['access_token'] = $cookie['access_token'];
}
}
$url = 'https://graph.facebook.com/'. $obj;
if (!empty($connection)) $url .= '/'.$connection;
if ($type == 'GET') $url .= '?access_token='.$args['access_token'];
if ($type == 'POST') {
$data = wp_remote_post($url, $args);
} else if ($type == 'GET') {
$data = wp_remote_get($url, $args);
}
if ($data && !is_wp_error($data)) {
$resp = json_decode($data['body'],true);
return $resp;
}
return false;
}
// code to create a pretty excerpt given a post object
function sfc_base_make_excerpt($post) {
if (!empty($post->post_excerpt)) $text = $post->post_excerpt;
else $text = $post->post_content;
$text = strip_shortcodes( $text );
remove_filter( 'the_content', 'wptexturize' );
$text = apply_filters('the_content', $text);
add_filter( 'the_content', 'wptexturize' );
$text = str_replace(']]>', ']]>', $text);
$text = wp_strip_all_tags($text);
$text = str_replace(array("\r\n","\r","\n"),' ',$text);
$excerpt_more = apply_filters('excerpt_more', '[...]');
$excerpt_more = html_entity_decode($excerpt_more, ENT_QUOTES, 'UTF-8');
$text = html_entity_decode($text, ENT_QUOTES, 'UTF-8');
$max = min(1000,apply_filters('sfc_excerpt_length',1000));
$max -= strlen ($excerpt_more) + 1;
$max -= strlen ('') * 2 - 1;
if ($max<1) return ''; // nothing to send
if (strlen($text) >= $max) {
$text = substr($text, 0, $max);
$words = explode(' ', $text);
array_pop ($words);
array_push ($words, $excerpt_more);
$text = implode(' ', $words);
}
return $text;
}
// code to find any and all images in a post's actual content, given a post object (returns array of urls)
// this should give the best representative sample of images from the post to push to FB
function sfc_base_find_images($post) {
$images = array();
// first we apply the filters to the content, just in case they're using shortcodes or oembed to display images
$content = apply_filters('the_content', $post->post_content);
// next, we get the post thumbnail, put it first in the image list
if ( current_theme_supports('post-thumbnails') && 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];
}
}
// now search for images in the content itself
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
if ( !in_array( $img['src'], $images ) && strpos( $img['src'], 'fbcdn.net' ) === false ) {
$images[] = $img['src'];
}
}
}
}
}
return $images;
}
// tries to find any video content in a post for meta stuff (only finds first video embed)
function sfc_base_find_video($post) {
$vid = array();
// first we apply the filters to the content, just in case they're using shortcodes or oembed to display videos
$content = apply_filters('the_content', $post->post_content);
// look for an embed to add with video_src (simple, just add first embed)
if ( preg_match('/