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:
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:
-
// theme widget: Twitter
-
function fusion_TwitterWidget($args){
-
extract($args);
-
echo $before_widget;
-
print $before_title.__(‘Twitter posts’,'fusion’).$after_title; ?>
-
-
<?php
-
$username = get_option(‘fusion_twitterid’);
-
$limit = get_option(‘fusion_twitterentries’);
-
if($username<>”) {
-
$feed = file_get_contents("http://search.twitter.com/search.atom?q=from:" . $username . "&rpp=" . $limit);
-
-
// joyd: fix for the broken hyperlinks of twitter plugin due to encoded quotes
-
// $feed = str_replace("<", "< ", $feed);
-
// $feed = str_replace(">", ">", $feed);
-
-
print ‘<ul id="twitterupdates">’;
-
for ($i = 1; $i < = $amount; $i++) {
-
print ‘<li class="entry">’;
-
echo $cleaner[0];
-
print ‘</li>’;
-
}
-
print ‘</ul>’;
-
}
-
-
echo $after_widget;
-
}
Thanks a lot to Francesco to point this out !
#1 by Simon on November 13, 2009 - 4:13 pm
Thanks for the post Joy, but using this code completely stopped my blog from running – something isn’t right here!
I see on your Fusion sidebar that the links are formatted correctly, yet when i use the code you’ve suggested above, it doesn’t work. In fact, nothing on my blog works!
Any suggestions? Thanks!
#2 by therider on November 13, 2009 - 4:17 pm
Simon, can you just try the change I outlined instead of the whole piece of code I posted ? Your plugin could be of later version with more changes.
#3 by deuts on July 29, 2010 - 8:38 pm
I have tried implementing this fix. And it fixed the wrong url’s in the twitter widget very well. However, it actually broke my blog’s feed in return.
#4 by therider on July 29, 2010 - 9:18 pm
It is hard to tell if my fix will work with everyone because of continuously changing wordpress software versions. Even a minor change can break a fix done against an older version. I will check if anything breaks when I upgrade my wordpress to latest.
#5 by Programador PHP on December 23, 2010 - 10:12 pm
Thanks
Excelent post!!!!