<?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>Nerdaphernalia &#187; do_action</title>
	<atom:link href="http://striderweb.com/nerdaphernalia/tag/do_action/feed/" rel="self" type="application/rss+xml" />
	<link>http://striderweb.com/nerdaphernalia</link>
	<description>"It's All Geek To Me"</description>
	<lastBuildDate>Wed, 21 Dec 2011 18:51:28 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Use Custom Actions in Your WordPress Plugins</title>
		<link>http://striderweb.com/nerdaphernalia/2008/08/use-custom-actions-in-your-wordpress-plugins/</link>
		<comments>http://striderweb.com/nerdaphernalia/2008/08/use-custom-actions-in-your-wordpress-plugins/#comments</comments>
		<pubDate>Tue, 12 Aug 2008 15:08:10 +0000</pubDate>
		<dc:creator>Stephen R</dc:creator>
				<category><![CDATA[Codecraft]]></category>
		<category><![CDATA[Webcraft]]></category>
		<category><![CDATA[add_action]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[coding]]></category>
		<category><![CDATA[do_action]]></category>
		<category><![CDATA[how to]]></category>
		<category><![CDATA[plugins]]></category>
		<category><![CDATA[WordPress]]></category>

		<guid isPermaLink="false">http://striderweb.com/nerdaphernalia/?p=172</guid>
		<description><![CDATA[If you&#8217;ve been using WordPress for any amount of time, you&#8217;ve probably come across a plugin that asks you to add something to your template. The instructions will say something like: Insert the following into your theme files where you want the plugin&#8217;s widget to appear: &#60;?php my_plugin_widget() ?&#62; The slightly more intelligent instructions will [...]]]></description>
			<content:encoded><![CDATA[<p>If you&#8217;ve been using WordPress for any amount of time, you&#8217;ve probably come across a plugin that asks you to add something to your template.  The instructions will say something like:</p>
<blockquote><p>Insert the following into your theme files where you want the plugin&#8217;s widget to appear:</p>
<p><code >&lt;?php my_plugin_widget() ?&gt;</code>
</p></blockquote>
<p>The slightly more intelligent instructions will understand that the plugin might be deactivated, and suggest you wrap the function in an <code>if()</code> that checks for its existence:</p>
<pre><code >&lt;?php
if ( function_exists( 'my_plugin_widget' ) ) {
	my_plugin_widget();
}
?&gt;</code></pre>
<p>In your own plugins, you can streamline this for the end user by wrapping your function in a custom add_action.  How?  It&#8217;s incredibly easy.  Just add an <code>add_action()</code> to your plugin file, like so:</p>
<pre><code>add_action( 'show_my_plugin_widget', 'my_plugin_widget' );

function my_plugin_widget() {
	...
}</code></pre>
<p>Now your users can use one straightforward line in their templates.</p>
<pre><code>&lt;?php do_action('show_my_plugin_widget'); ?&gt;</code></pre>
<p>One short line of code.  No worrying about deactivated plugins.  A small extra effort on your end can save your end users some frustration down the road.</p>
<p class="note">Next Time: Cold Fusion!  (article may be delayed by technical feasibility)</p>
<p class="note">Previously: <a href="http://striderweb.com/nerdaphernalia/2008/07/use-classes-in-your-wordpress-plugins/">Use Classes in your WordPress plugins to increase code portability and reduce name conflicts</a></p>
<hr />
© <a href="http://striderweb.com/">Stephen Rider</a> 2008
<p>This article was originally published at <a href="http://striderweb.com/nerdaphernalia">Nerdaphernalia</a>.  <a href="http://planetwordpress.planetozh.com/" rel="nofollow">Planet WordPress</a> is authorized to reproduce WordPress-related entries.  <em>If you're reading this at any other web site, the site owner is stealing copyrighted work.  Please visit the original page:</em></p>

<small><a href="http://striderweb.com/nerdaphernalia/2008/08/use-custom-actions-in-your-wordpress-plugins/">Permalink to Use Custom Actions in Your WordPress Plugins</a></small>
<p><small>Feed enhanced by <a href='http://planetozh.com/blog/my-projects/wordpress-plugin-better-feed-rss/'>Better Feed</a> from  <a href='http://planetozh.com/blog/'>Ozh</a></small></p>
]]></content:encoded>
			<wfw:commentRss>http://striderweb.com/nerdaphernalia/2008/08/use-custom-actions-in-your-wordpress-plugins/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
	</channel>
</rss>

