WordPress.org

Make WordPress Core

Opened 3 months ago

Last modified 3 months ago

#43585 new defect (bug)

Dynamically created setting not received on previewer

Reported by: jegbagus Owned by:
Milestone: Awaiting Review Priority: normal
Severity: normal Version: 4.9.4
Component: Customize Keywords:
Focuses: javascript Cc:

Description

I try to create dynamic setting & control on customizer, but setting is not propagated on previewer when setting created. Setting that dynamically created will only available on previewer when previewer refreshed.

i create a simple plugin to explain this issue : https://gist.github.com/jegbagus/e6bfe04fe45f4fa91b1fdc1c3b5b7a89

please take a look at browser console to see the message

Change History (1)

#1 @westonruter
3 months ago

Hi. You just have to send the setting to the preview after you create it. For example, in the controls app:

setting.previewer.send( 'setting', [ setting.id, setting() ] );

It will then get created as a dirty setting in the preview here: https://github.com/WordPress/wordpress-develop/blob/0cc1c1104998bc4c0e4a4a484e6467f6b1fa0c6b/src/wp-includes/js/customize-preview.js#L695-L735

Note: See TracTickets for help on using tickets.