[wp-trac] [WordPress Trac] #47692: Optgroup in Customizer Select Control

WordPress Trac noreply at wordpress.org
Wed May 20 14:54:53 UTC 2020


#47692: Optgroup in Customizer Select Control
-------------------------+-----------------------------
 Reporter:  chintan1896  |       Owner:  (none)
     Type:  enhancement  |      Status:  new
 Priority:  normal       |   Milestone:  Future Release
Component:  Customize    |     Version:  3.4
 Severity:  normal       |  Resolution:
 Keywords:  needs-patch  |     Focuses:
-------------------------+-----------------------------

Comment (by Lwangaman):

 I'm guessing this might work, I will test it now:

 {{{#!javascript
 <# } else if ( 'select' === data.type ) { #>
         <# delete inputAttrs.type; #>
         <select
                 <# _.each( _.extend( inputAttrs ), function( value, key )
 { #>
                         {{{ key }}}="{{ value }}"
                 <# }); #>
                 >
                 <# _.each( data.choices, function( val, key ) { #>
                         <#
                         var value, text;
                         if ( _.isObject( val ) && _.isArray( val ) ) {
                                 var optgpval, optgptext, data;
                                 value = key;
                                 data = val;
                                 #>
                                 <optgroup label="{{ value }}">
                                 <# _.each(value, function(val, key ) {
                                         optgpval = key;
                                         optgptext = val; #>
                                         <option value="{{ optgpval }}">{{
 optgptext }}</option>
                                 <# } ); #>
                                 </optgroup>
                                 <#
                         }
                         else if( _.isObject( val ) && !_.isArray( val ) ){
                                 value = val.value;
                                 text = val.text;
                         } else {
                                 value = key;
                                 text = val;
                         }
                         #>
                         <option value="{{ value }}">{{ text }}</option>
                 <# } ); #>
         </select>
 <# } else { #>

 }}}

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


More information about the wp-trac mailing list