ThinkTwit Update 1.1.6

So I recently noticed that although my last update included caching, there were some times in which the cache would not be accessed correctly – specifically, when updating from Twitter it was overwriting the cache rather than updating it and then displaying the cache. This wouldn’t be a problem if the live update was full of tweets, but if it had only one it would overwrite the cache with only 1 tweet.

Additionally, have split the Live option in to “Live (uncached)” and “Live (cached)”. The former will not use the cache at all and will always go straight to Twitter (meaning if Twitter is down it will not display anything) and the latter will always check for updates from Twitter (rather than waiting x since last update to check it) and then store the updates in the cache before displaying cached tweets.

I’ve updated the ThinkTwit page on my blog with the roadmap as during this update I’ve realised a few other minor bugs. I’ll get on to these in the coming weeks.

ThinkTwit Update 1.1.5

So it’s been slightly over a year and due to various problems with my PC (an incredibly difficult issue to resolve as I had issues with more than one part) and lack of time I’ve been unable to complete the work that I started after the last update.

Anyway, I’ve finally found time and am happy to announce version 1.1.5 – it includes caching of tweets to the local WordPress database and the implementation of shortcodes. Please check the readme for more details.

I have also updated the roadmap – I will do my best to keep ThinkTwit up-to-date in the future.

ThinkTwit Update 1.1.4

I’ve added another update to ThinkTwit as of yesterday; this includes use of ordered lists (ol) instead of unordered lists (ul) as it is more semantically correct, removed some old code left over from some time back that was no longer necessary, and added the ability to output usernames instead of Twitter names.

The roadmap has been updated – check it out if you want to know what features will be coming soon, and feel free to provide suggestions.

AJAX-ifying WordPress Widgets

I recently found the need to give AJAX abilities to a WordPress widget. Notably, I had a request from Kjell Martin Bovre of Scribo.no to allow ThinkTwit to update when used with a caching engine, for instance WP Super Cache. Caching engines work by converting the pages of a site in to HTML and, rather than loading the website code using calls to its database, calling these pages directly when a user makes a request.

The first time that a user visits a site with a caching engine the pages they visit will be converted to HTML. After a period of time these pages will get updated, but if you have a particular item on that page that should be updated more often this will not happen. One way to ensure this item is updated correctly is to enable it to use AJAX. The AJAX code will get called whenever the site is loaded, even in its HTML format – therefore it will work even when cached as the Javascript will make a server call, the server will respond with the up-to-date data and the Javascript will then update the HTML within that page.

After a good few hours research I was able to find a site that helped me do most of this, but there were some errors and it did not work with WordPress widgets as it would break their ability to create multiple instantiations. It was therefore necessary to update the code to allow this, so I thought I would just write a quick and easy guide to writing AJAX capable widgets to allow other developers to quickly and easily resolve this issue. I hope it comes in handy!

Continue reading

ThinkTwit Update 1.1.2

I’ve today updated ThinkTwit to version 1.1.2 with 2 key changes:

  • Added support for caching engines
  • Added support for CURL

These changes were requested by ThinkTwit users but will no doubt be useful to others out there. The no-caching support uses AJAX (via jQuery) to output code from a pure HTML file (the format in which the cached page is stored) and the CURL support offers an alternative to the standard URL get method which may cause the following error (or similar) if URL file-access is disabled:

Warning: file_get_contents() [function.file-get-contents]: URL file-access is disabled in the server configuration in /..../wp-content/plugins/thinktwit/thinktwit.php on line 145

Warning: file_get_contents(http://search.twitter.com/search.atom?q=from%3Adeleted&rpp=3) [function.file-get-contents]: failed to open stream: no suitable wrapper could be found in /.../wp-content/plugins/thinktwit/thinktwit.php on line 145

Additionally I have added debug messages to assist in locating errors when calling the method that requests the Twitter feed.

I learnt some valuable lessons about creating AJAX capable widgets and maintaining their ability to multi-instance, so I will post a blog on this shortly.