Skip to content
Snippets Groups Projects
Commit 7769119f authored by Erick Hitter's avatar Erick Hitter
Browse files

Initial commit of release 2.0.3 from WP.org

parent aefbe51f
No related branches found
No related tags found
No related merge requests found
buttons/box_count.png

2.12 KiB

buttons/button.png

1.08 KiB

buttons/button_count.png

1.58 KiB

buttons/icon.png

279 B

buttons/icon_link.png

1.13 KiB

=== Simple Facebook Share Button ===
Contributors: ethitter
Donate link: http://www.ethitter.com/plugins/simple-facebook-share-button/
Tags: share, facebook, social media, button
Requires at least: 2.7
Tested up to: 3.2.1
Stable tag: 2.0.3
Painlessly add a Facebook Share button to your posts and/or pages. Supports all button styles, manual or automatic inclusion, and shortcode.
== Description ==
Painlessly add a Facebook Share button to your posts and pages.
Features include:
* Supports all five button types, including custom button text;
* Supports placing button above or below content;
* Button can be shown on either posts (including excerpts), pages, or both;
* Includes compatibility modes for seamless theme integration;
* Allows user to override default padding options (defaults provided in admin interface);
* Button can be added via shortcode;
* Function can be added manually.
== Installation ==
1. Unzip simple-fb-share-button.zip and upload entire simple-fb-share-button folder to wp-content/plugins/.
2. Activate plugin through the Wordpress Plugins menu.
3. Set display, button, and placement options from Settings > Simple FB Share Button.
4. To manually include the Share button, see the Help page in the plugin's Settings page.
== Frequently Asked Questions ==
= After upgrading to version 2.0, the button no longer appears on my site. How can I fix this? =
The most common reason for this problem lies with your theme's footer.php file. If `wp_footer()` does not appear somewhere in footer.php, my plugin cannot add the scripts needed to render the Share button. If your theme is missing `wp_footer()`, add the following code just before the `</body>` tag: `<?php wp_footer(); ?>`.
= How Do I Manually Add Share Buttons? =
After activating the plugin, go to Settings > Simple FB Share Button and select "Plugin Help" at the top of the screen.
= Why Does My Blog's Tagline Appear Instead of a Summary of My Content? =
The Facebook Sharer uses the `<meta name="description" content="description">` tag to gather information about the content you are sharing. Some templates set the description tag to be your tagline. If you are using a plugin that creates a meta description tag from your content, such as HeadSpace or All In One SEO, you should edit your template's header.php file to remove the `<meta name="description" content="<?php bloginfo('description'); ?>">` tag.
= What are the Theme Compatibility Modes? =
In certain themes, the button may overlap other theme elements, such as comment buttons or other plugins. The plugin includes three compatibility modes to help resolve these problems with minimal effort user effort. Know that in some cases, these modes will not resolve button placement problems. In that case, a custom CSS style may be needed.
Mode 1 disables the CSS float property (a setting that allows the button to, as the name implies, float adjacent to your blog's content) and relies on the alignment of the button wrapper to place the button.
Mode 2 prevents other elements from floating adjacent to the button (using the CSS clear property).
Mode 3 combines the functions of Modes 1 and 2.
== Changelog ==
= 2.0.3 =
* Fix bug in custom styling option.
= 2.0.2 =
* Fix bug in shortcode.
= 2.0.1 =
* Fix bug in button type setting.
= 2.0 =
* Rewrite entire plugin.
* Add option to display button on post excerpts.
= 1.0.5 =
* Fixed problem where direct implementation may fail to render correct button.
= 1.0.4 =
* Plugin pages moved to ethitter.com
= 1.0.3 =
* Fixed FB.Loader error caused by some versions of Internet Explorer.
= 1.0.1 =
* Corrected Subversion error that omitted buttons from version 1.0.
= 1.0 =
* Added shortcode;
* Removed SFBSB_do() function and replaced with SFBSB_direct();
* Added built-in help page;
* Reformatted settings page for better navigation;
* Removed redundant button style.
== Upgrade Notice ==
= 2.0.3 =
Fix bug in custom styling option.
= 2.0.2 =
Fix bug in shortcode.
= 2.0.1 =
Fix bug in button type setting.
= 2.0 =
Plugin is entirely rewritten including options storage. Also added option to display button on post excerpts.
= 1.0.5 =
Fixed problem where direct implementation may fail to render correct button.
= 1.0.4 =
Plugins pages moved to ethitter.com
= 1.0.3 =
Resolved FB.Loader error exhibited by certain versions of Internet Explorer.
= 1.0.1 =
Buttons will appear in options screen and help pane.
= 1.0 =
Removed redundant button style; added new, more flexible function for direct implementation; added shortcode; reformatted settings page.
\ No newline at end of file
<?php
/*
Plugin Name: Simple Facebook Share Button
Plugin URI: http://www.ethitter.com/plugins/simple-facebook-share-button/
Description: Painlessly add a Facebook® Share button to your posts and/or pages. Supports all five button types, including custom button text, and placement above or below content. Includes compatibility modes to ensure seamless theme integration. Button can also be added using a shortcode or by inserting a function in your template.
Author: Erick Hitter
Version: 2.0.3
Author URI: http://www.ethitter.com/
*/
require( 'simple_fb_share_button_options.php' );
/*
* Set up options, convert old options, add filters if automatic display is enabled, and enqueue scripts
* @uses get_option, update_option, add_filter, wp_enqueue_script
* @return null
*/
function SFBSB_setup() {
//Convert options or set up defaults
if( !$options = get_option( 'SFBSB' ) ) {
if( get_option( 'SFBSB_button' ) ) {
$options = array();
$keys = array(
'SFBSB_button' => 'button',
'SFBSB_display' => 'display',
'SFBSB_content' => 'content',
'SFBSB_placement' => 'placement',
'SFBSB_style' => 'style',
'SFBSB_align' => 'align',
'SFBSB_custom_text' => 'custom_text',
'SFBSB_tpad' => 'tpad',
'SFBSB_bpad' => 'bpad',
'SFBSB_lpad' => 'lpad',
'SFBSB_rpad' => 'rpad',
'SFBSB_compatibility' => 'compatibility',
'SFBSB_uninstall' => 'uninstall'
);
foreach( $keys as $old_key => $new_key ) {
if( $old_option = get_option( $old_key ) ) $options[ $new_key ] = $old_option;
delete_option( $old_key );
}
}
else {
$options = array(
'display' => 0,
'button' => 'button',
'placement' => 'tl',
'content' => 'post'
);
}
update_option( 'SFBSB', $options );
}
//Add filters if set to automatic display
if( $options[ 'display' ] == 1 ) add_filter( 'the_content', 'SFBSB_auto' );
if( $options[ 'display' ] == 1 && $options[ 'content-excerpt' ] == 1 ) add_filter( 'the_excerpt', 'SFBSB_auto' );
//Register scripts
wp_enqueue_script( 'FB-Loader', 'http://static.ak.fbcdn.net/connect.php/js/FB.Loader', array(), 322597, true );
wp_enqueue_script( 'FB-Share', 'http://static.ak.fbcdn.net/connect.php/js/FB.Share', array( 'FB-Loader' ), 322597, true );
}
add_action( 'plugins_loaded', 'SFBSB_setup' );
/*
* Remove plugin options on deactivation if requested to do so.
* @uses get_option, delete_option
* @action register_deactivation_hook
*/
function SFBSB_deactivate() {
$options = get_option( 'SFBSB' );
if ($options[ 'uninstall' ] == 1 ) delete_option('SFBSB');
}
register_deactivation_hook( __FILE__, 'SFBSB_deactivate' );
/*
* On-demand Share button implementation.
* Must be used within the loop.
* @params string button type, string custom button text
* @uses get_permalink
* @return html
*/
function SFBSB_direct( $button = 'button_count', $custom_text = false ) {
//Possible button types
$buttons = array(
'box_count',
'button_count',
'button',
'icon'
);
//Check button type
if( $button == 'icon_link' && $custom_text ) $button_type = $button;
elseif( in_array( $button, $buttons ) ) $button_type = $button;
else $button_type = 'button_count';
return '<a name="fb_share" type="' . $button_type . '" share_url="' . get_permalink() . '">' . $custom_text . '</a>';
}
/*
* Shortcode Share button implementation.
* Must be used within the loop.
* @params array shortcode attributes
* @uses shortcode_atts, get_permalink, add_shortcode
*/
function SFBSB_shortcode( $atts ) {
extract( shortcode_atts( array(
'button' => 'button',
'align' => false,
'style' => 'float:left;',
'custom_text' => ''
), $atts ) );
//Button type
if( $button == 'custom' ) $button = 'icon_link';
$style_do = ' style="' . $style . '"';
if( $align !== false ) $align_do = ' align="' . $align . '"';
return '<div' . $align_do . $style_do . '><a name="fb_share" type="' . $button . '" share_url="' . get_permalink() . '">' . $custom_text . '</a></div>';
}
add_shortcode( 'SFBSB', 'SFBSB_shortcode' );
/*
* Add button to content via the_content and the_excerpt filters
* @param string $content post content
* @uses $post, get_option
* @return string post content
*/
function SFBSB_auto( $content ) {
global $post;
$options = get_option( 'SFBSB' );
//Button
if( $options[ 'button' ] == 'custom' ) {
$button_type = 'icon_link';
}
else $button_type = $options[ 'button'];
//Padding
$default_padding = '5px';
$_padding = array();
if( ( $options[ 'placement' ] == 'tl' || $options[ 'placement' ] == 'tr' ) && !isset( $options[ 'tpad' ] ) ) $options[ 'tpad' ] = '0';
if( ( $options[ 'placement' ] == 'bl' || $options[ 'placement' ] == 'br' ) && !isset( $options[ 'bpad' ] ) ) $options[ 'bpad' ] = '0';
if( ( $options[ 'placement' ] == 'tl' || $options[ 'placement' ] == 'bl' ) && !isset( $options[ 'lpad' ] ) ) $options[ 'lpad' ] = '0';
if( ( $options[ 'placement' ] == 'tr' || $options[ 'placement' ] == 'br' ) && !isset( $options[ 'rpad' ] ) ) $options[ 'rpad' ] = '0';
$_padding[ 0 ] = strlen( $options[ 'tpad' ] ) > 0 ? $options[ 'tpad' ] . 'px' : $default_padding;
$_padding[ 1 ] = strlen( $options[ 'rpad' ] ) > 0 ? $options[ 'rpad' ] . 'px' : $default_padding;
$_padding[ 2 ] = strlen( $options[ 'bpad' ] ) > 0 ? $options[ 'bpad' ] . 'px' : $default_padding;
$_padding[ 3 ] = strlen( $options[ 'lpad' ] ) > 0 ? $options[ 'lpad' ] . 'px' : $default_padding;
$padding = trim( implode( ' ', $_padding ) );
//Placement
if( $options[ 'placement' ] == 'tl' || $options[ 'placement' ] == 'bl' ) $align=' align="left"';
elseif( $options[ 'placement' ] == 'tr' || $options[ 'placement' ] == 'br' ) $align=' align="right"';
//Compatibility mode
if( $options[ 'compatibility' ] == 1 ) $float = 'none';
elseif( $options[ 'compatibility' ] == 2 ) {
if( $options[ 'placement' ] == 'tl' || $options[ 'placement' ] == 'bl' ) $float = 'left; clear:right';
elseif( $options[ 'placement' ] == 'tr' || $options[ 'placement' ] == 'br' ) $float = 'right; clear:left';
}
elseif( $options[ 'compatibility' ] == 3 ) {
if( $options[ 'placement' ] == 'tl' || $options[ 'placement' ] == 'bl' ) $float = 'none; clear:right';
elseif( $options[ 'placement' ] == 'tr' || $options[ 'placement' ] == 'br' ) $float = 'none; clear:left';
}
else {
if( $options[ 'placement' ] == 'tl' || $options[ 'placement' ] ==' bl' ) $float = 'left';
elseif( $options[ 'placement' ] == 'tr' || $options[ 'placement' ] == 'br' ) $float = 'right';
}
//Style
if( !empty( $options[ 'style' ] ) ) $style_do = ' style="' . $options[ 'style' ] . '"';
else $style_do = ' style="float: ' . $float . '; padding: ' . $padding . ';"';
//Build button
$fb = '<div' . $align . $style_do . '><a name="fb_share" type="' . $button_type . '" share_url="' . get_permalink() . '">' . $options[ 'custom_text' ] . '</a></div>';
//Add button to $content
if ( ( $post->post_type == $options[ 'content' ] || $options[ 'content' ] == 'both' ) && ( $options[ 'placement' ] == 'tl' || $options[ 'placement' ] == 'tr' ) ) $content = $fb . $content;
elseif( ( $post->post_type == $options[ 'content' ] || $options[ 'content' ] == 'both' ) && ( $options[ 'placement' ] == 'bl' || $options[ 'placement' ] == 'br' ) ) $content = $content . $fb;
return $content;
}
/*
* LEGACY FUNCTION
* @uses _deprecated_function
* @return text
*/
function SFBSB_do() {
_deprecated_function( __FUNCTION__, '2.0', 'SFBSB_direct()' );
return '<!-- Simple Facebook Share Button: this function is no longer supported. See the plugin documentation and replace this function with SFBSB_direct(). -->';
}
?>
\ No newline at end of file
This diff is collapsed.
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment