<?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>Sycha Web Design &#38; Development &#187; Magento, WordPress, jQuery, CSS | Web Development Resources</title>
	<atom:link href="http://www.sycha.com/resources/web-development/feed" rel="self" type="application/rss+xml" />
	<link>http://www.sycha.com</link>
	<description>Website Design &#38; Development</description>
	<lastBuildDate>Mon, 09 May 2011 09:59:07 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>Magento Performance Boost: Enable Log Cleaning</title>
		<link>http://www.sycha.com/magento-performance-boost-enable-log-cleaning</link>
		<comments>http://www.sycha.com/magento-performance-boost-enable-log-cleaning#comments</comments>
		<pubDate>Mon, 09 May 2011 09:56:22 +0000</pubDate>
		<dc:creator>Charlie Evans</dc:creator>
				<category><![CDATA[Magento Development]]></category>

		<guid isPermaLink="false">http://www.sycha.com/?p=1459</guid>
		<description><![CDATA[Magento has automated log cleaning functionality built in, but it is not enabled by default. Here's how to turn it on.]]></description>
			<content:encoded><![CDATA[<p>Magento stores a lot of logging information in the database tables prefixed with log_<br />
e.g. log_visitor_info, log_url_info, etc. As with <a href="/magento-performance-boost-cleanup-old-session-files">Magento&#8217;s session files</a>, if not handled properly, these tables will grow out of control and hinder performance.</p>
<p>Magento has automated log cleaning functionality built in, but it is not enabled by default. Here&#8217;s how to turn it on.</p>
<ol>
<li>Firstly you need make sure Magento&#8217;s cron system is running.<br />
If you are unsure about this, see this article on <a href="/magento-tip-setting-up-cron-scheduled-tasks">setting up cron (scheduled tasks)</a>.</li>
<li>Once cron is enabled and running, simply enable log cleaning via the admin:

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">System <span style="color: #000000; font-weight: bold;">&gt;</span> Configuration <span style="color: #000000; font-weight: bold;">&gt;</span> Advanced <span style="color: #000000; font-weight: bold;">&gt;</span> System <span style="color: #000000; font-weight: bold;">&gt;</span> Log Cleaning</pre></div></div>

</li>
</ol>
<p>As per the screenshot below, I like to save 1 days logs, and perform the cleaning at 4:00am each morning.</p>
<p><img src="http://www.sycha.com/wp-content/uploads/2011/05/log-cleaning.png" alt="" title="Magento Log Cleaning" width="517" height="260" class="aligncenter size-full wp-image-1460" /></p>
]]></content:encoded>
			<wfw:commentRss>http://www.sycha.com/magento-performance-boost-enable-log-cleaning/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Magento Performance Boost: Cleanup Old Session Files</title>
		<link>http://www.sycha.com/magento-performance-boost-cleanup-old-session-files</link>
		<comments>http://www.sycha.com/magento-performance-boost-cleanup-old-session-files#comments</comments>
		<pubDate>Mon, 09 May 2011 09:51:09 +0000</pubDate>
		<dc:creator>Charlie Evans</dc:creator>
				<category><![CDATA[Magento Development]]></category>

		<guid isPermaLink="false">http://www.sycha.com/?p=1456</guid>
		<description><![CDATA[If left unchecked, Magento session files can grow out of control and have a negative impact on your sites performance (aswell as taking up storage space). This article explains how to make sure old session files are removed automatically.]]></description>
			<content:encoded><![CDATA[<p>If left unchecked, Magento session files can grow out of control and have a negative impact on your sites performance (aswell as taking up storage space). This article explains how to make sure old session files are removed automatically.</p>
<p>Magento stores it&#8217;s session files in var/session and I&#8217;ve seen too many Magento installations where the size of this directory has grown into the gigabytes. A quick browse of this directory should tell you whether you have a problem or not.</p>
<p>PHP has it&#8217;s own &#8216;garbage collection&#8217; process for deleting old session files, but it&#8217;s disabled in Debian &#8220;due to the strict permissions on /var/lib/php5&#8243;<br />
So, if you are using Debian then you&#8217;ll need to setup a simple cron script to do this garbage collection for you.</p>
<p>For this example, let&#8217;s say the path to your Magento installation is <strong>/path/to/magento</strong> and we want to delete session files over a week old.</p>
<ol>
<li>Create a new file /path/to/magento/session_cleanup.sh

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">vi</span> <span style="color: #000000; font-weight: bold;">/</span>path<span style="color: #000000; font-weight: bold;">/</span>to<span style="color: #000000; font-weight: bold;">/</span>magento<span style="color: #000000; font-weight: bold;">/</span>session_cleanup.sh</pre></div></div>

</li>
<li>Add the following 2 lines to the file

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">#!/bin/sh</span>
<span style="color: #c20cb9; font-weight: bold;">find</span> <span style="color: #000000; font-weight: bold;">/</span>path<span style="color: #000000; font-weight: bold;">/</span>to<span style="color: #000000; font-weight: bold;">/</span>magento<span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>session <span style="color: #660033;">-name</span> <span style="color: #ff0000;">'sess_*'</span> <span style="color: #660033;">-type</span> f <span style="color: #660033;">-mtime</span> +<span style="color: #000000;">7</span> <span style="color: #660033;">-exec</span> <span style="color: #c20cb9; font-weight: bold;">rm</span> <span style="color: #7a0874; font-weight: bold;">&#123;</span><span style="color: #7a0874; font-weight: bold;">&#125;</span> \;</pre></div></div>

</li>
<li>Make sure the file is executable

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">chmod</span> u+x <span style="color: #000000; font-weight: bold;">/</span>path<span style="color: #000000; font-weight: bold;">/</span>to<span style="color: #000000; font-weight: bold;">/</span>magento<span style="color: #000000; font-weight: bold;">/</span>session_cleanup.sh</pre></div></div>

</li>
<li>Now add it to your crontab

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">crontab <span style="color: #660033;">-e</span></pre></div></div>

<p>and set it to run every day, let&#8217;s say at 3am</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #000000;">0</span> <span style="color: #000000;">3</span> <span style="color: #000000; font-weight: bold;">*</span> <span style="color: #000000; font-weight: bold;">*</span> <span style="color: #000000; font-weight: bold;">*</span>  <span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span><span style="color: #c20cb9; font-weight: bold;">sh</span> <span style="color: #000000; font-weight: bold;">/</span>path<span style="color: #000000; font-weight: bold;">/</span>to<span style="color: #000000; font-weight: bold;">/</span>magento<span style="color: #000000; font-weight: bold;">/</span>session_cleanup.sh</pre></div></div>

</li>
</ol>
<p>And we&#8217;re done.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.sycha.com/magento-performance-boost-cleanup-old-session-files/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Magento Tip: Setting Up Cron (Scheduled Tasks)</title>
		<link>http://www.sycha.com/magento-tip-setting-up-cron-scheduled-tasks</link>
		<comments>http://www.sycha.com/magento-tip-setting-up-cron-scheduled-tasks#comments</comments>
		<pubDate>Mon, 09 May 2011 09:33:13 +0000</pubDate>
		<dc:creator>Charlie Evans</dc:creator>
				<category><![CDATA[Magento Development]]></category>

		<guid isPermaLink="false">http://www.sycha.com/?p=1448</guid>
		<description><![CDATA[Magento has it's own cron (scheduled tasks) system which handles such things as newsletter sends, sitemap generation and database log cleaning. To activate this system, you need to set up a cron job on the server to run Magento's cron script at a regular interval.]]></description>
			<content:encoded><![CDATA[<p>Magento has it&#8217;s own cron (scheduled tasks) system which handles such things as newsletter sends, sitemap generation and database log cleaning. To activate this system, you need to set up a cron job on the server to run Magento&#8217;s cron script at a regular interval.</p>
<p>Magento provides a shell script (cron.sh) which calls a PHP script (cron.php)<br />
Both files are in the root directory of the Magento installation.<br />
I like to bypass the shell script and run the PHP script directly, and I set it to run every 5 mins</p>
<p>To do this in Debian, you should open your crontab for editing:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">crontab <span style="color: #660033;">-e</span></pre></div></div>

<p>Then add a crontab entry such as this (replacing with your path):</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">*/</span><span style="color: #000000;">5</span> <span style="color: #000000; font-weight: bold;">*</span> <span style="color: #000000; font-weight: bold;">*</span> <span style="color: #000000; font-weight: bold;">*</span> <span style="color: #000000; font-weight: bold;">*</span> php <span style="color: #660033;">-q</span> <span style="color: #000000; font-weight: bold;">/</span>path<span style="color: #000000; font-weight: bold;">/</span>to<span style="color: #000000; font-weight: bold;">/</span>magento<span style="color: #000000; font-weight: bold;">/</span>cron.php</pre></div></div>

<p>The default cron scheduling settings work fine for me but you can tweak them if you like to have more control:</p>
<pre>System > Configuration > Advanced > System > Cron (Scheduled Tasks)</pre>
<p><img src="http://www.sycha.com/wp-content/uploads/2011/05/cron1.png" alt="" title="Magento Default Cron Settings" width="521" height="257" class="aligncenter size-full wp-image-1452" /></p>
<p>Note: A quick way to test your setup is to check the database table called <strong>cron_schedule</strong>. If cron is running, this table will have records in it. Remember to wait 5 mins after adding the crontab entry so it has a chance to run <img src='http://www.sycha.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://www.sycha.com/magento-tip-setting-up-cron-scheduled-tasks/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>WordPress: Assign custom CSS classes with the Visual Editor (TinyMCE)</title>
		<link>http://www.sycha.com/wordpress-assign-custom-css-classes-visual-editor</link>
		<comments>http://www.sycha.com/wordpress-assign-custom-css-classes-visual-editor#comments</comments>
		<pubDate>Sat, 23 Apr 2011 08:52:57 +0000</pubDate>
		<dc:creator>Charlie Evans</dc:creator>
				<category><![CDATA[WordPress Development]]></category>

		<guid isPermaLink="false">http://www.sycha.com/?p=1441</guid>
		<description><![CDATA[As a WordPress theme developer, it's very useful to be able to define CSS classes in a theme's stylesheet, then allow them to be assigned to elements by the user with the Visual editor. Classic examples would be special classes to style links, lists and images.]]></description>
			<content:encoded><![CDATA[<p>As a WordPress theme developer, it&#8217;s very useful to be able to define CSS classes in a theme&#8217;s stylesheet, then allow them to be assigned to elements by the user with the Visual editor. Classic examples would be special classes to style links, lists and images.</p>
<p>For anyone comfortable with editing code, it&#8217;s easy enough to switch to HTML mode and add the class attribute manually to the desired element. But for most people, it&#8217;s far easier to select the text or image, then choose the desired style from a dropdown.</p>
<p>To set up this capability we need to:</p>
<ol>
<li>hook into the tiny_mce_before_init filter</li>
<li>define the list of classes we wish to appear in the dropdown</li>
<li>activate the &#8220;Styles&#8221; dropdown in the editor</li>
</ol>
<p>The format for the custom class list is <strong>{label}</strong>=<strong>{class-name}</strong> seperated by semi-colons,<br />
e.g.<br />
<em>&#8220;Special Style 1=special-1;Special Style 2=special-2;Special Style 3=special-3&#8243;</em></p>
<p>Using this example list of classes, the code which can go in your functions.php file is as follows:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;">add_filter<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'tiny_mce_before_init'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'add_custom_classes'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">function</span> add_custom_classes<span style="color: #009900;">&#40;</span><span style="color: #000088;">$arr_options</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	<span style="color: #000088;">$arr_options</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'theme_advanced_styles'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;Special Style 1=special-1;Special Style 2=special-2;Special Style 3=special-3&quot;</span><span style="color: #339933;">;</span>
	<span style="color: #000088;">$arr_options</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'theme_advanced_buttons2_add_before'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;styleselect&quot;</span><span style="color: #339933;">;</span>
	<span style="color: #b1b100;">return</span> <span style="color: #000088;">$arr_options</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p><strong>Note: </strong>Prior to WordPress 3.1, the &#8220;Insert/edit link&#8221; dialog included a &#8220;class&#8221; drop down, which was populated by the same theme_advanced_styles list we have used here. In version 3.1 this drop down was removed by the core dev team. The technique described in this post is one way to work around this update to the WordPress admin.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.sycha.com/wordpress-assign-custom-css-classes-visual-editor/feed</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>WordPress: Specify a different version of jQuery with wp_enqueue_script()</title>
		<link>http://www.sycha.com/wordpress-specify-different-version-jquery-wp_enqueue_script</link>
		<comments>http://www.sycha.com/wordpress-specify-different-version-jquery-wp_enqueue_script#comments</comments>
		<pubDate>Wed, 20 Apr 2011 05:16:04 +0000</pubDate>
		<dc:creator>Charlie Evans</dc:creator>
				<category><![CDATA[WordPress Development]]></category>

		<guid isPermaLink="false">http://www.sycha.com/?p=1433</guid>
		<description><![CDATA[I find using the wp_enqueue_script function a nice tidy way to include javascript files in my theme. Especially when using scripts that come bundled with WordPress, such as jQuery, script.aculo.us, etc. However I recently had an issue with the very cool Fancybox jQuery plugin not playing nice with the version of jQuery that shipped with WordPress. Here's the solution.]]></description>
			<content:encoded><![CDATA[<p>I find using the <strong>wp_enqueue_script</strong> function a nice tidy way to include javascript files in my theme. Especially when using scripts that come bundled with WordPress, such as jQuery, script.aculo.us, etc. However I recently had an issue with the very cool Fancybox jQuery plugin not playing nice with the version of jQuery that shipped with WordPress. Here&#8217;s the solution.</p>
<p>You essentially need to tell WordPress to use a different version, by way of the functions <strong>wp_deregister_script</strong> and <strong>wp_register_script</strong>.</p>
<p>FYI at the time of writing, I&#8217;m using Fancybox Version 1.3.4 which plays nice with jQuery 1.4.3</p>
<p>Here&#8217;s the PHP code to go in your functions.php:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">function</span> my_enqueue_scripts<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	wp_deregister_script<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'jquery'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	wp_register_script<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'jquery'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'http://ajax.googleapis.com/ajax/libs/jquery/1.4.3/jquery.min.js'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	wp_enqueue_script<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: #009900;">&#125;</span>
&nbsp;
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;">'my_enqueue_scripts'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>For more information on wp_enqueue_script, see the codex:<br />
<a href="http://codex.wordpress.org/Function_Reference/wp_enqueue_script" target="_blank">http://codex.wordpress.org/Function_Reference/wp_enqueue_script</a></p>
<p>Check out Fancybox &#8211; jQuery Plugin here:<br />
<a href="http://fancybox.net" target="_blank">http://fancybox.net</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.sycha.com/wordpress-specify-different-version-jquery-wp_enqueue_script/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>jQuery: Smooth Scrolling Internal Anchor Links</title>
		<link>http://www.sycha.com/jquery-smooth-scrolling-internal-anchor-links</link>
		<comments>http://www.sycha.com/jquery-smooth-scrolling-internal-anchor-links#comments</comments>
		<pubDate>Sat, 13 Nov 2010 01:59:16 +0000</pubDate>
		<dc:creator>Charlie Evans</dc:creator>
				<category><![CDATA[jQuery / Javascript Resources]]></category>

		<guid isPermaLink="false">http://www.sycha.com/?p=1369</guid>
		<description><![CDATA[Here's a neat little jQuery trick to fancy up your internal anchor links, by making them scroll smoothly to their target as opposed to jumping instantly.]]></description>
			<content:encoded><![CDATA[<p>Here&#8217;s a neat little jQuery trick to fancy up your internal anchor links, by making them scroll smoothly to their target as opposed to jumping instantly.</p>
<p>Internal anchor links are very common place,<br />
e.g. &#8220;back to top&#8221; links, or FAQ pages which list all the questions at the top.<br />
Making them visually scroll to their target not only looks a bit fancy, it also gives some visual feedback to the user as to their new position on the page.</p>
<p>This is what it looks like in action, click the following link:<br />
<a href="#comments" class="scroll">Scroll to comments</a></p>
<p>This technique is very simple.</p>
<ol>
<li>
Set up your link as you normally would,<br />
e.g. href=&#8221;#comments&#8221; <em>(where comments is the id of your target)</em>
</li>
<li>
Add a class=&#8221;scroll&#8221; attribute to the link element, so it now looks something like this:</p>

<div class="wp_syntax"><div class="code"><pre class="html" style="font-family:monospace;">&lt;a href=&quot;#comments&quot; class=&quot;scroll&quot;&gt;Scroll to comments&lt;/a&gt;</pre></div></div>

</li>
<li>
Finally add the following jQuery code wherever is most appropriate</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">jQuery<span style="color: #009900;">&#40;</span>document<span style="color: #009900;">&#41;</span>.<span style="color: #660066;">ready</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>$<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
&nbsp;
	$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;.scroll&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">click</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>event<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>		
		event.<span style="color: #660066;">preventDefault</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'html,body'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">animate</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span>scrollTop<span style="color: #339933;">:</span>$<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">hash</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">offset</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">top</span><span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">500</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: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

</li>
</ol>
<p>And that&#8217;s all there is to it <img src='http://www.sycha.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://www.sycha.com/jquery-smooth-scrolling-internal-anchor-links/feed</wfw:commentRss>
		<slash:comments>15</slash:comments>
		</item>
		<item>
		<title>WordPress Function: is_page_or_descendant()</title>
		<link>http://www.sycha.com/wordpress-function-is_page_or_descendant</link>
		<comments>http://www.sycha.com/wordpress-function-is_page_or_descendant#comments</comments>
		<pubDate>Thu, 04 Nov 2010 08:08:55 +0000</pubDate>
		<dc:creator>Charlie Evans</dc:creator>
				<category><![CDATA[WordPress Development]]></category>

		<guid isPermaLink="false">http://www.sycha.com/?p=1199</guid>
		<description><![CDATA[Here's a handy little function to check if the page you're currently viewing is a specific page or a descendant of it (child, grandchild, etc). I've come across a few simliar functions: is_child(), is_subpage(), is_descendant(), etc; but none that met my needs exactly.]]></description>
			<content:encoded><![CDATA[<p>Here&#8217;s a handy little function to check if the page you&#8217;re currently viewing is a specific page or a descendant of it (child, grandchild, etc). I&#8217;ve come across a few simliar functions: is_child(), is_subpage(), is_descendant(), etc; but none that met my needs exactly.</p>
<h3>Example scenario:</h3>
<p>You need a conditional tag to use in your theme template, which checks if a navigation item is &#8220;current&#8221; or not. If it&#8217;s current you want to highlight it somehow using CSS.</p>
<h3>Working example:</h3>
<p>On <a href="http://www.melissaevans.com" target="_blank">Melissa&#8217;s website</a>, the top navigation is a list of pages.<br />
Each tutorial on her site is a child page of the main <a href="http://www.melissaevans.com/tutorials" target="_blank">Tutorials</a> page.<br />
When you are viewing the <a href="http://www.melissaevans.com/tutorials/pop-art-inspired-by-lichtenstein" target="_blank">Pop Art Tutorial</a>, the little triangle above the main nav indicates that you are in the Tutorials section of the site.<br />
<!--(see here for how to make that cool little animated navigation slider)--></p>
<h3>Example theme code</h3>
<p>The main nav is an unordered list, here&#8217;s the list item for Tutorials:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;">&lt;li <span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span>is_page_or_descendant<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Tutorials'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">'class=&quot;current&quot;'</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>&gt;
	&lt;a href=&quot;/tutorials&quot;&gt;Tutorials&lt;/a&gt;
&lt;/li&gt;</pre></div></div>

<p>This code checks if the current page is &#8216;Tutorials&#8217; or a descendant of it.<br />
If so, then it adds the class=&#8221;current&#8221; attribute to the list item.<br />
CSS and jQuery are then used to position the triangle above it.</p>
<h3>Function Definition</h3>
<p><code><strong>bool is_page_or_descendant($page)</strong></code></p>
<p>returns TRUE if the page you&#8217;re viewing is the specified page or a descendant of it</p>
<h3>Function Parameters</h3>
<p><code>$page</code><br />
<em>(mixed) (required)</em> Page specified by ID (integer), title (string) or path (string)</p>
<h3>Function Code</h3>
<p>I hope this function is as useful for you as it is for me, enjoy <img src='http://www.sycha.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">function</span> is_page_or_descendant<span style="color: #009900;">&#40;</span><span style="color: #000088;">$page</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: #339933;">!</span>is_page<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #b1b100;">return</span> <span style="color: #009900; font-weight: bold;">false</span><span style="color: #339933;">;</span> 
&nbsp;
	<span style="color: #666666; font-style: italic;">// retrieve page being currently viewed</span>
	<span style="color: #000000; font-weight: bold;">global</span> <span style="color: #000088;">$wp_query</span><span style="color: #339933;">;</span>
	<span style="color: #000088;">$obj_current_page</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$wp_query</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">get_queried_object</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #990000;">empty</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$obj_current_page</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">ID</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #b1b100;">return</span> <span style="color: #009900; font-weight: bold;">false</span><span style="color: #339933;">;</span> 
&nbsp;
	<span style="color: #666666; font-style: italic;">// retrieve specified page (ID, title or path)</span>
	<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #990000;">is_numeric</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$page</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #000088;">$obj_specified_page</span> <span style="color: #339933;">=</span> get_page<span style="color: #009900;">&#40;</span><span style="color: #000088;">$page</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #b1b100;">else</span> <span style="color: #000088;">$obj_specified_page</span> <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$page_by_path</span> <span style="color: #339933;">=</span> get_page_by_path<span style="color: #009900;">&#40;</span><span style="color: #000088;">$page</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> ? <span style="color: #000088;">$page_by_path</span> <span style="color: #339933;">:</span> get_page_by_title<span style="color: #009900;">&#40;</span><span style="color: #000088;">$page</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #990000;">empty</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$obj_specified_page</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">ID</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #b1b100;">return</span> <span style="color: #009900; font-weight: bold;">false</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #b1b100;">return</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$obj_specified_page</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">ID</span> <span style="color: #339933;">==</span> <span style="color: #000088;">$obj_current_page</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">ID</span> or <span style="color: #000088;">$obj_specified_page</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">ID</span> <span style="color: #339933;">==</span> <span style="color: #000088;">$obj_current_page</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">post_parent</span> or <span style="color: #990000;">in_array</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$obj_specified_page</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">ID</span><span style="color: #339933;">,</span> get_post_ancestors<span style="color: #009900;">&#40;</span><span style="color: #000088;">$obj_current_page</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">ID</span><span style="color: #009900;">&#41;</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></div></div>

]]></content:encoded>
			<wfw:commentRss>http://www.sycha.com/wordpress-function-is_page_or_descendant/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>WordPress: Add the &lt;hr&gt; button to the Visual Editor (TinyMCE)</title>
		<link>http://www.sycha.com/wordpress-add-hr-button-tinymce-visual-editor</link>
		<comments>http://www.sycha.com/wordpress-add-hr-button-tinymce-visual-editor#comments</comments>
		<pubDate>Mon, 18 Oct 2010 07:40:18 +0000</pubDate>
		<dc:creator>Charlie Evans</dc:creator>
				<category><![CDATA[WordPress Development]]></category>

		<guid isPermaLink="false">http://www.sycha.com/?p=1360</guid>
		<description><![CDATA[Strangely, the &#60;hr&#62; tag (horizontal rule) button isn't enabled by default in the WordPress Visual Editor (TinyMCE). Here's how to turn it on, along with any other buttons you want to use.]]></description>
			<content:encoded><![CDATA[<p>Strangely, the &lt;hr&gt; tag (horizontal rule) button isn&#8217;t enabled by default in the WordPress Visual Editor (TinyMCE). Here&#8217;s how to turn it on, along with any other buttons you want to use.</p>
<p>Open up your functions.php file and add the following code:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">function</span> enable_more_buttons<span style="color: #009900;">&#40;</span><span style="color: #000088;">$buttons</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
  <span style="color: #000088;">$buttons</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'hr'</span><span style="color: #339933;">;</span>
&nbsp;
  <span style="color: #666666; font-style: italic;">/* 
  Repeat with any other buttons you want to add, e.g.
	  $buttons[] = 'fontselect';
	  $buttons[] = 'sup';
  */</span>
&nbsp;
  <span style="color: #b1b100;">return</span> <span style="color: #000088;">$buttons</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
add_filter<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;mce_buttons&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;enable_more_buttons&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>The idea here is that you are tapping into the filter hooks which are applied to each row of buttons on the editor toolbar.</p>
<p>The example above adds the &lt;hr&gt; button to the first row of buttons. If you&#8217;d like to add to the second row you&#8217;d use the <strong>mce_buttons_2</strong> filter hook, etc etc.</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;">add_filter<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;mce_buttons_2&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;enable_more_buttons&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// add to second row</span>
<span style="color: #666666; font-style: italic;">//add_filter(&quot;mce_buttons_3&quot;, &quot;enable_more_buttons&quot;); // add to third row</span></pre></div></div>

<p>Hope you find this useful <img src='http://www.sycha.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://www.sycha.com/wordpress-add-hr-button-tinymce-visual-editor/feed</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
		<item>
		<title>CSS: Style your &lt;hr&gt; tags with a background image</title>
		<link>http://www.sycha.com/css-style-hr-tag-background-image</link>
		<comments>http://www.sycha.com/css-style-hr-tag-background-image#comments</comments>
		<pubDate>Wed, 13 Oct 2010 22:10:29 +0000</pubDate>
		<dc:creator>Charlie Evans</dc:creator>
				<category><![CDATA[HTML / CSS Resources]]></category>

		<guid isPermaLink="false">http://www.sycha.com/?p=1346</guid>
		<description><![CDATA[I find &#60;hr&#62; (horizontal rule) tags to be a nice semantic way to separate or break up content on a page. To give them some style, you can replace them with a nice background image.]]></description>
			<content:encoded><![CDATA[<p>I find &lt;hr&gt; (horizontal rule) tags to be a nice semantic way to separate or break up content on a page. To give them some style, you can replace them with a nice background image.</p>
<p><img src="http://www.sycha.com/wp-content/uploads/2010/10/spiral-shape.png" alt="" title="spiral-shape" width="255" height="42" class="aligncenter" /></p>
<p>By default, &lt;hr&gt; tags are pretty ugly and basic, a line at their simplest or some 3D bordered monstrosity at worst. Using the CSS background property you can specify an image, just make sure to set the height to be at least that of the image, and set the border to none.</p>

<div class="wp_syntax"><div class="code"><pre class="css" style="font-family:monospace;">hr <span style="color: #00AA00;">&#123;</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;">spiral-shape.png</span><span style="color: #00AA00;">&#41;</span> <span style="color: #993333;">no-repeat</span> <span style="color: #000000; font-weight: bold;">top</span> <span style="color: #993333;">center</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">height</span><span style="color: #00AA00;">:</span><span style="color: #933;">42px</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">border</span><span style="color: #00AA00;">:</span><span style="color: #993333;">none</span> !important<span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span></pre></div></div>

<p>As usual, Internet Explorer (7 and less) doesn&#8217;t play nice so you need to set up some IE specific CSS (if you care).<br />
I always use a separate IE css file included with a condiional as follows:</p>

<div class="wp_syntax"><div class="code"><pre class="html" style="font-family:monospace;">&lt;!--[if lte IE 7]&gt;
	&lt;link rel='stylesheet' href='ie.css' type='text/css' media='screen' /&gt;
&lt;![endif]--&gt;</pre></div></div>

<p>And the IE hack as follows (Props to <a href="http://blog.neatlysliced.com/2008/03/hr-image-replacement/" target="_blank" rel="nofollow">NeatlySliced</a>):</p>

<div class="wp_syntax"><div class="code"><pre class="css" style="font-family:monospace;">hr <span style="color: #00AA00;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">display</span><span style="color: #3333ff;">:list-</span>item<span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">list-style</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;">spiral-shape.png</span><span style="color: #00AA00;">&#41;</span> <span style="color: #993333;">inside</span><span style="color: #00AA00;">;</span>
	filter<span style="color: #00AA00;">:</span>alpha<span style="color: #00AA00;">&#40;</span>opacity<span style="color: #00AA00;">=</span><span style="color: #cc66cc;">0</span><span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">;</span><span style="color: #808080; font-style: italic;">/* gets rid of horizontal bar to right of image */</span>
	<span style="color: #000000; font-weight: bold;">width</span><span style="color: #00AA00;">:</span><span style="color: #cc66cc;">0</span><span style="color: #00AA00;">;</span>		<span style="color: #808080; font-style: italic;">/* prevents tiling */</span>
	<span style="color: #000000; font-weight: bold;">margin-top</span><span style="color: #00AA00;">:</span><span style="color: #933;">-10px</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://www.sycha.com/css-style-hr-tag-background-image/feed</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Magento: Enable Terms &amp; Conditions checkbox at Checkout</title>
		<link>http://www.sycha.com/magento-terms-conditions-checkout</link>
		<comments>http://www.sycha.com/magento-terms-conditions-checkout#comments</comments>
		<pubDate>Tue, 12 Oct 2010 00:01:03 +0000</pubDate>
		<dc:creator>Charlie Evans</dc:creator>
				<category><![CDATA[Magento Development]]></category>

		<guid isPermaLink="false">http://www.sycha.com/?p=1340</guid>
		<description><![CDATA[A very common requirement for online shop owners is to force the customer to accept their terms and conditions before placing an order. When a client requested this recently, I was happy to find that Magento has this functionality built in, meaning time saved and no custom coding. It just requires some setting up in the admin, here's how.]]></description>
			<content:encoded><![CDATA[<p>A very common requirement for online shop owners is to force the customer to accept their terms and conditions before placing an order. When a client requested this recently, I was happy to find that Magento has this functionality built in, meaning time saved and no custom coding. It just requires some setting up in the admin, here&#8217;s how.</p>
<p>In your admin go to:</p>
<pre>Menu > System > Configuration > Sales > Checkout > Checkout Options</pre>
<ol>
<li>Set &#8220;Enable Terms and Conditions&#8221; to &#8220;Yes&#8221;</li>
<li>Click &#8220;Save Config&#8221;</li>
</ol>
<p>Next, go to:</p>
<pre>Menu > Sales > Terms and conditions</pre>
<ol>
<li>Click &#8220;Add New Condition&#8221;</li>
<li>Fill in the required fields
<ul>
<li>&#8220;Condition Name&#8221; is only shown in the admin so can be whatever you want.</li>
<li>Set &#8220;Status&#8221; to &#8220;Enabled&#8221;</li>
<li>Set &#8220;Show content as&#8221; to &#8220;HTML&#8221; if you want to stylize the content or have links</li>
<li>&#8220;Checkbox text&#8221; will be shown next to the checkbox, e.g. &#8220;I accept the terms and conditions&#8221;</li>
<li>&#8220;Content&#8221; will be shown in a scrolling text area above the checkbox. This could be your entire terms and conditions or a link to your terms and conditions page.</li>
</ul>
</li>
<li>Click &#8220;Save Condition&#8221;</li>
</ol>
<p>You&#8217;re all done. The terms and conditions text and checkbox will now show on the final step of the checkout. Customers will be required to check the checkbox before they can place an order. </p>
]]></content:encoded>
			<wfw:commentRss>http://www.sycha.com/magento-terms-conditions-checkout/feed</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
	</channel>
</rss>

<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Page Caching using disk: enhanced
Database Caching 2/28 queries in 0.009 seconds using disk: basic
Object Caching 492/541 objects using disk: basic

Served from: www.sycha.com @ 2012-02-04 18:08:48 -->
