<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[23810] trunk/wp-admin: Move nav menus to a tabbed interface, so that users with a lot of locations can do bulk assignment.</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg > ul, #logmsg > ol { margin-left: 0; margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://core.trac.wordpress.org/changeset/23810">23810</a></dd>
<dt>Author</dt> <dd>markjaquith</dd>
<dt>Date</dt> <dd>2013-03-27 11:46:08 +0000 (Wed, 27 Mar 2013)</dd>
</dl>

<h3>Log Message</h3>
<pre>Move nav menus to a tabbed interface, so that users with a lot of locations can do bulk assignment.

props DrewAPicture, lessbloat. fixes <a href="http://core.trac.wordpress.org/ticket/23770">#23770</a></pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkwpadmincsswpadminrtlcss">trunk/wp-admin/css/wp-admin-rtl.css</a></li>
<li><a href="#trunkwpadmincsswpadmincss">trunk/wp-admin/css/wp-admin.css</a></li>
<li><a href="#trunkwpadminjsnavmenujs">trunk/wp-admin/js/nav-menu.js</a></li>
<li><a href="#trunkwpadminnavmenusphp">trunk/wp-admin/nav-menus.php</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkwpadmincsswpadminrtlcss"></a>
<div class="modfile"><h4>Modified: trunk/wp-admin/css/wp-admin-rtl.css (23809 => 23810)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-admin/css/wp-admin-rtl.css        2013-03-27 08:58:40 UTC (rev 23809)
+++ trunk/wp-admin/css/wp-admin-rtl.css        2013-03-27 11:46:08 UTC (rev 23810)
</span><span class="lines">@@ -697,6 +697,9 @@
</span><span class="cx"> .fixed .column-comments a {
</span><span class="cx">         float: right;
</span><span class="cx"> }
</span><ins>+.fixed .column-menus {
+        text-align: right;
+}
</ins><span class="cx"> .sorting-indicator {
</span><span class="cx">         margin-left: 0;
</span><span class="cx">         margin-right: 7px;
</span><span class="lines">@@ -2083,6 +2086,27 @@
</span><span class="cx">         float: right;
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+.menu-location-menus select {
+        float: right;
+}
+
+.locations-row-links {
+        float: right;
+        margin: 4px 6px 0 0;
+}
+
+.locations-add-menu-link {
+        direction: rtl;
+}
+
+.locations-edit-menu-link {
+        border-left: 1px solid #CCCCCC;
+        border-right: 0;
+        padding-left: 6px;
+        padding-right: 0;
+        float: right;
+}
+
</ins><span class="cx"> /* Menu Container */
</span><span class="cx"> #menu-management-liquid {
</span><span class="cx">         float: right;
</span></span></pre></div>
<a id="trunkwpadmincsswpadmincss"></a>
<div class="modfile"><h4>Modified: trunk/wp-admin/css/wp-admin.css (23809 => 23810)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-admin/css/wp-admin.css        2013-03-27 08:58:40 UTC (rev 23809)
+++ trunk/wp-admin/css/wp-admin.css        2013-03-27 11:46:08 UTC (rev 23810)
</span><span class="lines">@@ -2423,6 +2423,7 @@
</span><span class="cx">         width: 8%;
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+.fixed .column-posts,
</ins><span class="cx"> .fixed .column-date,
</span><span class="cx"> .fixed .column-parent,
</span><span class="cx"> .fixed .column-links,
</span><span class="lines">@@ -2439,6 +2440,14 @@
</span><span class="cx">         width: 15%;
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+.fixed .column-slug {
+        width: 25%;
+}
+
+.fixed .column-locations {
+        width: 35%;
+}
+
</ins><span class="cx"> .fixed .column-comments {
</span><span class="cx">         width: 4em;
</span><span class="cx">         padding: 8px 0;
</span><span class="lines">@@ -2453,14 +2462,6 @@
</span><span class="cx">         float: left;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-.fixed .column-slug {
-        width: 25%;
-}
-
-.fixed .column-posts {
-        width: 10%;
-}
-
</del><span class="cx"> .fixed .column-icon {
</span><span class="cx">         width: 80px;
</span><span class="cx"> }
</span><span class="lines">@@ -2547,6 +2548,10 @@
</span><span class="cx">         margin-top: 3px;
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+#menu-locations-wrap .widefat {
+        width: 60%;
+}
+
</ins><span class="cx"> .widefat th.sortable,
</span><span class="cx"> .widefat th.sorted {
</span><span class="cx">         padding: 0;
</span><span class="lines">@@ -7384,7 +7389,7 @@
</span><span class="cx"> 
</span><span class="cx"> #nav-menus-frame {
</span><span class="cx">         margin-left: 300px;
</span><del>-        margin-top: 28px;
</del><ins>+        margin-top: 23px;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> #wpbody-content #menu-settings-column {
</span><span class="lines">@@ -7401,7 +7406,8 @@
</span><span class="cx">         margin: 10px 0 0;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-.metabox-holder-disabled .postbox {
</del><ins>+.metabox-holder-disabled .postbox,
+.metabox-holder-disabled .accordion-section-content  {
</ins><span class="cx">         opacity: 0.5;
</span><span class="cx">         filter: alpha(opacity=50);
</span><span class="cx"> }
</span><span class="lines">@@ -7432,7 +7438,7 @@
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> .manage-menus {
</span><del>-        margin-top: 13px;
</del><ins>+        margin-top: 23px;
</ins><span class="cx">         padding: 10px;
</span><span class="cx">         overflow: hidden;
</span><span class="cx">         -webkit-border-radius: 3px;
</span><span class="lines">@@ -7566,6 +7572,39 @@
</span><span class="cx">         margin-top: -2px;
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+.widefat td.menu-location-menus {
+        padding-bottom: 5px;
+}
+
+.menu-location-menus select {
+        float: left;
+}
+
+#locations-nav-menu-wrapper {
+        padding: 5px 0;
+}
+
+.locations-nav-menu-select select {
+        float: left;
+        width: 160px;
+        margin-right: 5px;
+}
+
+.locations-row-links {
+        float: left;
+        margin: 6px 0 0 6px;
+}
+
+.locations-edit-menu-link,
+.locations-add-menu-link {
+        margin: 0 3px;
+}
+
+.locations-edit-menu-link {
+        padding-right: 3px;
+        border-right: 1px solid #ccc;
+}
+
</ins><span class="cx"> #wpbody .open-label {
</span><span class="cx">         display: block;
</span><span class="cx">         float:left;
</span></span></pre></div>
<a id="trunkwpadminjsnavmenujs"></a>
<div class="modfile"><h4>Modified: trunk/wp-admin/js/nav-menu.js (23809 => 23810)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-admin/js/nav-menu.js        2013-03-27 08:58:40 UTC (rev 23809)
+++ trunk/wp-admin/js/nav-menu.js        2013-03-27 11:46:08 UTC (rev 23810)
</span><span class="lines">@@ -48,6 +48,8 @@
</span><span class="cx">                         if ( menus.oneThemeLocationNoMenus )
</span><span class="cx">                                 $( '#posttype-page' ).addSelectedToMenu( api.addMenuItemToBottom );
</span><span class="cx"> 
</span><ins>+                        this.initManageLocations();
+
</ins><span class="cx">                         this.initAccessibility();
</span><span class="cx"> 
</span><span class="cx">                         this.initToggles();
</span><span class="lines">@@ -735,6 +737,19 @@
</span><span class="cx">                         }
</span><span class="cx">                 },
</span><span class="cx"> 
</span><ins>+                initManageLocations : function () {
+                        $('#menu-locations-wrap form').submit(function(){
+                                window.onbeforeunload = null;
+                        });
+                        $('.menu-location-menus select').on('change', function () {
+                                var editLink = $(this).closest('tr').find('.locations-edit-menu-link');
+                                if ($(this).find('option:selected').data('orig'))
+                                        editLink.show();
+                                else
+                                        editLink.hide();
+                        });
+                },
+
</ins><span class="cx">                 attachMenuEditListeners : function() {
</span><span class="cx">                         var that = this;
</span><span class="cx">                         $('#update-nav-menu').bind('click', function(e) {
</span><span class="lines">@@ -927,11 +942,11 @@
</span><span class="cx">                 },
</span><span class="cx"> 
</span><span class="cx">                 attachUnsavedChangesListener : function() {
</span><del>-                        $('#menu-management input, #menu-management select, #menu-management, #menu-management textarea').change(function(){
</del><ins>+                        $('#menu-management input, #menu-management select, #menu-management, #menu-management textarea, .menu-location-menus select').change(function(){
</ins><span class="cx">                                 api.registerChange();
</span><span class="cx">                         });
</span><span class="cx"> 
</span><del>-                        if ( 0 != $('#menu-to-edit').length ) {
</del><ins>+                        if ( 0 != $('#menu-to-edit').length || 0 != $('.menu-location-menus select').length ) {
</ins><span class="cx">                                 window.onbeforeunload = function(){
</span><span class="cx">                                         if ( api.menusChanged )
</span><span class="cx">                                                 return navMenuL10n.saveAlert;
</span></span></pre></div>
<a id="trunkwpadminnavmenusphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-admin/nav-menus.php (23809 => 23810)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-admin/nav-menus.php        2013-03-27 08:58:40 UTC (rev 23809)
+++ trunk/wp-admin/nav-menus.php        2013-03-27 11:46:08 UTC (rev 23810)
</span><span class="lines">@@ -37,6 +37,11 @@
</span><span class="cx"> // The menu id of the current menu being edited
</span><span class="cx"> $nav_menu_selected_id = isset( $_REQUEST['menu'] ) ? (int) $_REQUEST['menu'] : 0;
</span><span class="cx"> 
</span><ins>+// Get existing menu locations assignments
+$locations = get_registered_nav_menus();
+$menu_locations = get_nav_menu_locations();
+$num_locations = count( array_keys( $locations ) );
+
</ins><span class="cx"> // Allowed actions: add, update, delete
</span><span class="cx"> $action = isset( $_REQUEST['action'] ) ? $_REQUEST['action'] : 'edit';
</span><span class="cx"> 
</span><span class="lines">@@ -262,10 +267,6 @@
</span><span class="cx">         case 'update':
</span><span class="cx">                 check_admin_referer( 'update-nav_menu', 'update-nav-menu-nonce' );
</span><span class="cx"> 
</span><del>-                // Get existing menu locations assignments
-                $locations = get_registered_nav_menus();
-                $menu_locations = get_nav_menu_locations();
-
</del><span class="cx">                 // Remove menu locations that have been unchecked
</span><span class="cx">                 foreach ( $locations as $location =&gt; $description ) {
</span><span class="cx">                         if ( ( empty( $_POST['menu-locations'] ) || empty( $_POST['menu-locations'][ $location ] ) ) &amp;&amp; isset( $menu_locations[ $location ] ) &amp;&amp; $menu_locations[ $location ] == $nav_menu_selected_id )
</span><span class="lines">@@ -307,7 +308,15 @@
</span><span class="cx">                                                 }
</span><span class="cx">                                                 set_theme_mod( 'nav_menu_locations', $locations );
</span><span class="cx">                                         }
</span><del>-                                        $messages[] = '&lt;div id=&quot;message&quot; class=&quot;updated&quot;&gt;&lt;p&gt;' . sprintf( __( '&lt;strong&gt;%s&lt;/strong&gt; has been created.' ), $nav_menu_selected_title ) . '&lt;/p&gt;&lt;/div&gt;';
</del><ins>+                                        if ( isset( $_REQUEST['use-location'] ) ) {
+                                                $locations = get_theme_mod( 'nav_menu_locations' );
+                                                if ( isset( $locations[$_REQUEST['use-location']] ) )
+                                                        $locations[$_REQUEST['use-location']] = $nav_menu_selected_id;
+                                                set_theme_mod( 'nav_menu_locations', $locations );
+                                        }
+                                        // $messages[] = '&lt;div id=&quot;message&quot; class=&quot;updated&quot;&gt;&lt;p&gt;' . sprintf( __( '&lt;strong&gt;%s&lt;/strong&gt; has been created.' ), $nav_menu_selected_title ) . '&lt;/p&gt;&lt;/div&gt;';
+                                        wp_redirect( admin_url( 'nav-menus.php?menu=' . $_nav_menu_selected_id ) );
+                                        exit();
</ins><span class="cx">                                 }
</span><span class="cx">                         } else {
</span><span class="cx">                                 $messages[] = '&lt;div id=&quot;message&quot; class=&quot;error&quot;&gt;&lt;p&gt;' . __( 'Please enter a valid menu name.' ) . '&lt;/p&gt;&lt;/div&gt;';
</span><span class="lines">@@ -341,6 +350,20 @@
</span><span class="cx">                         }
</span><span class="cx">                 }
</span><span class="cx">                 break;
</span><ins>+        case 'locations':
+                add_filter( 'screen_options_show_screen', '__return_false' );
+
+                if ( isset( $_POST['menu-locations'] ) ) {
+                        check_admin_referer( 'save-menu-locations' );
+
+                        $new_menu_locations = array_map( 'absint', $_POST['menu-locations'] );
+                        $menu_locations = array_merge( $menu_locations, $new_menu_locations );
+                        // Set menu locations
+                        set_theme_mod( 'nav_menu_locations', $menu_locations );
+
+                        $messages[] = '&lt;div id=&quot;message&quot; class=&quot;updated&quot;&gt;&lt;p&gt;' . __( 'Menu locations updated.' ) . '&lt;/p&gt;&lt;/div&gt;';
+                }
+                break;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> // Get all nav menus
</span><span class="lines">@@ -350,6 +373,8 @@
</span><span class="cx"> // Are we on the add new screen?
</span><span class="cx"> $add_new_screen = ( isset( $_GET['menu'] ) &amp;&amp; 0 == $_GET['menu'] ) ? true : false;
</span><span class="cx"> 
</span><ins>+$locations_screen = ( isset( $_GET['action'] ) &amp;&amp; 'locations' == $_GET['action'] ) ? true : false;
+
</ins><span class="cx"> // If we have one theme location, and zero menus, we take them right into editing their first menu
</span><span class="cx"> $page_count = wp_count_posts( 'page' );
</span><span class="cx"> $one_theme_location_no_menus = ( 1 == count( get_registered_nav_menus() ) &amp;&amp; ! $add_new_screen &amp;&amp; empty( $nav_menus ) &amp;&amp; ! empty( $page_count-&gt;publish ) ) ? true : false;
</span><span class="lines">@@ -474,19 +499,82 @@
</span><span class="cx"> ?&gt;
</span><span class="cx"> &lt;div class=&quot;wrap&quot;&gt;
</span><span class="cx">         &lt;?php screen_icon(); ?&gt;
</span><del>-        &lt;h2&gt;&lt;?php _e( 'Menus' ); ?&gt; &lt;a href=&quot;&lt;?php echo esc_url( add_query_arg( array( 'action' =&gt; 'edit', 'menu' =&gt; 0, ), admin_url( 'nav-menus.php' ) ) ); ?&gt;&quot; class=&quot;add-new-h2&quot;&gt;&lt;?php _ex( 'Add New', 'menu' ); ?&gt;&lt;/a&gt;&lt;/h2&gt;
</del><ins>+        &lt;h2 class=&quot;nav-tab-wrapper&quot;&gt;
+                &lt;a href=&quot;&lt;?php echo admin_url( 'nav-menus.php' ); ?&gt;&quot; class=&quot;nav-tab&lt;?php if ( ! isset( $_GET['action'] ) || isset( $_GET['action'] ) &amp;&amp; 'locations' != $_GET['action'] ) echo ' nav-tab-active'; ?&gt;&quot;&gt;&lt;?php esc_html_e( 'Edit Menus' ); ?&gt;&lt;/a&gt;
+                &lt;a href=&quot;&lt;?php echo esc_url( add_query_arg( array( 'action' =&gt; 'locations' ), admin_url( 'nav-menus.php' ) ) ); ?&gt;&quot; class=&quot;nav-tab&lt;?php if ( $locations_screen ) echo ' nav-tab-active'; ?&gt;&quot;&gt;&lt;?php esc_html_e( 'Manage Locations' ); ?&gt;&lt;/a&gt;
+        &lt;/h2&gt;
</ins><span class="cx">         &lt;?php
</span><span class="cx">         foreach( $messages as $message ) :
</span><span class="cx">                 echo $message . &quot;\n&quot;;
</span><span class="cx">         endforeach;
</span><span class="cx">         ?&gt;
</span><ins>+        &lt;?php
+        if ( $locations_screen ) :
+                echo '&lt;p&gt;' . sprintf( _n( 'Your theme supports %s menu. Select which menu you would like to use below.', 'Your theme supports %s menus. Select a menu to use for each theme location below.', $num_locations ), number_format_i18n( $num_locations ) ) . '&lt;/p&gt;';
+        ?&gt;
+        &lt;div id=&quot;menu-locations-wrap&quot;&gt;
+                &lt;form method=&quot;post&quot; action=&quot;&lt;?php echo esc_url( add_query_arg( array( 'action' =&gt; 'locations' ), admin_url( 'nav-menus.php' ) ) ); ?&gt;&quot;&gt;
+                        &lt;table class=&quot;widefat fixed&quot; cellspacing=&quot;0&quot; id=&quot;menu-locations-table&quot;&gt;
+                                &lt;thead&gt;
+                                &lt;tr&gt;
+                                        &lt;th scope=&quot;col&quot; class=&quot;manage-column column-locations&quot;&gt;&lt;?php _e( 'Theme Location' ); ?&gt;&lt;/th&gt;
+                                        &lt;th scope=&quot;col&quot; class=&quot;manage-column column-menus&quot;&gt;&lt;?php _e( 'Assigned Menu' ); ?&gt;&lt;/th&gt;
+                                &lt;/tr&gt;
+                                &lt;/thead&gt;
+                                &lt;!--&lt;tfoot&gt;
+                                &lt;tr&gt;
+                                        &lt;th scope=&quot;col&quot; class=&quot;manage-column column-locations&quot;&gt;&lt;?php _e( 'Theme Location' ); ?&gt;&lt;/th&gt;
+                                        &lt;th scope=&quot;col&quot; class=&quot;manage-column column-menus&quot;&gt;&lt;?php _e( 'Assigned Menu' ); ?&gt;&lt;/th&gt;
+                                &lt;/tr&gt;
+                                &lt;/tfoot&gt;--&gt;
+                                &lt;tbody class=&quot;menu-locations&quot;&gt;
+                                &lt;?php foreach ( $locations as $_location =&gt; $_name ) { ?&gt;
+                                        &lt;tr id=&quot;menu-locations-row&quot;&gt;
+                                                &lt;td class=&quot;menu-location-title&quot;&gt;&lt;strong&gt;&lt;?php echo $_name; ?&gt;&lt;/strong&gt;&lt;/td&gt;
+                                                &lt;td class=&quot;menu-location-menus&quot;&gt;
+                                                        &lt;select name=&quot;menu-locations[&lt;?php echo $_location; ?&gt;]&quot; id=&quot;locations-&lt;?php echo $_location; ?&gt;&quot;&gt;
+                                                                &lt;option value=&quot;0&quot;&gt;&lt;?php printf( '&amp;mdash; %s &amp;mdash;', esc_html__( 'Select a Menu' ) ); ?&gt;&lt;/option&gt;
+                                                                &lt;?php foreach ( $nav_menus as $menu ) : ?&gt;
+                                                                        &lt;?php $selected = isset( $menu_locations[$_location] ) &amp;&amp; $menu_locations[$_location] == $menu-&gt;term_id; ?&gt;
+                                                                        &lt;option &lt;?php if ( $selected ) echo 'data-orig=&quot;true&quot;'; ?&gt; &lt;?php selected( $selected ); ?&gt; value=&quot;&lt;?php echo $menu-&gt;term_id; ?&gt;&quot;&gt;
+                                                                                &lt;?php $truncated_name = wp_html_excerpt( $menu-&gt;name, 40 );
+                                                                                echo $truncated_name == $menu-&gt;name ? $menu-&gt;name : trim( $truncated_name ) . '&amp;hellip;'; ?&gt;
+                                                                        &lt;/option&gt;
+                                                                &lt;?php endforeach; ?&gt;
+                                                        &lt;/select&gt;
+                                                        &lt;div class=&quot;locations-row-links&quot;&gt;
+                                                                &lt;?php if ( isset( $menu_locations[ $_location ] ) &amp;&amp; 0 != $menu_locations[ $_location ] ) : ?&gt;
+                                                                &lt;span class=&quot;locations-edit-menu-link&quot;&gt;
+                                                                        &lt;a href=&quot;&lt;?php echo esc_url( add_query_arg( array( 'action' =&gt; 'edit', 'menu' =&gt; $menu_locations[$_location] ), admin_url( 'nav-menus.php' ) ) ); ?&gt;&quot;&gt;
+                                                                                &lt;?php _ex( 'Edit', 'menu' ); ?&gt;
+                                                                        &lt;/a&gt;
+                                                                &lt;/span&gt;
+                                                                &lt;?php endif; ?&gt;
+                                                                &lt;span class=&quot;locations-add-menu-link&quot;&gt;
+                                                                        &lt;a href=&quot;&lt;?php echo esc_url( add_query_arg( array( 'action' =&gt; 'edit', 'menu' =&gt; 0, 'use-location' =&gt; $_location ), admin_url( 'nav-menus.php' ) ) ); ?&gt;&quot;&gt;
+                                                                                &lt;?php _ex( 'Use new menu', 'menu' ); ?&gt;
+                                                                        &lt;/a&gt;
+                                                                &lt;/span&gt;
+                                                        &lt;/div&gt;&lt;!-- #locations-row-links --&gt;
+                                                &lt;/td&gt;&lt;!-- .menu-location-menus --&gt;
+                                        &lt;/tr&gt;&lt;!-- #menu-locations-row --&gt;
+                                &lt;?php } // foreach ?&gt;
+                                &lt;/tbody&gt;
+                        &lt;/table&gt;
+                        &lt;p class=&quot;button-controls&quot;&gt;&lt;?php submit_button( __( 'Save Changes' ), 'primary left', 'nav-menu-locations', false ); ?&gt;&lt;/p&gt;
+                        &lt;?php wp_nonce_field( 'save-menu-locations' ); ?&gt;
+                        &lt;input type=&quot;hidden&quot; name=&quot;menu&quot; id=&quot;nav-menu-meta-object-id&quot; value=&quot;&lt;?php echo esc_attr( $nav_menu_selected_id ); ?&gt;&quot; /&gt;
+                &lt;/form&gt;
+        &lt;/div&gt;&lt;!-- #menu-locations-wrap --&gt;
+        &lt;?php do_action( 'after_menu_locations_table' ); ?&gt;
+        &lt;?php else : ?&gt;
</ins><span class="cx">         &lt;div class=&quot;manage-menus&quot;&gt;
</span><del>-        &lt;?php if ( $menu_count &lt; 2 ) : ?&gt;
</del><ins>+                 &lt;?php if ( $menu_count &lt; 2 ) : ?&gt;
</ins><span class="cx">                 &lt;span class=&quot;add-edit-menu-action&quot;&gt;
</span><span class="cx">                         &lt;?php printf( __( 'Edit your menu below, or &lt;a href=&quot;%s&quot;&gt;create a new menu&lt;/a&gt;.' ), esc_url( add_query_arg( array( 'action' =&gt; 'edit', 'menu' =&gt; 0 ), admin_url( 'nav-menus.php' ) ) ) ); ?&gt;
</span><span class="cx">                 &lt;/span&gt;&lt;!-- /add-edit-menu-action --&gt;
</span><del>-        &lt;?php else : ?&gt;
-                &lt;form method=&quot;get&quot; action=&quot;&quot;&gt;
</del><ins>+                &lt;?php else : ?&gt;
+                        &lt;form method=&quot;get&quot; action=&quot;&lt;?php echo admin_url( 'nav-menus.php' ); ?&gt;&quot;&gt;
</ins><span class="cx">                         &lt;input type=&quot;hidden&quot; name=&quot;action&quot; value=&quot;edit&quot; /&gt;
</span><span class="cx">                         &lt;label for=&quot;menu&quot; class=&quot;selected-menu&quot;&gt;&lt;?php _e( 'Select a menu to edit:' ); ?&gt;&lt;/label&gt;
</span><span class="cx">                         &lt;select name=&quot;menu&quot; id=&quot;menu&quot;&gt;
</span><span class="lines">@@ -578,6 +666,9 @@
</span><span class="cx">                                                         &lt;?php endif; ?&gt;
</span><span class="cx">                                                         &lt;?php if ( $add_new_screen ) : ?&gt;
</span><span class="cx">                                                                 &lt;p class=&quot;post-body-plain&quot;&gt;&lt;?php _e( 'Give your menu a name above, then click Create Menu.' ); ?&gt;&lt;/p&gt;
</span><ins>+                                                                &lt;?php if ( isset( $_GET['use-location'] ) ) : ?&gt;
+                                                                        &lt;input type=&quot;hidden&quot; name=&quot;use-location&quot; value=&quot;&lt;?php echo esc_attr( $_GET['use-location'] ); ?&gt;&quot; /&gt;
+                                                                &lt;?php endif; ?&gt;
</ins><span class="cx">                                                         &lt;?php endif; ?&gt;
</span><span class="cx">                                                         &lt;div class=&quot;menu-settings&quot; &lt;?php if ( $one_theme_location_no_menus ) { ?&gt;style=&quot;display: none;&quot;&lt;?php } ?&gt;&gt;
</span><span class="cx">                                                                 &lt;h3&gt;&lt;?php _e( 'Menu Settings' ); ?&gt;&lt;/h3&gt;
</span><span class="lines">@@ -633,5 +724,6 @@
</span><span class="cx">                 &lt;/div&gt;&lt;!-- /#menu-management --&gt;
</span><span class="cx">         &lt;/div&gt;&lt;!-- /#menu-management-liquid --&gt;
</span><span class="cx">         &lt;/div&gt;&lt;!-- /#nav-menus-frame --&gt;
</span><ins>+        &lt;?php endif; ?&gt;
</ins><span class="cx"> &lt;/div&gt;&lt;!-- /.wrap--&gt;
</span><span class="cx"> &lt;?php include( './admin-footer.php' ); ?&gt;
</span></span></pre>
</div>
</div>

</body>
</html>