<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Jeff Malterre &#187; w3 validation</title>
	<atom:link href="http://www.jeffmalterre.com/tag/w3-validation/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.jeffmalterre.com</link>
	<description>accessible web programmer, SEO specialist, e-commerce professional</description>
	<lastBuildDate>Tue, 05 Oct 2010 18:23:29 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>Delicious for WordPress Plugin &#8211; W3C Validation Error: Fixed</title>
		<link>http://www.jeffmalterre.com/2008/12/11/delicious-for-wordpress-plugin-w3c-validation-error-fixed/</link>
		<comments>http://www.jeffmalterre.com/2008/12/11/delicious-for-wordpress-plugin-w3c-validation-error-fixed/#comments</comments>
		<pubDate>Thu, 11 Dec 2008 15:22:05 +0000</pubDate>
		<dc:creator>Jeff</dc:creator>
				<category><![CDATA[Snippet]]></category>
		<category><![CDATA[delicious]]></category>
		<category><![CDATA[w3 validation]]></category>
		<category><![CDATA[wordpress plugin]]></category>

		<guid isPermaLink="false">http://www.sibble.com/?p=881</guid>
		<description><![CDATA[I keep almost all my bookmarks at Delicious (formerly del.icio.us.)  So I noticed there is a WordPress plugin to display your Delicious bookmarks.  One of the things I do after I add a new plugin to WordPress, is to validate a page using The W3C Markup Validate Service.  I noticed that my markup was now invalid, but [...]]]></description>
			<content:encoded><![CDATA[<p>I keep <em>almost</em> all my bookmarks at <a title="Delicious is a social bookmarking web service for storing, sharing, and discovering web bookmarks." href="http://www.delicious.com">Delicious</a> (formerly del.icio.us.)  So I noticed there is a <a title="A plugin used to add a widget to your sidebar that will display your Delicious bookmarks." href="http://wordpress.org/extend/plugins/delicious-for-wordpress/">WordPress plugin to display your Delicious bookmarks</a>.  One of the things I do after I add a new plugin to WordPress, is to validate a page using <a title="A service used to validate markup." href="http://validator.w3.org/">The W3C Markup Validate Service</a>.  I noticed that my markup was now invalid, but it wasn&#8217;t really because of the plugin itself.  The errors were caused because some of my Delicious bookmarks have predefined ampersand characters, and the plugin did not replace these with HTML entities.  I first tried replacing my bookmark titles in Delicious, but that just screwed up my titles (I always go for the easy way first.)  So it&#8217;s time to start editing sources again&#8230;</p>
<p>What we need to do to fix this is really quite simple, find the string that stores our bookmark title, and replace the predefined characters with HTML entities.  While looking for the best method to do this using PHP, I found a function that I never knew about before.  There&#8217;s actually a nice PHP function to do this: <a title="This function returns a string with some of these conversions made.  The translations made are those most useful for everyday web programming." href="http://www.php.net/htmlspecialchars">htmlspecialchars()</a></p>
<blockquote>
<p class="para rdfs-comment">Certain characters have special significance in HTML, and should be represented by HTML entities if they are to preserve their meanings. This function returns a string with some of these conversions made; the translations made are those most useful for everyday web programming. If you require all HTML character entities to be translated, use <a class="function" href="http://us2.php.net/function.htmlentities.php">htmlentities()</a> instead.</p>
<p class="simpara">This function is useful in preventing user-supplied text from containing HTML markup, such as in a message board or guest book application.</p>
</blockquote>
<p class="simpara">Perfect, this is what we&#8217;re going to use.  So let&#8217;s find that string now&#8230;</p>
<p class="simpara">Open <strong>delicious.php</strong> and go to <strong>line 74</strong>:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>73
74
75
76
77
</pre></td><td class="code"><pre class="css" style="font-family:monospace;">foreach <span style="color: #00AA00;">&#40;</span> $bookmarks-&amp;gt<span style="color: #00AA00;">;</span>items as $bookmark <span style="color: #00AA00;">&#41;</span> <span style="color: #00AA00;">&#123;</span>
$msg <span style="color: #00AA00;">=</span> $bookmark<span style="color: #00AA00;">&#91;</span><span style="color: #ff0000;">'title'</span><span style="color: #00AA00;">&#93;</span><span style="color: #00AA00;">;</span>
if<span style="color: #00AA00;">&#40;</span>$encode_utf8<span style="color: #00AA00;">&#41;</span> utf8_encode<span style="color: #00AA00;">&#40;</span>$msg<span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">;</span>
$link <span style="color: #00AA00;">=</span> $bookmark<span style="color: #00AA00;">&#91;</span><span style="color: #ff0000;">'link'</span><span style="color: #00AA00;">&#93;</span><span style="color: #00AA00;">;</span>
$desc <span style="color: #00AA00;">=</span> $bookmark<span style="color: #00AA00;">&#91;</span><span style="color: #ff0000;">'description'</span><span style="color: #00AA00;">&#93;</span><span style="color: #00AA00;">;</span></pre></td></tr></table></div>

<p>So we&#8217;re going to take <strong>line 74</strong> and change it to this:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>73
74
75
76
77
</pre></td><td class="code"><pre class="css" style="font-family:monospace;">foreach <span style="color: #00AA00;">&#40;</span> $bookmarks-&amp;gt<span style="color: #00AA00;">;</span>items as $bookmark <span style="color: #00AA00;">&#41;</span> <span style="color: #00AA00;">&#123;</span>
$msg <span style="color: #00AA00;">=</span> htmlspecialchars<span style="color: #00AA00;">&#40;</span>$bookmark<span style="color: #00AA00;">&#91;</span><span style="color: #ff0000;">'title'</span><span style="color: #00AA00;">&#93;</span><span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">;</span>
if<span style="color: #00AA00;">&#40;</span>$encode_utf8<span style="color: #00AA00;">&#41;</span> utf8_encode<span style="color: #00AA00;">&#40;</span>$msg<span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">;</span>
$link <span style="color: #00AA00;">=</span> $bookmark<span style="color: #00AA00;">&#91;</span><span style="color: #ff0000;">'link'</span><span style="color: #00AA00;">&#93;</span><span style="color: #00AA00;">;</span>
$desc <span style="color: #00AA00;">=</span> $bookmark<span style="color: #00AA00;">&#91;</span><span style="color: #ff0000;">'description'</span><span style="color: #00AA00;">&#93;</span><span style="color: #00AA00;">;</span></pre></td></tr></table></div>

<p>Quite simple, now we&#8217;re back on the right track <img src='http://www.jeffmalterre.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://www.jeffmalterre.com/2008/12/11/delicious-for-wordpress-plugin-w3c-validation-error-fixed/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>

