Once again, another post about the Sociable WordPress plug-in, which has, apparently, been taken over by a group called BlogPlay. This time, it’s about HTML Validation. If you use the sociable plugin, you’ll notice that it doesn’t validate if you use it on category post lists or any page that compiles a list of posts. This is because the link uses an id rather than a class to identify the link. Valid HTML does not allow duplicate ids. As such, having multiple sets of sociable links on a page invalidates the page. There’s an easy fix to this, which was already incorporated into the previous URL Shortening and Google Tracking modifications we did. However, I forgot to mention that part and how to do it. This post, hopefully, will rectify that oversight.
Using Sociable 3.5.1, if you look within the file, sociable.php, on line 777, note the following string of code:
$link .= ' id="'.esc_attr(strtolower(str_replace(" ", "", $sitename))).'" ';
Simply change the “id” to “class” and voila, it’s fixed. Your final code should look like this:
$link .= ' class="'.esc_attr(strtolower(str_replace(" ", "", $sitename))).'" ';
That should validate now and work just as it did before.
Note: If you modified the sociable.php, then the line number where the code appears may be different, simple do a search of the line of code to find where it is located.
That’s it. You’re done.