[wp-trac] [WordPress Trac] #28216: Allow to register pre-instantiated widgets
WordPress Trac
noreply at wordpress.org
Mon May 12 11:44:31 UTC 2014
#28216: Allow to register pre-instantiated widgets
-------------------------------+-----------------------------
Reporter: Denis-de-Bernardy | Owner:
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting Review
Component: Widgets | Version: 3.9.1
Severity: normal | Keywords:
Focuses: |
-------------------------------+-----------------------------
As things stand, the current API doesn't allow to instantiate a widget
that relies on dependency injection because `register_widget()` and
`WP_Widget_Factory#register()` expect a class name as a parameter.
It would be convenient if the factory would conditionally instantiate the
widget classes instead:
{{{
function register($widget_class) {
$this->widgets[$widget_class] = is_object($widget_class) ?
$widget_class : new $widget_class();
}
}}}
--
Ticket URL: <https://core.trac.wordpress.org/ticket/28216>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list