<?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>Troy Chaplin &#187; Blog</title>
	<atom:link href="http://troychaplin.ca/blog/feed/" rel="self" type="application/rss+xml" />
	<link>http://troychaplin.ca</link>
	<description>Web Design and Development</description>
	<lastBuildDate>Fri, 25 Feb 2011 21:04:33 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2</generator>
		<item>
		<title>Including Scripts on Selected WordPress Templates Using Conditional Tags</title>
		<link>http://troychaplin.ca/blog/wordpress-optimization/including-scripts-on-selected-wordpress-templates-using-conditional-tags/</link>
		<comments>http://troychaplin.ca/blog/wordpress-optimization/including-scripts-on-selected-wordpress-templates-using-conditional-tags/#comments</comments>
		<pubDate>Fri, 25 Feb 2011 20:59:00 +0000</pubDate>
		<dc:creator>Troy</dc:creator>
				<category><![CDATA[WordPress Optimization]]></category>

		<guid isPermaLink="false">http://troychaplin.ca/?p=490</guid>
		<description><![CDATA[Running scripts on your posts or pages can give you the ability to enhance website functionality, but loading them in areas where they are not going to be used can add extra load times to your content pages. Using a conditional statement along with WordPress conditional tags will help you specify which pages your script [...]]]></description>
			<content:encoded><![CDATA[<p>Running scripts on your posts or pages can give you the ability to enhance website functionality, but loading them in areas where they are not going to be used can add extra load times to your content pages. Using a conditional statement along with <a href="http://codex.wordpress.org/Conditional_Tags" target="_blank">WordPress conditional tags</a> will help you specify which pages your script will load into, preventing the rest of the site from becoming bogged down with additional code and requests.</p>
<p>A perfect example of this can be found on this site through the use of the <a href="http://nivo.dev7studios.com/" target="_blank">Nivo Slider</a> and <a href="http://codex.wordpress.org/Using_Image_and_File_Attachments" target="_blank">WP Attachments</a> slideshow setup, which only gets loaded on the homepage and the individual work pages. I use two variations of the Nivo Slider script functionality, with the homepage slideshow having a different transition speed, pause time and randomizing the slides than the slideshow functionality used throughout the work section.</p>
<p>Using the tutorial on <a href="/blog/wordpress-tutorials/using-nivo-slider-and-wordpress-attachments-to-create-an-easy-to-use-slideshow/">Using Nivo Slider and WordPress Attachments to Create an Easy to Use Slideshow</a>, this example will show you how to load the script and functionality on your homepage only, but I will add the example used on this site for loading different variations on separate pages at the end of the post.</p>
<p>Let&#8217;s start by creating a new php file in your theme directory called &#8220;hp-slideshow.php&#8221; and paste in the following code:</p>

<div class="wp_codebox_msgheader wp_codebox_hide"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p490code7'); return false;">View Code</a> PHP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p4907"><td class="code" id="p490code7"><pre class="php" style="font-family:monospace;"><span style="color: #339933;">&lt;!--</span> jQuery Script <span style="color: #339933;">--&gt;</span>
<span style="color: #339933;">&lt;</span>script type<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;text/javascript&quot;</span> src<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;&lt;?php bloginfo('template_directory'); ?&gt;/FILELOCATION/jquery-1.4.4.min.js&quot;</span><span style="color: #339933;">&gt;&lt;/</span>script<span style="color: #339933;">&gt;</span>
&nbsp;
<span style="color: #339933;">&lt;!--</span> Nivo Slider Script <span style="color: #339933;">--&gt;</span>
<span style="color: #339933;">&lt;</span>script type<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;text/javascript&quot;</span> src<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;&lt;?php bloginfo('template_directory'); ?&gt;/FILELOCATION/jquery.nivo.slider.pack.js&quot;</span><span style="color: #339933;">&gt;&lt;/</span>script<span style="color: #339933;">&gt;</span>
&nbsp;
<span style="color: #339933;">&lt;!--</span> Nivo Slider <span style="color: #000000; font-weight: bold;">Function</span> <span style="color: #339933;">--&gt;</span>
<span style="color: #339933;">&lt;</span>script type<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;text/javascript&quot;</span><span style="color: #339933;">&gt;</span>
$<span style="color: #009900;">&#40;</span>window<span style="color: #009900;">&#41;</span><span style="color: #339933;">.</span>load<span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">var</span> total <span style="color: #339933;">=</span> $<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'#DIVNAME img'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">.</span>length<span style="color: #339933;">;</span>
	<span style="color: #000000; font-weight: bold;">var</span> <a href="http://www.php.net/rand"><span style="color: #990000;">rand</span></a> <span style="color: #339933;">=</span> Math<span style="color: #339933;">.</span><a href="http://www.php.net/floor"><span style="color: #990000;">floor</span></a><span style="color: #009900;">&#40;</span>Math<span style="color: #339933;">.</span>random<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">*</span>total<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	$<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'#DIVNAME'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">.</span>nivoSlider<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span>
		effect<span style="color: #339933;">:</span><span style="color: #0000ff;">'fade'</span><span style="color: #339933;">,</span> <span style="color: #666666; font-style: italic;">//Specify sets like: 'fold,fade,sliceDown'</span>
		animSpeed<span style="color: #339933;">:</span><span style="color: #cc66cc;">600</span><span style="color: #339933;">,</span> <span style="color: #666666; font-style: italic;">//Slide transition speed</span>
		pauseTime<span style="color: #339933;">:</span><span style="color: #cc66cc;">6000</span><span style="color: #339933;">,</span>
		directionNav<span style="color: #339933;">:</span><span style="color: #009900; font-weight: bold;">false</span><span style="color: #339933;">,</span> <span style="color: #666666; font-style: italic;">//Next and Prev</span>
		controlNav<span style="color: #339933;">:</span><span style="color: #009900; font-weight: bold;">false</span><span style="color: #339933;">,</span> <span style="color: #666666; font-style: italic;">//1,2,3...</span>
		pauseOnHover<span style="color: #339933;">:</span><span style="color: #009900; font-weight: bold;">false</span><span style="color: #339933;">,</span> <span style="color: #666666; font-style: italic;">//Stop animation while hovering</span>
		captionOpacity<span style="color: #339933;">:</span><span style="color: #cc66cc;">1</span><span style="color: #339933;">,</span> <span style="color: #666666; font-style: italic;">//Universal caption opacity</span>
		startSlide<span style="color: #339933;">:</span><span style="color: #cc66cc;">0</span> <span style="color: #666666; font-style: italic;">//Set starting Slide (0 index)</span>
	<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">&lt;/script&gt;</span></pre></td></tr></table></div>

<p>Normally you would place this whole piece of code before the closing body tag in your themes footer.php file, but if I&#8217;m using variations of the same script function I like to create each as its own php file and use a php includes within the conditional statement, so I make sure that the script code does not exist in the footer. Instead, you will want to add the following conditional statement above the closing body tag:</p>

<div class="wp_codebox_msgheader wp_codebox_hide"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p490code8'); return false;">View Code</a> PHP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p4908"><td class="code" id="p490code8"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span>is_home<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><span style="color: #000000; font-weight: bold;">?&gt;</span>
	<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">include</span><span style="color: #009900;">&#40;</span>TEMPLATEPATH <span style="color: #339933;">.</span> <span style="color: #0000ff;">'/hp-slideshow.php'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #009900;">&#125;</span><span style="color: #000000; font-weight: bold;">?&gt;</span></pre></td></tr></table></div>

<p>This statement will load the contents of the hp-slideshow.php file only if the user is on the site homepage, preventing it from loading throughout the rest of the site when not necessary.</p>
<p>If you want to load the script on multiple pages, or as this example shows, loading variations of the script on different pages, use the following conditional statement:</p>

<div class="wp_codebox_msgheader wp_codebox_hide"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p490code9'); return false;">View Code</a> PHP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p4909"><td class="code" id="p490code9"><pre class="php" style="font-family:monospace;"><span style="color: #339933;">&lt;!--</span> load script on homepage <span style="color: #339933;">--&gt;</span>
<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span>is_home<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><span style="color: #000000; font-weight: bold;">?&gt;</span>
	<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">include</span><span style="color: #009900;">&#40;</span>TEMPLATEPATH <span style="color: #339933;">.</span> <span style="color: #0000ff;">'/hp-slideshow.php'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #009900;">&#125;</span><span style="color: #000000; font-weight: bold;">?&gt;</span>
&nbsp;
<span style="color: #339933;">&lt;!--</span> load script on single post pages <span style="color: #339933;">--&gt;</span>
<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span>is_single<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><span style="color: #000000; font-weight: bold;">?&gt;</span>
	<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">include</span><span style="color: #009900;">&#40;</span>TEMPLATEPATH <span style="color: #339933;">.</span> <span style="color: #0000ff;">'/post-slideshow.php'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #009900;">&#125;</span><span style="color: #000000; font-weight: bold;">?&gt;</span></pre></td></tr></table></div>

<p>To view more <a href="http://codex.wordpress.org/Conditional_Tags" target="_blank">WordPress conditional tags</a> that can be used, please visit the WordPress Codex.</p>
<p>&nbsp;</p>
]]></content:encoded>
			<wfw:commentRss>http://troychaplin.ca/blog/wordpress-optimization/including-scripts-on-selected-wordpress-templates-using-conditional-tags/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Using Nivo Slider and WordPress Attachments to Create an Easy to Use Slideshow</title>
		<link>http://troychaplin.ca/blog/wordpress-tutorials/using-nivo-slider-and-wordpress-attachments-to-create-an-easy-to-use-slideshow/</link>
		<comments>http://troychaplin.ca/blog/wordpress-tutorials/using-nivo-slider-and-wordpress-attachments-to-create-an-easy-to-use-slideshow/#comments</comments>
		<pubDate>Tue, 25 Jan 2011 00:34:25 +0000</pubDate>
		<dc:creator>Troy</dc:creator>
				<category><![CDATA[WordPress Tutorials]]></category>
		<category><![CDATA[Attachments]]></category>
		<category><![CDATA[Functions]]></category>
		<category><![CDATA[Images]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[Nivo Slider]]></category>
		<category><![CDATA[Theming]]></category>
		<category><![CDATA[WordPress]]></category>

		<guid isPermaLink="false">http://troychaplin.ca/?p=461</guid>
		<description><![CDATA[For the work section of this site I wanted a simple slideshow to showcase my design and development work over the years, but also make it very simple to create them as a WordPress post. I was a fan of the functionality of a jQuery add-on called Nivo Slider, and thought that it would work [...]]]></description>
			<content:encoded><![CDATA[<p>For the work section of this site I wanted a simple slideshow to showcase my design and development work over the years, but also make it very simple to create them as a <a href="http://wordpress.org" target="_blank">WordPress</a> post. I was a fan of the functionality of a <a href="http://jquery.com" target="_blank">jQuery</a> add-on called <a href="http://nivo.dev7studios.com/" target="_blank">Nivo Slider</a>, and thought that it would work well for what I wanted to achieve if I could incorporate it with WordPress attachments.</p>
<p>The end result is pretty simple: create a post, upload some images and order them, then publish. The images that have been attached to the post will be put into a slideshow which you can modify with a few simple edits to Nivo Sliders options. The sizes of the images also conform to what you have specified in the media settings in the WordPress dashboard, so you should take that into consideration when planning your slideshow.</p>
<p>Let&#8217;s take a look at how I&#8217;ve set this up for my work portfolio.</p>
<h2>Adding jQuery and Nivo Slider to Your Theme</h2>
<p>First off, you need to <a href="http://docs.jquery.com/Downloading_jQuery" target="_blank">download jQuery</a> and <a href="http://nivo.dev7studios.com/" target="_blank">Nivo Slider</a>. I would recommend reading through the <a href="http://nivo.dev7studios.com/#usage" target="_blank">usage documentation</a> for Nivo Slider, and maybe building an HTML example to see how it all works.</p>
<p>After downloading and copying the scripts into my theme folder, I added it to the footer right before the closing body and html tags. There are quite a few options available to <a href="http://nivo.dev7studios.com/#usage" target="_blank">customize how Nivo Slider </a>acts, try them out and see what works for you. The following code is how I have things setup. Be sure to change the FILELOCATION and DIVNAME in two areas to match up with the path to your scripts as well as the div that your slideshow will be placed within.</p>

<div class="wp_codebox_msgheader wp_codebox_hide"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p461code18'); return false;">View Code</a> PHP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p46118"><td class="code" id="p461code18"><pre class="php" style="font-family:monospace;"><span style="color: #339933;">&lt;!--</span> jQuery Script <span style="color: #339933;">--&gt;</span>
<span style="color: #339933;">&lt;</span>script type<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;text/javascript&quot;</span> src<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;&lt;?php bloginfo('template_directory'); ?&gt;/FILELOCATION/jquery-1.4.4.min.js&quot;</span><span style="color: #339933;">&gt;&lt;/</span>script<span style="color: #339933;">&gt;</span>
&nbsp;
<span style="color: #339933;">&lt;!--</span> Nivo Slider Script <span style="color: #339933;">--&gt;</span>
<span style="color: #339933;">&lt;</span>script type<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;text/javascript&quot;</span> src<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;&lt;?php bloginfo('template_directory'); ?&gt;/FILELOCATION/jquery.nivo.slider.pack.js&quot;</span><span style="color: #339933;">&gt;&lt;/</span>script<span style="color: #339933;">&gt;</span>
&nbsp;
<span style="color: #339933;">&lt;!--</span> Nivo Slider <span style="color: #000000; font-weight: bold;">Function</span> <span style="color: #339933;">--&gt;</span>
<span style="color: #339933;">&lt;</span>script type<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;text/javascript&quot;</span><span style="color: #339933;">&gt;</span>
$<span style="color: #009900;">&#40;</span>window<span style="color: #009900;">&#41;</span><span style="color: #339933;">.</span>load<span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">var</span> total <span style="color: #339933;">=</span> $<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'#DIVNAME img'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">.</span>length<span style="color: #339933;">;</span>
	<span style="color: #000000; font-weight: bold;">var</span> <a href="http://www.php.net/rand"><span style="color: #990000;">rand</span></a> <span style="color: #339933;">=</span> Math<span style="color: #339933;">.</span><a href="http://www.php.net/floor"><span style="color: #990000;">floor</span></a><span style="color: #009900;">&#40;</span>Math<span style="color: #339933;">.</span>random<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">*</span>total<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	$<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'#DIVNAME'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">.</span>nivoSlider<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span>
		effect<span style="color: #339933;">:</span><span style="color: #0000ff;">'fade'</span><span style="color: #339933;">,</span> <span style="color: #666666; font-style: italic;">//Specify sets like: 'fold,fade,sliceDown'</span>
		animSpeed<span style="color: #339933;">:</span><span style="color: #cc66cc;">600</span><span style="color: #339933;">,</span> <span style="color: #666666; font-style: italic;">//Slide transition speed</span>
		pauseTime<span style="color: #339933;">:</span><span style="color: #cc66cc;">6000</span><span style="color: #339933;">,</span>
		directionNav<span style="color: #339933;">:</span><span style="color: #009900; font-weight: bold;">false</span><span style="color: #339933;">,</span> <span style="color: #666666; font-style: italic;">//Next and Prev</span>
		controlNav<span style="color: #339933;">:</span><span style="color: #009900; font-weight: bold;">false</span><span style="color: #339933;">,</span> <span style="color: #666666; font-style: italic;">//1,2,3...</span>
		pauseOnHover<span style="color: #339933;">:</span><span style="color: #009900; font-weight: bold;">false</span><span style="color: #339933;">,</span> <span style="color: #666666; font-style: italic;">//Stop animation while hovering</span>
		captionOpacity<span style="color: #339933;">:</span><span style="color: #cc66cc;">1</span><span style="color: #339933;">,</span> <span style="color: #666666; font-style: italic;">//Universal caption opacity</span>
		startSlide<span style="color: #339933;">:</span><span style="color: #cc66cc;">0</span> <span style="color: #666666; font-style: italic;">//Set starting Slide (0 index)</span>
	<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">&lt;/script&gt;</span></pre></td></tr></table></div>

<h2>Creating the Function</h2>
<p>Once you have the two scripts added into your footer.php file we can create the function need. This can be added into your functions.php file, or directly into the page or post template that you want to use your slideshows.</p>

<div class="wp_codebox_msgheader wp_codebox_hide"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p461code19'); return false;">View Code</a> PHP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p46119"><td class="code" id="p461code19"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">function</span> nivo_get_images<span style="color: #009900;">&#40;</span><span style="color: #000088;">$size</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'large'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$limit</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'0'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$offset</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'0'</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">global</span> <span style="color: #000088;">$post</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #000088;">$images</span> <span style="color: #339933;">=</span> get_children<span style="color: #009900;">&#40;</span> <a href="http://www.php.net/array"><span style="color: #990000;">array</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'post_parent'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$post</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">ID</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'post_status'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'inherit'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'post_type'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'attachment'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'post_mime_type'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'image'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'order'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'ASC'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'orderby'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'menu_order ID'</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$images</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
&nbsp;
		<span style="color: #000088;">$num_of_images</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/count"><span style="color: #990000;">count</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$images</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$offset</span> <span style="color: #339933;">&gt;</span> <span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">:</span> <span style="color: #000088;">$start</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$offset</span><span style="color: #339933;">--;</span> <span style="color: #b1b100;">else</span> <span style="color: #339933;">:</span> <span style="color: #000088;">$start</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span> <span style="color: #b1b100;">endif</span><span style="color: #339933;">;</span>
		<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$limit</span> <span style="color: #339933;">&gt;</span> <span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">:</span> <span style="color: #000088;">$stop</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$limit</span><span style="color: #339933;">+</span><span style="color: #000088;">$start</span><span style="color: #339933;">;</span> <span style="color: #b1b100;">else</span> <span style="color: #339933;">:</span> <span style="color: #000088;">$stop</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$num_of_images</span><span style="color: #339933;">;</span> <span style="color: #b1b100;">endif</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #000088;">$i</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span>
		<span style="color: #b1b100;">foreach</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$images</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$image</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
			<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$start</span> <span style="color: #339933;">&lt;=</span> <span style="color: #000088;">$i</span> and <span style="color: #000088;">$i</span> <span style="color: #339933;">&lt;</span> <span style="color: #000088;">$stop</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
			<span style="color: #000088;">$img_title</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$image</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">post_title</span><span style="color: #339933;">;</span>   <span style="color: #666666; font-style: italic;">// title.</span>
			<span style="color: #000088;">$img_description</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$image</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">post_content</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// description.</span>
			<span style="color: #000088;">$img_caption</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$image</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">post_excerpt</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// caption.</span>
			<span style="color: #000088;">$img_url</span> <span style="color: #339933;">=</span> wp_get_attachment_url<span style="color: #009900;">&#40;</span><span style="color: #000088;">$image</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">ID</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// url of the full size image.</span>
			<span style="color: #000088;">$preview_array</span> <span style="color: #339933;">=</span> image_downsize<span style="color: #009900;">&#40;</span> <span style="color: #000088;">$image</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">ID</span><span style="color: #339933;">,</span> <span style="color: #000088;">$size</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
 			<span style="color: #000088;">$img_preview</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$preview_array</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// thumbnail or medium image to use for preview.</span>
&nbsp;
 			<span style="color: #000000; font-weight: bold;">?&gt;</span>
&nbsp;
			<span style="color: #339933;">&lt;</span>img src<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;&lt;?php echo <span style="color: #006699; font-weight: bold;">$img_preview</span>; ?&gt;&quot;</span> alt<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;&lt;?php echo <span style="color: #006699; font-weight: bold;">$img_caption</span>; ?&gt;&quot;</span> <span style="color: #339933;">/&gt;</span>
&nbsp;
			<span style="color: #000000; font-weight: bold;">&lt;?</span>
&nbsp;
			<span style="color: #009900;">&#125;</span>
			<span style="color: #000088;">$i</span><span style="color: #339933;">++;</span>
		<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></td></tr></table></div>

<h2>Adding the Slideshow to Your Template</h2>
<p>Once you have created the function, all that&#8217;s left to do is add a small line of php into the area in which you want your slideshow to appear. You can set the size of the image by replacing &#8216;large&#8217; in the example with &#8216;medium&#8217; or &#8216;thumb&#8217; and it will resize based on your media settings.</p>

<div class="wp_codebox_msgheader wp_codebox_hide"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p461code20'); return false;">View Code</a> PHP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p46120"><td class="code" id="p461code20"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span> nivo_get_images<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'large'</span><span style="color: #339933;">,</span><span style="color: #0000ff;">'0'</span><span style="color: #339933;">,</span><span style="color: #0000ff;">'0'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span></pre></td></tr></table></div>

<p>Once you have all of this done, you should be able to create a new post or page, and when uploading images, drag and drop them into your preferred order, give them title or alt tags, and let the scripts and functions handle the rest.</p>
<h2>UPDATE: Styling the Slideshow with CSS</h2>
<p>I realized late last night that I completely forgot to add the styling. If you had gone through the <a href="http://nivo.dev7studios.com/#usage" target="_blank">usage documentation</a> on the Nivo Slider website you would have gone through this step already. If not, here&#8217;s an example of the simple CSS that I use for my slideshow. The third item (#DIVNAME img) is used to prevent all the images from displaying as the page loads, and adds a loading image, which you can replace with your own customized animated GIF.</p>

<div class="wp_codebox_msgheader wp_codebox_hide"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p461code21'); return false;">View Code</a> CSS</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p46121"><td class="code" id="p461code21"><pre class="css" style="font-family:monospace;"><span style="color: #cc00cc;">#DIVNAME-bg</span> <span style="color: #00AA00;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">margin-top</span><span style="color: #00AA00;">:</span><span style="color: #933;">8px</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">padding</span><span style="color: #00AA00;">:</span><span style="color: #933;">5px</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">background-image</span><span style="color: #00AA00;">:</span><span style="color: #993333;">url</span><span style="color: #00AA00;">&#40;</span><span style="color: #ff0000; font-style: italic;">PATHTOTHEMEIMAGES/filename.png</span><span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">background-repeat</span><span style="color: #00AA00;">:</span><span style="color: #993333;">repeat</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
&nbsp;
<span style="color: #cc00cc;">#DIVNAME</span> <span style="color: #00AA00;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">width</span><span style="color: #00AA00;">:</span><span style="color: #933;">620px</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">height</span><span style="color: #00AA00;">:</span><span style="color: #933;">620px</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
&nbsp;
<span style="color: #cc00cc;">#DIVNAME</span> img <span style="color: #00AA00;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">display</span><span style="color: #00AA00;">:</span><span style="color: #993333;">none</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">background</span><span style="color: #00AA00;">:</span><span style="color: #993333;">url</span><span style="color: #00AA00;">&#40;</span><span style="color: #ff0000; font-style: italic;">PATHTONIVOIMAGES/loading.gif</span><span style="color: #00AA00;">&#41;</span> <span style="color: #993333;">no-repeat</span> <span style="color: #933;">50%</span> <span style="color: #933;">50%</span>
<span style="color: #00AA00;">&#125;</span></pre></td></tr></table></div>

]]></content:encoded>
			<wfw:commentRss>http://troychaplin.ca/blog/wordpress-tutorials/using-nivo-slider-and-wordpress-attachments-to-create-an-easy-to-use-slideshow/feed/</wfw:commentRss>
		<slash:comments>13</slash:comments>
		</item>
		<item>
		<title>My New Work Section is Live Using Custom Post Type and Taxonomies</title>
		<link>http://troychaplin.ca/blog/website-updates/my-new-work-section-is-live-using-custom-post-type-and-taxonomies/</link>
		<comments>http://troychaplin.ca/blog/website-updates/my-new-work-section-is-live-using-custom-post-type-and-taxonomies/#comments</comments>
		<pubDate>Tue, 18 Jan 2011 12:06:48 +0000</pubDate>
		<dc:creator>Troy</dc:creator>
				<category><![CDATA[Website Updates]]></category>

		<guid isPermaLink="false">http://troychaplin.ca/?p=453</guid>
		<description><![CDATA[Since launching the new look and feel for my blog I&#8217;ve been investigating my options as to how I wanted to structure the work section of the site. Using a custom post type to separate the blog posts from the work posts was an obvious choice, but I starting thinking about other new features of [...]]]></description>
			<content:encoded><![CDATA[<p>Since launching the new look and feel for my blog I&#8217;ve been investigating my options as to how I wanted to structure the work section of the site. Using a custom post type to separate the blog posts from the work posts was an obvious choice, but I starting thinking about other new features of <a href="http://wordpress.org" target="_blank">WordPress</a> that could also be incorporated that would improve the functionality.</p>
<p>One thing that kept coming to mind were taxonomies. I&#8217;ve seen several sites do a great job at using them to allow a user to browse content in a variety of different ways, and that was something I knew that I wanted for visitors of my site as well. Several large company sites that I&#8217;ve visited over the years offer ways to browse their work by color schemes, layout type and more, and I always liked the idea of being able to view things based on those terms.</p>
<p>My portfolio was setup using three basic taxonomies: Design Styles, Layout Styles and Tools and Methods. Each of these main categories allows for infinite ways to further breakdown the organization of the content. So when a user visits my site and wants to view the work I&#8217;ve done that uses the color blue, then they can. If they want to view two or three column layouts, they can.</p>
<p>The selection of content that is currently available in the portfolio is small, but is just a start. In the coming weeks I plan on digging through the work I&#8217;ve done over the last 10 years and adding pieces that I really like, enjoyed working on, or that I feel has pushed me creatively.</p>
<p>Please take a look through <a href="/work">my work</a> and feel free to leave a comment here, or send me some <a href="/services-available-to-you/">website feedback</a> by filling out this form.</p>
]]></content:encoded>
			<wfw:commentRss>http://troychaplin.ca/blog/website-updates/my-new-work-section-is-live-using-custom-post-type-and-taxonomies/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>A New Year, a New Site Design</title>
		<link>http://troychaplin.ca/blog/website-updates/a-new-year-a-new-site-design/</link>
		<comments>http://troychaplin.ca/blog/website-updates/a-new-year-a-new-site-design/#comments</comments>
		<pubDate>Mon, 10 Jan 2011 03:31:09 +0000</pubDate>
		<dc:creator>Troy</dc:creator>
				<category><![CDATA[Website Updates]]></category>
		<category><![CDATA[Design]]></category>
		<category><![CDATA[WordPress]]></category>

		<guid isPermaLink="false">http://troychaplin.ca/?p=301</guid>
		<description><![CDATA[So with a New Year upon us, I thought it was a good opportunity to relaunch this site with a whole new look and feel. I&#8217;ve been working on this new design for a while now, albeit quite infrequently. I wasn&#8217;t completely happy with the previous site design and found it had limitations in both [...]]]></description>
			<content:encoded><![CDATA[<p>So with a New Year upon us, I thought it was a good opportunity to relaunch this site with a whole new look and feel. I&#8217;ve been working on this new design for a while now, albeit quite infrequently. I wasn&#8217;t completely happy with the previous site design and found it had limitations in both content management and future expansion.</p>
<p>This new theme is nowhere near complete. I&#8217;m currently working through ideas and concepts for how my portfolio would functions, while looking to dig deeper into some of the new features of <a href="http://wordpress.org" target="_blank">WordPress 3.0</a>, and the soon to be released 3.1. The first round of development focused primarily on the blog and site pages, and the next round will be all about my portfolio.</p>
<p>For now, the portfolio will have to wait for a short time while I work on some other projects. In the meantime, I&#8217;m going to try and make a better effort on blogging more, trying to share more resources and hopefully learn more from readers. So enjoy the new site, and feel free to <a href="/services-available-to-you/">send me your feedback</a>.</p>
<div id="attachment_307" class="wp-caption alignnone" style="width: 620px"><a rel="prettyPhoto" href="http://troychaplin.ca/cms/wp-content/files/new-old-blog-comparison.jpg"><img class="size-large wp-image-307 " title="Old and New Blog Comarison" src="http://troychaplin.ca/cms/wp-content/files/new-old-blog-comparison-620x426.jpg" alt="Old and New Blog Comarison" width="620" height="426" /></a><p class="wp-caption-text">A comparison of last years blog, and the new one</p></div>
]]></content:encoded>
			<wfw:commentRss>http://troychaplin.ca/blog/website-updates/a-new-year-a-new-site-design/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>The New Macbook Air: Is It Worth the Price?</title>
		<link>http://troychaplin.ca/blog/apple/the-new-macbook-air-is-it-worth-the-price/</link>
		<comments>http://troychaplin.ca/blog/apple/the-new-macbook-air-is-it-worth-the-price/#comments</comments>
		<pubDate>Thu, 21 Oct 2010 00:03:59 +0000</pubDate>
		<dc:creator>Troy</dc:creator>
				<category><![CDATA[Apple]]></category>
		<category><![CDATA[Macbook Air]]></category>
		<category><![CDATA[Reviews]]></category>

		<guid isPermaLink="false">http://troychaplin.ca/?p=222</guid>
		<description><![CDATA[Leading up to Apple&#8217;s &#8220;Back to the Mac&#8221; conference today there were lots of rumors floating around about the potential unveiling of a new and improved Macbook Air, amongst other things. With each Apple conference always comes a lot of rumor, expectation and excitement, and this time around it was no different. I was particularly [...]]]></description>
			<content:encoded><![CDATA[<p>Leading up to Apple&#8217;s &#8220;Back to the Mac&#8221; conference today there were lots of rumors floating around about the potential unveiling of a <a href="http://www.apple.com/ca/macbookair/" target="_blank">new and improved Macbook Air</a>, amongst other things. With each Apple conference always comes a lot of rumor, expectation and excitement, and this time around it was no different. I was particularly excited for today&#8217;s conference. As much as I love the products that Apple has worked on and released recently, especially being an owner of the new <a href="http://www.apple.com/ca/iphone/" target="_blank">iPhone 4</a> as well as an <a href="http://www.apple.com/ca/ipad/" target="_blank">iPad</a>, I was excited that the theme of the conference would turn its focus back towards their line of Mac products, one that I felt took a bit of a back seat to their mobile products lately.</p>
<p><a rel="prettyPhoto" href="http://troychaplin.ca/cms/wp-content/files/macbook-air-1.jpg"><img class="alignnone size-large wp-image-279" title="The new Macbook Air" src="http://troychaplin.ca/cms/wp-content/files/macbook-air-1-620x221.jpg" alt="The new Macbook Air" width="620" height="221" /></a></p>
<p>The idea of a whole new Macbook Air had particularly peaked my interest, as I was doing my own bit of speculation as to where they would go with it. Was there really a specific market that they hadn&#8217;t tapped into somewhere in between their Macbook and iPad line-up?</p>
<p>I was initially impressed with the new and improved Air product, but on my way out of the office I ran into a friend who had also been interested in this product as he was contemplating purchasing his first Macbook, and he said something to me that I never fully contemplated in my initial excitement. He simply said something along the lines of &#8220;I would want at least the 256GB model, and $1600 is a little steep&#8221;. This statement got me thinking more about the price point and overall specs of the Air on my drive home, and I started to think about what a consumer actually got at that price point in comparison to the other Macbook options.</p>
<p>As nice as it sounds to have this ultra thin, extremely light, beautiful looking machine, I think Apple has yet to hit the right mark on this product line. For the base model at a $1049 price point you get a slick 11.6 inch machine with 2GB of ram, 64GB of flash storage, a 1.4GHz Intel Core 2 Duo processor, and up to  hours of battery life, all weighing in at a mere 2.3 pounds (<a href="http://www.apple.com/ca/macbookair/specs.html" target="_blank">view all tech specs</a>). Sounds pretty good right?</p>
<p>Compare that to the Macbook. The sexy little white machine features a 13.3 inch display, 2GB of ram, 250GB of storage space, a 2.4GHz Intel Core 2 Duo processor, up to 10 hours of battery life, and weighs 4.7 pounds (<a href="http://www.apple.com/ca/macbook/specs.html" target="_blank">view all tech specs</a>). The price point? Equally priced at $1049.</p>
<div id="attachment_280" class="wp-caption alignnone" style="width: 620px"><a rel="prettyPhoto" href="http://troychaplin.ca/cms/wp-content/files/macbook-air-2.jpg"><img class="size-large wp-image-280 " title="The new Macbook Air comes in two sizes; 11.6 inch and 13.3 inch" src="http://troychaplin.ca/cms/wp-content/files/macbook-air-2-620x236.jpg" alt="The new Macbook Air comes in two sizes; 11.6 inch and 13.3 inch" width="620" height="236" /></a><p class="wp-caption-text">The new Macbook Air comes in two sizes; 11.6 inch and 13.3 inch</p></div>
<p>Now, I know some people will quickly point out a few features of the Air that are not available on the Macbook, such as the instant-on and up-to 30 day standby mode, or the face time camera, but are they enough to swing a purchasing decision away from what I feel is a better bang for the buck option in the Macbook? Maybe for some, but I still feel that the majority of users would opt for the slightly larger screen size, and more specifically the significant amount of additional storage space.</p>
<p>Sure the boot-up time may be better, but after using my 17 inch Macbook Pro for the last year, I have no reason to complain about the quick startup time. My machine is booted up and ready to go in about the time it would take me to pour a coffee and get comfortable in my office chair, and that includes automatic loading of my most used software such as Photoshop, Firefox, Suitcase Fushion, Mail, Coda and iTunes.</p>
<p>When I take into consideration the amount of storage space that I would required, even the 256GB option would be a hard thing to deal with, as my current Macbook Pro has 500Gb, 230 of which is currently being used for photos, music, and other work related files, let alone having to settle with 64GB. This would require me to carry an external hard drive for all that stuff.</p>
<p>And I don&#8217;t think the difference in the weight of each machine should be an issue. I carry around a 6.6 pound, 17 inch model, and have no complaints (I went from a monsterous Dell machine that feels like a behemoth in comparison), and if the difference between carrying 2.3 pounds versus 4.7 pounds is a big factor, I would recommend investing your hard earned money into a yearly gym membership instead.</p>
<p>At the end of the day, what was an initially high level of excitement for a new Apple product turned into the realization that for most consumers there was already a much better machine available in the Macbook at the exact same price point. I still think there&#8217;s a very small market for the new Air, but it&#8217;s not something that I could see people lining up in hopes to get one right away.</p>
<p>I&#8217;d love to hear your thoughts on the Macbook Air, so please leave a comment below.</p>
]]></content:encoded>
			<wfw:commentRss>http://troychaplin.ca/blog/apple/the-new-macbook-air-is-it-worth-the-price/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Customize the WordPress Administration Area to Suit a Clients Needs</title>
		<link>http://troychaplin.ca/blog/wordpress-functions/customize-the-wordpress-administration-area-to-suit-a-clients-needs/</link>
		<comments>http://troychaplin.ca/blog/wordpress-functions/customize-the-wordpress-administration-area-to-suit-a-clients-needs/#comments</comments>
		<pubDate>Mon, 04 Oct 2010 20:06:41 +0000</pubDate>
		<dc:creator>Troy</dc:creator>
				<category><![CDATA[WordPress Functions]]></category>
		<category><![CDATA[Customization]]></category>
		<category><![CDATA[Dashboard]]></category>
		<category><![CDATA[Functions]]></category>
		<category><![CDATA[Theming]]></category>
		<category><![CDATA[WordPress]]></category>

		<guid isPermaLink="false">http://troychaplin.ca/?p=215</guid>
		<description><![CDATA[In my opinion, WordPress is the best option for building a custom CMS for clients, as it provides one of the best administration area setups that I&#8217;ve ever worked with. Things are laid out in a simple way, and the user interface is intuitive and easy to navigate. But yet there are always certain clients [...]]]></description>
			<content:encoded><![CDATA[<p>In my opinion, WordPress is the best option for building a custom CMS for clients, as it provides one of the best administration area setups that I&#8217;ve ever worked with. Things are laid out in a simple way, and the user interface is intuitive and easy to navigate. But yet there are always certain clients that will aimlessly click around into any possible area and will sometimes change, alter or remove important items that are critical to how the front facing website functions.</p>
<p>There are a few good functions out there to help in hiding some of those areas, but I recently came across an <a href="http://sixrevisions.com/wordpress/how-to-customize-the-wordpress-admin-area/" target="_blank">incredible post at Six Revisions</a> that has allowed me to further customize what individuals can and can&#8217;t do in the administration area, so be sure to check out the full post, as it provides some great resources.</p>
<h2>Removing Post and Page Modules</h2>
<p>I&#8217;m currently working on a new project that involves lots of automation, and there are quite a number of modules on both the post and page editing areas that are not required. Instead of going into the screen options each time a new user account is created, I&#8217;m using the following function to hidden certain modules on all accounts in the system.</p>
<p>The following piece of code includes all the modules that can be hidden from each editor, nicely commented so you can customize your function to suit your specific needs.</p>

<div class="wp_codebox_msgheader wp_codebox_hide"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p215code24'); return false;">View Code</a> PHP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p21524"><td class="code" id="p215code24"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">function</span> customize_meta_boxes<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
&nbsp;
	<span style="color: #666666; font-style: italic;">/* Removes meta boxes from Posts */</span>
	remove_meta_box<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'categorydiv'</span><span style="color: #339933;">,</span><span style="color: #0000ff;">'post'</span><span style="color: #339933;">,</span><span style="color: #0000ff;">'normal'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// remove categories module</span>
	remove_meta_box<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'tagsdiv-post_tag'</span><span style="color: #339933;">,</span><span style="color: #0000ff;">'post'</span><span style="color: #339933;">,</span><span style="color: #0000ff;">'normal'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// remove tags module</span>
	remove_meta_box<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'postexcerpt'</span><span style="color: #339933;">,</span><span style="color: #0000ff;">'post'</span><span style="color: #339933;">,</span><span style="color: #0000ff;">'normal'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// remove excerpt module</span>
	remove_meta_box<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'trackbacksdiv'</span><span style="color: #339933;">,</span><span style="color: #0000ff;">'post'</span><span style="color: #339933;">,</span><span style="color: #0000ff;">'normal'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// remove trackbacks module</span>
	remove_meta_box<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'postcustom'</span><span style="color: #339933;">,</span><span style="color: #0000ff;">'post'</span><span style="color: #339933;">,</span><span style="color: #0000ff;">'normal'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// remove custom fields module</span>
	remove_meta_box<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'commentstatusdiv'</span><span style="color: #339933;">,</span><span style="color: #0000ff;">'post'</span><span style="color: #339933;">,</span><span style="color: #0000ff;">'normal'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// remove discussions module</span>
	remove_meta_box<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'commentsdiv'</span><span style="color: #339933;">,</span><span style="color: #0000ff;">'post'</span><span style="color: #339933;">,</span><span style="color: #0000ff;">'normal'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// remove comments module</span>
	remove_meta_box<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'authordiv'</span><span style="color: #339933;">,</span><span style="color: #0000ff;">'post'</span><span style="color: #339933;">,</span><span style="color: #0000ff;">'normal'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// remove author module</span>
	remove_meta_box<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'revisionsdiv'</span><span style="color: #339933;">,</span><span style="color: #0000ff;">'post'</span><span style="color: #339933;">,</span><span style="color: #0000ff;">'normal'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// remove revisions module</span>
&nbsp;
	<span style="color: #666666; font-style: italic;">/* Removes meta boxes from pages */</span>
	remove_meta_box<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'postcustom'</span><span style="color: #339933;">,</span><span style="color: #0000ff;">'page'</span><span style="color: #339933;">,</span><span style="color: #0000ff;">'normal'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// remove custom fields module</span>
	remove_meta_box<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'trackbacksdiv'</span><span style="color: #339933;">,</span><span style="color: #0000ff;">'page'</span><span style="color: #339933;">,</span><span style="color: #0000ff;">'normal'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// remove trackbacks module</span>
	remove_meta_box<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'commentstatusdiv'</span><span style="color: #339933;">,</span><span style="color: #0000ff;">'page'</span><span style="color: #339933;">,</span><span style="color: #0000ff;">'normal'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// remove discussion module</span>
	remove_meta_box<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'commentsdiv'</span><span style="color: #339933;">,</span><span style="color: #0000ff;">'page'</span><span style="color: #339933;">,</span><span style="color: #0000ff;">'normal'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// remove comments module</span>
	remove_meta_box<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'authordiv'</span><span style="color: #339933;">,</span><span style="color: #0000ff;">'page'</span><span style="color: #339933;">,</span><span style="color: #0000ff;">'normal'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// remove author module</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
add_action<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'admin_init'</span><span style="color: #339933;">,</span><span style="color: #0000ff;">'customize_meta_boxes'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>Again, a big thanks to <a href="http://sixrevisions.com" target="_blank">Six Revisions</a> for this incredible post. The information provided there will be a big help in created a much easier administration experience for clients, which was already pretty great to begin with!</p>
]]></content:encoded>
			<wfw:commentRss>http://troychaplin.ca/blog/wordpress-functions/customize-the-wordpress-administration-area-to-suit-a-clients-needs/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>New WordPress 3.1 Features Aim to Create a Better CMS</title>
		<link>http://troychaplin.ca/blog/wordpress-features/new-wordpress-3-1-features-aim-to-create-a-better-cms/</link>
		<comments>http://troychaplin.ca/blog/wordpress-features/new-wordpress-3-1-features-aim-to-create-a-better-cms/#comments</comments>
		<pubDate>Wed, 15 Sep 2010 11:00:05 +0000</pubDate>
		<dc:creator>Troy</dc:creator>
				<category><![CDATA[WordPress Features]]></category>
		<category><![CDATA[CMS]]></category>
		<category><![CDATA[WordPress]]></category>

		<guid isPermaLink="false">http://troychaplin.ca/?p=203</guid>
		<description><![CDATA[It seems that with every release of a WordPress upgrade there are a few key features that move the software a few steps closer to becoming a much more powerful CMS, and the plan for WordPress 3.1 is no different. As usual, there will be lots of work done around fixing remaining bugs from 3.0.1, [...]]]></description>
			<content:encoded><![CDATA[<p>It seems that with every release of a WordPress upgrade there are a few key features that move the software a few steps closer to becoming a much more powerful CMS, and the plan for WordPress 3.1 is no different. As usual, there will be lots of work done around fixing remaining bugs from 3.0.1, but some of the new features planned include adding Ajax to the admin area to improve the browsing and search of content, advanced taxonomy queries, and other user interface cleanup. The planned addition of post templates and styles is also interesting and could be a big benefit to designers and developers in giving users more control over how their posts look and act. The two features that I&#8217;m the most excited and interested in are the addition of internal linking and the front end admin bar.</p>
<h2>Internal Linking</h2>
<p>While I&#8217;m surprised that it took this long to have this feature added to the core of WordPress, I&#8217;m excited that this will now finally be a standard feature. This is a standard feature of just about every other CMS product that I&#8217;ve used, and even though the options, customization and general ease of use within WordPress is far superior than any other product I&#8217;ve used, this was one significant area in which WordPress failed.</p>
<p>Sure, there are plugins that can add this functionality, but I&#8217;m always looking for ways to cut down on the amount of plugins I use, and would much rather have features in the core, or add it through the functions.php file. I&#8217;ve used plugins for this feature in the past, but the problem was that when pages were moved around in the navigation, particularly when making them child pages, the linking often times broke. I&#8217;m sure the team working on these features will accommodate for this and use this feature to take one large step towards a better CMS option.</p>
<h2>Admin Bar</h2>
<p>Having a toolbar on the front-facing website is one big step towards a more simple content creation and site administration system. Much like the toolbar available if you run a blog on <a href="http://wordpress.com" target="_blank">WordPress.com</a>, users will have the ability to access the main administration area sections if they are logged in.</p>
<p>With this feature, I&#8217;m hoping that the development team gives administrators the ability to determine which areas of the admin area are visible in this toolbar, as often times when building themes for clients I will hide items from the admin navigation for users roles below admin in a effort to prevent accidental setting changes, or to avoid confusion for those who simply want to edit and create content and will not understand the purpose of the other areas.</p>
<h2>When Can We Expect 3.1?</h2>
<p>The tentative release date for WordPress version 3.1 is mid-December, which is perfect for me. With a little time off from work between Christmas and New Years, I hope they make the planned release date and I can have plenty of time to get my feet wet with these new features.</p>
<p>To read more details about all the plans for WordPress 3.1 features <a href="http://www.wpbeginner.com/news/whats-coming-in-wordpress-3-1-features/" target="_blank">read this post by WP Beginner</a>, and for all future updates and news, check in on the <a href="http://wpdevel.wordpress.com/" target="_blank">WordPress Development Updates</a> blog.</p>
]]></content:encoded>
			<wfw:commentRss>http://troychaplin.ca/blog/wordpress-features/new-wordpress-3-1-features-aim-to-create-a-better-cms/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Variable Post Excerpt Lengths Based on Title Character Count</title>
		<link>http://troychaplin.ca/blog/wordpress-functions/variable-post-excerpt-lengths-based-on-title-character-count/</link>
		<comments>http://troychaplin.ca/blog/wordpress-functions/variable-post-excerpt-lengths-based-on-title-character-count/#comments</comments>
		<pubDate>Sat, 21 Aug 2010 18:06:15 +0000</pubDate>
		<dc:creator>Troy</dc:creator>
				<category><![CDATA[WordPress Functions]]></category>
		<category><![CDATA[Excerpts]]></category>
		<category><![CDATA[Hacks]]></category>
		<category><![CDATA[Theming]]></category>
		<category><![CDATA[WordPress]]></category>

		<guid isPermaLink="false">http://troychaplin.ca/cms/?p=98</guid>
		<description><![CDATA[If you are looking to create a post landing page layout that flows across multiple columns while maintaining a consistent height to each post coming through from the loop, then the following piece of code will do just that. It will allow you to set the number of characters output on the excerpt based on [...]]]></description>
			<content:encoded><![CDATA[<p>If you are looking to create a post landing page layout that flows across multiple columns while maintaining a consistent height to each post coming through from the loop, then the following piece of code will do just that. It will allow you to set the number of characters output on the excerpt based on the title character count.</p>

<div class="wp_codebox_msgheader wp_codebox_hide"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p98code27'); return false;">View Code</a> PHP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p9827"><td class="code" id="p98code27"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #000088;">$excerpt</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/strip_tags"><span style="color: #990000;">strip_tags</span></a><span style="color: #009900;">&#40;</span>get_the_excerpt<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #666666; font-style: italic;">// Limit $summary to how many characters?</span>
&nbsp;
<span style="color: #000088;">$title_len</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/strlen"><span style="color: #990000;">strlen</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$post</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">post_title</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">//get length of title</span>
&nbsp;
<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$title_len</span> <span style="color: #339933;">&lt;=</span> <span style="color: #cc66cc;">30</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
	<span style="color: #000088;">$limit</span><span style="color: #339933;">=</span><span style="color: #cc66cc;">270</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">//calc space remaining for excerpt</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #b1b100;">else</span> <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$title_len</span> <span style="color: #339933;">&lt;=</span> <span style="color: #cc66cc;">60</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
	<span style="color: #000088;">$limit</span><span style="color: #339933;">=</span><span style="color: #cc66cc;">230</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">//calc space remaining for excerpt</span>
<span style="color: #009900;">&#125;</span><span style="color: #b1b100;">else</span> <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$title_len</span> <span style="color: #339933;">&lt;=</span> <span style="color: #cc66cc;">75</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
	<span style="color: #000088;">$limit</span><span style="color: #339933;">=</span><span style="color: #cc66cc;">180</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #000088;">$summary</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/substr"><span style="color: #990000;">substr</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$excerpt</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">,</span> <a href="http://www.php.net/strrpos"><span style="color: #990000;">strrpos</span></a><span style="color: #009900;">&#40;</span><a href="http://www.php.net/substr"><span style="color: #990000;">substr</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$excerpt</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">,</span> <span style="color: #000088;">$limit</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">' '</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">'...'</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">'
&nbsp;
'</span><span style="color: #339933;">.</span><span style="color: #000088;">$summary</span><span style="color: #339933;">,</span><span style="color: #0000ff;">'
&nbsp;
'</span><span style="color: #339933;">;</span>  <span style="color: #000000; font-weight: bold;">?&gt;</span>
<span style="color: #339933;">&lt;</span>div <span style="color: #000000; font-weight: bold;">class</span><span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;da-more-link&quot;</span><span style="color: #339933;">&gt;&lt;</span>a href<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;&lt;?php the_permalink(); ?&gt;&quot;</span> title<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;Read Full Post: &lt;?php the_title(); ?&gt;&quot;</span><span style="color: #339933;">&gt;</span>Read Full Post <span style="color: #339933;">&amp;</span>raquo<span style="color: #339933;">;&lt;/</span>a<span style="color: #339933;">&gt;&lt;/</span>div<span style="color: #339933;">&gt;</span></pre></td></tr></table></div>

<p>The way this works is rather simple. The $title_len represents the length of the post title, while the $limit represents the excerpt length limit. In the first if statement, the title_len is less than 30 characters, then the excerpt will output 270 characters.</p>
<p>The next series of else if statement function in the same way, reducing the size of the excerpt as the title character counts increases. This example only displays 3 possible sizes, but add more else if&#8217;s if required.</p>
<p>The second portion of the code will create a summary by stripping the post and apply the conditional statement values, which will then be output onto the page wrapped in p tags. The first line of the summary also end with three periods, this can be changed to whatever you wish to output to end the excerpt text.</p>
<p>The read more link is the last line of the code, simply change the READ MORE LINK portion of the code to set the text for viewing the full post.</p>
]]></content:encoded>
			<wfw:commentRss>http://troychaplin.ca/blog/wordpress-functions/variable-post-excerpt-lengths-based-on-title-character-count/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Deregister and Move WordPress Plugin Javascripts Into the Footer</title>
		<link>http://troychaplin.ca/blog/wordpress-optimization/deregister-and-move-wordpress-plugin-javascripts-into-the-footer/</link>
		<comments>http://troychaplin.ca/blog/wordpress-optimization/deregister-and-move-wordpress-plugin-javascripts-into-the-footer/#comments</comments>
		<pubDate>Sun, 15 Aug 2010 18:06:29 +0000</pubDate>
		<dc:creator>Troy</dc:creator>
				<category><![CDATA[WordPress Optimization]]></category>
		<category><![CDATA[Hacks]]></category>
		<category><![CDATA[Minification]]></category>
		<category><![CDATA[Plugins]]></category>
		<category><![CDATA[Theming]]></category>
		<category><![CDATA[WordPress]]></category>

		<guid isPermaLink="false">http://troychaplin.ca/cms/?p=100</guid>
		<description><![CDATA[As a javascript is being loaded on a site, it will prevent any other item from downloading. This can be very frustrating for your visitors if the scripts are loading before the images, styles, or other site components. Having your javascript calls placed in your footer will allow other resources on your site to load [...]]]></description>
			<content:encoded><![CDATA[<p>As a javascript is being loaded on a site, it will prevent any other item from downloading. This can be very frustrating for your visitors if the scripts are loading before the images, styles, or other site components. Having your javascript calls placed in your footer will allow other resources on your site to load first, effectively speeding up the overall load time of your site.</p>
<p>Often times a WordPress plugin will use a javascript, but the plugins load them into the wp_head tag. Moving a plugin javascript into the footer area requires a simple function, but is dependent on the plugin authors inclusion of the wp_print_scripts action. Search the plugins main php file for the wp_print_scripts item, and it will be closely followed by the script name.</p>
<p>The following piece of code uses a sample to move the javascript from the WP-Codebox plugin:</p>

<div class="wp_codebox_msgheader wp_codebox_hide"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p100code40'); return false;">View Code</a> PHP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p10040"><td class="code" id="p100code40"><pre class="php" style="font-family:monospace;">add_action<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'wp_enqueue_scripts'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'wp_codebox_scripts'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">function</span> wp_codebox_scripts<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	wp_enqueue_script<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'codebox'</span><span style="color: #339933;">,</span> plugins_url<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'wp-codebox/js/codebox.js'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <a href="http://www.php.net/array"><span style="color: #990000;">array</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'jquery'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'2.50'</span><span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	wp_localize_script<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'codebox'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'codebox'</span><span style="color: #339933;">,</span> <a href="http://www.php.net/array"><span style="color: #990000;">array</span></a><span style="color: #009900;">&#40;</span>
		<span style="color: #0000ff;">'ajax_url'</span> <span style="color: #339933;">=&gt;</span> plugins_url<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'wp-codebox/wp-codebox.php'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
		<span style="color: #0000ff;">'text_wait'</span> <span style="color: #339933;">=&gt;</span> __<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Your last request is still being processed. Please wait a while ...'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'codebox'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
	<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>Before inserting the code into the functions.php file of the WordPress theme, open your theme footer.php and check to see if it contains the following line of code, if not, then add it above the closing body tag. <strong>Note:</strong> both the wp_header and wp_footer are used by a plugin file to insert CSS and javascript code into your theme.</p>

<div class="wp_codebox_msgheader wp_codebox_hide"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p100code41'); return false;">View Code</a> PHP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p10041"><td class="code" id="p100code41"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span> wp_footer<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span></pre></td></tr></table></div>

<p>On lines one and two of the full function, the first line will add an action to hook into the wp_enqueue_script, and replace it with an action of your own choosing, in this case wp_codebox_scripts. Then on line two, you specify the name of your newly created action to register it as a function, as seen in the following example:</p>

<div class="wp_codebox_msgheader wp_codebox_hide"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p100code42'); return false;">View Code</a> PHP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p10042"><td class="code" id="p100code42"><pre class="php" style="font-family:monospace;">add_action<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'wp_enqueue_scripts'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'wp_codebox_scripts'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">function</span> wp_codebox_scripts<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span></pre></td></tr></table></div>

<p>Navigate into the plugin folder and open the main php file and do a search for wp_print_scripts. This function will only be possible if it is available in the plugin structure. In the wp-codebox.php file, the print scripts action can be found on line 61, and a little further down on line 67 we see the line of code that includes the wp_enqueue_script which also contains the script name and the path to the plugin javascript file:</p>

<div class="wp_codebox_msgheader wp_codebox_hide"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p100code43'); return false;">View Code</a> PHP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p10043"><td class="code" id="p100code43"><pre class="php" style="font-family:monospace;">wp_enqueue_script<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'codebox'</span><span style="color: #339933;">,</span> get_bloginfo <span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'wpurl'</span> <span style="color: #009900;">&#41;</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">'/wp-content/plugins/wp-codebox/js/codebox.js'</span><span style="color: #339933;">,</span> <a href="http://www.php.net/array"><span style="color: #990000;">array</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'jquery'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'0.1'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>Make note of the script name and path to the javascript file and insert it into line 3 of the full function code (<strong>note:</strong> because the function uses a plugin_url reference, you should not add the wp-content and plugins slugs as part of the path to the javascript file):</p>

<div class="wp_codebox_msgheader wp_codebox_hide"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p100code44'); return false;">View Code</a> PHP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p10044"><td class="code" id="p100code44"><pre class="php" style="font-family:monospace;">wp_enqueue_script<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'codebox'</span><span style="color: #339933;">,</span> plugins_url<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'wp-codebox/js/codebox.js'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <a href="http://www.php.net/array"><span style="color: #990000;">array</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'jquery'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'2.50'</span><span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>On line 4 there is two areas that you would need to insert the script name, as seen in the following example. Line five also requires you to insert the plugin directory, as well as the main php file name:</p>

<div class="wp_codebox_msgheader wp_codebox_hide"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p100code45'); return false;">View Code</a> PHP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p10045"><td class="code" id="p100code45"><pre class="php" style="font-family:monospace;">wp_localize_script<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'codebox'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'codebox'</span><span style="color: #339933;">,</span> <a href="http://www.php.net/array"><span style="color: #990000;">array</span></a><span style="color: #009900;">&#40;</span>
	<span style="color: #0000ff;">'ajax_url'</span> <span style="color: #339933;">=&gt;</span> plugins_url<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'wp-codebox/wp-codebox.php'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span></pre></td></tr></table></div>

<p>Once you&#8217;ve added the proper script names and paths in the final function, refresh your site and take a look at the source code. You should see that the call to the plugin javascript is located in the footer, as opposed to the header.</p>
]]></content:encoded>
			<wfw:commentRss>http://troychaplin.ca/blog/wordpress-optimization/deregister-and-move-wordpress-plugin-javascripts-into-the-footer/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to Deregistering the Default Plugin CSS Files in WordPress</title>
		<link>http://troychaplin.ca/blog/wordpress-optimization/how-to-deregistering-the-default-plugin-css-files-in-wordpress/</link>
		<comments>http://troychaplin.ca/blog/wordpress-optimization/how-to-deregistering-the-default-plugin-css-files-in-wordpress/#comments</comments>
		<pubDate>Sun, 08 Aug 2010 18:11:03 +0000</pubDate>
		<dc:creator>Troy</dc:creator>
				<category><![CDATA[WordPress Optimization]]></category>
		<category><![CDATA[Functions]]></category>
		<category><![CDATA[Hacks]]></category>
		<category><![CDATA[Minification]]></category>
		<category><![CDATA[Theming]]></category>
		<category><![CDATA[WordPress]]></category>

		<guid isPermaLink="false">http://troychaplin.ca/cms/?p=102</guid>
		<description><![CDATA[With every file loaded into a site an HTTP request is made to the server, and the higher the number of requests made will decrease the overall load time of your site pages and posts. A simple way to cut down on those requests is by combining your CSS and Javascript files into as few [...]]]></description>
			<content:encoded><![CDATA[<p>With every file loaded into a site an HTTP request is made to the server, and the higher the number of requests made will decrease the overall load time of your site pages and posts. A simple way to cut down on those requests is by combining your CSS and Javascript files into as few as possible.</p>
<p>Disabling the plugin CSS allows you to copy it directly into the main theme style sheet, effectively removing one or more HTTP requests on your site. Although a handful of recent WordPress plugins have begun to offer the option to disable its CSS through its configuration, most plugins still place a call to its CSS file inside the wp_header tag. Disabling the default CSS file requires a simple function, but is dependent on the plugin authors inclusion of the wp_print_styles action.</p>
<p>Search the plugins main php file in the plugin folder for the wp_print_styles item, and it will be closely followed by the script name. The following piece of code uses a sample to disable the default CSS file for the wp-pagenavi plugin:</p>

<div class="wp_codebox_msgheader wp_codebox_hide"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p102code56'); return false;">View Code</a> PHP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p10256"><td class="code" id="p102code56"><pre class="php" style="font-family:monospace;">add_action<span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'wp_print_styles'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'my_deregister_styles'</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">100</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">function</span> my_deregister_styles<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	wp_deregister_style<span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'wp-pagenavi'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<h2>Setting Up the Function</h2>
<p>Before inserting the code into the functions.php file of the WordPress theme, open your theme header.php and check to see if it contains the following line of code, if not, then add it in the header tag. <strong>Note:</strong> the wp_header tag is used by plugins to load resources and is required for them to function.</p>

<div class="wp_codebox_msgheader wp_codebox_hide"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p102code57'); return false;">View Code</a> PHP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p10257"><td class="code" id="p102code57"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span> wp_header<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span></pre></td></tr></table></div>

<p>Navigate into the plugin folder and open the main php file and do a search for wp_enqueue_style. This function will only be possible if it is available in the plugin structure. In the wp-pagenavi.php file, the print scripts action and style name can be found on line 204:</p>

<div class="wp_codebox_msgheader wp_codebox_hide"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p102code58'); return false;">View Code</a> PHP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p10258"><td class="code" id="p102code58"><pre class="php" style="font-family:monospace;">wp_enqueue_style<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'wp-pagenavi'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$css_file</span><span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">false</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'2.70'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>In the first argument in the enqueue for the plugin, the name of the style is wp-pagenavi. Copy this name and paste it into the wp_deregister_style line of the full function, as shown in the following example:</p>

<div class="wp_codebox_msgheader wp_codebox_hide"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p102code59'); return false;">View Code</a> PHP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p10259"><td class="code" id="p102code59"><pre class="php" style="font-family:monospace;">wp_deregister_style<span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'wp-pagenavi'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<h2>Deregistering Multiple Plugin CSS Files</h2>
<p>If you have multiple plugins that use the wp_enqueue_style action, you can add multiple instances of the wp_deregister_style in one single function with the following sample:</p>

<div class="wp_codebox_msgheader wp_codebox_hide"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p102code60'); return false;">View Code</a> PHP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p10260"><td class="code" id="p102code60"><pre class="php" style="font-family:monospace;">add_action<span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'wp_print_styles'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'my_deregister_styles'</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">100</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">function</span> my_deregister_styles<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	wp_deregister_style<span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'wp-pagenavi'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	wp_deregister_style<span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'NextGEN'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	wp_deregister_style<span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'codebox'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

]]></content:encoded>
			<wfw:commentRss>http://troychaplin.ca/blog/wordpress-optimization/how-to-deregistering-the-default-plugin-css-files-in-wordpress/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

