423 | | // @todo if ( ! $menus ) : make a "default" menu |
424 | | if ( $menus ) { |
425 | | $choices = array( '0' => __( '— Select —' ) ); |
426 | | foreach ( $menus as $menu ) { |
427 | | $choices[ $menu->term_id ] = wp_html_excerpt( $menu->name, 40, '…' ); |
428 | | } |
429 | | |
430 | | foreach ( $locations as $location => $description ) { |
431 | | $setting_id = "nav_menu_locations[{$location}]"; |
432 | | |
433 | | $setting = $this->manager->get_setting( $setting_id ); |
434 | | if ( $setting ) { |
435 | | $setting->transport = 'postMessage'; |
436 | | remove_filter( "customize_sanitize_{$setting_id}", 'absint' ); |
437 | | add_filter( "customize_sanitize_{$setting_id}", array( $this, 'intval_base10' ) ); |
438 | | } else { |
439 | | $this->manager->add_setting( $setting_id, array( |
440 | | 'sanitize_callback' => array( $this, 'intval_base10' ), |
441 | | 'theme_supports' => 'menus', |
442 | | 'type' => 'theme_mod', |
443 | | 'transport' => 'postMessage', |
444 | | ) ); |
445 | | } |
| 423 | $choices = array( '0' => __( '— Select —' ) ); |
| 424 | foreach ( $menus as $menu ) { |
| 425 | $choices[ $menu->term_id ] = wp_html_excerpt( $menu->name, 40, '…' ); |
| 426 | } |
447 | | $this->manager->add_control( new WP_Customize_Nav_Menu_Location_Control( $this->manager, $setting_id, array( |
448 | | 'label' => $description, |
449 | | 'location_id' => $location, |
450 | | 'section' => 'menu_locations', |
451 | | 'choices' => $choices, |
452 | | ) ) ); |
| 428 | foreach ( $locations as $location => $description ) { |
| 429 | $setting_id = "nav_menu_locations[{$location}]"; |
| 430 | |
| 431 | $setting = $this->manager->get_setting( $setting_id ); |
| 432 | if ( $setting ) { |
| 433 | $setting->transport = 'postMessage'; |
| 434 | remove_filter( "customize_sanitize_{$setting_id}", 'absint' ); |
| 435 | add_filter( "customize_sanitize_{$setting_id}", array( $this, 'intval_base10' ) ); |
| 436 | } else { |
| 437 | $this->manager->add_setting( $setting_id, array( |
| 438 | 'sanitize_callback' => array( $this, 'intval_base10' ), |
| 439 | 'theme_supports' => 'menus', |
| 440 | 'type' => 'theme_mod', |
| 441 | 'transport' => 'postMessage', |
| 442 | ) ); |