<?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>Matthew Simo &#187; code</title>
	<atom:link href="http://matt-simo.com/tag/code/feed/" rel="self" type="application/rss+xml" />
	<link>http://matt-simo.com</link>
	<description>Front-End Designer/Developer</description>
	<lastBuildDate>Mon, 01 Feb 2010 21:51:14 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>html5 Comments in WordPress &#8211; quickfix</title>
		<link>http://matt-simo.com/html5-comments-quickfix/</link>
		<comments>http://matt-simo.com/html5-comments-quickfix/#comments</comments>
		<pubDate>Mon, 01 Feb 2010 21:16:29 +0000</pubDate>
		<dc:creator>Matthew</dc:creator>
				<category><![CDATA[Blog]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[comments]]></category>
		<category><![CDATA[html]]></category>
		<category><![CDATA[nathan stains]]></category>
		<category><![CDATA[starkers-html]]></category>
		<category><![CDATA[wordpress]]></category>

		<guid isPermaLink="false">http://matt-simo.com/?p=326</guid>
		<description><![CDATA[Introduction I&#8217;m not even going to acknowledge my terrible blogging habits ( or in reality, lack thereof ) and get to a little something something that will hopefully be of some use to someone. With html5 making a lot of &#8230; <a href="http://matt-simo.com/html5-comments-quickfix/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<h5>Introduction</h5>
<p>I&#8217;m not even going to acknowledge my terrible blogging habits ( or in reality, lack thereof ) and get to a little something something that will hopefully be of some use to someone.</p>
<p>With html5 making a lot of noise and gaining steam ( <a href="http://mashable.com/2010/01/26/google-voice-web-app/">Google Voice</a> &#038; <a href="http://www.youtube.com/html5">Youtube</a> as examples ), it&#8217;s only a matter of time.</p>
<p>On January 25th, 2010, a nice chap by the name of <a href="http://nathanstaines.com/">Nathan Staines</a> released his html5 version of <a href="http://elliotjaystocks.com/">Elliot Jay Stocks</a>&#8216; <a href="http://elliotjaystocks.com/starkers/">Starkers</a> theme.</p>
<p>As I&#8217;m still in the process of learning the nuances of html5 I decided to use Starkers html5 as a learning ground. Being a <a href="http://twitter.com/matthewsimo">typical twitter user</a> I <a href="http://twitter.com/matthewsimo/status/8417509972">let the world know what I was up to</a>. Nathan fairly quickly <a href="http://twitter.com/nathanstaines/status/8424452760">responded</a>, asking my thoughts and recommendations on any adjustments, I <a href="http://twitter.com/matthewsimo/status/8429465764">replied</a> in kind. </p>
<p>I sat down to see if I could tackle it, I&#8217;ve always been a bit wary of messing with the comments code for wordpress seeing as recursive code can get complicated if you don&#8217;t know exactly what is going on. I thought it was an excellent opportunity to learn and I came up with a (mostly) strait forward quick fix for now. I still want to go back and rewrite the wp_list_comments(); function but that will have to wait as I have other priorities.</p>
<h5>My quick fix:</h5>
<h6>In the comments.php template file find this bit of code: </h6>
<pre><code>&lt;?php wp_list_comments(...); ?&gt; </code></pre>
<p>We&#8217;ll be using this instead:</p>
<pre><code>&lt;?php wp_list_comments('style=div&amp;callback=html5_comment&amp;end-callback=html5_closecomment'); ?&gt;
'</code></pre>
<h6>In your theme&#8217;s functions.php file we&#8217;ll be adding the following code:</h6>
<pre><code>// Changes the trailing &lt;/li&gt; into a trailing &lt;/article&gt;
function html5_closecomment() {?&gt;
	&lt;/article&gt;
&lt;?php
	}

// This is the new comment markup - edit as you feel necessary
function html5_comment($comment, $args, $depth) {
   $GLOBALS['comment'] = $comment; ?&gt;

	&lt;article id="comment-&lt;?php comment_ID() ?&gt;" &lt;?php comment_class(); ?&gt;&gt;
		&lt;header class="comment-author vcard"&gt;
			&lt;?php echo get_avatar($comment,$size='48',$default='&lt;path_to_url&gt;' ); ?&gt;

			&lt;?php printf(__('&lt;cite class="fn"&gt;%s&lt;/cite&gt; <span class="says">says:</span>'), get_comment_author_link()) ?&gt;

			&lt;p&gt;&lt;time pubdate&gt;<a href="<?php echo htmlspecialchars( get_comment_link( $comment->comment_ID ) ) ?&gt;"&gt;&lt;?php printf(__('%1$s at %2$s'), get_comment_date(),  get_comment_time()) ?&gt;</a>&lt;?php edit_comment_link(__('(Edit)'),'  ','') ?&gt;&lt;/time&gt;&lt;/p&gt;

			&lt;p&gt;&lt;?php echo $args ['style']; ?&gt;&lt;/p&gt;

		&lt;/header&gt;
		&lt;?php if ($comment-&gt;comment_approved == '0') : ?&gt;
			&lt;p&gt;<em>&lt;?php _e('Your comment is awaiting moderation.') ?&gt;</em>&lt;/p&gt;
		&lt;?php endif; ?&gt;

		&lt;?php comment_text() ?&gt;

		&lt;footer class="reply"&gt;&lt;?php comment_reply_link(array_merge( $args, array('depth' =&gt; $depth, 'max_depth' =&gt; $args['max_depth']))) ?&gt;&lt;/footer&gt;

&lt;?php
	}</code></pre>
<p>This will force your comments to display like the following:</p>
<pre><code>
&lt;article&gt;
<!-- comment stuff -->
    &lt;article&gt; <!-- depth-2 -->
    <!--  comment stuff -->
    &lt;/article&gt;
&lt;/article&gt;
...
...</code></pre>
<h5>A couple of notes</h5>
<p>Usually, theme&#8217;s wrap the <code>wp_list_comments();</code> call in an ordered list, this isn&#8217;t necessary for our super awesome html5 anymore since articles can (and I guess <a href="http://dev.w3.org/html5/spec/Overview.html#the-article-element">should</a>) be nested. Personally I wrapped it in a div with &#8220;the_comments&#8221; as a class ( For styling purposes mainly. ).</p>
<p>These are the only changes I made to the <a href="http://drp.ly/j57c">starkers html5</a>, take a look for yourself. </p>
<p>Feel free to use, modify and share as you like. Try to give references where they are due though, that&#8217;s all I ask. </p>
<p>Once I rewrite the function for wp_list_comments to handle &#8216;style=article&#8217; I&#8217;ll let you all know.</p>
<h5>More on html5</h5>
<p><a href="http://dev.w3.org/html5/spec/Overview.html">W3C html5 spec overview</a></p>
<p><a href="http://www.whatwg.org/specs/web-apps/current-work/multipage/">WhatWG.org html5 Working Draft</a></p>
<p><a href="http://html5doctor.com/">html5Doctor</a></p>
<p><a href="http://html5gallery.com/">html5 Gallery</a></p>
]]></content:encoded>
			<wfw:commentRss>http://matt-simo.com/html5-comments-quickfix/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Added &amp; Configured SimplePie for WP</title>
		<link>http://matt-simo.com/configured-simplepie-for-wp/</link>
		<comments>http://matt-simo.com/configured-simplepie-for-wp/#comments</comments>
		<pubDate>Tue, 19 May 2009 18:43:22 +0000</pubDate>
		<dc:creator>Matthew</dc:creator>
				<category><![CDATA[Tutorial]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[css]]></category>
		<category><![CDATA[html]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[plugin]]></category>
		<category><![CDATA[SimplePie]]></category>
		<category><![CDATA[WP]]></category>

		<guid isPermaLink="false">http://matt-simo.com/?p=68</guid>
		<description><![CDATA[I started thinking&#8230; &#8220;Man, having some lame post explaining that I&#8217;m off developing and hacking WP is almost as bad as having a big fat image saying that I&#8217;m &#8216;Under Construction&#8217; (see this).&#8221; As a result, I figured loading some &#8230; <a href="http://matt-simo.com/configured-simplepie-for-wp/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>I started thinking&#8230; &#8220;Man, having some lame post explaining that I&#8217;m off developing and hacking WP is almost as bad as having a big fat image saying that I&#8217;m &#8216;Under Construction&#8217; (see <a href="http://images.google.com/images?q=under+construction&#038;oe=utf-8&#038;rls=org.mozilla:en-US:official&#038;client=firefox-a&#038;um=1&#038;ie=UTF-8&#038;ei=k_MSSq_RLYSs8QTPufT8Aw&#038;sa=X&#038;oi=image_result_group&#038;resnum=1&#038;ct=title">this</a>).&#8221;</p>
<p>As a result, I figured loading some dynamic content that tracks the latest 5 things I&#8217;m up to on the web would be far superior. </p>
<p>I was in luck. It just so happened that not too long ago I had played around with <a href="http://simplepie.org/">SimplePie</a>. The SimplePie website describes SimplePie as &#8220;a very fast and easy-to-use class, written in PHP, that puts the &#8216;simple&#8217; back into &#8216;really simple syndication&#8217;&#8221;. I used a great <a href="http://css-tricks.com/video-screencasts/55-adding-rss-content-with-simplepie/">css-tricks video tutorial</a> as a guide and decided to play around to make SimplePie track my web activity from the last week.</p>
<p>It went great. My initial exposure to working with SimplePie was quick, intuitive, and strait-forward. It took me a couple of hours to learn all I needed to know and code up what I wanted SimplePie to do for me. It should be stated that while I&#8217;m comfortable with php, I am by no means am a master or guru or even consider myself really all that experienced.</p>
<p>As a result, I was extremely pleased when I found the <a href="http://wordpress.org/extend/plugins/simplepie-plugin-for-wordpress/">SimplePie Plugin for WP</a>. I downloaded, installed and went to work. (Don&#8217;t forget to get the <a href="http://wordpress.org/extend/plugins/simplepie-core/">SimplePie Core Plugin</a>, you need it so the classes the WP plugin uses are understood!) Since I was familiar with the basic concept of how SimplePie worked it was a breeze, I coded what I needed (This time I only wanted to track the 5 most recent items.), integrated it into the theme I recently installed (Which, by the way, finding a theme that is intelligently and cleanly coded like <a href="http://jimbarraud.com/2009/03/19/manifest/">Manifest</a> is makes this go faster too. Kudos Jim!) and added some css classes to make it look pretty.</p>
<p>I put the very strait forward SimplePie code into the Header Template.</p>
<blockquote><p>
<code>  &lt;div id="simplepie"&gt;<br />
		&lt;?php<br />
		echo SimplePieWP(array(<br />
			    'http://digg.com/users/MaSimo/history.rss',<br />
    			'http://twitter.com/M_A_Simo',<br />
    			'http://feeds.pandora.com/feeds/people/simo5436/favorites.xml',<br />
    			'http://feeds.pandora.com/feeds/people/simo5436/favoriteartists.xml',<br />
    			'http://feeds.pandora.com/feeds/people/simo5436/nowplaying.xml',<br />
    			'http://delicious.com/M_A_Simo',<br />
		), array(<br />
			'items' =&gt; 5,<br />
			'cache_duration' =&gt; 1800,<br />
			'date_format' =&gt; 'M jS, g:i a'<br />
		));<br />
		?&gt;<br />
  &lt;/div&gt;</code>
</p></blockquote>
<p>I also took advantage of the template system that the WP Plugin uses and edited one of the .tmpl files that came with the plugin. After some tinkering and a little thought I came up with the following as my defined .tmpl&#8230;</p>
<blockquote>
<p><code>div id="simplepie"&gt;<br />
	{IF_ERROR_BEGIN}p class="error"&gt;{ERROR_MESSAGE}/p&gt;{IF_ERROR_END}</p>
<p>	ul&gt;<br />
	{ITEM_LOOP_BEGIN}<br />
	li&gt;<br />
		p class="title"&gt;strong&gt;&lt;img src="{ITEM_PARENT_FAVICON}" alt="{ITEM_PARENT_TITLE}" title="{ITEM_PARENT_TITLE}" /&gt; a href="{ITEM_PARENT_PERMALINK}"&gt;{ITEM_PARENT_TITLE}/a&gt;/strong&gt;/p&gt;<br />
		br /&gt;<br />
		p class="simplepie_content"&gt;a href="{ITEM_PERMALINK}"&gt;{ITEM_DESCRIPTION}/a&gt;/p&gt;<br />
		p class="date"&gt;{ITEM_DATE}/p&gt;<br />
	/li&gt;<br />
		br class="clear" /&gt;<br />
	{ITEM_LOOP_END}<br />
	/ul&gt;<br />
/div&gt;</code>
</p></blockquote>
<blockquote><p><strong>**See Note In Commets RE: Above Code**</strong></p></blockquote>
<p>Great, I got SimplePie to parse the feeds I wanted and embed it into WP where I wanted, but now I needed to make a few .css classes so it would match the look of my current theme. I whipped up the following, still a bit dirty and rough, I&#8217;ll be the first to admit.</p>
<blockquote><p>
<code>#simplepie{<br />
  margin-top: 10px;<br />
  margin-bottom: 70px;<br />
}<br />
#simplepie ul{<br />
  margin 0 auto;<br />
  background: #FBFBFB;<br />
  border-top: 1px solid #EAEAEA;<br />
  border-bottom: 1px solid #EAEAEA;<br />
}<br />
#simplepie li{<br />
  padding: 5px 5px 0px 5px;<br />
  display:block;<br />
  font-size:1.5em;<br />
  border-bottom: 1px solid #EAEAEA;<br />
}<br />
#simplepie p.simplepie_content{<br />
  text-align: left;<br />
  display: block;<br />
  padding: 0 10px 10px;<br />
}<br />
#simplepie p.date {<br />
  display: block;<br />
  font-size: .7em;<br />
  margin-bottom: 10px;<br />
}<br />
#simplepie li:last-child{<br />
  border-bottom: none;<br />
}<br />
br.clear {<br />
  clear:both;<br />
  display: block;<br />
  height: 0;<br />
}</code>
</p></blockquote>
<p>Almost there! Now I just edited a few already made classes that controlled the links how I liked and made them target the html that the .tmpl rendered as the SimplePie Plugin parsed my code.</p>
<blockquote><p>
<code>#mainNav, #simplepie a:link,<br />
#mainNav, #simplepie a:visited{<br />
  color: #999;<br />
}<br />
#mainNav, #simplepie a:hover,<br />
#mainNav, #simplepie a:active{<br />
  text-decoration: underline;<br />
  color: #2E301C;<br />
}</code>
</p></blockquote>
<p>Viola! The result??? Well, you should be seeing it, just above the post area. Simple, strait-forward, &#038; I hope it keeps you at least cursorily entertained while I&#8217;m working on my theme.  </p>
]]></content:encoded>
			<wfw:commentRss>http://matt-simo.com/configured-simplepie-for-wp/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

