[wp-hackers] Modern Hello Dolly for your review

Viper007Bond viper at viper007bond.com
Tue May 27 02:39:27 GMT 2008


Er, minus phpdoc that is. I don't usually document my plugins to that
extent, just a small comment on what a function does most of the time. I'm
lazy.

On Mon, May 26, 2008 at 7:37 PM, Viper007Bond <viper at viper007bond.com>
wrote:

> In addition to Alexander's suggestions, the class should also not be
> started until plugins_loaded technically to ensure all functions and such
> are fully loaded. When plugin files are loaded, there are still missing
> functions such as current_user_can().
>
> Here's my shortest and simplest plugin. It contains from what my
> understanding is the "recommended" method of writing a plugin:
> http://wordpress.org/extend/plugins/dashboard-fixer/
>
>
> On Mon, May 26, 2008 at 12:34 PM, Alexander Beutl <xel at netgra.de> wrote:
>
>> 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
>>            add_action('admin_footer',
>> 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
>> Alex
>>
>>
>> 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
>> >
>> >
>> _______________________________________________
>> wp-hackers mailing list
>> wp-hackers at lists.automattic.com
>> http://lists.automattic.com/mailman/listinfo/wp-hackers
>>
>
>
>
> --
> Viper007Bond | http://www.viper007bond.com/ | http://www.finalgear.com/




-- 
Viper007Bond | http://www.viper007bond.com/ | http://www.finalgear.com/


More information about the wp-hackers mailing list