How to create extendable wordpress plugins

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?

Solutions Collecting From Web of "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


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

It is about creating custom hooks. The main ways is by using apply_filters() and do_action().

More detailed explanations is here