<?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>chromakode &#187; hack</title>
	<atom:link href="http://www.chromakode.com/tag/hack/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.chromakode.com</link>
	<description>Just another WordPress weblog</description>
	<lastBuildDate>Fri, 30 Apr 2010 17:50:39 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.1</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Hack: Wordpress cancel reply button</title>
		<link>http://www.chromakode.com/2009/02/wordpress-cancel-reply-button/</link>
		<comments>http://www.chromakode.com/2009/02/wordpress-cancel-reply-button/#comments</comments>
		<pubDate>Sat, 28 Feb 2009 08:34:21 +0000</pubDate>
		<dc:creator>chromakode</dc:creator>
				<category><![CDATA[code]]></category>
		<category><![CDATA[button]]></category>
		<category><![CDATA[comments]]></category>
		<category><![CDATA[hack]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[reply]]></category>
		<category><![CDATA[wordpress]]></category>

		<guid isPermaLink="false">http://www.chromakode.com/?p=783</guid>
		<description><![CDATA[I&#8217;m a huge fan of the commenting improvements introduced in Wordpress 2.7. It&#8217;s been a tremendous boon to have first-class threaded commenting features right out of the box.
However, one thing I&#8217;ve never understood is the decision to use an anchor element to cancel an open reply box. I&#8217;m far more accustomed to the reddit style [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m a huge fan of the commenting improvements introduced in <a href="http://wordpress.org/development/2008/12/coltrane/">Wordpress 2.7</a>. It&#8217;s been a tremendous boon to have first-class threaded commenting features right out of the box.</p>
<p>However, one thing I&#8217;ve never understood is the decision to use an anchor element to cancel an open reply box. I&#8217;m far more accustomed to the reddit style of placing a cancel button next to the submit button, like this:</p>
<p><img class="aligncenter size-full wp-image-812 frame" title="A comment reply form from reddit" src="http://www.chromakode.com/wordpress/wp-content/uploads/2009/02/reddit-comment.png" alt="A comment reply form from reddit" width="411" height="159" /></p>
<p>The problem with the anchor element generated by Wordpress is that it looks really out of place when arranged next to the &#8220;submit comment&#8221; button. I had hoped there would be a parameter to change the anchor element into a button, but was disappointed to find that this particular HTML is hardcoded into the <code>get_cancel_comment_reply_link()</code> function.</p>
<p>However, the function does provide a filter hook, which I&#8217;ve used to make the change I desired. I simply intercept the HTML and return my own version with a button. It&#8217;s not very elegant, but it works.</p>
<p>If you&#8217;d like to use this hack, just add the following code to your theme&#8217;s <code>functions.php</code> file:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span class="co4">/**
 * Use an HTML button element for the cancel comment reply link.
 */</span>
<span class="kw2">function</span> cancel_comment_reply_button<span class="br0">&#40;</span><span class="re0">$html</span><span class="sy0">,</span> <span class="re0">$link</span><span class="sy0">,</span> <span class="re0">$text</span><span class="br0">&#41;</span> <span class="br0">&#123;</span>
    <span class="re0">$style</span> <span class="sy0">=</span> <span class="kw3">isset</span><span class="br0">&#40;</span><span class="re0">$_GET</span><span class="br0">&#91;</span><span class="st_h">'replytocom'</span><span class="br0">&#93;</span><span class="br0">&#41;</span> ? <span class="st_h">''</span> <span class="sy0">:</span> <span class="st_h">' style=&quot;display:none;&quot;'</span><span class="sy0">;</span>
    <span class="re0">$button</span> <span class="sy0">=</span> <span class="st_h">'&lt;button id=&quot;cancel-comment-reply-link&quot;'</span> <span class="sy0">.</span> <span class="re0">$style</span> <span class="sy0">.</span> <span class="st_h">'&gt;'</span><span class="sy0">;</span>
    <span class="kw1">return</span> <span class="re0">$button</span> <span class="sy0">.</span> <span class="re0">$text</span> <span class="sy0">.</span> <span class="st_h">'&lt;/button&gt;'</span><span class="sy0">;</span>
<span class="br0">&#125;</span>
&nbsp;
add_action<span class="br0">&#40;</span><span class="st_h">'cancel_comment_reply_link'</span><span class="sy0">,</span>
           <span class="st_h">'cancel_comment_reply_button'</span><span class="sy0">,</span> <span class="nu0">10</span><span class="sy0">,</span> <span class="nu0">3</span><span class="br0">&#41;</span><span class="sy0">;</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://www.chromakode.com/2009/02/wordpress-cancel-reply-button/feed/</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
	</channel>
</rss>
