WordPress.org

Make WordPress Core

Opened 3 years ago

Last modified 10 months ago

#43585 new defect (bug)

Dynamically created setting not received on previewer

Reported by: jegbagus Owned by:
Milestone: Future Release Priority: normal
Severity: normal Version:
Component: Customize Keywords: reporter-feedback
Focuses: docs 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 (2)

#1 @westonruter
3 years 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

#2 @dlh
10 months ago

  • Focuses docs added; javascript removed
  • Keywords reporter-feedback added
  • Milestone changed from Awaiting Review to Future Release
  • Version 4.9.4 deleted

Based on comment:1, there isn't a code bug here, but there's still an opportunity to document this potential gotcha.

@jegbagus Can you think back to when you submitted this ticket to suggest a location in the codebase or the Customizer handbook where it would have been helpful to see the snippet in comment:1?

Note: See TracTickets for help on using tickets.