Tech Notes: Twitter Widget Pro not updating for Heart Internet users

I’ve had problems with the Twitter Widget Pro WordPress plugin not updating on several sites. I sat down and had a good trawl through the code tonight and it looks like it’s another ‘Heart Attack’ – a case of a Heart Internet feature preventing something from operating correctly.

Don’t get me wrong – I love my Heart Hosting and would highly recommend them, but if you’re hosting WordPress you need to know about this particular thing (and the WP-cron thing too!)

This same issue may apply to other hosts too, I’m not sure. If your Twitter Widget Pro isn’t updating then read on and find out.

Update 1:

Knocked up hastily, and it’s my first foray into modifying other people’s work, so I hope I’ve done a good job, but I’ve put together a modified version of 2.3.8 that fixes the problem, for me at least.  I won’t promise to update this when the main plugin gets updated. Discussion seems to be ongoing about whether this issue deserves attention or not.

Twitter Widget Pro – No Background Updates Fix

Heart Internet’s Security Feature

Heart Internet’s security is pretty good.  That’s one of the things I like about them. But one of their features is that they don’t allow a website’s server process to make HTTP requests to it’s own website.  By this I mean that a PHP script serving a page on the domain can not make an HTTP request to anywhere on

I’m not entirely sure what this prevents – my guess is that it stops you making a PHP script that calls itself and loops forever.

I’ve so far discovered that this has two unforseen consequences:

  1. It stop WP Cron scheduled jobs working.
  2. It stops Twitter Widget Pro version 2.3.0 and above from working properly.

I did a write up for a post on the Twitter Widget Pro forums.  I’m awaiting a response but thought I’d copy (an edited version of) it here for reference.

My Investigation

I’ve had problems with numerous installs of Twitter Widget Pro not updating tweets and I’ve discovered – I think – that it’s all down to a problem with my hosting and the plugin’s use of TLC Transients. This MAY (or may not) also be the cause of other people’s lack of updates.

The behaviour I was seeing was that I appeared to have different versions of my tweet stream “cached” and I could flick between the different cached versions by changing the settings. So, for example, with one lot of widget settings I might see Tweets A, B and C. With a different set of widget settings I would see Tweets C, D and E. Changing the widget’s settings between the two brought up to two different cached lists. BUT…when I posted a new Tweet NEITHER cached list of Tweets got updated.

I checked the database and noted a few timestamps in transient values in there and then went and checked the code.

TWP uses a hash of the widget options as a key for the transient “cache” of fetched Tweets. See line 710 of the plugin in the _getTweets function:

$key = 'twp_' . md5( $this->_getFeedUrl( $widgetOptions ) );

So that explains why different Tweet settings have different cached lists of Tweets, and how I can switch between them.

But why are they never updating?

Well, I’ve not done a too-thorough inspection of the code but TLC transients seems to use a “loopback” URL to fetch the cached list of Tweets without holding up the user – similar to how WP-Cron works. When scheduled it does:

add_action( 'shutdown', array( $this, 'spawn_server' ) );

And the spawn_server callback looks like this:

public function spawn_server() {
  $server_url = home_url( '/?tlc_transients_request' );
  wp_remote_post( $server_url, array( 'body' => array( '_tlc_update' => $this->lock, 'key' => $this->key ), 'timeout' => 0.01, 'blocking' => false, 'sslverify' => apply_filters( 'https_local_ssl_verify', true ) ) );

NOW…my hosting company don’t actually allow me to make these “loopback” HTTP requests. So, all my installed instances of TWP are broken.

Options for me seem to be:

  1. The TWP developer make use of TLC Transients optional
  2. I could put some hack in that deletes the transients every now and then. I DO have WP-Cron working (via a Unix cron job), so I could setup a job to clear the transients from the database using that.
  3. I could use another plugin.

I know that TLC Transients is a clever way of making some big efficiencies. And I know that my hosting issue is probably a rare thing. But I could really use some feedback on whether TLC Transients will continue to be used or not, or if I have to consider one of the other options.

I hope that write up is useful to someone else too.

Tags: , , , ,

14 Responses to “Tech Notes: Twitter Widget Pro not updating for Heart Internet users”

  1. Simon Vincent March 23, 2012 at 9:13 pm #

    Confused…Downloaded this version and still no joy?

    • oikos_uk March 24, 2012 at 10:33 pm #

      Hi Simon, sounds from our Twitter conversation that you managed to get this working. Feel free to comment again if you’ve more to add on the topic. Thanks for your interest.

  2. Simon Vincent March 25, 2012 at 10:08 am #

    Hi, yes all working great now :) Your modified version is fine, WordPress was getting its knickers in a twist and didn’t remove all the old settings, so in the widget area it was still trying to pull in an old feed.

    I did change expires_in, in the wp-twitter-widget.php to the example below

    * Gets tweets, from cache if possible
    * @param array $widgetOptions - options needed to get feeds
    * @return array - Array of objects
    private function _getTweets( $widgetOptions ) {
    $key = 'twp_' . md5( $this->_getFeedUrl( $widgetOptions ) );
    return tlc_transient( $key )
    ->expires_in( 5 ) // cache for 5 minutes
    ->updates_with( array( $this, 'parseFeed' ), array( $widgetOptions ) )

    Now seems to update itself almost immediately, rather than waiting the 5 minutes before emptying the cache.

    Thanks again for the modified plugin and the support :)

  3. Joel Williams May 15, 2012 at 6:34 pm #

    Awesome, just what I was looking for, many thanks!

  4. Marie TwoThirds July 5, 2012 at 7:26 am #

    Thanks for your work on this… I’ve installed new version, time will tell if it’s fixed my problem too.

  5. LizT July 19, 2012 at 1:16 pm #

    This worked perfectly and helped solve a month-long error. Thanks so much for the updated plug-in!

  6. Richard Bland August 3, 2012 at 2:46 pm #

    Just downloaded the plugin, did a copy and paste of the php files, deactivated and reactivated the plugin and boom – all working fine now! Thank you for this fix.

  7. Dave Goodman August 6, 2012 at 1:17 pm #

    Perfect – works great – thanks so much! My client is on Heart and I was just about to give up and find another plugin!

  8. blankPixels August 11, 2012 at 2:42 pm #

    It worked perfectly on our blog ( Thank you so much! Been trying to fix it myself to no avail. :))

  9. Tim Durden August 18, 2012 at 12:53 pm #

    An excellent post, and a highly effective plugin. Thankyou so much for posting this update. Client very happy.

  10. karlo October 19, 2012 at 12:06 am #

    Hi. I can’t thank you enough for the effort you put in to this to fix this issue. I never would have thought this has something to do with Heart (we host there too!). Again thank you!

  11. Snapcat November 3, 2012 at 10:36 pm #

    Hi man, i’ve tried your fix, but it gives me a white screen of death when i’ve replaced the files or upload the plugin on WP 3.4.2. Any thoughts? I’d love to use your fix.

  12. D-J Millward November 9, 2012 at 2:48 pm #

    thanks for this code by the way :) I still had a problem with it only working occasional. However I written a rather ugly fix :/ if anyone needs it


  1. Heart Hosting Review | Steve's Web Hosting Consumer Reports - July 3, 2014

    […] […]

Leave a Reply