+ <?php
+ if ( $locations_screen ) :
+ echo '<p>' . sprintf( _n( 'Your theme supports %s menu. Select which menu you would like to use.', 'Your theme supports %s menus. Select which menu appears in each location.', $num_locations ), number_format_i18n( $num_locations ) ) . '</p>';
+ ?>
+ <div id="menu-locations-wrap">
+ <form method="post" action="<?php echo esc_url( add_query_arg( array( 'action' => 'locations' ), admin_url( 'nav-menus.php' ) ) ); ?>">
+ <table class="widefat fixed" cellspacing="0" id="menu-locations-table">
+ <thead>
+ <tr>
+ <th scope="col" class="manage-column column-locations"><?php _e( 'Theme Location' ); ?></th>
+ <th scope="col" class="manage-column column-menus"><?php _e( 'Assigned Menu' ); ?></th>
+ </tr>
+ </thead>
+ <!--<tfoot>
+ <tr>
+ <th scope="col" class="manage-column column-locations"><?php _e( 'Theme Location' ); ?></th>
+ <th scope="col" class="manage-column column-menus"><?php _e( 'Assigned Menu' ); ?></th>
+ </tr>
+ </tfoot>-->
+ <tbody class="menu-locations">
+ <?php foreach ( $locations as $_location => $_name ) { ?>
+ <tr id="menu-locations-row">
+ <td class="menu-location-title"><strong><?php echo $_name; ?></strong></td>
+ <td class="menu-location-menus">
+ <select name="menu-locations[<?php echo $_location; ?>]" id="locations-<?php echo $_location; ?>">
+ <option value="0"><?php printf( '— %s —', esc_html__( 'Select a Menu' ) ); ?></option>
+ <?php foreach ( $nav_menus as $menu ) : ?>
+ <?php $selected = isset( $menu_locations[$_location] ) && $menu_locations[$_location] == $menu->term_id; ?>
+ <option <?php if ( $selected ) echo 'data-orig="true"'; ?> <?php selected( $selected ); ?> value="<?php echo $menu->term_id; ?>">
+ <?php echo wp_html_excerpt( $menu->name, 40, '…' ); ?>
+ </option>
+ <?php endforeach; ?>
+ </select>
+ <div class="locations-row-links">
+ <?php if ( isset( $menu_locations[ $_location ] ) && 0 != $menu_locations[ $_location ] ) : ?>
+ <span class="locations-edit-menu-link">
+ <a href="<?php echo esc_url( add_query_arg( array( 'action' => 'edit', 'menu' => $menu_locations[$_location] ), admin_url( 'nav-menus.php' ) ) ); ?>">
+ <?php _ex( 'Edit', 'menu' ); ?>
+ </a>
+ </span>
+ <?php endif; ?>
+ <span class="locations-add-menu-link">
+ <a href="<?php echo esc_url( add_query_arg( array( 'action' => 'edit', 'menu' => 0, 'use-location' => $_location ), admin_url( 'nav-menus.php' ) ) ); ?>">
+ <?php _ex( 'Use new menu', 'menu' ); ?>
+ </a>
+ </span>
+ </div><!-- #locations-row-links -->
+ </td><!-- .menu-location-menus -->
+ </tr><!-- #menu-locations-row -->
+ <?php } // foreach ?>
+ </tbody>
+ </table>
+ <p class="button-controls"><?php submit_button( __( 'Save Changes' ), 'primary left', 'nav-menu-locations', false ); ?></p>
+ <?php wp_nonce_field( 'save-menu-locations' ); ?>
+ <input type="hidden" name="menu" id="nav-menu-meta-object-id" value="<?php echo esc_attr( $nav_menu_selected_id ); ?>" />
+ </form>
+ </div><!-- #menu-locations-wrap -->
+ <?php
+ /**
+ * Fires after the menu locations table is displayed.
+ *
+ * @since 3.6.0
+ */
+ do_action( 'after_menu_locations_table' ); ?>
+ <?php else : ?>
+ <div class="manage-menus">
+ <?php if ( $menu_count < 2 ) : ?>
+ <span class="add-edit-menu-action">
+ <?php printf( __( 'Edit your menu below, or <a href="%s">create a new menu</a>.' ), esc_url( add_query_arg( array( 'action' => 'edit', 'menu' => 0 ), admin_url( 'nav-menus.php' ) ) ) ); ?>
+ </span><!-- /add-edit-menu-action -->
+ <?php else : ?>
+ <form method="get" action="<?php echo admin_url( 'nav-menus.php' ); ?>">
+ <input type="hidden" name="action" value="edit" />
+ <label for="menu" class="selected-menu"><?php _e( 'Select a menu to edit:' ); ?></label>
+ <select name="menu" id="menu">
+ <?php if ( $add_new_screen ) : ?>
+ <option value="0" selected="selected"><?php _e( '-- Select --' ); ?></option>
+ <?php endif; ?>
+ <?php foreach( (array) $nav_menus as $_nav_menu ) : ?>
+ <option value="<?php echo esc_attr( $_nav_menu->term_id ); ?>" <?php selected( $_nav_menu->term_id, $nav_menu_selected_id ); ?>>
+ <?php
+ echo esc_html( $_nav_menu->truncated_name ) ;
+
+ if ( ! empty( $menu_locations ) && in_array( $_nav_menu->term_id, $menu_locations ) ) {
+ $locations_assigned_to_this_menu = array();
+ foreach ( array_keys( $menu_locations, $_nav_menu->term_id ) as $menu_location_key ) {
+ if ( isset( $locations[ $menu_location_key ] ) ) {
+ $locations_assigned_to_this_menu[] = $locations[ $menu_location_key ];
+ }
+ }
+
+ /**
+ * Filter the number of locations listed per menu in the drop-down select.
+ *
+ * @since 3.6.0
+ *
+ * @param int $locations Number of menu locations to list. Default 3.
+ */
+ $assigned_locations = array_slice( $locations_assigned_to_this_menu, 0, absint( apply_filters( 'wp_nav_locations_listed_per_menu', 3 ) ) );
+
+ // Adds ellipses following the number of locations defined in $assigned_locations
+ if ( ! empty( $assigned_locations ) ) {
+ printf( ' (%1$s%2$s)',
+ implode( ', ', $assigned_locations ),
+ count( $locations_assigned_to_this_menu ) > count( $assigned_locations ) ? ' …' : ''
+ );
+ }
+ }
+ ?>
+ </option>
+ <?php endforeach; ?>
+ </select>
+ <span class="submit-btn"><input type="submit" class="button-secondary" value="<?php _e( 'Select' ); ?>"></span>
+ <span class="add-new-menu-action">
+ <?php printf( __( 'or <a href="%s">create a new menu</a>.' ), esc_url( add_query_arg( array( 'action' => 'edit', 'menu' => 0 ), admin_url( 'nav-menus.php' ) ) ) ); ?>
+ </span><!-- /add-new-menu-action -->
+ </form>
+ <?php endif; ?>
+ </div><!-- /manage-menus -->