Simple Facebook Link
Simple Facebook Link displays a link allowing you to share posts and pages with Facebook users.
Download
Download Simple Facebook Link (v1.3, 12/11/2009)
Changelog
Version 1.0
- Initial release
Version 1.1
- Added bit.ly to list of URL shortening services
Version 1.2
- Fixed issue with ampersands (and probably other characters) in the blog title causing linking issues
- Added su.pr as another URL shortening service
Version 1.3
- Now using Simple URL Shortener plugin to provide URL shortening
- Added new parameter that allows overriding of passed URL
- Blog title again corrected, using code from Simple Social Bookmarks plugin
- Code tidied
Installation
- Upload the entire
simple-facebook-linkfolder to yourwp-content/plugins/directory. - Activate the plugin through the ‘Plugins’ menu in WordPress.
- There is no options screen – configuration is done in your code.
Configuration
From version 1.3 you must now install the Simple URL Shortener plugin for the URL shortening to work in this plugin
The code for Simple Facebook Link should be added to the bottom of appropriate post/page templates within your theme (and in the case of posts, within the loop).
Simple Facebook Link simply returns a URL – this URL is a link to Facebook with your post/page URL and blog title within it. It can even use TinyURL and other URL shortening services to make the link passed to Facebook even more convenient.
Here’s an example.
<a href="<?php simple_facebook_link(''); ?>">Share on Facebook</a>
This will display the text “Share on Facebook” on your page/post. However, when clicked on it will take you to Facebook, where it will have your blog post/page details and will give the current user an option to add a comment before sharing it with their Facebook community.
In the case of this example, no parameters were passed and, hence, no URL shortening service was used. If, however, you’d like to use a such a service, simply add one as a parameter. A full list can be found in the documentation for the Simple URL Shortener plugin.
The following is an example of how it could be used, with a function_exists check so that it doesn’t cause problems if the plugin is not active…
<?php if (function_exists('simple_facebook_link')) : ?>
<a href="<?php simple_facebook_link('is.gd'); ?>">Share on Facebook</a>
<?php endif; ?>
This also requests is.gd to be used to shorten the URL.
From version 1.3, you can also specify a second parameter (which is optional and can be omitted), allowing you to override the URL. This is useful if you wish to add a Facebook link outside of “the loop”.
An example is…
<a href="<?php simple_facebook_link('is.gd','http://www.artiss.co.uk'); ?>">Share on Facebook</a>
This overrides the URL to the artiss.co.uk homepage and shortens it using the is.gd service.
Known Issues
“cannot yet handle MBCS in html_entity_decode”
This is a known bug in PHP 4. Please read this post for further details and possible workarounds.
Problems/Queries
Please report any problems, or suggestions for enhancements, to me either via my contact form or by commenting on the appropriate entries on my blog.
Updates
Updates to this and any other of my WordPress plugins will be published on this blog.
Subscribe to my WordPress category feed.


















Artiss.co.uk is checked by
I read the instructions but I’m not entirely clear on how to implement this. The plugin is activated, but if I paste <a href=”">Share on Facebook onto the end of my post nothing show up. Where am I suppesed to add this code?
i.e. I don’t know what this means: The code for Simple Facebook Link should be added to the bottom of appropriate post/page templates within your theme (and in the case of posts, within the loop).
thanks.
Hi, thanks for the comment. Sorry to hear you’re having problems.
If you don’t know how to add code to “the loop” then it can be quite difficult to explain. Here’s the WordPress page on it – http://codex.wordpress.org/The_Loop. The code for this plugin needs to be added somewhere within “the loop” but where is up to you – it depends where you want this to display. You will have “the loop” within any page or post code you have within your theme – this will include index.php, single.php and page.php.
If all else fails, contact me via my form and attach the code of the page that you’re attempting to add the code to. I’ll show you exactly where the code goes and try and give you a better explanation of why.
Hello !
I’m French, sorry for my bad english !
…
Thanks for your nice plugin !
I want to know how i can open the facebook window in a new little window !?
(i want the same thing that on the Youtube page for exemple !)
Thanks
Regards,
You need to add a simple
TARGETto the link.So here’s the example with the
TARGETadded…<a href="<?php simple_facebook_link(''); ?>" target="_blank"> Share on Facebook</a>Thx David !
But i want open a new window in this format > 620×440px !
How i can to do it ?
Thx !
In this case you’ll need to use JavaScript.
The following should work (although I’ve not tested it)…
<a href="" onClick="window.open('<?php simple_facebook_link(''); ?>', 'Share on Facebook','width=620,height=440')">Share on Facebook</a>More details about how to do this can be found here (or, in fact, Google “open window with JavaScript”…
http://www.pageresource.com/jscript/jwinopen.htm
Thanks a lot David !
I go to try this !
Works great, thank you
You have a section at the top left of the page that says “Find Me Online” with all the different places you have profiles. What WordPress plugin is that? I presume that is functionally different than say Add to Any.
Hi Jeff, that’s a plugin of my own. However, I’ve never made it available to the public as I’ve pretty much hardcoded the links for myself. I’m currently working on a social sharing plugin for post entries, so this may be a natural progression for me – to launch this plugin “properly”!
Nice plugin, but not show Facebook Image, only Text link, Too Bad. Can you make this plugin show Facebook Image before the Text link.
Iman, the text is not part of the plugin. All the plugin does is return a link – it’s completely up to you whether you assign this link to some text or an image. There are many Facebook icons to be found on the ‘net, so simply grab one of those and wrap the plugin around a link to that.
I think you plugin miss spelling, below I paste the link code froum your Plugin…
http://www.facebook.com/sharer.php?u=http://hariansib.com/?
See you make sharer not share, this make wrong function with some case.
Iman, that link works fine for me. Although producing slightly different screens, both share.php and sharer.php should work – sharer.php is the one that Facebook uses in its examples, and hence why I’ve used it.
Are you saying that this link does NOT work but does if you replace it with share.php?
Links Works, But Cancel button didnt work well, the windows still open after we push the Cancel Button. Now I have replaced the shares with share, and Cancel button did work well now.
You’re right Iman. It appears that the
sharepage has kept step with recent Facebook changes butsharerhasn’t. I’m looking at a change in the code anyway, so may possibly implement a change tosharer.First of all, thanks for this wonderful plugin. I am going to use it on the new version of my norwegian website about waterpolo, http://www.vannpolo.org.
However, when I validated my site after activating your plugin the Facebook link caused a validation error. This is because of the ampersand in the URL. I fixed it easily by changing “&” to “&”, which W3C recommends, on line 32.
Can you please implement this change in your plugin, so I don’t have to do this manually for every update?
Einar
Hi Einar, thanks for the comments.
Yes, you’re right about the validation. It’s my intention in the next few weeks to go through all my plugins and give them a good “spring clean” – ensuring validation is one thing I’ll be doing. I’ve had a number of suggestions recently about various plugins that will be useful to implement with others too, so these are the kinds of things I’ll be doing.
Thanks David for a simple plugin. It is so cool and I had no problem installing it especially considering I just started using Wordpress for my new Travelogue.
http://graystarcity.info/
Hi David,
What’s the “Find Me Online” widget at the top of your page? It’s Brilliant.
I get asked this a lot.
However, although it is a plugin of my own, it’s not a “proper” released one, as it has my links hard-coded into it. For this to be viable I’d have to put an admin screen, etc, in it.
But, if anybody wants the plugin to modify themselves with their own site links, then let me know and I’ll happily email it to you.