- /* Nav Menus */
-
- $locations = get_registered_nav_menus();
- $menus = wp_get_nav_menus();
- $num_locations = count( array_keys( $locations ) );
-
- if ( 1 == $num_locations ) {
- $description = __( 'Your theme supports one menu. Select which menu you would like to use.' );
- } else {
- $description = sprintf( _n( 'Your theme supports %s menu. Select which menu appears in each location.', 'Your theme supports %s menus. Select which menu appears in each location.', $num_locations ), number_format_i18n( $num_locations ) );
- }
-
- $this->add_section( 'nav', array(
- 'title' => __( 'Navigation' ),
- 'theme_supports' => 'menus',
- 'priority' => 100,
- 'description' => $description . "\n\n" . __( 'You can edit your menu content on the Menus screen in the Appearance section.' ),
- ) );
-
- if ( $menus ) {
- $choices = array( '' => __( '— Select —' ) );
- foreach ( $menus as $menu ) {
- $choices[ $menu->term_id ] = wp_html_excerpt( $menu->name, 40, '…' );
- }
-
- foreach ( $locations as $location => $description ) {
- $menu_setting_id = "nav_menu_locations[{$location}]";
-
- $this->add_setting( $menu_setting_id, array(
- 'sanitize_callback' => 'absint',
- 'theme_supports' => 'menus',
- ) );
-
- $this->add_control( $menu_setting_id, array(
- 'label' => $description,
- 'section' => 'nav',
- 'type' => 'select',
- 'choices' => $choices,
- ) );
- }
- }
-