Sharethis WordPress Plugin – Invalid XHTML

Building on my previous post regarding invalid XHTML (Version 1.0 Strict), I have been trying to find out why my site has not been validating. It turns out, the last bit of the problem is the “Sharethis” plugin for WordPress. In this plugin, the authors decided to define some custom parameter fields within the ‘span’ tag causing the validation problems. A post here indicates it is for “simplicity” for their less technically inclined users. So, this post is to show you how to modify the plugin to get valid XHTML out of it instead.

In the sharethis.php file, the offending lines are here:


And here are the updated lines:


In this case, disabling the extra fields means that the “sharethis” text and some minor styling disappear from the sharethis button. It seems the easiest way to have compliant XHTML and still a decent looking sharethis button is to use the a custom button style (see this page).

So the result is this:


The ‘ShareThis’ text is enclosed in an “a” tag so that we get the mouseover behaviour and link styling that it had previously. Additionally, the css file for your template must be changed. This is what I added to mine to make it work:

.st_sharethis_custom { background: url("img/sharethis.png") no-repeat scroll left top transparent; padding-left: 18px; padding-top:3px;}

You will want to change the url to wherever you have located the sharethis icon, and the padding and margins may need to be adjusted for your own template.

Twitter Tools – Plugin update for Valid XHTML

Today I noticed my site was not generating valid XHTML (for the 1.0 Strict Standard). I isolated some of the problems to the “Twitter Tools” plugin for WordPress. The problem is that a couple of parameters are not passed using the correct encoding (The & character is not properly encoded). The changes should be made to the “twitter-tools.php” file. Here is the original source for a couple of the offending lines:

And here it is with the changes made (notice the ‘&’ is replaced with ‘&’):

Hope this helps someone 😛