<?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/"
	>

<channel>
	<title>Kaizeku Ban &#187; web design</title>
	<atom:link href="http://blog.kaizeku.com/taxonomy/web-design/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.kaizeku.com</link>
	<description>So many evil plans, so little time...</description>
	<pubDate>Sat, 13 Dec 2008 17:01:04 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.7</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<xhtml:meta xmlns:xhtml="http://www.w3.org/1999/xhtml" name="robots" content="noindex" />
	<meta xmlns="http://pipes.yahoo.com" name="pipes" content="noprocess" />
	<image>
		<link>http://blog.kaizeku.com/</link>
		<url>http://i.istalker.net/1.6.2/stamp.png</url>
		<title>Kaizeku Ban</title>
	</image>
		<item>
		<title>Themes plugin dependencies</title>
		<link>http://blog.kaizeku.com/wordpress/themes-plugin-dependencies/</link>
		<comments>http://blog.kaizeku.com/wordpress/themes-plugin-dependencies/#comments</comments>
		<pubDate>Sun, 08 Jun 2008 11:06:53 +0000</pubDate>
		<dc:creator>Avice</dc:creator>
		
		<category><![CDATA[Themes]]></category>

		<category><![CDATA[WordPress]]></category>

		<category><![CDATA[hook]]></category>

		<category><![CDATA[web design]]></category>

		<guid isPermaLink="false">http://blog.kaizeku.com/?p=166</guid>
		<description><![CDATA[Wordpress Designer theme guide on implementing plugins for public release.]]></description>
			<content:encoded><![CDATA[<p><img src="http://blog.kaizeku.com/wp-content/uploads/2008/06/wordpress-theme-plugin-dependencies-preview-pin-up-by-chaoskaizer.png" alt="Wordpress theme plugin dependencies" title="wordpress-theme-plugin-dependencies-preview-pin-up-by-chaoskaizer" width="128" height="128" class="alignleft size-full wp-image-167 fl" />A good theme designer should avoid the need to relies on third party plugins.</p>
<h2>Is plugin deactivated</h2>
<p><img src="http://static4.animepaper.net/images/ck/tuzki/headslam.gif" width="70" height="50" alt="bunny" longdesc="/#" class="fr"/>Unfortunately, some WordPress theme out there has a &#8220;major pending headache&#8221; for <strong>plugin dependencies breakdown sydrome</strong>. Because of this un-friendly trends there is bound shit to happen when the specific plugin is not maintain properly or on certain case of a sudden WordPress upgrade render the plugin useless (this happen a lot when previous <abbr title="WordPress">WP</abbr> 2.3 release). </p>
<p>To make it worse some ignorant-end-user decide &#8220;not to&#8221; upgrade their WordPress blog because their favorites theme&#8217;s has this specific plugins that will only work with previous vulnerability WordPress version &amp; thus the never ending quotes war begin. </p>
<p><span id="more-166"></span></p>
<h3>Theme with Plugin dependencies</h3>
<p>From <strong>the smashing lists</strong> of <em>&#8220;<a href="http://www.smashingmagazine.com/2007/05/07/10-fresh-elegant-and-clean-wordpress-themes/" title="10 Fresh, Elegant and Clean Wordpress Themes">10 Fresh, Elegant and Clean Wordpress Themes</a>&#8220;</em> there is <strong>3</strong> out of 10 theme with plugins dependencies issue. These threesome is an experienced theme designer. How many wordpress theme with plugin dependencies is out there? </p>
<p>So what&#8217;s the point of having <dfn>clean &#038; elegant</dfn> theme if it doesn&#8217;t properly work and throw &#8220;Fatal Error&#8221; when certain plugin is deactivated. </p>
<h5>Similar issue</h5>
<p>Before you asked why you need to write better plugin support read on the following articles at <abbr title="Weblog Tools Collections">WTC</abbr>.</p>
<ul class="xoxo">
<li><a href="http://weblogtoolscollection.com/archives/2008/06/07/plugin-deactivation-issues-solved-with-actions-and-filters/">Plugin Deactivation Issues</a> by <em class="vcard di"><a href="http://www.ronalfy.com/" title="Ronal Huereca" class="url fn" rel="contact"><span class="family-name">Ronald</span> <span class="given-name">Huereca</span></a></em> </li>
<li> <a href="http://weblogtoolscollection.com/archives/2008/06/01/if-plugin-deactivation-breaks-your-blog/">If Plugin Deactivation Breaks Your Blog</a> by <em class="vcard di"><a href="http://www.jeffro2pt0.com/">Jeff Chandler</a> <span class="nickname dn">Jeffro2pt0</span></em>.</li>
</ul>
<hr/>
<h2>Introduction</h2>
<p>This guide is intent for WordPress theme designer in hope to improve theme quality and avoid plugin dependencies.</p>
<h3>Wordpress Hook</h3>
<p>As this is a &#8220;quick guide&#8221; so I wont cover this broad topics. It might take sometimes to understand the concept still its worth the time. You can read it at WordPress Codex &darr;</p>
<ul class="xoxo mgb pdb">
<li><a href="http://codex.wordpress.org/Plugin_API" class="ext">http://codex.wordpress.org/Plugin_API</a></li>
</ul>
<h3>Avoid Plugin dependencies best practice guide</h3>
<p>Lets assume you want to add <a href="http://lesterchan.net/" title="Lester GaMerZ Chan">Lester Chan</a> advanced pagination plugin (<a href="wordpress.org/extend/plugins/wp-pagenavi/">Wp-pagenavi</a>) in your theme.</p>
<h5>Fallback function</h5>
<p><big class="dropno">1<span>)</span></big> First we created a default function for the page navigation links (the next &#038; previous page links). Saved it inside <tt>functions.php</tt> in your theme folder <tt>/wp-content/themes/mytheme/</tt>.</p>
<p><small class="fr icn-r"><tt>functions.php</tt></small></p>
<pre class="prebox cr">
function wpi_post_link&#40;&#41;
&#123;
	next_posts_link&#40;__&#40;&#39;&#38;laquo&#59; Older Entries&#39;&#44;&#39;mytheme&#45;name&#39;&#41;&#41;&#59;
	echo &#39;&#38;nbsp&#59;&#39;&#59;
	previous_posts_link&#40;__&#40;&#39;Newer Entries &#38;raquo&#59;&#39;&#44;&#39;mytheme&#45;name&#39;&#41;&#41;&#59;
&#125;
</pre>
<p class="sticky"><small>Tips: to avoid duplicated function name conflict, its a good practice to have your own unique prefix for function name , <em>( i.e., wpi_get_time, themename_foo )</em></small></p>
<h5>HTML &amp; Action Hook Placement</h5>
<p><big class="dropno">2<span>)</span></big>Next we add our <strong>pagination hook</strong> <tt>(wpi_pagination)</tt> inside <tt>index.php</tt> templates ( &amp; similar templates files i.e., home.php, category.php, archive.php ) .</p>
<p><small class="fr icn-r"><tt>index.php</tt></small></p>
<pre class="prebox cr">
&#60;&#33;&#45;&#45; pagination &#45;&#45;&#62;
&#60;div id&#61;&#34;pagination&#34; class&#61;&#34;border clear&#45;both&#34;&#62;
&#60;&#63;php do_action&#40;&#39;wpi_pagination&#39;&#41;&#59;&#63;&#62;
&#60;&#47;div&#62;
</pre>
<p>Example using default (kubrick) wordpress theme <tt>index.php</tt> templates files.</p>
<p><small class="fr icn-r"><tt>(kubrick) index.php</tt></small></p>
<pre class="prebox cr">
&#60;&#63;php get_header&#40;&#41;&#59; &#63;&#62;

	&#60;div id&#61;&#34;content&#34; class&#61;&#34;narrowcolumn&#34;&#62;

	&#60;&#63;php if &#40;have_posts&#40;&#41;&#41; &#58; &#63;&#62;

		&#60;&#63;php while &#40;have_posts&#40;&#41;&#41; &#58; the_post&#40;&#41;&#59; &#63;&#62;

			&#60;div class&#61;&#34;post&#34; id&#61;&#34;post&#45;&#60;&#63;php the_ID&#40;&#41;&#59; &#63;&#62;&#34;&#62;
				&#60;h2&#62;&#60;a href&#61;&#34;&#60;&#63;php the_permalink&#40;&#41; &#63;&#62;&#34; rel&#61;&#34;bookmark&#34; title&#61;&#34;Permanent Link to &#60;&#63;php the_title_attribute&#40;&#41;&#59; &#63;&#62;&#34;&#62;&#60;&#63;php the_title&#40;&#41;&#59; &#63;&#62;&#60;&#47;a&#62;&#60;&#47;h2&#62;
				&#60;small&#62;&#60;&#63;php the_time&#40;&#39;F jS&#44; Y&#39;&#41; &#63;&#62; &#60;&#33;&#45;&#45; by &#60;&#63;php the_author&#40;&#41; &#63;&#62; &#45;&#45;&#62;&#60;&#47;small&#62;

				&#60;div class&#61;&#34;entry&#34;&#62;
					&#60;&#63;php the_content&#40;&#39;Read the rest of this entry &#38;raquo&#59;&#39;&#41;&#59; &#63;&#62;
				&#60;&#47;div&#62;

				&#60;p class&#61;&#34;postmetadata&#34;&#62;&#60;&#63;php the_tags&#40;&#39;Tags&#58; &#39;&#44; &#39;&#44; &#39;&#44; &#39;&#60;br &#47;&#62;&#39;&#41;&#59; &#63;&#62; Posted in &#60;&#63;php the_category&#40;&#39;&#44; &#39;&#41; &#63;&#62; &#124; &#60;&#63;php edit_post_link&#40;&#39;Edit&#39;&#44; &#39;&#39;&#44; &#39; &#124; &#39;&#41;&#59; &#63;&#62; &#60;&#63;php comments_popup_link&#40;&#39;No Comments &#38;&#35;187&#59;&#39;&#44; &#39;1 Comment &#38;&#35;187&#59;&#39;&#44; &#39;&#37; Comments &#38;&#35;187&#59;&#39;&#41;&#59; &#63;&#62;&#60;&#47;p&#62;
			&#60;&#47;div&#62;

		&#60;&#63;php endwhile&#59; &#63;&#62;

		&#60;&#33;&#45;&#45; pagination &#45;&#45;&#62;
		&#60;div id&#61;&#34;pagination&#34; class&#61;&#34;border clear&#45;both&#34;&#62;
		&#60;&#63;php do_action&#40;&#39;wpi_pagination&#39;&#41;&#59;&#63;&#62;
		&#60;&#47;div&#62;

	&#60;&#63;php else &#58; &#63;&#62;

		&#60;h2 class&#61;&#34;center&#34;&#62;Not Found&#60;&#47;h2&#62;
		&#60;p class&#61;&#34;center&#34;&#62;Sorry&#44; but you are looking for something that isn&#39;t here&#46;&#60;&#47;p&#62;
		&#60;&#63;php include &#40;TEMPLATEPATH &#46; &#34;&#47;searchform&#46;php&#34;&#41;&#59; &#63;&#62;

	&#60;&#63;php endif&#59; &#63;&#62;

	&#60;&#47;div&#62;

&#60;&#63;php get_sidebar&#40;&#41;&#59; &#63;&#62;

&#60;&#63;php get_footer&#40;&#41;&#59; &#63;&#62;
</pre>
<h5>is plugin active (optional)</h5>
<p><big class="dropno">3<span>)</span></big> For earlier version of WordPress <tt>(version 2.3.x &amp; below)</tt> you will need to add the following function.</p>
<p><small class="fr icn-r"><tt>functions.php</tt></small></p>
<pre class="prebox cr">if &#40;version_compare&#40;&#36;GLOBALS&#91;&#39;wp_version&#39;&#93;&#44; &#39;2&#46;5&#39;&#44; &#39;lt&#39;&#41;&#41;
&#123;
	function is_plugin_active&#40;&#36;plugin_filename&#41;
	&#123;
		&#36;plugins &#61; get_option&#40;&#39;active_plugins&#39;&#41;&#59;

			if&#40; &#33;is_array&#40;&#36;plugins&#41; &#41; settype&#40;&#36;plugins&#44;&#39;array&#39;&#41;&#59;			

		return &#40; in_array&#40;&#36;plugin_filename&#44; &#36;plugins&#41; &#41; &#59;
	&#125;
