[wp-trac] [WordPress Trac] #36389: Selective refresh for widgets gets lost once `refresh` is used

WordPress Trac noreply at wordpress.org
Thu Apr 7 20:58:58 UTC 2016


#36389: Selective refresh for widgets gets lost once `refresh` is used
------------------------------+--------------------------
 Reporter:  scamartist26      |       Owner:  westonruter
     Type:  defect (bug)      |      Status:  closed
 Priority:  normal            |   Milestone:  4.5
Component:  Customize         |     Version:  trunk
 Severity:  normal            |  Resolution:  fixed
 Keywords:  has-patch commit  |     Focuses:
------------------------------+--------------------------
Changes (by ocean90):

 * status:  accepted => closed
 * resolution:   => fixed


Comment:

 In [changeset:"37166"]:
 {{{
 #!CommitTicketReference repository="" revision="37166"
 Customize: Harden assignment of Customizer settings transports for
 selective refreshable widgets

 Theme support for `customize-selective-refresh-widgets` can be added
 _after_ the logic for registering the settings for incoming widgets that
 have been changed. This is due to themes adding the theme support in
 `after_setup_theme` which is also the action where
 `WP_Customize_Widgets::register_settings()` is called. If these both
 happen at priority 10, which one is called first depends on which one was
 added first. The other issue is that at the time that
 `WP_Customize_Widgets::register_settings()` is called at
 `after_setup_theme`, it is called before `widgets_init` and thus no
 widgets are yet registered. This means that any settings registered at
 this point will always have a `refresh` transport even if the theme
 supports `customize-selective-refresh-widgets`, since the `WP_Widget`
 instance is not visible yet to see if it supports selective refresh.

 The fix: Defer `WP_Customize_Widgets::register_settings()` from
 `after_setup_theme` to `widgets_init` at priority 95 when the widget
 objects have all been registered. Also, ensure that the preview filter for
 `sidebars_widgets` is added before the sidebars are iterated for adding
 the controls.

 Props westonruter.
 Fixes #36389.
 }}}

--
Ticket URL: <https://core.trac.wordpress.org/ticket/36389#comment:30>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list