Make WordPress Core

Opened 8 years ago

Closed 8 years ago

#34597 closed enhancement (fixed)

Let WP_Customize_Manager::add_setting() honor filters added for dynamic settings

Reported by: westonruter's profile westonruter Owned by: westonruter's profile westonruter
Milestone: 4.5 Priority: normal
Severity: normal Version: 4.2
Component: Customize Keywords: has-patch
Focuses: Cc:


In 4.2, the Customizer added support for dynamic settings (see #30936). Dynamic settings are those which are created via JS on the client (e.g. widget instances or nav menu items) and then sent to the server along with any statically-added settings that have changes. Settings can be represented by any number of subclasses forWP_Customize_Setting, for instance nav_menu_item[...] settings are represented as WP_Customize_Nav_Menu_Setting classes.

Nevertheless, when you add a new setting via: WP_Customize_Manager::add_setting( $id, $args ) the class used is hard-coded to be WP_Customize_Setting. This means that if a plugin has specifically added a filter to use a specific WP_Customize_Setting subclass for a given setting ID, then this will not be honored when add_setting() is called.

I propose that WP_Customize_Manager::add_setting() be made to explicitly support dynamic settings by applying the customize_dynamic_setting_class (and customize_dynamic_setting_args) filters.

Attachments (2)

34597.0.diff (908 bytes) - added by westonruter 8 years ago.
34597.1.diff (3.9 KB) - added by westonruter 8 years ago.
Unit testing

Download all attachments as: .zip

Change History (6)

8 years ago

#1 @westonruter
8 years ago

  • Keywords has-patch added

#2 @westonruter
8 years ago

  • Milestone changed from Future Release to 4.5

8 years ago

Unit testing

#3 @westonruter
8 years ago

  • Keywords needs-unit-tests removed

#4 @westonruter
8 years ago

  • Owner set to westonruter
  • Resolution set to fixed
  • Status changed from new to closed

In 35810:

Customizer: Apply customize_dynamic_setting_class and customize_dynamic_setting_args filters in calls to WP_Customize_Manager::add_setting( $id, $args ).

Ensure that plugin filters apply as expected for any settings registered statically without passing in an explicit class instance to WP_Customize_Manager::add_setting().

Fixes #34597.

Note: See TracTickets for help on using tickets.