Sociable Wordpress Plugin
by Hersey on Apr.10, 2009, under Cool Stuff, Tools
This afternoon I installed a Wordpress Plugin called Sociable that automatically adds icons that link to different social networking/bookmarking sites such as Twitter and Facebook to post. Neat little tool since it allow people to share your post with others on these networks by basically just clicking on the icons. Just check out the Share & Enjoy icons at the bottom of this post.
I regularly post to Twitter and it updates my Facebook status. Anyway the Sociable plugin works well but I found another version Sociable-Italia that has a feature that creates TinyUrls to help you keep to the 140 character limit of twitter. Other than TinyUrls and the settings page being in Italian in Sociable-Italia, I think the plugins are basically identical.
Anyway I added the code that generates the TinyUrl from Sociable-Italia to the Sociable plugin by editing sociable.php in the wp-content/plugins/sociable directory. Find the line
$url = $site['url'];
and add this after it
if ($sitename == ‘TwitThis’) {
$twitperma = file_get_contents(‘http://tinyurl.com/api-create.php?url=’.$permalink);
$url = str_replace(‘PERMALINK’, $twitperma, $url);
} else {
$url = str_replace(‘PERMALINK’, $permalink, $url);
}
I also added the title of the post to the twitthis icon. Find the line:
‘url’ => ‘http://twitter.com/home?status=PERMALINK’,
and change it to this
‘url’ => ‘http://twitter.com/home?status=PERMALINK :: TITLE’,
Of course if I have to update the plugin in the future this will stop working unless I remember to redo this, perhaps the author of the plugin will add this to a future release.
Great little plugin – download it here.

April 14th, 2009 on 1:03 pm
This was hugely helpful. I tried to convert it to work with tr.im, but evidently I am not getting the api call quite right. It literally hangs my whole blog. I have gone back to TinyURL. It is working like a charm!
April 14th, 2009 on 3:34 pm
For tr.im I think you just need to replace ’http://tinyurl.com/api-create.php?url=’.$permalink with ’http://api.tr.im/api/trim_simple?url=’.$permalink in the file_get_contents call.
If you have a username and password for tr.im try this
’http://api.tr.im/api/trim_simple?url=’.$permalink.’&username=yourtrimusername&password=yourtrimpassword’
If you try it and it works, let us know.
Thanks
Hersey
April 14th, 2009 on 3:47 pm
FYI – went ahead and tested using tr.im – works with out username and password, don’t have an account so I didn’t try that.