[wp-hackers] Modern Hello Dolly for your review

Alexander Beutl xel at netgra.de
Mon May 26 19:34:08 GMT 2008

Hi Tom,
seems ok but I only looked some seconds...

What I would recommend is put the following stuff inside the constructor
since this would make it possible to create new instances which would add
themselfe automatically to the right places. Alternativly create a method
which calls the hooks. This way you can use $this which is perfect since it
can be used universally when inside the plugin classes methods.

        if ( function_exists('add_action') ) {
            // Now we set that function up to execute when the admin_footer
action is called
array(&$matt_hellodolly,'hello_dolly') );
            add_action('admin_head', array(&$matt_hellodolly,'dolly_css') );

What I would really recommend would be to create a parent class "plugin"
which can be extended. This would drop any needs to check for functions
since they could be mapped inside this plugin class (which should then be
part of core and therefor up to date at any time).
This would make it possible to use something like
$this->add_action('foo','bar'); instead of the
add_action('foo',array(&$this,'bar')); which would be really handy.

Just my thoughts

2008/5/26 Tom Ransom <automattic.713k at tomransom.com>:

> Risking considerable flames, I am positing a "modern" Hello Dolly plug-in.
> I have been working on developing WP plugins for clients and like most,
> learned by opening and reviewing other's plugins. The first plug-in we all
> look at is Hello Dolly. But Hello Dolly hasn't changed much since Matt first
> released it. (and why should it?)
> I took a few moments this week to put together a "modern" Hello Dolly
> plug-in that others could use a template.  Some of the features include:
> - Object-oriented class architecture (with PHP4/PHP5 construct/destruct)
> - Tests that functions have been defined for executing them
> - Tests that the class was successful constructed
>   i.e. shouldn't break WordPress if the API were to change in the future (a
> best practice?)
> I am posting this for your comments. I recently finished another plugin
> using these coding practices and was looking for a peer code review. I
> thought that Hello Dolly would be a perfect place to get feedback from
> long-time WordPress hackers on use of classes and coding (and
> documentation?) best practices.
> I am attaching Hello Dolly, but on the chance that the mailing list engine
> strips attachments - I am also posting it at
> http://1bigidea.com/blog/wordpress
> Thanks, and I am really looking forward to your feedback after this (U.S.)
> holiday weekend.
> regards,
> Tom Ransom
> 1bigidea.com
> _______________________________________________
> wp-hackers mailing list
> wp-hackers at lists.automattic.com
> http://lists.automattic.com/mailman/listinfo/wp-hackers

More information about the wp-hackers mailing list