<?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>matty.co.za &#187; Coding</title>
	<atom:link href="http://matty.co.za/category/coding/feed/" rel="self" type="application/rss+xml" />
	<link>http://matty.co.za</link>
	<description>Web developer, WordPress enthusiast, avid musician, music lover and blogger</description>
	<lastBuildDate>Thu, 26 Jan 2012 18:06:55 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Filtering the Options API in WordPress</title>
		<link>http://matty.co.za/2012/01/filtering-wordpress-options-api/</link>
		<comments>http://matty.co.za/2012/01/filtering-wordpress-options-api/#comments</comments>
		<pubDate>Thu, 19 Jan 2012 09:00:13 +0000</pubDate>
		<dc:creator>Matty</dc:creator>
				<category><![CDATA[Coding]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[WordPress]]></category>
		<category><![CDATA[Project 365]]></category>
		<category><![CDATA[Tips]]></category>
		<category><![CDATA[Web Developer]]></category>
		<category><![CDATA[WordPress Plugins]]></category>
		<category><![CDATA[WordPress Themes]]></category>

		<guid isPermaLink="false">http://matty.co.za/?p=1228</guid>
		<description><![CDATA[The Options API in WordPress is one of the many WordPress APIs we all use every day when developing with WordPress. A quick call to get_option() is not an uncommon sight. What if you could dynamically filter those options? You can. Adding filters in WordPress is also a common practice. Combining this with the Options [...]]]></description>
			<content:encoded><![CDATA[<p>The Options API in WordPress is one of the many WordPress APIs we all use every day when developing with WordPress. A quick call to get_option() is not an uncommon sight. What if you could dynamically filter those options? <strong>You can</strong>.</p>
<p>Adding filters in WordPress is also a common practice. Combining this with the Options API can allow for, for example, the ability to change an option when in preview mode without committing to the change.</p>
<p>In the &#8220;Magazine&#8221; template in Canvas by WooThemes, for example, WooTumblog &#8220;image&#8221; and &#8220;video&#8221; posts are aware when they are present in the magazine-style grid. This is an example of filtering the Options API.</p>
<p><span id="more-1228"></span><br />
<h3>How do I use this?</h3>
<p>Filtering the Options API is as easy as compiling any other filter. The filter hook is as follows: &#8220;<code>option_optionname</code>&#8221; (replace &#8220;<code>optionname</code>&#8221; with the name of the option you want to filter).</p>
<h3>That filter is applied after the database lookup. What about before that even happens?</h3>
<p>It is possible to short-circuit an option&#8217;s value using a second filter that has been made available. This means it&#8217;s possible to set a custom value, via a filter, for an option, bypassing the database lookup. My thoughts are packed with ideas for where to use this filter!</p>
<p>To short-circuit an option called, for example, &#8220;testoption&#8221;, you&#8217;d add the following code to your <code>functions.php</code> file:</p>
<p><code></p>
<pre>
add_filter( 'pre_option_testoption', 'matty_shortcircuit_options' );

function matty_shortcircuit_options ( $default ) {
	$value = 'this is a short-circuited option';
	return $value;
} // End matty_shortcircuit_options()
</pre>
<p></code></p>
<p>Using the &#8220;testoption&#8221; example again, this is how you&#8217;d override the value after it&#8217;s been retrieved from the database:</p>
<p><code></p>
<pre>
add_filter( 'option_testoption', 'matty_override_options' );

function matty_override_options ( $value ) {
	$value = 'this is an overridden option';

	// To override based on a condition, do this.
	if ( $value == 'test' ) {
		$value = 'this is an overridden option, based on a condition.';
	}

	return $value;
} // End matty_override_options()
</pre>
<p></code></p>
<p>This is just, however, a starting point as to how to do this. The possibilities are virtually limitless as to what is possible here and how to apply this in your projects.</p>
]]></content:encoded>
			<wfw:commentRss>http://matty.co.za/2012/01/filtering-wordpress-options-api/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to improve web developer coding practices (and code)</title>
		<link>http://matty.co.za/2012/01/web-coding-best-practices/</link>
		<comments>http://matty.co.za/2012/01/web-coding-best-practices/#comments</comments>
		<pubDate>Sun, 15 Jan 2012 18:44:15 +0000</pubDate>
		<dc:creator>Matty</dc:creator>
				<category><![CDATA[Coding]]></category>
		<category><![CDATA[Technology]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[Project 365]]></category>
		<category><![CDATA[Tips]]></category>
		<category><![CDATA[Web Developer]]></category>

		<guid isPermaLink="false">http://matty.co.za/?p=1223</guid>
		<description><![CDATA[Every developer approaches their day to day development tasks from a different angle. In addition to this, each developer &#8220;designs&#8221; their code to suit their own personal preferences and approaches towards specifics in a project. When developers examine code written by other developers, we&#8217;re often critical (sometimes hyper-critical) of the code itself, mostly according to [...]]]></description>
			<content:encoded><![CDATA[<p>Every developer approaches their day to day development tasks from a different angle. In addition to this, each developer &#8220;designs&#8221; their code to suit their own personal preferences and approaches towards specifics in a project. When developers examine code written by other developers, we&#8217;re often critical (sometimes hyper-critical) of the code itself, mostly according to our personal preferences. While there is a place for being critical of code, and it should be encouraged, there are a few aspects of this criticism that should be left at the door&#8230; namely, the personal preferences.</p>
<p>While we all have our own preferences, it&#8217;s important to solidify a few areas when approaching code and to, ultimately, hone the developer&#8217;s mindset into certain guidelines. Below are a few thoughts I have running through my mind constantly while developing:</p>
<p><span id="more-1223"></span><br />
<h3>1. Minimize lookups.</h3>
<p>This one is crucial when developing systems with heavy load. How many times are you hitting the database for information and how can you minimize that number? For example, when <a title="A Quick Guide to the WordPress Transients API" href="http://matty.co.za/2012/01/wordpress-transients-api/">using the Transients API in WordPress</a>, why would you run get_transient() again after you&#8217;ve just set the transient up? You&#8217;ve already got the data, so there&#8217;s no need.</p>
<h3>2. D.R.Y (don&#8217;t repeat yourself).</h3>
<p>This is a common development practice. Don&#8217;t repeat yourself. If you&#8217;ve got, for example, two functions that perform API requests, create a function that runs the API request with a few parameters to customise it in each case, rather than coding the request twice.</p>
<h3>3. One function, one purpose.</h3>
<p>This one helps me every day. It also ensures that your code is kept clean. If, for example, you have to display a collection of posts with specific criteria, why compile one function to do it all, when you could have a small function to get the data from the database and a second small function to output the data neatly? Surely that would make your code easier to read and maintain? Yep, it would. <img src='http://matty.co.za/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<h3>4. Do I need this function here?</h3>
<p>This one is about load and separation of code. Why load extra functions when you don&#8217;t need them in a specific context? Keeping this in mind ensures that you keep your code in &#8220;bite size chunks&#8221;, for example, splitting admin-related functions versus frontend functionality.</p>
<p>These items, while simple to adhere to, can alter the way a developer approaches a project, as well as creating a better end result. Most are also common development practices that most developers should be familiar with, making it easier for other developers to read and understand your projects.</p>
<p><em>Do you have any tips and tricks that help you day to day while developing?</em></p>
]]></content:encoded>
			<wfw:commentRss>http://matty.co.za/2012/01/web-coding-best-practices/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Re-thinking the concept of the &#8220;impossible&#8221;</title>
		<link>http://matty.co.za/2012/01/re-thinking-the-impossible/</link>
		<comments>http://matty.co.za/2012/01/re-thinking-the-impossible/#comments</comments>
		<pubDate>Fri, 13 Jan 2012 17:00:14 +0000</pubDate>
		<dc:creator>Matty</dc:creator>
				<category><![CDATA[Coding]]></category>
		<category><![CDATA[General]]></category>
		<category><![CDATA[Technology]]></category>
		<category><![CDATA[WordPress]]></category>
		<category><![CDATA[Project 365]]></category>
		<category><![CDATA[Thoughts]]></category>
		<category><![CDATA[Web Developer]]></category>

		<guid isPermaLink="false">http://matty.co.za/?p=1213</guid>
		<description><![CDATA[In today&#8217;s society, it seems to be a common occurrence to use the word &#8220;impossible&#8221;. For example, after climbing a mountain, one might say something like; &#8220;wow, that was impossible&#8221;. No it wasn&#8217;t&#8230; you just did it. Nowadays we seem to have a tendency to over-exaggerate (pardon the tautology there) and, in many cases, start to believe what [...]]]></description>
			<content:encoded><![CDATA[<p>In today&#8217;s society, it seems to be a common occurrence to use the word &#8220;impossible&#8221;. For example, after climbing a mountain, one might say something like; &#8220;wow, that was impossible&#8221;. No it wasn&#8217;t&#8230; you just did it. Nowadays we seem to have a tendency to over-exaggerate (pardon the tautology there) and, in many cases, start to believe what we&#8217;re saying. Surely, this affects how we approach tasks and situations. Why should it?</p>
<p>Over the past few years (I&#8217;d say, since about 2008), I&#8217;ve decided to approach tasks day to day from a different angle. How can we say that a task is &#8220;impossible&#8221; if we haven&#8217;t even yet attempted it?</p>
<p>This is quite a common occurrence in web development&#8230; developers looking at a task, attempting to analyze it, getting &#8220;stuck&#8221; at one point and then moving on, deeming it &#8220;impossible&#8221;. Why does it have to, all of a sudden, be &#8220;impossible&#8221;, if you haven&#8217;t even attempted it yet? Why settle for the &#8220;shortcut&#8221; when you could just sit down and develop it how you envision it in the first place?</p>
<p><span id="more-1213"></span>It&#8217;s not about it being &#8220;impossible&#8221;&#8230; you just haven&#8217;t found the correct pieces yet, or how they fit together.</p>
<p>As a small example to illustrate how this approach sucks and how it could be improved with a simple re-thinking process, lets take a look at a real-world scenario I experienced last year.</p>
<p>During the development of our &#8220;Editorial&#8221; theme at WooThemes, we wanted to add functionality to provide the administrator with more control over how many columns their content should be laid out in. This, at first glance, seems quite straight forward. A simple PHP script to cut and re-arrange the words at certain points would do this.</p>
<p>What if the author wants to control where the content is cut off? What if they want virtually infinite possible columns? Well, a shortcode would do this, right?</p>
<p>What if they switch themes? Their content would look ugly and be riddled with a bunch of shortcodes that aren&#8217;t in use anymore. In a context like this, where the content is everything, we couldn&#8217;t have that.</p>
<p>This is where we got down to the drawing board and found the solution that stands to date. A simple button that adds an HTML comment into the author&#8217;s content. We then use a WordPress filter (and regular expression) to convert the HTML comments into semantic HTML tags on the frontend, keeping count of how many columns are being generated and adjusting the layout accordingly. If the administrator decides to switch themes, the HTML comments won&#8217;t affect the display of the content, nor the functionality of the WordPress admin. The button itself, as well as how the HTML comments are displayed in the WordPress admin, echoes how WordPress itself handles similar functionality, integrating seamlessly into the authoring experience.</p>
<p>To illustrate how this relates to the &#8220;impossible&#8221;, many would settle for the shortcode option, as it is the most direct and &#8220;obvious&#8221; choice, without taking into account the ramifications thereof.</p>
<p>We&#8217;ve taken this same approach on many other pieces of functionality within themes and functionality developed at WooThemes. I&#8217;ve made this concept a part of my day to day approach to things as well.</p>
<p>To sum it up in a sentence, I&#8217;d say, &#8220;don&#8217;t assume something is &#8216;impossible&#8217; until you&#8217;ve tried it. You never know&#8230; you may just get a better result&#8221;. <img src='http://matty.co.za/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://matty.co.za/2012/01/re-thinking-the-impossible/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>GROW Academy Bootcamp 2012</title>
		<link>http://matty.co.za/2012/01/grow-academy-bootcamp-2012/</link>
		<comments>http://matty.co.za/2012/01/grow-academy-bootcamp-2012/#comments</comments>
		<pubDate>Mon, 09 Jan 2012 13:00:31 +0000</pubDate>
		<dc:creator>Matty</dc:creator>
				<category><![CDATA[Coding]]></category>
		<category><![CDATA[Design]]></category>
		<category><![CDATA[Technology]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[WordPress]]></category>
		<category><![CDATA[Blogging]]></category>
		<category><![CDATA[Project 365]]></category>
		<category><![CDATA[Social Media]]></category>
		<category><![CDATA[Tips]]></category>
		<category><![CDATA[Web Developer]]></category>

		<guid isPermaLink="false">http://matty.co.za/?p=1198</guid>
		<description><![CDATA[This week, Jeff and I will be presenting at our second GROW Academy Bootcamp session. We&#8217;ll be discussing &#8220;Website Design &#38; Development&#8221; with the recruits, running through WordPress and how to setup a website using WordPress.com or WordPress.org. The GROW Academy is an initiative to educate and empower the youth of today through technology. The [...]]]></description>
			<content:encoded><![CDATA[<p>This week, <a title="Jeffikus" href="http://jeffikus.com/">Jeff</a> and I will be presenting at our second GROW Academy Bootcamp session. We&#8217;ll be discussing &#8220;Website Design &amp; Development&#8221; with the recruits, running through WordPress and how to setup a website using WordPress.com or WordPress.org.</p>
<p>The <a title="The GROW Academy" href="http://grow.org.za/">GROW Academy</a> is an initiative to educate and empower the youth of today through technology. The Bootcamp session covers everything from social media and setting up e-mail, all the way through to search engine optimisation and an internet super-user course, for those who wish to continue on with more advanced studies. The GROW website&#8217;s &#8220;<a title="About GROW" href="http://grow.org.za/about/">About</a>&#8221; page (built on Canvas and Canvas BuddyPress by WooThemes) has a detailed explanation of the initiative and it&#8217;s founding partners.</p>
<p><span id="more-1198"></span>This year, Jeff and I will be making some exciting additions to our presentation. While code, to some, can seem dry and boring, I can assure you that there&#8217;s nothing dry or boring about our presentation. We had such a blast at last year&#8217;s Bootcamp and are really looking forward to getting into some code with this year&#8217;s recruits.</p>
<p>If you&#8217;re keen to get involved with GROW, I&#8217;d encourage you to contact the GROW Academy and see how you can help out.</p>
<p>Remember: it&#8217;s all easy, and there&#8217;s no such thing as a stupid question. <img src='http://matty.co.za/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://matty.co.za/2012/01/grow-academy-bootcamp-2012/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>A Quick Guide to the WordPress Transients API</title>
		<link>http://matty.co.za/2012/01/wordpress-transients-api/</link>
		<comments>http://matty.co.za/2012/01/wordpress-transients-api/#comments</comments>
		<pubDate>Thu, 05 Jan 2012 08:00:38 +0000</pubDate>
		<dc:creator>Matty</dc:creator>
				<category><![CDATA[Coding]]></category>
		<category><![CDATA[WordPress]]></category>
		<category><![CDATA[Project 365]]></category>
		<category><![CDATA[Tips]]></category>
		<category><![CDATA[Web Developer]]></category>

		<guid isPermaLink="false">http://matty.co.za/?p=1168</guid>
		<description><![CDATA[The Transient API in WordPress is one of the many APIs available in the WordPress core that, once used, become invaluable and used on a daily basis. This is a quick guide to getting started with the transients API, when to use it and why. The Transients API, while similar to the WordPress options API, [...]]]></description>
			<content:encoded><![CDATA[<p>The Transient API in WordPress is one of the many APIs available in the WordPress core that, once used, become invaluable and used on a daily basis. This is a quick guide to getting started with the transients API, when to use it and why.</p>
<p>The Transients API, while similar to the WordPress options API, has the addition of an expiry time. The API is used to store data in the database for a fix amount of time, at which point it is deleted and would need to be re-added, if one requires the data again. The WordPress Codex explains the <a href="http://codex.wordpress.org/Transients_API" title="The Transients API documentation on the WordPress Codex">Transients API</a> as:</p>
<blockquote><p>…very similar to the Options API but with the added feature of an expiration time, which simplifies the process of using the wp_options database table to store cached information.</p></blockquote>
<p>From a technical standpoint, transients are also sped up by caching plugins, which store the data in memory, rather than in the database, making for a faster lookup.</p>
<p><span id="more-1168"></span><br />
<h3>Getting started</h3>
<p>Using transients is easier than you might think. The first thing to note is that there are two types of transients; conventional (only on the specified site within a WordPress multisite installation) and &#8220;site&#8221; (across the entire WordPress multisite installation). They interact in the same way though.</p>
<p>The Transients API has 3 core functions; <code>set_transient()</code>, <code>get_transient()</code> and <code>delete_transient()</code>. They function in the same way as <code>add_option()</code>, <code>get_option()</code> and <code>delete_option()</code> do, so they should be familiar.</p>
<h3>Brief function analysis</h3>
<h4>set_transient()</h4>
<p>Stores data in a transient.</p>
<p>The parameters are:</p>
<ol>
<li>The transient key (the name of the transient to store the data in)</li>
<li>The value (the data to store)</li>
<li>The expiration (the time expiration, in seconds, from the time of storage &#8211; one day would be 60 * 60 * 24)</li>
</ol>
<h4>get_transient()</h4>
<p>Retrieve the transient data, if it&#8217;s available.</p>
<p>The parameters are:</p>
<ol>
<li>The transient key (the name of the transient the data is stored in)</li>
</ol>
<h4>delete_transient()</h4>
<p>Force the expiry/removal of a specified transient.</p>
<p>The parameters are:</p>
<ol>
<li>The transient key (the name of the transient the data is stored in)</li>
</ol>
<h3>The Transients API in use</h3>
<p>To use the Transients API, the process is straight forward. Check if the transient is available. If it isn&#8217;t, get the data (this could be anything from a simple line of text -which may not be too practical- to an advanced and resource-intensive database query, which you may not want to run every time your website is loaded) and assign it to the transient. Assign the data to a variable and return it for use in your code.</p>
<p>In code, this may look like the following:</p>
<p><code></p>
<pre>
&lt;?php
	$transient_key = 'my-transient-key';
	$data = get_transient( $transient_key );
	if ( $data == '' ) {
		$data = get_posts( array( 'posts_per_page' => -1 ) );
		set_transient( $transient_key, $data, 60 * 60 * 24 );
	}

	// You would then carry on using $data in your code.
?&gt;
</pre>
<p></code></p>
<p>An example of when WordPress itself uses the Transients API is during checks for updates of themes, plugins and WordPress itself. These checks don&#8217;t in fact happen each time you visit the &#8220;Updates&#8221; dashboard screen, but periodically based on a transient of stored information about the themes and plugins you have in your installation.</p>
<h3>Where and when to use the Transients API</h3>
<p>Usage of this API is vast and varied. Essentially, the Transients API can be seen as a form of caching system with an expiry time. Therefore, you may want to cache data (for example, from an RSS feed or API request) for a few hours or days, or you could cache something for a few seconds while a user is busy on your website (to make their experience that little bit faster). With such simple implementation, the usage possibilities are limited only by one&#8217;s imagination and a coding project&#8217;s requirements.</p>
<p>Now that you know about the Transients API, I&#8217;m certain you&#8217;ll start using it more often to speed up your projects. This API, while seemingly so small and simple, is incredibly powerful and can transform bloated code into streamlined genius.</p>
]]></content:encoded>
			<wfw:commentRss>http://matty.co.za/2012/01/wordpress-transients-api/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>Re-thinking &#8220;Uncategorized&#8221; in WordPress</title>
		<link>http://matty.co.za/2012/01/re-thinking-uncategorized-in-wordpress/</link>
		<comments>http://matty.co.za/2012/01/re-thinking-uncategorized-in-wordpress/#comments</comments>
		<pubDate>Tue, 03 Jan 2012 09:00:30 +0000</pubDate>
		<dc:creator>Matty</dc:creator>
				<category><![CDATA[Coding]]></category>
		<category><![CDATA[WordPress]]></category>
		<category><![CDATA[Project 365]]></category>
		<category><![CDATA[Thoughts]]></category>
		<category><![CDATA[Web Developer]]></category>
		<category><![CDATA[WordPress Support]]></category>

		<guid isPermaLink="false">http://matty.co.za/?p=1158</guid>
		<description><![CDATA[As WordPress users soon come to realise after setting up their website, a few defaults are loaded in. These defaults include a test &#8220;Hello World&#8221; post with a comment from Mr. WordPress, a &#8220;Sample Page&#8217; with some text and instructions and the &#8220;Uncategorized&#8221; category, amongst the various default &#8220;Links&#8221; data and &#8220;Blogroll&#8221; category. Having given [...]]]></description>
			<content:encoded><![CDATA[<p>As WordPress users soon come to realise after setting up their website, a few defaults are loaded in. These defaults include a test &#8220;Hello World&#8221; post with a comment from Mr. WordPress, a &#8220;Sample Page&#8217; with some text and instructions and the &#8220;Uncategorized&#8221; category, amongst the various default &#8220;Links&#8221; data and &#8220;Blogroll&#8221; category.</p>
<p>Having given this some thought, the &#8220;Uncategorized&#8221; category doesn&#8217;t really seem correct in that the term is a category in itself. It&#8217;s almost a full paradox to say that a post is &#8220;uncategorized&#8221;, meanwhile it is in fact in a category.</p>
<p><span id="more-1158"></span></p>
<p>Upon removing the relationship entirely between the &#8220;Uncategorized&#8221; category and a specific post, the post worked as expected with no issues. By default, a post is assigned to the category set as the default category in the WordPress settings screens within the WordPress admin. Therefore, while it is possible to assign a new default category and delete the &#8220;Uncategorized&#8221; category, the question is more, <strong>why do posts in WordPress need to be assigned to a specific category?</strong> Can they not just float independently?</p>
<p>I&#8217;m sure there&#8217;s a reason behind this (if you know it or can offer some insight into possible reasons, please share)&#8230; just thought I&#8217;d pose the thought and see what you all think. <img src='http://matty.co.za/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://matty.co.za/2012/01/re-thinking-uncategorized-in-wordpress/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Matty Theme QuickSwitch featured on The Sweet Plugin of the Day</title>
		<link>http://matty.co.za/2012/01/theme-quickswitch-on-the-sweet-plugin/</link>
		<comments>http://matty.co.za/2012/01/theme-quickswitch-on-the-sweet-plugin/#comments</comments>
		<pubDate>Mon, 02 Jan 2012 08:00:51 +0000</pubDate>
		<dc:creator>Matty</dc:creator>
				<category><![CDATA[Coding]]></category>
		<category><![CDATA[WordPress]]></category>
		<category><![CDATA[Project 365]]></category>
		<category><![CDATA[WordPress Plugins]]></category>

		<guid isPermaLink="false">http://matty.co.za/?p=1140</guid>
		<description><![CDATA[One thing I enjoy almost as much as developing with WordPress is reading about WordPress development and the goings-on within the WordPress community. WPCandy, a website I&#8217;ve written a few posts for, is my main go-to resource for community news and current happenings within the WordPress community. Ryan, the editor at WPCandy, broadcasts a video [...]]]></description>
			<content:encoded><![CDATA[<p>One thing I enjoy almost as much as developing with WordPress is reading about WordPress development and the goings-on within the WordPress community. <a title="WPCandy" href="http://wpcandy.com/">WPCandy</a>, a website I&#8217;ve written a few posts for, is my main go-to resource for community news and current happenings within the WordPress community.</p>
<p>Ryan, the editor at WPCandy, broadcasts a video podcast called &#8220;The Sweet Plugin of the Day&#8221;, where he reviews a plugin that he finds useful and/or interesting. <a title="Matty Theme QuickSwitch" href="http://matty.co.za/plugins/matty-theme-quickswitch/">Matty Theme QuickSwitch</a>, a plugin I recently released to make quick switching between WordPress themes easier, was recently featured on &#8220;The Sweet Plugin&#8221;.</p>
<p><span id="more-1140"></span><br />
<iframe src="http://player.vimeo.com/video/34124084?title=0&amp;byline=0&amp;portrait=0" frameborder="0" width="549" height="309"></iframe></p>
<p>Thanks for the great review and kind words, Ryan. <img src='http://matty.co.za/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>Click to read the <a title="The text-based review of Matty Theme QuickSwitch on WPCandy" href="http://wpcandy.com/category/broadcasts/the-sweet-plugin">full text-based review of Matty Theme QuickSwitch</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://matty.co.za/2012/01/theme-quickswitch-on-the-sweet-plugin/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>What a blog redesign means to me</title>
		<link>http://matty.co.za/2011/07/what-a-blog-redesign-means-to-me/</link>
		<comments>http://matty.co.za/2011/07/what-a-blog-redesign-means-to-me/#comments</comments>
		<pubDate>Sun, 31 Jul 2011 10:48:42 +0000</pubDate>
		<dc:creator>Matty</dc:creator>
				<category><![CDATA[Coding]]></category>
		<category><![CDATA[Design]]></category>
		<category><![CDATA[Theming]]></category>
		<category><![CDATA[Thoughts]]></category>
		<category><![CDATA[Web Developer]]></category>
		<category><![CDATA[WordPress Themes]]></category>

		<guid isPermaLink="false">http://matty.co.za/?p=1119</guid>
		<description><![CDATA[Today&#8217;s question, folks, is; &#8220;What does a blog redesign mean to you?&#8221;. Lets dive right in, shall we? For me, a blog redesign means quite a lot. It means the opportunity to hone my skills, experiment with new ideas and techniques and put a fresh coat of paint and a new engine behind my blog. [...]]]></description>
			<content:encoded><![CDATA[<p>Today&#8217;s question, folks, is; &#8220;What does a blog redesign mean to you?&#8221;. Lets dive right in, shall we?</p>
<p>For me, a blog redesign means quite a lot. It means the opportunity to hone my skills, experiment with new ideas and techniques and put a fresh coat of paint and a new engine behind my blog. Let me elaborate on the paint and engine for a moment.</p>
<p><span id="more-1119"></span><br />
Over the past few months, I&#8217;ve designed and developed at least 3 new themes for this blog. By the time I reach what looks like the end of the theme, I&#8217;ve become bored with the design or feel the code is now &#8220;old&#8221; and would prefer to start again on a new design idea I&#8217;ve come across while scouting around online for inspiration. This has proven to be a vicious cycle whereby the ultimate goal is never achieved: a new blog design.</p>
<h3>Why not just get someone else to do it?</h3>
<p>It comes down to personal preference on this one. I&#8217;m a professional web developer and am trained and qualified as a designer, so why not design and develop the theme myself? In addition, am I not letting an opportunity to show my abilities get put aside? In addition, at the end of the day, I can say that I designed and developed the entire theme from the ground up, which makes the achievement that much sweeter.</p>
<h3>The search for perfection?</h3>
<p>Designers often run into this, from what I&#8217;ve seen. There&#8217;s always something that can be done to improve a design further. Pixels can be shifted around until blue in the face… but will it ever be finished? The same goes for development. That one line of code can be optimised, written and re-written over and over until it becomes almost meaningless. Does it really improve or contribute anything?</p>
<p>Yes, it does. Does it have to be done right this very second, though? If it&#8217;s not a life-changing development decision, or an integral part of the design, probably not. Having the code as optimised as possible is great… but if no-one sees it, what good is it doing?</p>
<h3>Final words&#8230;</h3>
<p>With that said, I&#8217;ve come to a new conclusion (and am writing it in this post for posterity): a blog&#8217;s design is never truly &#8220;finished&#8221;. With the web evolving at the rate it is, it makes perfect sense to revamp your web presence every few months… kind of like putting a fresh coat of paint on a house. Therefore, I&#8217;ve published this redesign as is and will continue to work on it and make improvements. That way, the design and development will remain constantly fresh, and I&#8217;ll be able to hone my skills and experiment on things on a more regular basis, rather than tying that down into a phase of &#8220;I am now redesigning my blog, therefore, let me experiment&#8221;.</p>
<p>If you spot anything that could do with some more cowbell, give me a shout and I&#8217;ll get right on it. <img src='http://matty.co.za/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://matty.co.za/2011/07/what-a-blog-redesign-means-to-me/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>A theory on approaching difficult tasks</title>
		<link>http://matty.co.za/2009/11/approaching-difficult-tasks/</link>
		<comments>http://matty.co.za/2009/11/approaching-difficult-tasks/#comments</comments>
		<pubDate>Mon, 09 Nov 2009 18:09:17 +0000</pubDate>
		<dc:creator>Matty</dc:creator>
				<category><![CDATA[Coding]]></category>
		<category><![CDATA[General]]></category>
		<category><![CDATA[Thoughts]]></category>
		<category><![CDATA[Web Developer]]></category>

		<guid isPermaLink="false">http://matty.co.za/?p=729</guid>
		<description><![CDATA[Whichever industry you work in, whether you work for yourself or a company and whatever your job description, there are days where things just aren&#8217;t going your way. No matter how long you sit at your desk, tapping your pencil, the solution to the problem at hand just isn&#8217;t apparent. As a developer, the problem [...]]]></description>
			<content:encoded><![CDATA[<p>Whichever industry you work in, whether you work for yourself or a company and whatever your job description, there are days where things just aren&#8217;t going your way. No matter how long you sit at your desk, tapping your pencil, the solution to the problem at hand just isn&#8217;t apparent.</p>
<p>As a developer, the problem and solution are usually quite clean-cut (such is the nature of code, prodominantly). The solution, however clean-cut it may be, isn&#8217;t always visible when approaching a coding task. At times like those, I employ a theory:<br />
<span id="more-729"></span></p>
<blockquote><p>Whatever you do to figure out the solution, whatever pencil-tapping or repeated contact between your head and desk occurs, the end result will work and be exactly as per the task set out to you.</p></blockquote>
<p>Knowing this, the task of achieving the goal becomes seemingly less stressful and a bit clearer to tackle. In addition, I find it important to clear one&#8217;s head, move away from the problem for a few minutes and give it some thought from a different angle.</p>
<p>That&#8217;s my theory, anyways.</p>
<p>Stop. Think. Re-evaluate.</p>
]]></content:encoded>
			<wfw:commentRss>http://matty.co.za/2009/11/approaching-difficult-tasks/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Custom URL rewrites in WordPress &#8211; A Getting Started Guide</title>
		<link>http://matty.co.za/2009/11/custom-url-rewrites-in-wordpress/</link>
		<comments>http://matty.co.za/2009/11/custom-url-rewrites-in-wordpress/#comments</comments>
		<pubDate>Sat, 07 Nov 2009 10:11:06 +0000</pubDate>
		<dc:creator>Matty</dc:creator>
				<category><![CDATA[Coding]]></category>
		<category><![CDATA[WordPress]]></category>
		<category><![CDATA[Custom URL Rewrites]]></category>
		<category><![CDATA[WordPress Plugins]]></category>

		<guid isPermaLink="false">http://matty.co.za/?p=701</guid>
		<description><![CDATA[Hey everyone. I&#8217;ve been tweeting quite a bit recently about custom URL rewrites in WordPress. After a few hours of trial and error, I&#8217;ve managed to get my specific custom URL rewrites working. After reading through several tutorials online (the majority of which used the same examples to explain only a portion the information I [...]]]></description>
			<content:encoded><![CDATA[<p>Hey everyone.<br />
I&#8217;ve been tweeting quite a bit recently about custom URL rewrites in WordPress. After a few hours of trial and error, I&#8217;ve managed to get my specific custom URL rewrites working. After reading through several tutorials online (the majority of which used the same examples to explain only a portion the information I was looking for), here&#8217;s my tutorial- a getting started guide to Custom URL rewrites in WordPress.</p>
<h3>The process</h3>
<p>So, what exactly are we doing here? To put things in point form, this is the process:</p>
<ol>
<li>Create custom rewrite rules</li>
<li>Add our new variables to the public_query_vars array</li>
<li>Flush (and thus, regenerate) all WordPress rewrite rules</li>
<li>Add our functions from steps 1, 2 and 3 into WordPress via actions and filters</li>
</ol>
<p>Right, so lets get down to it then.<span id="more-701"></span></p>
<h3>Create custom rewrite rules</h3>
<p>Rewrite rules use a  token which is replaced by the necessary query variable. For example, we create a token called %token% which, using a regular expression, gets replaced by &#8220;id=&#8221;. This will be shown further below.</p>
<p><code></p>
<p style="margin-bottom: 0cm;">/**<br />
* create_custom_rewrite_rules()<br />
* Creates the custom rewrite rules.<br />
* return array $rules.<br />
**/</p>
<p style="margin-bottom: 0cm;">function create_custom_rewrite_rules() {<br />
global $wp_rewrite;</p>
<p style="margin-bottom: 0cm;">// Define custom rewrite tokens<br />
$rewrite_tag = '%exampletag%';</p>
<p style="margin-bottom: 0cm;">// Add the rewrite tokens<br />
$wp_rewrite-&gt;add_rewrite_tag( $rewrite_tag, '(.+?)', 'car=' );</p>
<p style="margin-bottom: 0cm;">// Define the custom permalink structure<br />
$rewrite_keywords_structure = $wp_rewrite-&gt;root . "%pagename%/$rewrite_tag/";<br />
// $rewrite_keywords_structure = $wp_rewrite-&gt;root . "$slug/$rewrite_tag/";</p>
<p style="margin-bottom: 0cm;">// Generate the rewrite rules<br />
$new_rule = $wp_rewrite-&gt;generate_rewrite_rules( $rewrite_keywords_structure );</p>
<p style="margin-bottom: 0cm;">// Add the new rewrite rule into the global rules array<br />
$wp_rewrite-&gt;rules = $new_rule + $wp_rewrite-&gt;rules;</p>
<p style="margin-bottom: 0cm;">return $wp_rewrite-&gt;rules;</p>
<p style="margin-bottom: 0cm;">} // End create_custom_rewrite_rules()</p>
<p></code></p>
<h3>Add our new variables to the public_query_vars array</h3>
<p>By default, WordPress has an array of public query variables which can be used within templates and plugins. In order to access our query variables (ie: the &#8220;id=&#8221; in the above example), the variable needs to be added to the public query vars array.<br />
<code><br />
/**<br />
* add_custom_page_variables()<br />
* Add the custom token as an allowed query variable.<br />
* return array $public_query_vars.<br />
**/</code></p>
<p><code>function add_custom_page_variables( $public_query_vars ) {<br />
$public_query_vars[] = 'car';</code></p>
<p><code>return $public_query_vars;</code></p>
<p><code> </code></p>
<p><code>} // End add_custom_page_variables()<br />
</code></p>
<h3>Flush all WordPress rewrite rules</h3>
<p>By flushing the rules, we are forcing WordPress to regenerate it&#8217;s rules list, including our new rules in the rules set.<br />
<code><br />
/**<br />
* flush_rewrite_rules()<br />
* Flush the rewrite rules, which forces the regeneration with new rules.<br />
* return void.<br />
**/</code></p>
<p><code>function flush_rewrite_rules() {</code></p>
<p><code>global $wp_rewrite;</code></p>
<p><code>$wp_rewrite-&gt;flush_rules();</p>
<p></code></p>
<p><code>} // End flush_rewrite_rules()<br />
</code></p>
<h3>Add our functions from steps 1, 2 and 3 into WordPress via actions and filters</h3>
<p>Now that our functions have been created, we need to hook them into the various necessary processes within WordPress. We do this using a combination of actions and filters.</p>
<p>Our first action runs on initialization. This is where we flush the rewrite rules in WordPress, causing them to be regenerated.</p>
<p>The regeneration brings us to action number 2. This is where we create our custom rewrite rule, hook it on to the global rewrites array and generate the rules.</p>
<p>Our final line is our filter where we add the new public query variable into the global public_query_vars array. We then later use this array to access the variable in our theme.<br />
<code><br />
add_action( 'init', 'flush_rewrite_rules' );<br />
add_action( 'generate_rewrite_rules', 'create_custom_rewrite_rules' );<br />
add_filter( 'query_vars', 'add_custom_page_variables' );<br />
</code></p>
<h3>The scope of rewrite rules</h3>
<p>By default, WordPress rules are applied across all pages. Thus, the tag &#8220;%pagename%&#8221; is used in place of a specific page slug. To use your rules on only a single page, replace &#8220;%pagename%&#8221; with a specific page slug. You can either generate this slug dynamically or staticly.</p>
<h3>That&#8217;s all, folks</h3>
<p>And there you have it. A custom rewrite rule in WordPress. This post is intended as a starting point for using custom rewrite rules in WordPress. There are virtually infinite possibilities created when using rewrite rules (either one or many) and some really interesting plugins and functionalities can come out of using rewrite rules.</p>
<p>Thanks must also go to <a href="http://www.joehoyle.co.uk/" target="_blank">Joe Hoyle</a> who&#8217;s use of rewrite rules provided the inspiration for this tutorial.</p>
<p>If there&#8217;s anything that isn&#8217;t clear, please comment below and I&#8217;ll do my best to clarify and help.</p>
<h3>Before I go&#8230; wouldn&#8217;t you like the files?</h3>
<p>I thought you might. Click below to download the code written above (it&#8217;s been written into a class for easy implementation in your projects).</p>
<p>Download the  &#8221;<a title="Custom URL rewrites in WordPress" href="http://matty.co.za/wp-content/uploads/2009/11/matty_rewrite.class.zip">Custom URL rewrites in WordPress &#8211; A Getting Started Guide</a>&#8221; code example.</p>
]]></content:encoded>
			<wfw:commentRss>http://matty.co.za/2009/11/custom-url-rewrites-in-wordpress/feed/</wfw:commentRss>
		<slash:comments>14</slash:comments>
		</item>
	</channel>
</rss>

<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Minified using disk: basic
Page Caching using disk: enhanced
Object Caching 651/711 objects using disk: basic

Served from: matty.co.za @ 2012-02-05 08:55:38 -->
