| 406 | | // @todo if ( ! $menus ) : make a "default" menu |
| 407 | | if ( $menus ) { |
| 408 | | $choices = array( '0' => __( '— Select —' ) ); |
| 409 | | foreach ( $menus as $menu ) { |
| 410 | | $choices[ $menu->term_id ] = wp_html_excerpt( $menu->name, 40, '…' ); |
| 411 | | } |
| | 406 | $choices = array( '0' => __( '— Select —' ) ); |
| | 407 | foreach ( $menus as $menu ) { |
| | 408 | $choices[ $menu->term_id ] = wp_html_excerpt( $menu->name, 40, '…' ); |
| | 409 | } |
| 416 | | $setting = $this->manager->get_setting( $setting_id ); |
| 417 | | if ( $setting ) { |
| 418 | | $setting->transport = 'postMessage'; |
| 419 | | remove_filter( "customize_sanitize_{$setting_id}", 'absint' ); |
| 420 | | add_filter( "customize_sanitize_{$setting_id}", array( $this, 'intval_base10' ) ); |
| 421 | | } else { |
| 422 | | $this->manager->add_setting( $setting_id, array( |
| 423 | | 'sanitize_callback' => array( $this, 'intval_base10' ), |
| 424 | | 'theme_supports' => 'menus', |
| 425 | | 'type' => 'theme_mod', |
| 426 | | 'transport' => 'postMessage', |
| 427 | | ) ); |
| 428 | | } |
| | 414 | $setting = $this->manager->get_setting( $setting_id ); |
| | 415 | if ( $setting ) { |
| | 416 | $setting->transport = 'postMessage'; |
| | 417 | remove_filter( "customize_sanitize_{$setting_id}", 'absint' ); |
| | 418 | add_filter( "customize_sanitize_{$setting_id}", array( $this, 'intval_base10' ) ); |
| | 419 | } else { |
| | 420 | $this->manager->add_setting( $setting_id, array( |
| | 421 | 'sanitize_callback' => array( $this, 'intval_base10' ), |
| | 422 | 'theme_supports' => 'menus', |
| | 423 | 'type' => 'theme_mod', |
| | 424 | 'transport' => 'postMessage', |
| | 425 | ) ); |
| | 426 | } |
| 430 | | $this->manager->add_control( new WP_Customize_Nav_Menu_Location_Control( $this->manager, $setting_id, array( |
| 431 | | 'label' => $description, |
| 432 | | 'location_id' => $location, |
| 433 | | 'section' => 'menu_locations', |
| 434 | | 'choices' => $choices, |
| 435 | | ) ) ); |
| 436 | | } |
| | 428 | $this->manager->add_control( new WP_Customize_Nav_Menu_Location_Control( $this->manager, $setting_id, array( |
| | 429 | 'label' => $description, |
| | 430 | 'location_id' => $location, |
| | 431 | 'section' => 'menu_locations', |
| | 432 | 'choices' => $choices, |
| | 433 | ) ) ); |