&#125;
</pre>
<h5>Register Action Hook</h5>
<p><big class="dropno">4<span>)</span></big> Open your <tt>wp-content/themes/mytheme/functions.php</tt> and add the below code.</p>
<p><small class="fr icn-r"><tt>functions.php</tt></small></p>
<pre class="prebox cr">
add_action&#40;&#39;wpi_pagination&#39;&#44;
		 &#40; is_plugin_active&#40;&#39;wp&#45;pagenavi&#47;wp&#45;pagenavi&#46;php&#39;&#41; &#41; &#63;
		 &#39;wp_pagenavi&#39; &#58; &#39;wpi_post_link&#39; &#41;&#59;
</pre>
<h3>Download example code</h3>
<ul class="xoxo">
<li>Note: There is a file embedded within this post, please visit this post to download the file.</li>
</ul>
<h2>Conclusion</h2>
<p>If you are one&#8217;s of those aspiring WP theme designer <em>&#8220;do try&#8221;</em> not to depend on third party plugins and avoid using the below phrase if possible</p>
<blockquote cite="http://blog.kaizeku.com/abou#cite"><p>&#8220;requires the following plugins to work &#8230;&#8221;</p>
</blockquote>
<p>A public release theme should be &#8220;clean from plugin dependencies&#8221; and let the end user decide what plugins they need and should have.</p>
<h2>External Links</h2>
<ul class="xoxo">
<li><a href="http://codex.wordpress.org/Plugin_API/Action_Reference" class="ext">WordPress Codex: Plugin API &rarr; Action Reference</a></li>
</ul>]]></content:encoded>
			<wfw:commentRss>http://blog.kaizeku.com/wordpress/themes-plugin-dependencies/feed/</wfw:commentRss>
		</item>
	</channel>
</rss>
