";
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 sfc_share_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', 'sfc_share_shortcode');
add_shortcode('fbshare', 'sfc_share_shortcode'); // FB Foundations Share uses this shortcode. This is compatible with it.
function sfc_share_button_automatic($content) {
global $post;
$post_types = apply_filters('sfc_share_post_types', get_post_types( array('public' => true) ) );
if ( !in_array($post->post_type, $post_types) ) return $content;
// exclude bbPress post types
if ( function_exists('bbp_is_custom_post_type') && bbp_is_custom_post_type() ) return $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 '
'.__('Facebook no longer supports the Share button. Therefore it has been replaced with the similar versions of the Like button.', 'sfc').'
';
}
function sfc_share_position() {
$options = get_option('sfc_options');
if (!isset($options['share_position'])) $options['share_position'] = 'manual';
?>