<?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; WordPress Development Tips, Tutorials and Plugins</title>
	<atom:link href="http://www.sycha.com/resources/web-development/wordpress-development/feed" rel="self" type="application/rss+xml" />
	<link>http://www.sycha.com</link>
	<description>Website Design &#38; Development</description>
	<lastBuildDate>Tue, 14 May 2013 23:44:04 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.5.1</generator>
		<item>
		<title>WordPress Command Line Database Upgrade</title>
		<link>http://www.sycha.com/wordpress-command-line-database-upgrade</link>
		<comments>http://www.sycha.com/wordpress-command-line-database-upgrade#comments</comments>
		<pubDate>Sat, 22 Sep 2012 06:55:12 +0000</pubDate>
		<dc:creator>Charlie Evans</dc:creator>
				<category><![CDATA[WordPress Development]]></category>

		<guid isPermaLink="false">http://www.sycha.com/?p=1477</guid>
		<description><![CDATA[If you're like me and manage dozens of WordPress sites, you've probably got a shared code base which allows you to upgrade the WordPress filesystem easily.. But most likely you've also found it painful to have to visit each wp-admin individually and click the "Update WordPress Database" button. Ever wanted to script this task to run from the command line? Here you go :)]]></description>
				<content:encoded><![CDATA[<p>If you&#8217;re like me and manage dozens of WordPress sites, you&#8217;ve probably got a shared code base which allows you to upgrade the WordPress filesystem easily.. But most likely you&#8217;ve also found it painful to have to visit each wp-admin individually and click the &#8220;Update WordPress Database&#8221; button. Ever wanted to script this task to run from the command line? Here you go <img src='http://www.sycha.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>The script below allows you to specify the path to one WordPress installation.. For multiple sites/installs just put this script in a loop.</p>
<p>Thanks to <a href="https://github.com/wp-cli/wp-cli" target="_blank">wp-cli</a> for pointing me in the right direction.</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">// specify path to your wordpress root - no trailing slash</span>
<span style="color: #000088;">$wp_root</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'/path/to/wordpress/root'</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// load wordpress</span>
<span style="color: #b1b100;">require</span> <span style="color: #0000ff;">&quot;<span style="color: #006699; font-weight: bold;">{$wp_root}</span>/wp-load.php&quot;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// ensure we don't run out of memory</span>
<span style="color: #339933;">@</span><span style="color: #990000;">ini_set</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'memory_limit'</span><span style="color: #339933;">,</span> <span style="color: #339933;">-</span><span style="color: #cc66cc;">1</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// load admin API</span>
<span style="color: #b1b100;">require</span> <span style="color: #0000ff;">&quot;<span style="color: #006699; font-weight: bold;">{$wp_root}</span>/wp-admin/includes/admin.php&quot;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// load upgrade API</span>
<span style="color: #b1b100;">require</span> <span style="color: #0000ff;">&quot;<span style="color: #006699; font-weight: bold;">{$wp_root}</span>/wp-admin/includes/upgrade.php&quot;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// upgrade database</span>
wp_upgrade<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

]]></content:encoded>
			<wfw:commentRss>http://www.sycha.com/wordpress-command-line-database-upgrade/feed</wfw:commentRss>
		<slash:comments>0</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"><table><tr><td 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></td></tr></table></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>6</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"><table><tr><td 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></td></tr></table></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>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"><table><tr><td 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></td></tr></table></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"><table><tr><td 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></td></tr></table></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"><table><tr><td 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></td></tr></table></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"><table><tr><td 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></td></tr></table></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>12</slash:comments>
		</item>
		<item>
		<title>WordPress Security Tip: Remove Generator Meta Tag (wp_generator)</title>
		<link>http://www.sycha.com/wordpress-security-tip-remove-generator-meta-tag</link>
		<comments>http://www.sycha.com/wordpress-security-tip-remove-generator-meta-tag#comments</comments>
		<pubDate>Thu, 25 Mar 2010 02:56:58 +0000</pubDate>
		<dc:creator>Charlie Evans</dc:creator>
				<category><![CDATA[WordPress Development]]></category>

		<guid isPermaLink="false">http://www.sycha.com/?p=947</guid>
		<description><![CDATA[Sometimes when a security hole is found in WordPress, the cyber-baddies will target specific versions of WordPress that are vulnerable to the exploit. There's no easier way for them to see which version a site is running, than by looking for the "generator" meta tag, which is added by the wp_head() function. ]]></description>
				<content:encoded><![CDATA[<p>Sometimes when a security hole is found in WordPress, the cyber-baddies will target specific versions of WordPress that are vulnerable to the exploit. There&#8217;s no easier way for them to see which version a site is running, than by looking for the &#8220;generator&#8221; meta tag, which is added by the wp_head() function. This tag specifies the WordPress version in it&#8217;s content attribute.</p>
<p>It looks like this:</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="html" style="font-family:monospace;">&lt;meta name=&quot;generator&quot; content=&quot;WordPress 2.9.0&quot; /&gt;</pre></td></tr></table></div>

<p>To remove this meta tag, simply add the following line to your functions.php file in your theme:</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="php" style="font-family:monospace;">remove_action<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'wp_head'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'wp_generator'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

]]></content:encoded>
			<wfw:commentRss>http://www.sycha.com/wordpress-security-tip-remove-generator-meta-tag/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>WordPress Snippet: Display multiple loops on the same page</title>
		<link>http://www.sycha.com/wordpress-snippet-multiple-loops-same-page</link>
		<comments>http://www.sycha.com/wordpress-snippet-multiple-loops-same-page#comments</comments>
		<pubDate>Fri, 11 Dec 2009 22:07:00 +0000</pubDate>
		<dc:creator>Charlie Evans</dc:creator>
				<category><![CDATA[WordPress Development]]></category>

		<guid isPermaLink="false">http://www.sycha.com/?p=503</guid>
		<description><![CDATA[Let's say that on a category page of your WordPress blog, you want to display a secondary list of posts, for example the 3 latest posts from a "featured" category. You have a couple of good options here.]]></description>
				<content:encoded><![CDATA[<p>Let&#8217;s say that on a category page of your WordPress blog, you want to display a secondary list of posts, for example the 3 latest posts from a &#8220;featured&#8221; category.</p>
<p>You have a couple of good options here:<br />
1. create a new WP_Query object, or<br />
2. use the get_posts() function.</p>
<p><em>Note: Using query_posts() is a bad option as it will upset your &#8220;main loop&#8221;</em></p>
<p>Both take pretty much the same arguments as query_posts() &#8211; <a href="http://codex.wordpress.org/Template_Tags/query_posts#Parameters" target="_blank" rel="nofollow">see a list here.</a></p>
<h3>Example usage of WP_Query:</h3>

<div class="wp_syntax"><table><tr><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$featured_category_id</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">10</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$args</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'posts_per_page'</span><span style="color: #339933;">=&gt;</span><span style="color: #cc66cc;">3</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'cat'</span><span style="color: #339933;">=&gt;</span><span style="color: #000088;">$featured_category_id</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$query</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> WP_Query<span style="color: #009900;">&#40;</span><span style="color: #000088;">$args</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #b1b100;">while</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$query</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">have_posts</span><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: #000088;">$query</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">the_post</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	the_title<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'&lt;h3&gt;'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'&lt;/h3&gt;'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">endwhile</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<h3>Example usage of get_posts():</h3>

<div class="wp_syntax"><table><tr><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$featured_category_id</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">10</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$args</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'numberposts'</span><span style="color: #339933;">=&gt;</span><span style="color: #cc66cc;">3</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'cat'</span><span style="color: #339933;">=&gt;</span><span style="color: #000088;">$featured_category_id</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #b1b100;">foreach</span> <span style="color: #009900;">&#40;</span>get_posts<span style="color: #009900;">&#40;</span><span style="color: #000088;">$args</span><span style="color: #009900;">&#41;</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$post</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">:</span>
	the_title<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'&lt;h3&gt;'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'&lt;/h3&gt;'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">endforeach</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

]]></content:encoded>
			<wfw:commentRss>http://www.sycha.com/wordpress-snippet-multiple-loops-same-page/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>WordPress Function: in_category_extended()</title>
		<link>http://www.sycha.com/wordpress-function-in-category-extended</link>
		<comments>http://www.sycha.com/wordpress-function-in-category-extended#comments</comments>
		<pubDate>Sun, 29 Nov 2009 22:49:50 +0000</pubDate>
		<dc:creator>Charlie Evans</dc:creator>
				<category><![CDATA[WordPress Development]]></category>

		<guid isPermaLink="false">http://www.sycha.com/?p=175</guid>
		<description><![CDATA[The core WordPress function in_category() is pretty handy but it’s also pretty basic. in_category_extended() is designed to extend the functionality of in_category() by examining descendant categories aswell as the current one.]]></description>
				<content:encoded><![CDATA[<p>The core WordPress function <code>in_category()</code> is pretty handy but it&#8217;s also pretty basic. </p>
<p><code><strong>in_category_extended()</strong></code> is designed to extend the functionality of <code>in_category()</code> in the following ways:</p>
<ol>
<li>test if the current post is assigned to the specified category <strong>OR</strong> any descendant categories</li>
<li>return <strong>TRUE</strong> if you are viewing the specified category page <strong>OR</strong> any descendant category pages</li>
</ol>
<p>Sure, you can do this a bunch of different ways, using multiple functions and code snippets, but I want <strong>a single boolean PHP function</strong> to use in my templates. </p>
<h3>Example Usage</h3>
<p>The main navigation consists of category tabs with on/off states.<br />
If I&#8217;m viewing a post OR a category page which is related to the &#8220;development&#8221; category, then I want to apply a <code>class="current"</code> to the development tab element, which I can then style accordingly with CSS.</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="php" style="font-family:monospace;">class=&quot;<span style="color: #000000; font-weight: bold;">&lt;?=</span> in_category_extended<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'development'</span><span style="color: #009900;">&#41;</span> ? <span style="color: #0000ff;">'current'</span> <span style="color: #339933;">:</span> <span style="color: #0000ff;">''</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>&quot;</pre></td></tr></table></div>

<h3>Function Definition</h3>
<p><code><strong>bool in_category_extended($category)</strong></code></p>
<p>returns TRUE if the current webpage is related to the specified category</p>
<h3>Function Parameters</h3>
<p><code>$category</code><br />
<em>(mixed) (required)</em> Category specified by ID (integer), or slug (string)</p>
<h3>Function Code</h3>
<p>This function has come in very handy for me &#8211; I hope you find it useful too!</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">function</span> in_category_extended<span style="color: #009900;">&#40;</span><span style="color: #000088;">$category</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
&nbsp;
	<span style="color: #666666; font-style: italic;">// easy out</span>
	<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><span style="color: #009900;">&#40;</span>is_category<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> or is_single<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</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 category (ID or slug)</span>
	<span style="color: #000088;">$obj_specified_category</span> <span style="color: #339933;">=</span> <span style="color: #990000;">is_numeric</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$category</span><span style="color: #009900;">&#41;</span> ? get_category<span style="color: #009900;">&#40;</span><span style="color: #000088;">$category</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">:</span> get_category_by_slug<span style="color: #009900;">&#40;</span><span style="color: #000088;">$category</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_category</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">cat_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;">// we're viewing a category</span>
	<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span>is_category<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: #000088;">$current_category_ID</span> <span style="color: #339933;">=</span> get_query_var<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'cat'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #b1b100;">return</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$obj_specified_category</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">cat_ID</span> <span style="color: #339933;">==</span> <span style="color: #000088;">$current_category_ID</span> or cat_is_ancestor_of<span style="color: #009900;">&#40;</span><span style="color: #000088;">$obj_specified_category</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">cat_ID</span><span style="color: #339933;">,</span><span style="color: #000088;">$current_category_ID</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #666666; font-style: italic;">// we're viewing a post</span>
	<span style="color: #b1b100;">else</span> <span style="color: #009900;">&#123;</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_post</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_post</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;">if</span> <span style="color: #009900;">&#40;</span>in_category<span style="color: #009900;">&#40;</span><span style="color: #000088;">$obj_specified_category</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">cat_ID</span><span style="color: #339933;">,</span> <span style="color: #000088;">$obj_post</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;">true</span><span style="color: #339933;">;</span>
		<span style="color: #b1b100;">else</span> <span style="color: #b1b100;">return</span> in_category<span style="color: #009900;">&#40;</span>get_term_children<span style="color: #009900;">&#40;</span><span style="color: #000088;">$obj_specified_category</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">cat_ID</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'category'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$obj_post</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: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

]]></content:encoded>
			<wfw:commentRss>http://www.sycha.com/wordpress-function-in-category-extended/feed</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
	</channel>
</rss>
