Modern Media Tweet Shortcode makes it easy to embed Twitter on your WordPress site. I use it in my “…from Twitter” category, which is now mercifully exempted from the front page and the RSS feed. It works fine, and even does you the favor of caching the JSON from Twitter so you don’t have to hammer their servers every time someone visits a page with an embedded tweet. It looks like this:
[tweet https://twitter.com/#!/ghelleks/status/163752762683822080]The trouble is that if you hit the Twitter rate limit (about 150/hour nowadays) Modern Media’s plugin won’t realize it, and will cache the error instead of the tweet. That permanently poisons the cache, and there’s no way to get your tweets displaying again. Here’s what the poisoned cached tweet looks like:
{"error":"Rate limit exceeded. Clients may not make more than 150 requests per hour.","request":"/1/statuses/oembed.json?id=150739352413147136&omit_script=true&lang=en&maxwidth=500&align="}
The solution is to head over to /wp-content/plugins/modern-media-tweet-shortcode/cache and find all the file that are 192 bytes in size. You can use find . -size 192c -print for that. If they change the wording of the error message, that size will change, but you get the idea. Delete all those files, and the plugin will retry caching the tweets.
The real solution is to fix the plugin so it realizes when it got an error message and avoid caching the error message in the first place, of course. I haven’t tested this, but I’m pretty sure this diff to ModernMediaTweetShortcode.class.php would do it:
71,74c71
< $json = json_decode($result);
< if (! $json->error){
< file_put_contents($path, $result);
< }
---
> file_put_contents($path, $result);
The moral of the story, if you want one, is that you should always check error conditions.