[wp-trac] [WordPress Trac] #35656: Deprecated old single non-WP_Widget widgets
WordPress Trac
noreply at wordpress.org
Sun Jan 31 04:50:53 UTC 2016
#35656: Deprecated old single non-WP_Widget widgets
-------------------------+------------------
Reporter: westonruter | Owner:
Type: enhancement | Status: new
Priority: normal | Milestone: 4.5
Component: Widgets | Version: 2.8
Severity: normal | Resolution:
Keywords: has-patch | Focuses:
-------------------------+------------------
Description changed by westonruter:
Old description:
> Widgets were introduced to Core in 2.2. These initial widgets only
> allowed one instance of a given widget to be registered at a given time.
> In 2.8 the `WP_Widget` was introduced which allowed for multiple
> instances of a widget type to be added, but more importantly it
> introduced an object-oriented MVC-ish paradigm for representing widgets.
> The `WP_Widget::update()` callback allows for a given widget instance to
> be sanitized without having to actually save it to the database. This
> ability is key for previewing widgets in the Customizer. In addition to
> the `update` callback, the `WP_Widget` can have schema information
> attached which works in conjunction with `update` to sanitize and
> validate a given widget for the REST API, for automatically generating a
> widget form, and automatically providing default values for a widget
> instance (see #35574). All of this is not possible with the old single
> widgets.
>
> I believe it is time to deprecate old single widgets so that widgets can
> evolve. If support for old single widgets is removed in 4.5, then in 4.6
> (or later) support can be removed which could clean up quite a bit of the
> widgets codebase, including the brittle “option transactions”
> functionality that was added to widgets in the Customizer.
New description:
Widgets were introduced to Core in 2.2. These initial widgets only allowed
one instance of a given widget to be registered at a given time. In 2.8
the `WP_Widget` was introduced which allowed for multiple instances of a
widget type to be added, but more importantly it introduced an object-
oriented MVC-ish paradigm for representing widgets. The
`WP_Widget::update()` callback allows for a given widget instance to be
sanitized without having to actually save it to the database. This ability
is key for previewing widgets in the Customizer. In addition to the
`update` callback, the `WP_Widget` can have schema information attached
which works in conjunction with `update` to sanitize and validate a given
widget for the REST API, for automatically generating a widget form, and
automatically providing default values for a widget instance (see #35574).
All of this is not possible with the old single widgets.
I believe it is time to deprecate old single widgets so that widgets can
evolve. If support for old single widgets is removed in 4.5, then in 4.6
(or later) support can be removed which could clean up quite a bit of the
widgets codebase, including the brittle “option transactions”
functionality that was added to widgets in the Customizer.
Once single widgets are removed, moving widgets from being stored in
options to a custom post type will be facilitated: #35669.
--
--
Ticket URL: <https://core.trac.wordpress.org/ticket/35656#comment:2>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list