When it comes to plugin development – be it either widgets or plugins – there are several different ways in which we can instantiate a WordPress plugin.
Unfortunately, you’re likely to get a different answer depending on who you ask, or what you read.
Case in point: According to the WordPress Codex, instantiating a WordPress widget is done like this:
add_action( 'widgets_init', create_function( '', 'register_widget( "foo_widget" );' ) );
But I know several people who are adamantly against using create_function.
Though I personally don’t have a problem with it, I’m always interested in hearing others’ approach to how they do it and why.
So in this post, I thought I’d lay out the various ways to instantiate a WordPress plugin, pros and cons of each, but also ask each of you what your favorite method is and why.


