<?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; how to</title>
	<atom:link href="http://striderweb.com/nerdaphernalia/tag/how-to/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.2</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>
		<item>
		<title>Use Classes in your WordPress plugins to increase code portability and reduce name conflicts</title>
		<link>http://striderweb.com/nerdaphernalia/2008/07/use-classes-in-your-wordpress-plugins/</link>
		<comments>http://striderweb.com/nerdaphernalia/2008/07/use-classes-in-your-wordpress-plugins/#comments</comments>
		<pubDate>Mon, 28 Jul 2008 15:16:21 +0000</pubDate>
		<dc:creator>Stephen R</dc:creator>
				<category><![CDATA[Codecraft]]></category>
		<category><![CDATA[Webcraft]]></category>
		<category><![CDATA[classes]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[efficiency]]></category>
		<category><![CDATA[how to]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[plugins]]></category>
		<category><![CDATA[WordPress]]></category>

		<guid isPermaLink="false">http://striderweb.com/nerdaphernalia/?p=102</guid>
		<description><![CDATA[One of the most powerful features of WordPress is the huge community of developers making plugins that extend the software far beyond what the core application provides. It also allows people to add just what they want to use, rather than having a single bloated homogeneous download. There are drawbacks as well, of course. Any [...]]]></description>
			<content:encoded><![CDATA[<p>One of the most powerful features of WordPress is the huge community of developers making plugins that extend the software far beyond what the core application provides.  It also allows people to add just what they want to use, rather than having a single bloated homogeneous download.  There are drawbacks as well, of course.</p>
<p>Any time a software package opens itself up to third-party additions, there is a potential for mischief.  With WordPress, different plugins can end up stumbling over each other, as each is coded for the core but doesn&#8217;t anticipate other plugins.  You can also have naming conflicts &#8212; when functions or variables in different plugins are given the same name.  This is often avoided by adding the plugin name to the beginning of each and every function, variable, constant, etc.</p>
<p>If you have multiple plugins, you probably have a good bit of code that you reuse in all of them.  If you&#8217;ve been appending the plugin name all along, then any time you update those common functions, you can&#8217;t simply copy the new versions over to the other plugins &#8212; you have to go over them and update the function names and any internal calls from one function to another.<span class="pullquote"><!-- These problems can be avoided by using classes --></span></p>
<p>These problems and others can be avoided by using classes.</p>
<p>By wrapping your plugin&#8217;s functions in a PHP class, you gain a number of advantages.  You can set plugin-wide variables.  You can use common function names and create easily-remembered &#8220;wrapper&#8221; functions that modify the way common WP functions do things.  You can create portable functions that can be copy-pasted into other plugins without any adjustment.</p>
<p>Ready?  Let&#8217;s get started&#8230;(...)<br/>Read the rest of <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> (835 words)</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/07/use-classes-in-your-wordpress-plugins/">Permalink to Use Classes in your WordPress plugins to increase code portability and reduce name conflicts</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/07/use-classes-in-your-wordpress-plugins/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>On Attribution and Plugin Priorities in WordPress</title>
		<link>http://striderweb.com/nerdaphernalia/2008/07/on-attribution-and-plugin-priorities-in-wordpress/</link>
		<comments>http://striderweb.com/nerdaphernalia/2008/07/on-attribution-and-plugin-priorities-in-wordpress/#comments</comments>
		<pubDate>Tue, 15 Jul 2008 16:42:07 +0000</pubDate>
		<dc:creator>Stephen R</dc:creator>
				<category><![CDATA[GUI Goodness]]></category>
		<category><![CDATA[Webcraft]]></category>
		<category><![CDATA[attribution]]></category>
		<category><![CDATA[caution]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[consistency]]></category>
		<category><![CDATA[GUI]]></category>
		<category><![CDATA[how to]]></category>
		<category><![CDATA[manners]]></category>
		<category><![CDATA[plugins]]></category>
		<category><![CDATA[priority]]></category>
		<category><![CDATA[standards]]></category>
		<category><![CDATA[WordPress]]></category>

		<guid isPermaLink="false">http://striderweb.com/nerdaphernalia/?p=83</guid>
		<description><![CDATA[A few weeks ago I wrote instructions on putting a plugin attribution in the footer of your plugin&#8217;s Admin/Settings screen. It&#8217;s a good technique, and I&#8217;ve already seen a few plugins using it. I&#8217;ve noticed somewhat of an issue recently. This is nothing Earth-shaking, nor will it break anybody&#8217;s blog; it&#8217;s really just a matter [...]]]></description>
			<content:encoded><![CDATA[<p>A few weeks ago I wrote instructions on <a href="http://striderweb.com/nerdaphernalia/2008/06/give-your-wordpress-plugin-credit/">putting a plugin attribution in the footer of your plugin&#8217;s Admin/Settings screen</a>.  It&#8217;s a good technique, and I&#8217;ve already seen a few plugins using it.  I&#8217;ve noticed somewhat of an issue recently.  This is nothing Earth-shaking, nor will it break anybody&#8217;s blog; it&#8217;s really just a matter of politeness.  Fixing it, however, involves a simple, powerful, and frequently overlooked, feature of calling hooks and filters in your plugins.</p>
<p>The issue that came up is that there is a plugin using the footer attribution, but because the plugin affects every page of the Admin section, the author chose to put the footer on every page instead of just on the plugin&#8217;s Settings page.  I don&#8217;t really have an issue with that &#8212; I do it myself with the <a href="http://striderweb.com/nerdaphernalia/features/virtual-multiblog/">Virtual Multiblog</a> (&#8220;VMB&#8221;) system &#8212; but the main point of the technique is discretion, and if many plugin authors start adding attributions to every single admin page, things are going to get awfully messy.  <span class="pullquote">I can&#8217;t wait to have an admin footer eight or ten lines long</span>!</p>
<p>So, I guess part one of this is an admonition:  Think hard about it before deciding that your plugin rates a, er&#8230; plug throughout the entire Admin section.  Maybe it does, but for the vast majority, it&#8217;s probably best to stick to just the footer on that plugin&#8217;s own page.  (I do it with <abbr title="Virtual Multiblog">VMB</abbr> because WordPress is running entirely on top of that system &#8212; it can affect <em>everything</em> WordPress does.)  Also, if you do put it on every page, be brief.  Don&#8217;t be chatty.  (The <abbr title="Virtual Multiblog">VMB</abbr> footer is two words long.)  As I suggested in the original article, make it look like it belongs there.</p>
<p>The second part of this is a small change to the code if you <em>are</em> going to put it on every page:  Set a later-than-default priority when calling the hook.  Why?  This one is a matter of politeness to other plugin authors.  If another author is also adding an attribution to just his plugin&#8217;s page, your &#8220;every page&#8221; footer should come <em>after</em> it.  (Also, it&#8217;s in keeping with the overall trend:  Page Specific, then Whole Admin, then WordPress.)</p>
<p>The change will take you about three seconds.  Ready?  Change this:</p>
<pre><code>add_action( 'in_admin_footer', 'myplugin_admin_footer' );</code></pre>
<p>to this:</p>
<pre><code>add_action( 'in_admin_footer', 'myplugin_admin_footer', 11 );</code></pre>
<p>What we&#8217;ve just done is set the priority for that call.  The default (if you don&#8217;t put any number there) is 10.  By setting it to 11, we&#8217;re saying that it should come just after the default run of that hook.  (We could set it lower than 10 also, but again, that would be kind of rude in this case&#8230;.)</p>
<p>This is a subtle but excellent technique for plugins.  <span class="pullquote"><!-- a good way to make your plugin compatible with another plugin --></span>It&#8217;s a good way to make your plugin <a href="#fnote83_1" class="fnotelink">compatible with another plugin<sup>*</sup></a> &#8212; setting your priority higher or lower so it runs before or after that other plugin (or as the case may warrant, convincing the other plugin&#8217;s author to do so).  The general range for the priority is from 1 to 20.  I&#8217;ve rarely set it anything other than 9 or 11 of I set it at all; though I&#8217;ve seen plugin authors set it in the thousands when they want to be <em>really, <strong>really</strong></em> sure that it runs after everything else.  (This of course can escalate into a rather silly &#8220;numbers race&#8221; &#8212; well, some other guy does his at a thousand, I&#8217;ll do mine at two thousand just to be sure.  Hm&#8230; some other guy set his to two thousand &#8212; I&#8217;ll make mine ten thousand&#8230;&#8230;..)  The &#8220;exteme end&#8221; standard seems to be around 995-1000 in the plugins I&#8217;ve looked at.  I wouldn&#8217;t go much beyond that.   If someone else wants to make theirs an even million, that&#8217;s their problem.</p>
<p>So putting it all briefly:  think twice before putting your footer on every page of the admin, and if you do, set the priority to 11 so that page specific footers will come first.</p>
<div class="fnote" id="fnote83_1">*: I remember an example of Plugin A specifically advertising compatibility with Plugin B.  Both made CSS changes to the Admin, but the instructions for Plugin A said &#8220;To use this with Plugin B, open up that plugin&#8217;s file and change such-and-such code.&#8221;  Some compatibility!  I emailed the author and suggested setting the later priority, so that his CSS came later.  He was very happy with the results, and his users didn&#8217;t have to edit files any more.</div>
<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/07/on-attribution-and-plugin-priorities-in-wordpress/">Permalink to On Attribution and Plugin Priorities in WordPress</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/07/on-attribution-and-plugin-priorities-in-wordpress/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Consolidate Options with Arrays in your WordPress Plugins</title>
		<link>http://striderweb.com/nerdaphernalia/2008/07/consolidate-options-with-arrays/</link>
		<comments>http://striderweb.com/nerdaphernalia/2008/07/consolidate-options-with-arrays/#comments</comments>
		<pubDate>Tue, 08 Jul 2008 22:24:15 +0000</pubDate>
		<dc:creator>Stephen R</dc:creator>
				<category><![CDATA[Codecraft]]></category>
		<category><![CDATA[Webcraft]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[elegant design]]></category>
		<category><![CDATA[how to]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[plugins]]></category>
		<category><![CDATA[settings]]></category>
		<category><![CDATA[software]]></category>
		<category><![CDATA[tutorials]]></category>
		<category><![CDATA[WordPress]]></category>

		<guid isPermaLink="false">http://striderweb.com/nerdaphernalia/?p=78</guid>
		<description><![CDATA[If you&#8217;ve ever written a plugin for WordPress you&#8217;ve probably dealt with giving the end user options. Unless you&#8217;ve taken the low road and forced the user to directly edit the plugin file, &#8220;options&#8221; means a Settings screen in the WordPress admin, and most likely you are storing those options in the blog&#8217;s wp-options table. [...]]]></description>
			<content:encoded><![CDATA[<p>If you&#8217;ve ever written a plugin for WordPress you&#8217;ve probably dealt with giving the end user options.  Unless you&#8217;ve taken the low road and forced the user to directly edit the plugin file, &#8220;options&#8221; means a Settings screen in the WordPress admin, and most likely you are storing those options in the blog&#8217;s <code>wp-options</code> table.  Over time, bloggers using various plugins can end up with hundreds of <a href="#fnote78_1" class="fnotelink">extraneous records in their options table<sup>*</sup></a>.  If they ever stop using a plugin, or if they ever want to manually clear out options, this job can be made difficult by all the clutter, and the problem is made far worse when plugin authors add a new record for each separate setting in a plugin.  Beyond the mess, plugins written this way generally make many more calls to the database than they need to, which adds unnecessary burden on the server.</p>
<p>I have seen and used plugins that added anywhere from ten to thirty new records to the options table, and a correspondent of mine reports that he has encountered a plugin that, upon activation, adds <span class="pullquote"><!-- A whopping 140 new records.... Egad! -->a whopping <em>140</em> new records to <code>wp_options</code>.   Egad!</span>  There has to be a better way!</p>
<p>There <em>is</em> a better way.  With a few simple changes to your code, plugin authors can put all the various settings into an array, and enter that array as a single record in the options table.  This article will show you how.</p>
<p>On this site I use a plugin called ShrinkyLink.  It performs the straightforward but useful function of shortening long URLs to a specified length, or replacing the link text entirely with a specified string.  It was created by Andrew Rader, but as far as I can tell his web site no longer exists. For the purposes of this article, it has a number of good qualities:</p>
<ul>
<li>It inserts 10 separate records into the WordPress options table</li>
<li>It is not likely to see further updates from the original author</li>
<li>It is useful and thus worthy of updating</li>
<li>The original author was kind enough to release it under the <a href="http://www.gnu.org/licenses/gpl-2.0.html">GPL2 license</a></li>
</ul>
<p>The last version of ShrinkyLink was 0.2, released in 2006.  Today we&#8217;re going to begin the rehabilitation of this plugin and create a version 0.3 that stores all its settings in a single array.</p>
<p>I&#8217;m going to split this into multiple sections:</p>
<ol>
<li>How to set and retrieve settings using arrays</li>
<li>Upgrading your plugin&#8217;s Admin Screen form to use an array</li>
<li>Upgrading existing settings from multiple records to a single array</li>
</ol>
<p>Let&#8217;s get to it.</p>
<p>(...)<br/>Read the rest of <a href="http://striderweb.com/nerdaphernalia/2008/07/consolidate-options-with-arrays/">Consolidate Options with Arrays in your WordPress Plugins</a> (1,731 words)</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/07/consolidate-options-with-arrays/">Permalink to Consolidate Options with Arrays 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/07/consolidate-options-with-arrays/feed/</wfw:commentRss>
		<slash:comments>33</slash:comments>
		</item>
		<item>
		<title>WordPress plugin attribution footer &#8212; update</title>
		<link>http://striderweb.com/nerdaphernalia/2008/07/wordpress-plugin-attribution-footer-update/</link>
		<comments>http://striderweb.com/nerdaphernalia/2008/07/wordpress-plugin-attribution-footer-update/#comments</comments>
		<pubDate>Fri, 04 Jul 2008 03:49:07 +0000</pubDate>
		<dc:creator>Stephen R</dc:creator>
				<category><![CDATA[GUI Goodness]]></category>
		<category><![CDATA[Webcraft]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[credit]]></category>
		<category><![CDATA[how to]]></category>
		<category><![CDATA[plugins]]></category>
		<category><![CDATA[WordPress]]></category>

		<guid isPermaLink="false">http://striderweb.com/nerdaphernalia/?p=77</guid>
		<description><![CDATA[In a recent post I showed how to put an attribution in the footer of your plugin&#8217;s admin screen. In the example I gave, I used a format of: MyWidget plugin &#124; Version 1.0 I have seen a few plugins already updated and using this methodology, but for the most part authors are adding a [...]]]></description>
			<content:encoded><![CDATA[<p>In a <a href="http://striderweb.com/nerdaphernalia/2008/06/give-your-wordpress-plugin-credit/">recent post</a> I showed how to put an attribution in the footer of your plugin&#8217;s admin screen.  In the example I gave, I used a format of:</p>
<p>MyWidget plugin | Version 1.0</p>
<p>I have seen a few plugins already updated and using this methodology, but for the most part authors are adding a third bit of information to that string, namely, themselves.</p>
<p>MyWidget plugin | Version 1.0 | by John Smith</p>
<p>Another thing that has happened since I posted that is that <a href="http://planetozh.com/">Ozh</a> came up with a better way to call the in_admin_footer hook.  Rather than calling it during init and then having to keep testing to see  what page is being displayed, he simply dropped the call into the function that creates the actual admin page.  That way, it&#8217;s only ever called in the first place when the admin page is created.  Nice improvement.</p>
<p>So in the continued interest of creating a relative standard, here&#8217;s an updated version of the footer plugin, including the author information:</p>
<pre>
<code >function myplugin_admin_footer() {
	$plugin_data = get_plugin_data( __FILE__ );
	printf('%1$s plugin | Version %2$s | by %3$s&lt;br /&gt;', $plugin_data['Title'], $plugin_data['Version'], $plugin_data['Author']);
}</code>
</pre>
<p>Remember to take the add_action and put it <em>inside</em> the function that echoes the admin page.  As a reminder, here&#8217;s the add_action that calls that footer:</p>
<pre>
<code >add_action( 'in_admin_footer', 'myplugin_admin_footer' );</code>
</pre>
<p>The original article is <a href="http://striderweb.com/nerdaphernalia/2008/06/give-your-wordpress-plugin-credit/">here</a>.</p>
<p>&#8230;and to all the people in the USA who are (not) reading this tonight, Happy 4th of July! <img src='http://striderweb.com/nerdaphernalia/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p class="update">[A further post on this topic is <a href="http://striderweb.com/nerdaphernalia/2008/07/on-attribution-and-plugin-priorities-in-wordpress/">here</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/07/wordpress-plugin-attribution-footer-update/">Permalink to WordPress plugin attribution footer &#8212; update</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/07/wordpress-plugin-attribution-footer-update/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Give your WordPress plugin credit without cluttering the GUI</title>
		<link>http://striderweb.com/nerdaphernalia/2008/06/give-your-wordpress-plugin-credit/</link>
		<comments>http://striderweb.com/nerdaphernalia/2008/06/give-your-wordpress-plugin-credit/#comments</comments>
		<pubDate>Mon, 30 Jun 2008 13:34:03 +0000</pubDate>
		<dc:creator>Stephen R</dc:creator>
				<category><![CDATA[GUI Goodness]]></category>
		<category><![CDATA[Webcraft]]></category>
		<category><![CDATA[blogging]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[GUI]]></category>
		<category><![CDATA[how to]]></category>
		<category><![CDATA[integration]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[plugins]]></category>
		<category><![CDATA[tutorials]]></category>
		<category><![CDATA[WordPress]]></category>

		<guid isPermaLink="false">http://striderweb.com/nerdaphernalia/?p=73</guid>
		<description><![CDATA[In a previous post I discussed the idea of locating your plugin&#8217;s Settings screen where it made sense within the Admin menus &#8212; giving an example of my own pull-quotes plugin&#8217;s Settings going under the Design menu. I briefly touched on a further aspect of this, when I suggested that authors not make their plugins [...]]]></description>
			<content:encoded><![CDATA[<p>In a <a href="/nerdaphernalia/2008/06/on-plugin-design/">previous post</a> I discussed the idea of locating your plugin&#8217;s Settings screen where it made sense within the Admin menus &#8212; giving an example of my own pull-quotes plugin&#8217;s Settings going under the Design menu.  I briefly touched on a further aspect of this, when I suggested that authors not make their plugins scream &#8220;This is a plugin!&#8221;</p>
<p><img src="/wp-content/docs/nerd/images/holiday_inn_sign.jpg" alt="A massive neon Holiday Inn sign" title="Ah, the 70s..." style="float: right;" />I&#8217;m sure a lot of people reading that first thought &#8220;But wait!  I put a lot of time into my plugin &#8212; I <em>want</em> people to know that it&#8217;s a plugin!&#8221;  So we end up with an admin screen titled <strong>John&#8217;s Comment Filter Plugin 3.2</strong> or worse, a &#8220;<a href="http://en.wikipedia.org/wiki/Mystery_meat_navigation">mystery meat</a>&#8221; menu item that <a href="#fnote73_1" class="fnotelink">doesn&#8217;t identify what the plugin does at all<sup>1</sup></a>!  That first example is somewhat like having a store with a giant flashing neon sign up front &#8212; it certainly gets the information across, but it&#8217;s not all that attractive, and very obtrusive on the surrounding landscape.</p>
<p>I admit that we&#8217;re riding a line here &#8212; we all want credit for our hard work; but awkward plugin integration, spread out over multiple plugins, can end up making WordPress itself look awfully kludgy.  <span class="pullquote pqLeft"><!-- Our plugins deserve better -->Our blogs, and our plugins, deserve better than that!</span></p>
<p>So, we&#8217;re looking for a way to give credit where credit is due, while maintaining a clean integrated interface that looks as though it were a part of WordPress from the beginning.  First, name the menu item for what the screen is for, not what the plugin is called.  Ditto the page &lt;title&gt; and header.  By way of example, my pull-quotes plugin is called &#8220;JavaScript Pull-Quotes&#8221;, but the Admin screen is under Design -&gt; Pull-Quotes, and the page title and header read &#8220;Pull-Quote Settings&#8221;.  The menu item and page header do <em>not</em> have to match the name of the plugin!</p>
<p>Okay, so&#8230; what if you still want to show the plugin name, and maybe have a link back to the plugin&#8217;s homepage?  Simply allow your eyes to drift downward to the bottom of the admin screen&#8230;</p>
<p><img src="/wp-content/docs/nerd/images/discreet_plugin_attribution.png" height="146" width="469" alt="screenshot" title="" /></p>
<p>There&#8217;s the name of the plugin, the version number, and a link back to the home page; but it&#8217;s discreet and unobtrusive &#8212; it looks as though it belongs there.  The information is there if you&#8217;re interested, but it doesn&#8217;t get in your way if you&#8217;re not; giving us a good balance between giving credit and keeping the GUI clean.  Of course, if enough plugin authors start doing it on all their plugins, people will come to expect that bit of extra info, and that little slice of screen real estate will be as good as gold.</p>
<p>Here&#8217;s how I do it:</p>
<ul>
<li>Within the function that creates the content of the Admin page itself, put the following line (probably best at the very beginning or very end of the function):
<pre><code>add_action( 'in_admin_footer', 'myplugin_admin_footer' );</code>
</pre>
<p>This attaches a function to the page footer that will insert our attribution text.
</li>
<li>Then of course we have to add the footer function itself:
<pre><code>function myplugin_admin_footer() {
	$plugin_data = get_plugin_data( __FILE__ );
	printf('%1$s plugin | Version %2$s&lt;br /&gt;', $plugin_data['Title'], $plugin_data['Version']);
}</code>
</pre>
</li>
</ul>
<p>That&#8217;s pretty straightforward &#8212; all we&#8217;re doing is outputting a line of HTML &#8212; but I should point out a couple of things.  <del datetime="2008-07-02T04:35:59+00:00" title="Removed -- see update note at bottom of article">First, we&#8217;re wrapping it in an <code>if()</code> and checking against <code>$_SERVER['REQUEST_URI']</code> because we don&#8217;t want our plugin&#8217;s attribution showing up on every page.  (Of course, you&#8217;ll have to change the URL string in that <code>if()</code> so it&#8217;s right for your particular page.)</del>  You can use <code>in_admin_footer</code> to insert anything you like, of course, but in the interests of creating something resembling a standard, I hope you consider sticking to the format I give above.  (One alternate that comes to mind, however, is that some people might prefer to use something like &#8220;Comments Filter Plugin | Version 3.2 | By John Smith&#8221;.  Go for it. <img src='http://striderweb.com/nerdaphernalia/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' />  )  I definitely recommend the <code >&lt;br /&gt;</code> at the end of the text you&#8217;re inserting &#8212; otherwise it will be clumped on the same line as the existing text, which will look cluttered and will diminish your own plugin&#8217;s attribution.</p>
<p>We&#8217;ve just torn down the ugly neon sign, and replaced it with an engraved brass plaque next to the door.  Not too bad, that.  In the longer run, this is something that might be nice to roll into core WordPress code, which would <em>really</em> make it a consistent standard.  Until then, it&#8217;s quite easy to give your own plugins credit in a way that cleanly and elegantly integrates with WordPress.</p>
<p class="update">[Update: Ozh improved upon my code a bit by moving the <code>add_action()</code> into the function that creates the Admin page itself.  It simplified things quite nicely, and the code above has been adjusted accordingly.]</p>
<p class="update">[There are updates to this topic <a href="http://striderweb.com/nerdaphernalia/2008/07/wordpress-plugin-attribution-footer-update/">here</a> and <a href="http://striderweb.com/nerdaphernalia/2008/07/on-attribution-and-plugin-priorities-in-wordpress/">here</a>.]</p>
<p class="note">Previously: <a href="/nerdaphernalia/2008/06/wp-use-action-links/">Use Action Links to direct users straight to your WordPress plugin&#8217;s admin page</a></p>
<p class="note">Coming next: <a href="/nerdaphernalia/2008/07/consolidate-options-with-arrays/">Consolidating your plugin&#8217;s settings so you don&#8217;t clutter up users&#8217; <code>wp_options</code> tables</a></p>
<div class="fnote" id="fnote73_1">1: I didn&#8217;t originally intend to name names, but a good example jumped out at me recently.  Under the &#8220;Manage&#8221; menu I have an item called &#8220;<a href="http://joelstarnes.co.uk/pagemash/">pageMash</a>&#8220;.  Quick (no peeking!) &#8212; what does it do???  It&#8217;s an <em>amazing</em> plugin, by the way, just poorly integrated in the menus.</div>
<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/06/give-your-wordpress-plugin-credit/">Permalink to Give your WordPress plugin credit without cluttering the GUI</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/06/give-your-wordpress-plugin-credit/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>Use Action Links to direct users straight to your WordPress plugin&#8217;s admin page</title>
		<link>http://striderweb.com/nerdaphernalia/2008/06/wp-use-action-links/</link>
		<comments>http://striderweb.com/nerdaphernalia/2008/06/wp-use-action-links/#comments</comments>
		<pubDate>Thu, 19 Jun 2008 14:30:12 +0000</pubDate>
		<dc:creator>Stephen R</dc:creator>
				<category><![CDATA[GUI Goodness]]></category>
		<category><![CDATA[Webcraft]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[GUI]]></category>
		<category><![CDATA[how to]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[plugins]]></category>
		<category><![CDATA[tutorials]]></category>
		<category><![CDATA[WordPress]]></category>

		<guid isPermaLink="false">http://striderweb.com/nerdaphernalia/?p=72</guid>
		<description><![CDATA[I&#8217;ve recently come across repeated discussions (especially on the wp-hackers mailing list) debating where plugin authors should place their custom admin pages. I discussed that question directly in my previous post, and basically stated that the plugin&#8217;s admin page can go any number of places, depending on what the plugin does. Some people disagree with [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve recently come across repeated discussions (especially on the <a href="http://lists.automattic.com/mailman/listinfo/wp-hackers">wp-hackers mailing list</a>) debating where plugin authors should place their custom admin pages.  I discussed that question directly in my <a href="/nerdaphernalia/2008/06/on-plugin-design/" title="Nerdaphernalia: On Plugin Design and Integration">previous post</a>, and basically stated that the plugin&#8217;s admin page can go any number of places, depending on what the plugin does.  Some people disagree with this argument, saying that <strong>all</strong> plugin admin screens should go under one menu &#8212; usually &#8220;Settings&#8221; or &#8220;Plugins&#8221;, depending on whom you ask.</p>
<p><span class="pullquote">While I disagree, they do raise one good point</span>:  many end users will have trouble finding your admin page because they have come to expect such pages to all be dumped under Settings.  Many plugin authors solve this by hard coding a link into the plugin Description, but this really isn&#8217;t the right place for that, and it can create inappropriate clutter in <a class="fnotelink" href="#fnote72_1">certain situations<sup>1</sup></a>.  There is a better way.</p>
<p>WordPress 2.5 makes it fairly easy for plugin authors to add &#8220;action&#8221; links to the Plugin Management screen, like so:</p>
<p><img src="/wp-content/docs/nerd/images/plugin_action_link.gif" alt='Screen shot of a "Settings" link next to the normal plugin "Deactivate" link' title="" height="68" width="488" /><br />
(...)<br/>Read the rest of <a href="http://striderweb.com/nerdaphernalia/2008/06/wp-use-action-links/">Use Action Links to direct users straight to your WordPress plugin&#8217;s admin page</a> (522 words)</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/06/wp-use-action-links/">Permalink to Use Action Links to direct users straight to your WordPress plugin&#8217;s admin page</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/06/wp-use-action-links/feed/</wfw:commentRss>
		<slash:comments>16</slash:comments>
		</item>
	</channel>
</rss>

