WordPress.org

Make WordPress Core

Opened 4 years ago

Last modified 3 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:

Description

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)

@westonruter
4 years ago

WIP

Note: See TracTickets for help on using tickets.