I have a generic question that I would like to ask.

How do we go about creating an extendable wordpress plugin. I would like to create a plugin that I can easily allow new extensions to be hooked up to it.

Does anyone have any tips or guides or tutorials to doing this?

2 Answers
2

The following:

  • Use hooks and filters to power things. Pass args into a filter before doing things with them, pass return values to filters before returning them, etc, hooks and filters everywhere
  • namespace everything, tomjn_twittercount is a better function name than twittercount
  • Practice good common sense generic programming, e.g. use dependency injection, use proper OOP ( a single class containing a bunch of functions isn’t OOP )
  • Document your APIs
  • Use your APIs internally to build the plugin
  • Document your APIs
  • Did I mention documenting your APIs?

I’d suggest using PHPDoc inline documentation extensively. It’ll allow you to auto-generate documentation using PHP Documentor

e.g.

/**
 * Prints hello world
 * 
 * @access private
 * @abstract
 * @return void
 */
 private function helloworld() {
     echo 'hello world';
 }

Leave a Reply

Your email address will not be published. Required fields are marked *