Who owns the function? [from Plugins development series]

Published: On Thursday, February 12, 2009

Once again, I find useful to recommend remind one important practice, when writing a plugin.

Be sure, that user will notice, he's using functions of your plugin.

Life example: In the first project, user did use the get_meta function and expected, it's a core function. It didn't do anything specific. Why should he ever expect, it's part of a plugin? But once he tried to use this function elsewhere, it surprisingly failed, function wasn't found. The (in other ways great) plugin called More fields was missing.

Two ways how to emphasize function's owner:

  • prefix function-name with your unique signature (will also lower the risk of name-collision): get_meta ⇒ mf_get_meta
  • use a bundling class: get_metaMoreFields::get_meta
Actually, WordPress itself should practise this habit too – since any function is in fact a part of a bigger unit.

Useful? Bookmark or share:

  • email
  • Digg
  • del.icio.us
  • StumbleUpon
  • Reddit
  • Propeller
  • Twitter

Comments

No comments yet.

Add a comment