Give your WordPress plugin credit without cluttering the GUI

In a previous post I discussed the idea of locating your plugin’s Settings screen where it made sense within the Admin menus — giving an example of my own pull-quotes plugin’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 “This is a plugin!”

A massive neon Holiday Inn signI’m sure a lot of people reading that first thought “But wait! I put a lot of time into my plugin — I want people to know that it’s a plugin!” So we end up with an admin screen titled John’s Comment Filter Plugin 3.2 or worse, a “mystery meat” menu item that doesn’t identify what the plugin does at all1! That first example is somewhat like having a store with a giant flashing neon sign up front — it certainly gets the information across, but it’s not all that attractive, and very obtrusive on the surrounding landscape.

I admit that we’re riding a line here — 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. Our blogs, and our plugins, deserve better than that!

So, we’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 <title> and header. By way of example, my pull-quotes plugin is called “JavaScript Pull-Quotes”, but the Admin screen is under Design -> Pull-Quotes, and the page title and header read “Pull-Quote Settings”. The menu item and page header do not have to match the name of the plugin!

Okay, so… what if you still want to show the plugin name, and maybe have a link back to the plugin’s homepage? Simply allow your eyes to drift downward to the bottom of the admin screen…

screenshot

There’s the name of the plugin, the version number, and a link back to the home page; but it’s discreet and unobtrusive — it looks as though it belongs there. The information is there if you’re interested, but it doesn’t get in your way if you’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.

Here’s how I do it:

  • 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):
    add_action( 'in_admin_footer', 'myplugin_admin_footer' );
    

    This attaches a function to the page footer that will insert our attribution text.

  • Then of course we have to add the footer function itself:
    function myplugin_admin_footer() {
    	$plugin_data = get_plugin_data( __FILE__ );
    	printf('%1$s plugin | Version %2$s<br />', $plugin_data['Title'], $plugin_data['Version']);
    }
    

That’s pretty straightforward — all we’re doing is outputting a line of HTML — but I should point out a couple of things. First, we’re wrapping it in an if() and checking against $_SERVER['REQUEST_URI'] because we don’t want our plugin’s attribution showing up on every page. (Of course, you’ll have to change the URL string in that if() so it’s right for your particular page.) You can use in_admin_footer 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 “Comments Filter Plugin | Version 3.2 | By John Smith”. Go for it. :-) ) I definitely recommend the <br /> at the end of the text you’re inserting — otherwise it will be clumped on the same line as the existing text, which will look cluttered and will diminish your own plugin’s attribution.

We’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 really make it a consistent standard. Until then, it’s quite easy to give your own plugins credit in a way that cleanly and elegantly integrates with WordPress.

[Update: Ozh improved upon my code a bit by moving the add_action() into the function that creates the Admin page itself. It simplified things quite nicely, and the code above has been adjusted accordingly.]

[There are updates to this topic here and here.]

Previously: Use Action Links to direct users straight to your WordPress plugin’s admin page

Coming next: Consolidating your plugin’s settings so you don’t clutter up users’ wp_options tables

1: I didn’t originally intend to name names, but a good example jumped out at me recently. Under the “Manage” menu I have an item called “pageMash“. Quick (no peeking!) — what does it do??? It’s an amazing plugin, by the way, just poorly integrated in the menus.
This entry was posted in GUI Goodness, Webcraft and tagged , , , , , , , , . Bookmark the permalink.

9 Responses to Give your WordPress plugin credit without cluttering the GUI

  1. Ozh says:

    Yet another very good tip. Can’t wait for the “coming next”! :)

  2. Strider says:

    Heh.

    Coming next: Maintain interest in your blog with “Coming Next” blurbs

  3. Strider says:

    The code has been updated to include an improvement by Ozh.

    We no longer have to test what Admin page we’re on before including the footer text, because the hook for the footer text is located in the same function that creates the admin page — thus it’s only called on the page made by the plugin.

  4. Pingback: New User Email Setup Update | Epic Alex :: Web Design

  5. Pingback: Eklenti Bilgilerimiz Footer Alan?nda · Yakup Gövler - WordPress'e dair ne varsa

  6. Pingback: Announcing the “SEO Ultimate” Plugin Beta

  7. Pingback: WordPress Plugin Competition Blog » SEO Ultimate

  8. Pingback: On Attribution and Plugin Priorities in WordPress – Nerdaphernalia

  9. Pingback: Announcing the “SEO Ultimate” Plugin

Leave a Reply

Your email address will not be published.

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>