Share on Facebook
Someone sent me a comment about my Add To Facebook plugin asking for it to work a little differently. They were asking for the page to be added to Facebook as a link instead of in the Mini-Feed. I am happy to oblige with the Share on Facebook plugin.
This plugin adds a link to the bottom of each post and page on your blog with the text “Share on Facebook”, Facebook icon, both or the Facebook share button depending on what you choose on the Options page. Alternately, you can add the link anywhere within your theme using a template tag.
This plugin has been tested on WordPress 3.1.3 and should work on previous WordPress versions as well. Now compatible with PHP 4.x. (PHP 5.x is no longer a requirement.)
- Add a directory called ‘share-on-facebook’ (without the quotes) to your ‘/wp-content/plugins/’ directory.
- Upload shareonfacebook.php to ‘/wp-content/plugins/share-on-facebook/’ directory.
- Activate the plugin through the ‘Plugins’ page in WordPress.
- Go to ‘Settings->Share on Facebook’ in your admin interface to select your options.
There are three options on the options page: Link Type, Insertion Type and Page Type.
- Link Type – This option sets if you want your Facebook link to be text, icon, both or share button.
- Insertion Type – This option sets how you want to insert the link into your posts/pages. There are two choices: auto or template.
- Auto – When insertion type is set to auto the Facebook link will automatically be inserted right after the post.
- Template – When insertion type is set to template the Facebook link will appear wherever the template tag for the plugin is added to your theme. This option requires the following template tag to be added to your theme:
<?php if(function_exists(shareonfacebook)) : shareonfacebook(); endif; ?>
- Page Type – This option sets whether you want you Facebook link to appear on Posts, Pages or both (Posts and Pages).
Once this option is set a link will appear after the content of each post/page with the text “Share on Facebook”, the Facebook icon, both or the familiar Facebook share button. Clicking the link will bring the user to the Facebook site to add the link to their profile. If the user isn’t logged in they will be prompted to do so.
Download Current Version
Share on Facebook 1.7
* v1.7 – Fixed the “You do not have sufficient permissions to access this page.” message some users were getting when saving options.
– Changed a $_SERVER['PHP_SELF'] call to $_SERVER['REQUEST_URI'] to address possible security issue.
* v1.5 – Added compatibility with PHP 4.x.
* v1.4 – Added option to choose to have the Facebook link appear on Posts, Pages or both (Posts and Pages).
* v1.3 – Facebook’s “Post to Profile” page now appears in a popup for all posts on the index page of a blog. Previously this would work only for the first post on the index pages with the rest of the posts opening the “Post to Profile” page in the same window (instead of the popup).
* v1.2 – Reworked with valid XHTML.
– Integrated redundant code.
– Updated styles for the button.
* v1.1 – Fixed bug in template tag implementation.
* v1.0 – Initial public release.
If you have any questions, comment or suggestions please leave them in a comment or email them to me.
If you find this plugin useful please feel free to donate a little money to help me offset the costs of this website. Thanks.