[wp-trac] [WordPress Trac] #30737: JS templates for Customizer Panels and Sections

WordPress Trac noreply at wordpress.org
Fri May 29 22:23:37 UTC 2015


#30737: JS templates for Customizer Panels and Sections
------------------------------+--------------------------
 Reporter:  celloexpressions  |       Owner:  westonruter
     Type:  enhancement       |      Status:  accepted
 Priority:  normal            |   Milestone:  4.3
Component:  Customize         |     Version:  4.1
 Severity:  normal            |  Resolution:
 Keywords:  has-patch         |     Focuses:
------------------------------+--------------------------

Comment (by westonruter):

 @celloexpressions I noticed something that may be unexpected when testing
 with Menu Customizer. Namely, I had to make sure I added:

 {{{#!php
 $this->manager->register_section_type( 'WP_Customize_Menu_Section' );
 }}}

 Or else the custom sections would never render. Nevertheless, Menu
 Customizer just needed the default section to render right? So it seems
 that if a custom section didn't have `register_section_type` called, it
 should fallback to render the default section.

 So I'm suggesting an additional patch something like this:


 {{{#!diff
 --- src/wp-admin/js/customize-controls.js
 +++ src/wp-admin/js/customize-controls.js
 @@ -170,6 +170,9 @@
     container.params = {};
     $.extend( container, options || {} );
     container.templateSelector = 'customize-' + container.containerType +
 '-' + container.params.type;
 +   if ( ! document.getElementById( 'tmpl-' + container.templateSelector )
 ) {
 +    container.templateSelector = 'customize-' + container.containerType +
 '-default';
 +   }
     container.container = $( container.params.content );
     if ( 0 === container.container.length ) {
      container.container = $( container.getContainer() );
 @@ -1211,11 +1214,18 @@
     */
    renderContent: function () {
     var template,
 +    templateSelector,
      panel = this;

 +   if ( document.getElementById( 'tmpl-' + panel.templateSelector +
 '-content' ) ) {
 +    templateSelector = panel.templateSelector + '-content';
 +   } else {
 +    templateSelector = 'customize-' + panel.containerType + '-default-
 content';
 +   }
 +
     // Add the content to the container.
 -   if ( 0 !== $( '#tmpl-' + panel.templateSelector + '-content' ).length
 ) {
 -    template = wp.template( panel.templateSelector + '-content' );
 +   if ( 0 !== $( '#tmpl-' + templateSelector ).length ) {
 +    template = wp.template( templateSelector );
      if ( template && panel.container ) {
       panel.container.find( '.accordion-sub-container' ).html( template(
 panel.params ) );
      }
 }}}

 Thoughts?

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


More information about the wp-trac mailing list