Posts Tagged twitter

WordPress fusion theme: twitter widget link problem

The twitter sidebar widget in the fusion theme of wordpress shows weird in Firefox browser, due to the encoding of the double quotes in the href attribute. For example, a link from a twitter post shows like this in source:

  1. <a href=&quot;http://bit.ly/foo123&quot;>bar</a>

Safari in quite intelligent regarding this and displays the links right.

A look in the code revealed that the output from twitter webservice call is not completely decoded. The function fusion_TwitterWidget() in wp-content/themes/fusion/functions.php looks like this after an easy fix:

  1. // theme widget: Twitter
  2. function fusion_TwitterWidget($args){
  3.  extract($args);
  4.  echo $before_widget;
  5.  print $before_title.__(‘Twitter posts’,'fusion’).$after_title; ?>
  6.  
  7.  <?php
  8.  $username = get_option(‘fusion_twitterid’);
  9.  $limit = get_option(‘fusion_twitterentries’);
  10.  if($username<>) {
  11.   $feed = file_get_contents("http://search.twitter.com/search.atom?q=from:" . $username . "&rpp=" . $limit);
  12.  
  13.   // joyd: fix for the broken hyperlinks of twitter plugin due to encoded quotes
  14.   // $feed = str_replace("&lt;", "< ", $feed);
  15.   // $feed = str_replace("&gt;", ">", $feed);
  16.   $feed = html_entity_decode($feed);
  17.  
  18.   $clean = explode("<content type=\"html\">", $feed);
  19.   $amount = count($clean) - 1;
  20.   print ‘<ul id="twitterupdates">’;
  21.   for ($i = 1; $i < = $amount; $i++) {
  22.    $cleaner = explode("</content>", $clean[$i]);
  23.    print ‘<li class="entry">’;
  24.    echo $cleaner[0];
  25.    print ‘</li>’;
  26.   }
  27.   print ‘</ul>’;
  28.  }
  29.  
  30.  echo $after_widget;
  31. }

Thanks a lot to Francesco to point this out !

,

5 Comments