How to create extendable wordpress plugins

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 Comment