[wp-trac] [WordPress Trac] #39040: Hide references to nav menu locations that are not visible in the customizer preview

WordPress Trac noreply at wordpress.org
Mon Dec 5 00:44:36 UTC 2016


#39040: Hide references to nav menu locations that are not visible in the
customizer preview
-------------------------+-----------------------------
 Reporter:  khela        |       Owner:
     Type:  enhancement  |      Status:  closed
 Priority:  normal       |   Milestone:  Future Release
Component:  Customize    |     Version:
 Severity:  normal       |  Resolution:  maybelater
 Keywords:               |     Focuses:
-------------------------+-----------------------------
Changes (by khela):

 * status:  new => closed
 * resolution:   => maybelater


Comment:

 Thank you @westonruter for your answer. My test is exactly as you wrote
 with active callbacks, it work in the static part of customizer but if you
 want nav locations checkboxes toggled when switching a setting you need to
 have this:

 {{{
 $.each({
   'header_style': {
     controls: [
       'nav_menu_locations[primary]',
       'nav_menu_locations[primary-left]',
       'nav_menu_locations[primary-right]'
     ],
     aux: ['singlemenu', 'doublemenu', 'doublemenu'],
     callback: function(to, aux) {
       return aux === to;
     }
   }
 }, function(settingId, o) {
   api(settingId, function(setting) {
     $.each(o.controls, function(i, controlId) {
       api.control(controlId, function(control) {
         var visibility = function(to) {
           if ('aux' in o) {
             control.container.toggle(o.callback(to, o.aux[i]));
           } else {
             control.container.toggle(o.callback(to));
           }
         };
         visibility(setting.get());
         setting.bind(visibility);
       });
     });
   });
 });
 }}}

 So, this work but the problem is that could be useless to register nav
 menu locations for maybe using only one of these.
 Finally, I think that nav_menu_location control should be
 organized/updated to support dynamic menu locations.

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


More information about the wp-trac mailing list