April 14th, 2008 Wordpress Twitter Widget
My latest plugin is a sidebar widget that handles Twitter feeds. It’s true that you could just point and RSS widget at one of the Twitter feeds, but you end up with the whole tweet (I honestly don’t know what they are called) as a link, @replies don’t function, etc. Twitter Widget Pro properly handles twitter feeds, including @username and link parsing, feeds that include friends or just one user, and can even display profile images for the users. It’s set up like the RSS widgets, so you can have as many of as you want on your sidebars.
I currently have my twitter feed in the right sidebar, showing the last five tweets, and Kevin Rose’s feed (with friends) in the left sidebar, showing profile images along with each of the last 10 tweets.
I tried to make everything easily styled, so there are no built-in styles. If you don’t know exactly what you need, here is what I’m using on this site:
/** * Twitter Widget */ .widget_twitter li { clear:both; } .widget_twitter li img { float:left; margin-right:.5em; } .widget_twitter li .clear { clear:both; }
Changelog
- 04/23/2008: 1.1.0
-
- Most major fix is the inclusion of json_decode.php for users that don’t have json_decode() which was added in PHP 5.2.0
- Fixed problem with displaying a useless li when profile images aren’t displayed on a single user widget
- Default title is now set to “Twitter: UserName”
- 04/17/2008: 1.0.0
-
- Released to wordpress.org repository
- 04/14/2008: 0.0.3
-
- Fixed some of the settings used with Snoopy
- Set a read timeout for fetching the files
- 04/14/2008: Version 0.0.2
-
- Changed some function names
- Moved form display to a separate function (_showForm)
- Now uses wp_parse_args to handle defaults
- Added comments to the code
- Added seconds to the _timeSince function so you can have something like “about 25 seconds ago”
le blog à Ollie » Liens du jour Says:
[...] Un widget Twitter pour WordPress. [...]
Raoul Says:
I’m looking for a WP twitter plugin at the moment, and ended here. Two questions:
1. Seeing how twitter is frequently down, does your plugin have some sort of caching device, in order not to slow down the loading of the page(s)?
2. I don’t want to use it as a widget. Any way to have good old tags instead?
Aaron D. Campbell Says:
Raoul Says:
Ok, thanks for your swift answers.
Julio Fernandez Says:
Hi Aaron, I’m a WP newbie. I added your Twitter widget and my host has php v 5.2.5. Two questions:
1. I see * Replace @username with a link to that twitter user
Is this right:?
sprintf(’http://twitter.com/statuses/%1$s_timeline/%2$s.%3$s%4$s’,$widgetOptions['feed'], $widgetOptions['oraclejulio'], $type, $count);
Are there any other places where I need to make changes?
2. I’m new to themes too. Your pluging was activated, but how do I add it to my right nav like you did?
Thanks @oraclejulio
Aaron D. Campbell Says:
Julio:
Those are things it does, not things you need to do. On twitter if you add a tweet, and put @aaroncampbell in it, it will link to my Twitter page. This widget does that too. It replaces @_____ with a link to that user on Twitter.
To add it to your sidebar, go to the admin section, then go to Design then Widgets. You will see it listed there, and can add it to an widgetized are of your theme.
ThePete Says:
When I try to use the widget in my WP 2.5 install (with php5) it blocks out the “save changes” button. However, I think when I first activated it it let me save changes, because now my sidebar doesn’t load properly when I try to pull up my site. So, I know it’s doing something. However, I’ve turned off the plugin so my sidebar will load properly. Not sure what is up, but wanted to let you know about it. Thanks!
Aaron D. Campbell Says:
ThePete: I sent you an E-Mail.
Joshua Kocurek Says:
Hi Aaron. Finally, a Twitter plugin that lets me show my friend’s feeds as well. I am excited to get this working. I have hit a snag though. I am running off of Wordpress 2.5 and when I install/configure the widget, I get this error on my sidebar where it is supposed to appear.
Fatal error: Call to undefined function json_decode() in /var/www/mist/wp-content/plugins/twitter-widget-pro/wp-twitter-widget.php on line 58
I checked that line, and even deleted the function, but it just led to more errors. Any insight you may have will be great. Thanks in advance!
Aaron D. Campbell Says:
Joshua: It seems that json_decode was not introduced until PHP 5.2.0. While I always recommend that you use PHP 5.2+ if possible, I have submitted a new version to the repository, which has a workaround using a modified version of ZendFramework’s Zend_Json_Decoder. PHP 5+ will still be required. It should be available from the wordpress.org repository in about 15 minutes, and is version 1.1.0. Let me know hoe it goes.
Joshua Kocurek Says:
Works flawlessly, Aaron! Thanks so much, keep up the good work!
Clesha Staten Says:
Hi Joshua.
I’m new to Twitter and trying to simplify as much as possible, so I’m excited that i found your plugin.
I installed it and got this message:
Plugin could not be activated because it triggered a fatal error.
Parse error: syntax error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or ‘}’ in /xxx/wp-content/plugins/twitter-widget-pro/wp-twitter-widget.php on line 69
I am running the blog on MySQL 5.0
Thanks.
Clesha
Aaron D. Campbell Says:
Clesha: It looks like you have PHP4 and PHP 5+ is a system requirement for the plugin.
Joshua Decosta Says:
I would just like to know how to remove the rss button and make it look more clean on the site.
Teeth Maestro Says:
Hey - cool plug-in but I might have a bug for you to look into.
When you publish a Twitter feed in a sidebar the main title (which is an optional feed title setting) it adopts the URL of the latest Twitter that has commented on the profile and does not carry the URL of the main account
Example - in your blog - the left side bar has the Twitter feed of Kevin Rose. The RSS feed icon has the correct link [http://twitter.com/statuses/friends_timeline/kevinrose.rss] BUT the title ‘Kevin Rose’ should have [http://twitter.com/kevinrose] but as of my posting this comment it has the URL of MELKINK http://twitter.com/MelKirk which was incidentally the latest twitter on Kevin Rose’s account.
This bug is replicated on my blog as well. any way to work around this bug
Aaron D. Campbell Says:
Teeth Maestro:
You are absolutely right, I’ve added this bug to my list of things to do, and will try to get it fixed as soon as possible. Your plugins page should let you know when the new version is available.
Aaron D. Campbell Says:
I just uploaded version 1.1.2, which fixes the bug that Teeth Maestro found, and adds the option to hides the RSS icon as per request from Joshua Decosta. the new version should be available from the wordpress.org repository in about 15 minutes.
Please let me know if you find any other bugs!
La folie Twitter : 101 liens sur Twitter et + | Le Blog Kinoa Says:
[...] Wordpress Twitter Widget [...]
Raj Says:
Hi.. thanks a lot.. i am searching for this plugin for a long time.. But as i new to wordpress i dont know how to show profile picture in tweets.. i inserted the css that you provided in my default theme stylesheet.. but it doesnt works.. can you instruct me how to make it happen..
Aaron D. Campbell Says:
Raj: The CSS is really just to help you on your way to positioning the images properly, after they are enabled. To enable them, there is an option in the widget control. It’s a checkbox labeled “Show Profile Image(s)” and all you have to do is check it, and save your changes using the “Save Changes” button.
Raj Says:
Thank you so much Campbell.. I checked that option in my widget and it works fine.. Other doubt, How can I call the twitter function from a page without activating in sidebar..
Aaron D. Campbell Says:
Raj: That’s on the todo list, but it’s not really set up for that yet.
Firefly Says:
I get a similar error as one of your earlier commenters, however, your response is that the server isn’t running PHP5. I do host with a company that offers both 4 and 5, and I still get the error. Is there something I’m not doing correctly?
Firefly Says:
Nvm, I’m dumb. I found it.
DogSolitude » Blog Archive » WP Plugin: Wordpress Twitter Widget Says:
[...] Plugin: Wordpress Twitter Widget. I don’t use the twitter. Buy maybe I will. Althought I can post right here with [...]