[wp-trac] [WordPress Trac] #20542: Extend register_widget to allow passing params as second argument
WordPress Trac
wp-trac at lists.automattic.com
Wed Apr 25 11:56:20 UTC 2012
#20542: Extend register_widget to allow passing params as second argument
--------------------------+-----------------------------
Reporter: codearachnid | Owner: codearachnid
Type: enhancement | Status: new
Priority: normal | Milestone: Awaiting Review
Component: Widgets | Version: 3.4
Severity: normal | Keywords:
--------------------------+-----------------------------
I ran into an issue recently where I needed to make multiple calls of
`register_widget('my_custom_class');` on the same class and have multiple
unique widgets registered.
The problem I ran into is that every time the same class is called it will
overwrite the last instance of the same class during the widget
constructor request `parent::__construct('unique_id', 'widget title');`
This does not allow for reuse of the same class to instantiate multiple
widgets. I found that if I were to extend the register method in
WP_Widget_Factory to pass through arguments into the extended WP_Widget
constructor that I can reuse the same class for multiple widget
registations. I am working out the logic to implement this directly into
/wp-includes/widgets.php for future functionality improvement.
--
Ticket URL: <http://core.trac.wordpress.org/ticket/20542>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software
More information about the wp-trac
mailing list