[wp-trac] [WordPress Trac] #29572: Customizer: add a framework for rendering controls from JS templates

WordPress Trac noreply at wordpress.org
Sun Sep 7 17:04:55 UTC 2014


#29572: Customizer: add a framework for rendering controls from JS templates
------------------------------+----------------------------
 Reporter:  celloexpressions  |      Owner:
     Type:  feature request   |     Status:  new
 Priority:  normal            |  Milestone:  Future Release
Component:  Customize         |    Version:  3.4
 Severity:  normal            |   Keywords:  needs-patch
  Focuses:  javascript        |
------------------------------+----------------------------
 In order to facilitate future performance improvements such as lazy-
 loading Customizer objects and to make it easier to dynamically add
 controls without Ajax calls, we should introduce a framework for rendering
 controls from JS templates instead of PHP.

 We would maintain the current PHP API and continue support it fully. But
 we should be able to leverage the framework in all of the core controls in
 a back-compatible way.

 Essentially, `WP_Customize_Control->render_content()` would output
 nothing. We would add a function to `WP_Customize_Control` for defining a
 JS template, and this would always be output in the Customizer controls
 footer (if possible, even for controls that weren't added with PHP, since
 any available control type would be able to be added dynamically later).
 That part may require registering available control types (and custom
 controls) with the Customizer, since we would want to only output the
 template once, and not every available control type would have controls
 added to it initially. All of the arguments passed in PHP when adding the
 control would be sent through to JS (which might eliminate the need for
 manually adding things to pass `to_json()`). Finally, all added controls
 of types that have templates would be rendered from their template using
 the parameters passed when adding the control.

 In the future if controls are dynamically created or loaded, any controls
 with JS templates could have new instances created directly, or by
 retrieving information in the form of json from an Ajax call (rather than
 having to get the markup for the control UI from Ajax). This would be a
 significantly more efficient approach for things like menu items in the
 Customizer.

 Most important thing here: '''make this completely optional and opt-in'''.
 The existing PHP API for controls and Custom controls would be completely
 untouched; this is something that would improve things internally, and
 that could be leveraged in custom controls.

 Scope for this ticket is to create this framework and to leverage it for
 the main `WP_Customize_Control`. After that, we can explore implementing
 it in core's custom controls.

--
Ticket URL: <https://core.trac.wordpress.org/ticket/29572>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list