[wp-trac] [WordPress Trac] #35574: Add default instance information to WP_Widget
WordPress Trac
noreply at wordpress.org
Fri Jan 22 12:24:08 UTC 2016
#35574: Add default instance information to WP_Widget
-------------------------+-----------------------------
Reporter: westonruter | Owner:
Type: enhancement | Status: new
Priority: normal | Milestone: Awaiting Review
Component: Widgets | Version:
Severity: normal | Keywords:
Focuses: |
-------------------------+-----------------------------
Widgets often have duplicated logic between the `WP_Widget::widget()`,
`WP_Widget::update()`, and `WP_Widget::form()` methods for checking if a
given `$instance` property has been set, and if not, supplying a default
value. In some cases, these `isset` checks are ''not'' performed resulting
in PHP notices if the methods are programmatically invoked with an empty
array. I suggest that we introduce a `WP_Widget::$default_instance`
property or `WP_Widget::get_default_instance()` method that will return
the `$instance` defaults that can be merged on top of with the current
`$instance`.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/35574>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list