436 | | // @todo if ( ! $menus ) : make a "default" menu |
437 | | if ( $menus ) { |
438 | | $choices = array( '0' => __( '— Select —' ) ); |
439 | | foreach ( $menus as $menu ) { |
440 | | $choices[ $menu->term_id ] = wp_html_excerpt( $menu->name, 40, '…' ); |
441 | | } |
442 | | |
443 | | foreach ( $locations as $location => $description ) { |
444 | | $setting_id = "nav_menu_locations[{$location}]"; |
445 | | |
446 | | $setting = $this->manager->get_setting( $setting_id ); |
447 | | if ( $setting ) { |
448 | | $setting->transport = 'postMessage'; |
449 | | remove_filter( "customize_sanitize_{$setting_id}", 'absint' ); |
450 | | add_filter( "customize_sanitize_{$setting_id}", array( $this, 'intval_base10' ) ); |
451 | | } else { |
452 | | $this->manager->add_setting( $setting_id, array( |
453 | | 'sanitize_callback' => array( $this, 'intval_base10' ), |
454 | | 'theme_supports' => 'menus', |
455 | | 'type' => 'theme_mod', |
456 | | 'transport' => 'postMessage', |
457 | | ) ); |
458 | | } |
| 436 | $choices = array( '0' => __( '— Select —' ) ); |
| 437 | foreach ( $menus as $menu ) { |
| 438 | $choices[ $menu->term_id ] = wp_html_excerpt( $menu->name, 40, '…' ); |
| 439 | } |
460 | | $this->manager->add_control( new WP_Customize_Nav_Menu_Location_Control( $this->manager, $setting_id, array( |
461 | | 'label' => $description, |
462 | | 'location_id' => $location, |
463 | | 'section' => 'menu_locations', |
464 | | 'choices' => $choices, |
465 | | ) ) ); |
| 441 | foreach ( $locations as $location => $description ) { |
| 442 | $setting_id = "nav_menu_locations[{$location}]"; |
| 443 | |
| 444 | $setting = $this->manager->get_setting( $setting_id ); |
| 445 | if ( $setting ) { |
| 446 | $setting->transport = 'postMessage'; |
| 447 | remove_filter( "customize_sanitize_{$setting_id}", 'absint' ); |
| 448 | add_filter( "customize_sanitize_{$setting_id}", array( $this, 'intval_base10' ) ); |
| 449 | } else { |
| 450 | $this->manager->add_setting( $setting_id, array( |
| 451 | 'sanitize_callback' => array( $this, 'intval_base10' ), |
| 452 | 'theme_supports' => 'menus', |
| 453 | 'type' => 'theme_mod', |
| 454 | 'transport' => 'postMessage', |
| 455 | ) ); |