[wp-trac] [WordPress Trac] #15536: Introduce register_plugin
WordPress Trac
wp-trac at lists.automattic.com
Mon Nov 22 09:55:19 UTC 2010
#15536: Introduce register_plugin
-------------------------+--------------------------------------------------
Reporter: filosofo | Owner: filosofo
Type: enhancement | Status: new
Priority: normal | Milestone: Future Release
Component: Plugins | Version:
Severity: normal | Keywords: has-patch, close
-------------------------+--------------------------------------------------
Comment(by filosofo):
Replying to [comment:3 westi]:
> For a non-static class it is just as simple:
>
> {{{
> add_action('plugins_loaded', create_function('','global
$my_plugin_instance; $my_plugin_instance = new My_Plugin();'));
> }}}
>
> You don't nee d a global scope function for this
Anonymous functions are often undesirable. See for example, #14424
Besides, that's still unnecessarily repeated code. And it depends on the
plugin authors' knowing to use `plugins_loaded` in the first place. I'm
suggesting that we remove duplicated code, avoid anonymous functions, make
plugin objects globally available, and initialize consistently, all in an
easy-to-remember function call.
The point isn't that it can't be done currently, but that it could be done
better.
Please explain why you think less than thirty more lines of core code is
worse than at least three or four lines repeated for ''every single
plugin''. Why wouldn't we want to
* avoid code duplication
* make initialization simpler
* make initialization more consistent
?
--
Ticket URL: <http://core.trac.wordpress.org/ticket/15536#comment:4>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software
More information about the wp-trac
mailing list