In: , , ,
On: 2008 / 06 / 30 Viewed: 56309 times
Shorter URL for this post: http://ozh.in/in

Stephen, on his geek blog Nerdaphernalia, is running a series of excellent posts giving advices to plugin authors for neat subtle effects: adding a "Configure" link right next to the "Activate" link on the Plugins page, or how to give credit to your plugin without cluttering the page (I'm a big fan of the "Configure" link trick, that I've added to my latest release of Better Feed and will definitely implement in all my plugins now)

What's coming next on Stephen's blog is what seems to be my biggest pet peeve regarding plugins: saving plugin settings without cluttering the option table. I've had a draft post here for about 18 months about plugin coding tips and guidelines, and for sure its main point would be: "for f*ck sake, why don't you save all your options into just one array into just one entry??"

Taken from an actual plugin (slightly changed for anonymity) randomly found on my test blog (warning: NSFW)

  1. /*Lets add some default options if they don't exist*/
  2. add_option('xxx_email', get_option('admin_email'));
  3. add_option('xxx_subject', 'From Website');
  4. add_option('xxx_success_msg', 'Thanks, your email has been sent!');
  5. add_option('xxx_error_msg', 'Please fill in the required fields');
  6. add_option('xxx_error_msg_2', 'You have not entered a valid email address');
  7. add_option('xxx_error_msg_3', 'That destination does not appear to exist');
  8. add_option('xxx_redirect_loc', get_option('siteurl'));
  9. add_option('xxx_redirect_time', '3');
  10. add_option('xxx_css_inject', '1');
  11. add_option('xxx_cc_myself', '1');
  12. add_option('xxx_user_subject', '1');

Arrrgh. When I look at a plugin for the first time, the very first thing I do is literally count the occurrences of "add_option". More than 3 and the plugin is a no-no on my blog.

Executive summary: read Nerdaphernalia (I mean, if you're not a subscriber of Planet WordPress already). And wait a few more months for my "10 stuff to do to write proper plugins" article :Þ

Shorter URL

Want to share or tweet this post? Please use this short URL: http://ozh.in/in

Metastuff

This entry "WordPress Plugin Coding Tips" was posted on 30/06/2008 at 9:57 pm and is tagged with , , ,
Watch this discussion : Comments RSS 2.0.

2 Blablas

  1. 1
    Stephen R United States »
    wrote, on 01/Jul/08 at 12:11 am # :

    NSFW??? Must be all that "xxx" material.

  2. 2
    2008 Plugin Competition Review, Part One... United States »
    pingback on 07/Aug/08 at 11:25 am # :

    […] a single nanosecond reading files it doesn't need. But most of all, the plugin fails with my main coding concern: add all your options into one single database entry, damnit! I totally hate it when doing some DB […]

Leave a Reply

Comment Guidelines or Die

  • HTML: You can use these tags: <a href=""> <em> <i> <b> <strong> <blockquote>
  • Posting code: Post raw code (no <> &lt; etc) within appropriate tags : [php][/php], [css][/css], [html][/html], [js][/js], [sql][/sql], [xml][/xml], or generic [code][code]
  • Gravatars: Curious about the little images next to each commenter's name ? Go to Gravatar.
  • Spam: Various spam plugins on patrol. I'll put pins in a Voodoo doll if you spam me.
  • I will mark as Spam test comments, all comments with SEO names (ie "My Cool Online Shop" instead of "Joe") or containing forum-like signatures.

Read more ?