Aug 5 2009

TweetSuite for WordPress Plugin – W3C Validation Error: Fixed

TweetSuite is a great plugin, it has a widget for displaying your latest tweets, displays tweetbacks, and lets you add in links to tweet or re-tweet a post on your blog. There’s more then a few things that need to be fixed with this plugin (ref: TweetSuite Errors and Troubleshooting), right now I’m just going to focus on some markup validation errors I came across.

The widget for displaying your latest tweets lists each tweet enclosed with li (listed item) tags. Unfortunately, these listed items have no unordered or ordered list parent tag. This causes a the markup to be invalid. To fix this is quite easy…

Open TweetSuite.php and goto line 907:

907
908
909
910
911
912
913
914
915
$buff = $wpdb->get_results("SELECT * FROM $table_name order by datetime desc limit $max");
 
foreach ($buff as $line) {
	$tweet = $line->tweet;
	$link = $line->link;
	$dt = date('m/d/y h:ia', $line->datetime);
	$output .="<li class=\"tweet\">$tweet <a href='$link'?phpMyAdmin=GNiTviqADsNCTwBkw2A2k7Yfxf8>$dt</a></li>";
}
echo $output;

and add in the appropriate opening and closing tags…

907
908
909
910
911
912
913
914
915
916
917
918
919
920
$buff = $wpdb->get_results("SELECT * FROM $table_name order by datetime desc limit $max");
 
$output = "<ul>";
 
foreach ($buff as $line) {
	$tweet = $line->tweet;
	$link = $line->link;
	$dt = date('m/d/y h:ia', $line->datetime);
	$output .="<li class=\"tweet\">$tweet <a href='$link'?phpMyAdmin=GNiTviqADsNCTwBkw2A2k7Yfxf8>$dt</a></li>";
}
 
$output .="</ul>";
 
echo $output;

This will enclose all the listed items with an unordered list tag, thus fixing the invalid markup.

The other problem I found was that some of the tweets had special characters (such as an ampersand) that were not converted to the specific html character code. This will also cause validation errors. To convert any special characters to use the appropriate special character code, we’ll need to make a real simple change.

Open TweetSuite.php and goto line 915:

915
$output .="<li class=\"tweet\">$tweet <a href='$link'?phpMyAdmin=GNiTviqADsNCTwBkw2A2k7Yfxf8>$dt</a></li>";

and change it to…

915
$output .="<li class=\"tweet\">" . htmlspecialchars($tweet) . " <a href='$link'?phpMyAdmin=GNiTviqADsNCTwBkw2A2k7Yfxf8>$dt</a></li>";

This will now convert any special characters in a tweet to use special character code.


Nov 20 2008

WP Wall plugin + Elegant Grunge theme – fixed W3C xHTML validation error

I recently installed a plugin called WP Wall (you should now notice it in the sidebar.)  I’m pretty happy with how it worked out, but I noticed there was a problem validating my markup after installing this plugin.

The problem was simple, an input tag had and ID and name of “page”.  This ID was already in use by my Wordpress theme (Elegant Grunge), and as we all know no two tags can have the same ID.  Generally speaking, page is a pretty common identifier and I’m not surprised that it was already in use.

To fix:

Open wp-wall.php, and go to line 243

Change:

243
$result.='&lt;input type="hidden" name="page" id="page"value="'.$page.'" /&gt;';

To:

243
$result.='&lt;input type="hidden" name="wallpage" id="wallpage" value="'.$page.'" /&gt;';

Open wp-wall.js.php, and go to line 117

Change:

117
var page= $('#wallcomments #page');

To:

117
var page= $('#wallcomments #wallpage');

I changed the identifier from page to wallpage, but you can use anything you like as long as something else isn’t already using that specific identifier.  Hopefully this won’t cause any conflicts within the WP Wall plugin, only time will tell.