=')) {
return;
}
}
deactivate_plugins(basename(__FILE__)); // Deactivate ourself
wp_die("The base SFC plugin must be activated before this plugin will run.");
}
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_share_section_callback', 'sfc');
add_settings_field('sfc_share_position', 'Share Button Position', 'sfc_share_position', 'sfc', 'sfc_share');
add_settings_field('sfc_share_type', 'Share Button Type', '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.
';
}
function sfc_share_position() {
$options = get_option('sfc_options');
if (!$options['share_position']) $options['share_position'] = 'manual';
?>
|
Preview:
|
Note: Counts will not show up until they reach at least three. This is a Facebook limitation on the Share button. |
" />
" />
/', $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 === strpos($img['class'], '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']) ) {
?>