[wp-trac] [WordPress Trac] #15536: Introduce register_plugin
WordPress Trac
wp-trac at lists.automattic.com
Mon Nov 22 09:14:54 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
-------------------------+--------------------------------------------------
== Problem ==
Plugins load themselves eclectically, with the result that many end up
initializing too soon or adding action/filter hook callbacks that can't be
accessed by other plugins. Furthermore, plugins all repeat a handful of
actions to initialize themselves, and that's code that's repeated across
all active plugins.
== Solution ==
I propose that we introduce the following new function,
`register_plugin()`. It's first, required, argument accepts either the
name of a function to call or a class to instantiate upon
`plugins_loaded`.
bool '''register_plugin''' ( string ''$init_callback'' [, array ''$args''
] )
== Examples of Use ==
=== Class name for the first argument ===
{{{
class My_Plugin_Factory
{
[snip]
}
register_plugin('My_Plugin_Factory');
}}}
=== Function name for the first argument ===
{{{
function my_plugin_loaded( $something = '' )
{
echo $something; // prints "Whatever"
}
register_plugin('my_plugin_loaded', array( 'init_args' => array(
'Whatever' ) ) );
}}}
--
Ticket URL: <http://core.trac.wordpress.org/ticket/15536>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software
More information about the wp-trac
mailing list