<?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>Chris&#039; Blog &#187; WordPress</title>
	<atom:link href="http://www.cs278.org/blog/category/technology/web/wordpress/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.cs278.org/blog</link>
	<description>“A metal loving, web developing, open source contributor.”</description>
	<lastBuildDate>Sun, 03 Apr 2011 14:36:34 +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>WordPress archives</title>
		<link>http://www.cs278.org/blog/2009/03/03/wordpress-archives/</link>
		<comments>http://www.cs278.org/blog/2009/03/03/wordpress-archives/#comments</comments>
		<pubDate>Tue, 03 Mar 2009 05:11:32 +0000</pubDate>
		<dc:creator>Chris</dc:creator>
				<category><![CDATA[Site]]></category>
		<category><![CDATA[Web]]></category>
		<category><![CDATA[WordPress]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[mods]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[tips]]></category>

		<guid isPermaLink="false">http://www.cs278.org/blog/?p=451</guid>
		<description><![CDATA[I&#8217;ve been running my blog since late 2005 as such my archives had been getting a little bit unwieldy in the sidebar and stretching the page to extraordinary heights. I&#8217;ve reduced this clutter with some very small changes. First I &#8230; <a href="http://www.cs278.org/blog/2009/03/03/wordpress-archives/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been running my blog since <a href="http://www.cs278.org/blog/2005/12/07/welcome/">late 2005</a> as such my archives had been getting a little bit unwieldy in the sidebar and stretching the page to extraordinary heights. I&#8217;ve reduced this clutter with some very small changes. First I dug around only to find out that WordPress doesn&#8217;t support fetching the monthly archives for one year, so I had to apply some filter foomongery. I discovered somebody else has done <a href="http://www.misthaven.org.uk/blog/2009/01/11/filtering-archives/" rel="external">something similar</a>, not quite as nice personally but it works.<br />
<span id="more-451"></span><br />
First I created a filter in my WordPress installation and added it.</p>
<pre>function getarchives_filter($where, $args)
{
	if (isset($args['year']))
	{
		$where .= ' AND YEAR(post_date) = ' . intval($args['year']);
	}
	return $where;
}
add_filter('getarchives_where', 'getarchives_filter', 10, 2);
</pre>
<p>Now the <a href="http://codex.wordpress.org/Template_Tags/wp_get_archives" rel="external"><code>wp_get_archives()</code></a> function supports a year parameter which restricts results to one particular year. Next we modify the sidebar to make use of this additional argument. Here is an example of the correct call to make:</p>
<pre>&lt;?php wp_get_archives('type=monthly&amp;year=' . get_the_time('Y', reset($GLOBALS['posts'])); ?&gt;</pre>
<p>This code also works properly when viewing the archives of a particular year, the months outputted change to the currently viewed year.</p>
<p>I have changed my own sidebar code to use this:</p>
<pre>
&lt;li&gt;&lt;h2&gt;Archives&lt;/h2&gt;
        &lt;ul&gt;
            &lt;li&gt;&lt;strong&gt;Months&lt;/strong&gt;
            &lt;ul&gt;
                    &lt;?php
                    // Use the current date when viewing a page, not the pages year
                    $year = (is_page()) ? date('Y') : get_the_time('Y', reset($GLOBALS['posts']));

                    wp_get_archives('type=monthly&amp;limit=12&amp;year[]=' . $year . (!is_archive() ? '&amp;year[]=' . ($year - 1) : ''));
                    ?&gt;
            &lt;/ul&gt;
            &lt;/li&gt;
            &lt;li&gt;&lt;strong&gt;Years&lt;/strong&gt;
            &lt;ul&gt;
                    &lt;?php wp_get_archives('type=yearly'); ?&gt;
            &lt;/ul&gt;
            &lt;/li&gt;
        &lt;/ul&gt;
&lt;/li&gt;
</pre>
<p class="note"><strong>Updated 31/01/2010:</strong> Paul spotted a bug, the code used the date of the last post displayed on the page rather than the first.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.cs278.org/blog/2009/03/03/wordpress-archives/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>WordPress Upgrade</title>
		<link>http://www.cs278.org/blog/2008/03/30/wordpress-upgrade-4/</link>
		<comments>http://www.cs278.org/blog/2008/03/30/wordpress-upgrade-4/#comments</comments>
		<pubDate>Sun, 30 Mar 2008 20:53:47 +0000</pubDate>
		<dc:creator>Chris</dc:creator>
				<category><![CDATA[Site]]></category>
		<category><![CDATA[WordPress]]></category>
		<category><![CDATA[upgrade]]></category>

		<guid isPermaLink="false">http://www.cs278.org/blog/?p=356</guid>
		<description><![CDATA[I am currently enjoying the visual refresh WordPress has been given in version 2.5. Its quite cool.]]></description>
			<content:encoded><![CDATA[<p>I am currently enjoying the visual refresh <a href="http://www.wordpress.org/" rel="external">WordPress</a> has been given in version 2.5. Its quite cool.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.cs278.org/blog/2008/03/30/wordpress-upgrade-4/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Upgraded</title>
		<link>http://www.cs278.org/blog/2007/10/20/upgraded/</link>
		<comments>http://www.cs278.org/blog/2007/10/20/upgraded/#comments</comments>
		<pubDate>Sat, 20 Oct 2007 14:56:34 +0000</pubDate>
		<dc:creator>Chris</dc:creator>
				<category><![CDATA[Site]]></category>
		<category><![CDATA[Web]]></category>
		<category><![CDATA[WordPress]]></category>

		<guid isPermaLink="false">http://www.cs278.org/blog/2007/10/20/upgraded/</guid>
		<description><![CDATA[I just upgraded this blog using a Subversion patch, seems to be working ok, will keep and eye out for any 404s see if I missed any new files and the like. I also started to burn my feed.]]></description>
			<content:encoded><![CDATA[<p>I just upgraded this blog using a Subversion patch, seems to be working ok, will keep and eye out for any 404s see if I missed any new files and the like. I also started to <a href="http://www.feedburner.com/" rel="external">burn</a> my <a href="http://www.cs278.org/blog/feed/">feed</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.cs278.org/blog/2007/10/20/upgraded/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Akismet Sanitised</title>
		<link>http://www.cs278.org/blog/2007/09/30/akismet-sanitised/</link>
		<comments>http://www.cs278.org/blog/2007/09/30/akismet-sanitised/#comments</comments>
		<pubDate>Sun, 30 Sep 2007 18:29:27 +0000</pubDate>
		<dc:creator>Chris</dc:creator>
				<category><![CDATA[Web]]></category>
		<category><![CDATA[WordPress]]></category>

		<guid isPermaLink="false">http://www.cs278.org/blog/2007/09/30/akismet-sanitised/</guid>
		<description><![CDATA[I made the Akismet plugin a little more sane after discovering it sent the entire $_SERVER array to akismets servers. I changed: $ignore = array( 'HTTP_COOKIE' ); foreach ( $_SERVER as $key => $value ) if ( !in_array( $key, $ignore &#8230; <a href="http://www.cs278.org/blog/2007/09/30/akismet-sanitised/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>I made the Akismet plugin a little more sane after <a href="http://www.cs278.org/blog/2007/09/25/disabled-akismet-comments-held-for-moderation/">discovering</a> it sent the entire $_SERVER array to akismets servers. I changed:</p>
<pre>        $ignore = array( 'HTTP_COOKIE' );

        foreach ( $_SERVER as $key => $value )
                if ( !in_array( $key, $ignore ) )
                        $comment["$key"] = $value;</pre>
<p>To:</p>
<pre>        foreach ($_SERVER as $k => $v)
        {
                if (strpos($k, 'HTTP_') === 0 &#038;&#038; $k != 'HTTP_COOKIE')
                {
                        $comment[$k] = $v;
                }
        }</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.cs278.org/blog/2007/09/30/akismet-sanitised/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Disabled Akismet, comments held for moderation.</title>
		<link>http://www.cs278.org/blog/2007/09/25/disabled-akismet-comments-held-for-moderation/</link>
		<comments>http://www.cs278.org/blog/2007/09/25/disabled-akismet-comments-held-for-moderation/#comments</comments>
		<pubDate>Tue, 25 Sep 2007 23:42:55 +0000</pubDate>
		<dc:creator>Chris</dc:creator>
				<category><![CDATA[Security]]></category>
		<category><![CDATA[Site]]></category>
		<category><![CDATA[Web]]></category>
		<category><![CDATA[WordPress]]></category>

		<guid isPermaLink="false">http://www.cs278.org/blog/2007/09/25/disabled-akismet-comments-held-for-moderation/</guid>
		<description><![CDATA[I have made the decision to disable Akismet, after reading some hype about the new WordPress 2.3&#8242;s plugin version check API, which turned out to be negative but reveals something interesting with regards to Akismet. The following code is taken &#8230; <a href="http://www.cs278.org/blog/2007/09/25/disabled-akismet-comments-held-for-moderation/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>I have made the decision to disable Akismet, after reading some hype about the new WordPress 2.3&#8242;s plugin version check API, which turned out to be negative but reveals something interesting with regards to Akismet. The following code is taken from the official Akismet plugin for Wordpres.</p>
<pre>        $ignore = array( 'HTTP_COOKIE' );

        foreach ( $_SERVER as $key => $value )
                if ( !in_array( $key, $ignore ) )
                        $comment["$key"] = $value;

        $query_string = '';
        foreach ( $comment as $key => $data )
                $query_string .= $key . '=' . urlencode( stripslashes($data) ) . '&#038;';

        $response = akismet_http_post($query_string, $akismet_api_host, '/1.1/comment-check', $akismet_api_port);</pre>
<p>The bit that worries me is the use of <var>$_SERVER</var>, the only item from this array not sent is <var>HTTP_COOKIE</var>, fair enough. But why do you need to know the full paths to the files on my server and other server environment variables Akismet? I do not have a problem with sending data to Akismet, just not this data!</p>
<p><a href="http://groups.google.com/group/wp-hackers/browse_thread/thread/bdced7524fa79a18/2d4e69fb46a6a947" rel="external">Source</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.cs278.org/blog/2007/09/25/disabled-akismet-comments-held-for-moderation/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

