Make WordPress Core

Opened 6 years ago

Last modified 5 years ago

#35574 new enhancement

Add default instance information to WP_Widget — at Initial Version

Reported by: westonruter Owned by:
Milestone: Future Release Priority: normal
Severity: normal Version: 2.8
Component: Widgets Keywords: needs-patch needs-unit-tests
Focuses: rest-api Cc:


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.

Change History (1)

6 years ago


Note: See TracTickets for help on using tickets.