Wordpress Coding standards
Jan 9th, 2006 by Karen
I was looking at the new coding standards that are listed on the Wordpress page and was a little perplexed when I saw the following:
Single and double quotes
When possible, single and double quotes should be used when appropriate. If you’re not evaluating anything in the string, use single quotes. You should almost never have to escape HTML quotes in a string, because you can just alternate your quoting style, like so:echo “<a xhref=’$link’ title=’$linktitle’>$linkname</a>”;
echo ‘<a xhref=”/static/link” mce_href=”/static/link” title=”Yeah yeah!”>Link name</a>’;
First, I would find that having different quote types in my HTML would make it more difficult to read. Second, I don’t think that using single quotes is valid XHTML. Everywhere I’ve looked at this described on the W3Cs site valid XHTML uses double-quotes because attributes in valid XML are enclosed in double-quotes. If this is the case (and I’m not sure if it is because I can’t find anywhere that says single quotes is wrong on the W3c’s site), Wordpress could be (depending on how people are writing things) generating code which isn’t standards compliant. This isn’t a good thing and is something that the Wordpress folks should check into. A part of me hopes that the single quotes are okay because it will save them time of recoding stuff that has single quotes. But another part of me really would prefer to see everything having double quotes even if that meant I had to escape my HTML quotes more often.

