<?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; Tips</title>
	<atom:link href="http://matty.co.za/tag/tips/feed/" rel="self" type="application/rss+xml" />
	<link>http://matty.co.za</link>
	<description>Web developer, WordPress enthusiast, avid musician and blogger</description>
	<lastBuildDate>Thu, 12 Apr 2012 08:43:04 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</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>1</slash:comments>
		</item>
		<item>
		<title>Presentations using SlideRocket</title>
		<link>http://matty.co.za/2012/01/presentations-using-sliderocket/</link>
		<comments>http://matty.co.za/2012/01/presentations-using-sliderocket/#comments</comments>
		<pubDate>Sat, 14 Jan 2012 20:37:57 +0000</pubDate>
		<dc:creator>Matty</dc:creator>
				<category><![CDATA[Technology]]></category>
		<category><![CDATA[Productivity]]></category>
		<category><![CDATA[Project 365]]></category>
		<category><![CDATA[Tips]]></category>

		<guid isPermaLink="false">http://matty.co.za/?p=1217</guid>
		<description><![CDATA[In the last week, Jeff and I presented a workshop at the GROW Academy&#8217;s BootCamp, discussing website design &#38; development and focussing on using WordPress to do this. For both our introductory session on Monday and our more in-depth theory discussion on Wednesday, we needed a slideshow presentation to work through the various areas of [...]]]></description>
			<content:encoded><![CDATA[<p>In the last week, Jeff and I <a title="GROW BootCamp 2012 – The Creations" href="http://matty.co.za/2012/01/grow-bootcamp-2012-creations/">presented a workshop</a> at the GROW Academy&#8217;s BootCamp, discussing website design &amp; development and focussing on using WordPress to do this. For both our introductory session on Monday and our more in-depth theory discussion on Wednesday, we needed a slideshow presentation to work through the various areas of website construction. Lets zoom back to Monday morning&#8230; I needed some slides&#8230; in a hurry.</p>
<p>As many of you know, I like to keep my computer as clean as possible. If I don&#8217;t use an application, it gets removed and everything that could go onto the machine is thought through before it&#8217;s loaded on. Thus, I don&#8217;t have PowerPoint, Keynote or anything of the sort&#8230; because I don&#8217;t need it. Suddenly, I did. Enter <a title="SlideRocket" href="http://sliderocket.com/" target="_blank">SlideRocket</a>.</p>
<p><span id="more-1217"></span>SlideRocket is a web-based presentation creation tool, similar to PowerPoint or Keynote. They also have a web-app in the Google Chrome Web Store, which is how I got started on it.</p>
<p>The team at SlideRocket have, by the looks of things, put much time, effort and thought into their product and how it interacts with it&#8217;s users. While the interface is familiar to anyone who has ever used PowerPoint or Keynote, it doesn&#8217;t get in the way of you creating your presentation. At no point did the interface bug me, crash or do anything I wasn&#8217;t expecting it to do. This is a welcome change in the arena of presentation tools.</p>
<p>My only concern was the lack of a free export of my presentation (maybe I didn&#8217;t see it?). While SlideRocket offers many export options, from PowerPoint to PDF, standalone OS X to standalone Windows, it seems I was unable to export my presentation for free (the above mentioned exports are available after a paid upgrade). While I understand the need for paid upgrades in a free application, I feel it would be advantageous to have some form of basic free export (even just to a set of static HTML files would be good&#8230; for simple, in-browser presenting).</p>
<p>To sum up, I really enjoyed my experience with SlideRocket&#8230; so much so, in fact, that I decided to blog about it. I needed a presentation quickly and was able to create one in a few minutes, with no hassle. Not only that, but with SlideRocket being a web-app, I could easily add Jeff into the mix and collaborate with him on the slides over the web-app (I mean, we sit next to each other at HQ, but still&#8230; collaboration of this nature is invaluable in a presentation tool).</p>
<p>The next time I do a presentation, I&#8217;ll most likely jump back into SlideRocket without thinking twice. Thanks for the awesome web-app, guys!</p>
]]></content:encoded>
			<wfw:commentRss>http://matty.co.za/2012/01/presentations-using-sliderocket/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>More tips for styling the WordPress tinyMCE editor</title>
		<link>http://matty.co.za/2010/08/more-wordpress-custom-editor-styles/</link>
		<comments>http://matty.co.za/2010/08/more-wordpress-custom-editor-styles/#comments</comments>
		<pubDate>Mon, 09 Aug 2010 13:11:07 +0000</pubDate>
		<dc:creator>Matty</dc:creator>
				<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[WordPress]]></category>
		<category><![CDATA[Theming]]></category>
		<category><![CDATA[Tips]]></category>
		<category><![CDATA[WordPress Support]]></category>
		<category><![CDATA[WordPress Themes]]></category>

		<guid isPermaLink="false">http://matty.co.za/?p=1084</guid>
		<description><![CDATA[A few weeks ago, I blogged about styling the tinyMCE editor in WordPress to resemble your WordPress theme&#8217;s content area. On this post, I received a comment from LA, asking if it&#8217;s possible to style the tinyMCE editor for specific posts or post templates. Folks, it&#8217;s WordPress&#8230; anything&#8217;s possible! With my mission at hand, I [...]]]></description>
			<content:encoded><![CDATA[<p><a title="Browse through more posts I've written about WordPress" href="http://matty.co.za/category/wordpress/"><img class="alignright size-full wp-image-1013" title="WordPress logo in blue" src="http://matty.co.za/wp-content/uploads/2010/04/blue-m.png" alt="Blue WordPress logo, courtesy http://wordpress.org/about/logos/" width="100" height="100" /></a>A few weeks ago, I blogged about <a title="Styling the tinyMCE editor in WordPress" href="http://matty.co.za/2010/05/editor-style-in-wordpress/">styling the tinyMCE editor in WordPress</a> to resemble your WordPress theme&#8217;s content area. On this post, I received a comment from LA, asking if it&#8217;s possible to style the tinyMCE editor for specific posts or post templates. Folks, it&#8217;s <a title="Browse more posts about WordPress" href="http://matty.co.za/category/wordpress/">WordPress</a>&#8230; anything&#8217;s possible!</p>
<p>With my mission at hand, I set to work. I&#8217;d been thinking about this for a while after writing the initial blog post and am please to say that I have found a solution. Please be sure you&#8217;ve read through the <a title="Styling the tinyMCE editor in WordPress" href="http://matty.co.za/2010/05/editor-style-in-wordpress/">initial blog post</a>, as the main points are covered over there.</p>
<p>There are a few steps we need to go through here. They&#8217;re pretty straight forward, so bear with me. <img src='http://matty.co.za/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p><span id="more-1084"></span></p>
<p><img class="aligncenter size-full wp-image-1088" title="LA's question regarding styling the tinyMCE editor in WordPress" src="http://matty.co.za/wp-content/uploads/2010/08/la_question.png" alt="LA's question regarding styling the tinyMCE editor in WordPress" width="620" height="150" /></p>
<h3>Reference the global $post object</h3>
<p>First things first. How do we know what page, post or custom post type entry we&#8217;re working with? We need to get this information from WordPress. Luckily for us, WordPress also needs to know which entry we&#8217;re editing. We get this information by adding the following to the beginning of our function:</p>
<pre>global $post;</pre>
<p>This lets us work with the variable $post, which was previously created outside of our function. This variable is an object that holds information about the entry we are currently editing (ID, title, content, template, etc). We will be using this information at a later stage to insert our custom CSS file(s).</p>
<p>Due to this being a custom solution specific to a particular page, post or custom post type entry, this solution will only truly take effect on the &#8220;Edit&#8221; screens when targeting a specific entry or an entry with a particular custom template applied.</p>
<h3>Check if the file we&#8217;re looking for exists</h3>
<p>We wouldn&#8217;t want to call a file that we know doesn&#8217;t exist. Therefore, we will use a conditional (in this case, an IF statement) to determine whether or not to look for our custom CSS file, based on whether or not it exists.</p>
<h3>If the CSS file exists, add it to the list of CSS files to include</h3>
<p>After the line where we include our main editor-style.css file, add the following code:</p>
<pre><code>if ( file_exists( trailingslashit( get_stylesheet_directory() ) . 'assets/css/editor-style-' . $post-&gt;post_type . '.css' ) ) {

	if ( !empty($url) )
 	$url .= ',';

	// Change the path here if using sub-directory
 	$url .= trailingslashit( get_stylesheet_directory_uri() ) . 'assets/css/editor-style-' . $post-&gt;post_type . '.css';

} // End IF Statement
</code></pre>
<p>The above code checks if our custom CSS file (in this case, for a post type-specific CSS file) exists and, if it does, adds it to the list of CSS files to include in the tinyMCE editor. We include it after checking for our main editor-style.css file so that any of our custom CSS declarations override the defaults we have in the main editor-style.css file.</p>
<h3>Extending this functionality</h3>
<p>In the above example, I am including a custom CSS file based on the post type of the entry being edited. Altering this is relatively straight forward and can allow for custom CSS files depending on date published, post publish status, custom template being used and virtually any condition imaginable.</p>
<p>As an example of extending this functionality, we will include a file based on post ID. To do this, simply paste the above code into the function again and replace all instances of `post_type` with `ID` (such that $post-&gt;post_type becomes $post-&gt;ID). Thus, if a post has an ID of 7 (for example), the system will look for a file called editor-style-7.css and, if it exists, include it in the tinyMCE editor.</p>
<p>Please note that using post IDs can result in a large quantity of custom CSS files and is not recommended. The above is simply an example for extending the functionality we just created.</p>
<p>Folks, there you have it. Not too difficult, I hope. This allows for further customisation of the WordPress tinyMCE editor, creating a richer user experience for the bloggers using your theme, as well as creating a more accurate representation of what the post will look like on the front end of their WordPress website.</p>
]]></content:encoded>
			<wfw:commentRss>http://matty.co.za/2010/08/more-wordpress-custom-editor-styles/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>A few guidelines for WordPress plugin development</title>
		<link>http://matty.co.za/2009/06/guidelines-for-wordpress-plugin-development/</link>
		<comments>http://matty.co.za/2009/06/guidelines-for-wordpress-plugin-development/#comments</comments>
		<pubDate>Sat, 20 Jun 2009 08:12:02 +0000</pubDate>
		<dc:creator>Matty</dc:creator>
				<category><![CDATA[Coding]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[WordPress]]></category>
		<category><![CDATA[Tips]]></category>
		<category><![CDATA[Web Developer]]></category>
		<category><![CDATA[WordPress Plugins]]></category>

		<guid isPermaLink="false">http://matty.co.za/?p=510</guid>
		<description><![CDATA[The WordPress plugin API is vast and powerful. It allows developers to essentially hook code into almost any area of the WordPress system without modifying the core files at all. It also allows for the creation of standalone plugins that work within the WordPress system but do not hook into the core modules. Over the [...]]]></description>
			<content:encoded><![CDATA[<p>The WordPress plugin API is vast and powerful. It allows developers to essentially hook code into almost any area of the WordPress system without modifying the core files at all. It also allows for the creation of standalone plugins that work within the WordPress system but do not hook into the core modules.</p>
<p>Over the last few weeks, WordPress plugin development has become one of my favourite things to do. I find it exciting to be able to create functionality, incorporate it seemlessly into the WordPress system and see it work smoothly with the other modules. While plugin development for WordPress is incredibly powerful, it also carries with it a few areas where people commonly stumble over and potentially lose interest in their code&#8230; which could be the next big thing. Here are a few guidelines I&#8217;ve picked up in order to step over the stumbling blocks.<br />
<span id="more-510"></span></p>
<h3>1. Understand actions, filters and hooks, where to use which action and their limitations.</h3>
<p><a title="Wordpress Actions Reference" href="http://codex.wordpress.org/Plugin_API/Action_Reference" target="_blank">Actions, filters and hooks</a> are what allow developers to insert their code into virtually any part of the WordPress system. While there are only almost 400 hooks documented, there are in fact around 800 hooks in the WordPress system. The WordPress codex has a great reference for actions, filters, hooks and how to use them.</p>
<h3>2. <code>register_activation_hook()</code> does not function the same way as <code>add_action()</code>.</h3>
<p>While looking through the WordPress forums, the <code>register_activation_hook()</code> function (runs the function you pass to it when the plugin is activated) has come up as a regular topic of conversation. Users are attempting to display text on activation, using it as if it were the add_action() function. register_activation_hook() does not function the same way. The function, the way I understand it, works in an almost overall scope, not having access to variables within your plugin for display purposes. In short, don&#8217;t try to echo or print variables with this function. It won&#8217;t work. The function is best used for doing common setup such as installing database tables, setting default options, etc.</p>
<h3>3. Use <code>dbDelta</code> instead of <code>mysql_query</code> or <code>$wpdb-&gt;query()</code> when installing database tables.</h3>
<p>The dbDelta function (which you pass your database query to) is used when installing tables into your WordPress database. It is also used as an upgrade script in the same area. Don&#8217;t forget to include the WordPress upgrade script before running <code>dbDelta()</code>. The include looks like this:</p>
<p><code>require_once(ABSPATH . 'wp-admin/includes/upgrade.php');</code></p>
<h3>4. Understand the scope of your plugin and work within it.</h3>
<p>As mentioned above, WordPress plugins can be used to hook into essentially any area of the WordPress system. This includes standalone menus, as well as running actions when a post or page is saved, for example. Understanding the objective/s and scope of one&#8217;s WordPress plugin is essential to choosing the correct approach for the plugin. If it&#8217;s a short plugin with specific objective, there&#8217;s no need, in my opinion, for more than one or two files. Keep it simple. On the other hand, if the plugin is a large, standalone module, I don&#8217;t believe there&#8217;s any reason to have cluttered files of hundreds of lines of code, where an Object Oriented approach would ultimately serve as a much cleaner and more extendable solution.</p>
<h3>5. Plan, plan, plan.</h3>
<p>Planning on paper, drafting a code map on screen, talking it through with other developers. Planning a plugin can never be done too much. It helps with all of the above steps as well as helping to see where you need to be at the end of the development and planning a solid roadmap for the journey to get there. Also, other users may have ideas that could streamline your plugin even further.</p>
<p>These are just a few things I&#8217;ve picked up on my WordPress plugin development journey. I&#8217;ll post more if and when they come up. I hope these tips are useful and help in overcoming the potential stumbling blocks when getting started with WordPress plugin development.</p>
]]></content:encoded>
			<wfw:commentRss>http://matty.co.za/2009/06/guidelines-for-wordpress-plugin-development/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Coding with the other side of your brain</title>
		<link>http://matty.co.za/2009/06/coding-with-the-other-side-of-your-brain/</link>
		<comments>http://matty.co.za/2009/06/coding-with-the-other-side-of-your-brain/#comments</comments>
		<pubDate>Fri, 19 Jun 2009 16:37:56 +0000</pubDate>
		<dc:creator>Matty</dc:creator>
				<category><![CDATA[Coding]]></category>
		<category><![CDATA[Thoughts]]></category>
		<category><![CDATA[Tips]]></category>
		<category><![CDATA[Web Developer]]></category>

		<guid isPermaLink="false">http://matty.co.za/?p=499</guid>
		<description><![CDATA[This might seem like a weird topic for a blog post. Let me elaborate. If you&#8217;ve ever coded for a system that is build in a convention you&#8217;re not used to (for example, coding using a MVC framework, if you&#8217;re not used to it), this concept will begin to make sense. It refers to the [...]]]></description>
			<content:encoded><![CDATA[<p>This might seem like a weird topic for a blog post. Let me elaborate.</p>
<p>If you&#8217;ve ever coded for a system that is build in a convention you&#8217;re not used to (for example, coding using a MVC framework, if you&#8217;re not used to it), this concept will begin to make sense. It refers to the almost complete paradigm shift required when approaching an unfamiliar coding framework or system. Here are a few things that I&#8217;ve found ease the process of coding with the other side of your brain.<br />
<span id="more-499"></span></p>
<h3>1. Find people who code using the other side of their brain, more often.</h3>
<p>Knowing one or two people who are used to the particular environment in which you are coding can be invaluable. It&#8217;s most useful, I believe, with those smaller tweaks and refinements that you may need to make&#8230; or the small and unexpected bugs in your code.</p>
<h3>2. If the system has a user guide, keep it open.</h3>
<p>User guides can often be bloated and unusable. If the documentation has a function reference and a brief explanation of the concepts behind the system, you&#8217;ve got it.</p>
<h3>3. Pay attention to coding conventions.</h3>
<p>If the original designers of the system are coding in a particular convention, stick to it. There&#8217;s usually a reason for the convention and sticking to it will save you time and potential future re-coding anyways.</p>
<h3>4. Try to lay as much groundwork as possible before integrating the system with your code.</h3>
<p>Pay attention to the finer details of the system and try to view the system on a more abstract level. This will enable you to see the bigger picture and to code or style any areas you may need to back-track and do at a later stage.</p>
<p>I hope these short tips are useful. If you have any to add, please add them in the comments. <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/2009/06/coding-with-the-other-side-of-your-brain/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>My WordPress plugins toolbox</title>
		<link>http://matty.co.za/2009/06/my-wordpress-plugins-toolbox/</link>
		<comments>http://matty.co.za/2009/06/my-wordpress-plugins-toolbox/#comments</comments>
		<pubDate>Wed, 17 Jun 2009 12:34:25 +0000</pubDate>
		<dc:creator>Matty</dc:creator>
				<category><![CDATA[Coding]]></category>
		<category><![CDATA[WordPress]]></category>
		<category><![CDATA[Tips]]></category>
		<category><![CDATA[WordPress Plugins]]></category>

		<guid isPermaLink="false">http://matty.co.za/?p=496</guid>
		<description><![CDATA[Hey everyone, Just thought I&#8217;d post a list of my most regularly installed WordPress plugins and why they are installed on virtually every WordPress installation I do. If there are any plugins I haven&#8217;t listed that should be, please let me know in the comments. 1. Maintenance Mode This plugin is truly awesome. It allows [...]]]></description>
			<content:encoded><![CDATA[<p>Hey everyone,<br />
Just thought I&#8217;d post a list of my most regularly installed WordPress plugins and why they are installed on virtually every WordPress installation I do. If there are any plugins I haven&#8217;t listed that should be, please let me know in the comments. <img src='http://matty.co.za/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<h3>1. <a title="Maintenance Mode WordPress Plugin" href="http://wordpress.org/extend/plugins/maintenance-mode/" target="_blank">Maintenance Mode</a></h3>
<p>This plugin is truly awesome. It allows the developer and end-user to test the WordPress installation thoroughly, on the server where it will eventually be hosted, without displaying it to the world. It also allows the user to, as it says in the title, take the website down for maintenance at any stage and leave a message for users letting them know of the downtime.<br />
<span id="more-496"></span></p>
<h3>2. <a title="All-in-One SEO Pack WordPress Plugin" href="http://wordpress.org/extend/plugins/all-in-one-seo-pack/" target="_blank">All-in-One SEO Pack</a></h3>
<p>I know this isn&#8217;t the be-all and end-all of SEO. It does have some nice features though. SEO-friendly re-writing of page titles (if this isn&#8217;t already in your theme, or you don&#8217;t have access to change it), canonical URLs and page-specific descriptions and keywords. All in all, a straight-forward and very useful plugin.</p>
<h3>3.  <a title="Google Sitemap Generator WordPress Plugin" href="http://wordpress.org/extend/plugins/google-sitemap-generator/" target="_blank">Google Sitemap Generator</a></h3>
<p>Assists with dynamic generation of an XML sitemap, to be submitted to Google. This plugin also allows for various sitemap formats (XML, zipped, etc) and customisation of priority settings for various areas of your WordPress installation.</p>
<h3>4. <a title="Askimet WordPress Plugin" href="http://wordpress.org/extend/plugins/akismet/" target="_blank">Askimet</a></h3>
<p>It comes standard with your installation and has proven very useful in blocking spam comments. Does what it says on the box, really.</p>
<h3>5. <a title="Plugin Resources - WordPress Codex" href="http://codex.wordpress.org/Plugin_Resources" target="_blank">Your Own</a></h3>
<p>Writing your own functionality is, I believe, very important. It has helped me work my way around the WordPress system, how it all hooks together, how to use functionality correctly and how to further enhance WordPress websites. It doesn&#8217;t have to be shiny and new&#8230; as long as it serves a purpose and helps. <img src='http://matty.co.za/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>A short and sweet list of a few plugins that I like to keep in the box. What&#8217;re yours? <img src='http://matty.co.za/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p><small>* These plugins are in no particular order.</small></p>
]]></content:encoded>
			<wfw:commentRss>http://matty.co.za/2009/06/my-wordpress-plugins-toolbox/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Getting the information of a root page in WordPress</title>
		<link>http://matty.co.za/2009/06/getting-the-information-of-a-root-page-in-wordpress/</link>
		<comments>http://matty.co.za/2009/06/getting-the-information-of-a-root-page-in-wordpress/#comments</comments>
		<pubDate>Wed, 10 Jun 2009 08:00:28 +0000</pubDate>
		<dc:creator>Matty</dc:creator>
				<category><![CDATA[Coding]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[WordPress]]></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=468</guid>
		<description><![CDATA[Often, when using WordPress as a content management or blogging tool on a website, one uses a multi-level page structure. This entails a page being listed &#8220;underneath&#8221; another page in a tree structure. Usually, if your WordPress installation&#8217;s permalinks deviate from the default setting, your page URL structure will look something like this: http://websiteurl.com/parentpageslug/subpageslug (Note: [...]]]></description>
			<content:encoded><![CDATA[<p>Often, when using WordPress as a content management or blogging tool on a website, one uses a multi-level page structure. This entails a page being listed &#8220;underneath&#8221; another page in a tree structure. Usually, if your WordPress installation&#8217;s permalinks deviate from the default setting, your page URL structure will look something like this:</p>
<p>http://websiteurl.com/parentpageslug/subpageslug (Note: note a real URL)</p>
<p>What if you require a value to be set depending on the highest level parent page? The process looks like this:</p>
<p><span id="more-468"></span></p>
<p>1. Get the permalink for the current page (using the global $post object).<br />
2. Remove the website URL from the string, leaving only the full slug.<br />
3. Split the slug into an array, using the &#8216;/&#8217; as a separator.<br />
4. The route slug should be at one of the indexes in your array (most likely index 1).</p>
<p>To get the information for the root page, we are going to use a native WordPress function called &#8220;<a title="Function Reference - get_page_by_path" href="http://codex.wordpress.org/Function_Reference/get_page_by_path" target="_blank">get_page_by_path</a>&#8220;. To run this function, we will declare it like this:</p>
<p><code>$root_page = get_page_by_path($root_slug);</code></p>
<p>This line returns an object (into <code>$root_page</code>) containing the information for the root page of the page we are currently viewing.</p>
<p>I&#8217;ve left points 1 to 4 up to you to work out. Everyone has their own way of coding things. If you know of a smoother or quicker way to achieve the same result, please let me know. <img src='http://matty.co.za/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>Thanks guys. I hope you found this quick snippet to be useful. <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/2009/06/getting-the-information-of-a-root-page-in-wordpress/feed/</wfw:commentRss>
		<slash:comments>0</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 663/773 objects using disk: basic

Served from: matty.co.za @ 2012-05-11 00:42:45 -->
