<!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" /><style type="text/css"><!--
#msg dl { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer { 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 #fc0 solid; padding: 6px; }
#msg ul, pre { overflow: auto; }
#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>
<title>[13704] trunk: Menus rework.</title>
</head>
<body>

<div id="msg">
<dl>
<dt>Revision</dt> <dd><a href="http://trac.wordpress.org/changeset/13704">13704</a></dd>
<dt>Author</dt> <dd>ryan</dd>
<dt>Date</dt> <dd>2010-03-15 16:26:46 +0000 (Mon, 15 Mar 2010)</dd>
</dl>

<h3>Log Message</h3>
<pre>Menus rework. Props ptahdunbar. see <a href="http://trac.wordpress.org/ticket/11817">#11817</a></pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkwpadmincssnavmenucss">trunk/wp-admin/css/nav-menu.css</a></li>
<li><a href="#trunkwpadmincssnavmenudevcss">trunk/wp-admin/css/nav-menu.dev.css</a></li>
<li><a href="#trunkwpadminincludesnavmenuphp">trunk/wp-admin/includes/nav-menu.php</a></li>
<li><a href="#trunkwpadminjsnavmenudefaultitemsdevjs">trunk/wp-admin/js/nav-menu-default-items.dev.js</a></li>
<li><a href="#trunkwpadminjsnavmenudefaultitemsjs">trunk/wp-admin/js/nav-menu-default-items.js</a></li>
<li><a href="#trunkwpadminjsnavmenudynamicfunctionsdevjs">trunk/wp-admin/js/nav-menu-dynamic-functions.dev.js</a></li>
<li><a href="#trunkwpadminjsnavmenudynamicfunctionsjs">trunk/wp-admin/js/nav-menu-dynamic-functions.js</a></li>
<li><a href="#trunkwpadminnavmenusphp">trunk/wp-admin/nav-menus.php</a></li>
<li><a href="#trunkwpcontentthemestwentytenheaderphp">trunk/wp-content/themes/twentyten/header.php</a></li>
<li><a href="#trunkwpcontentthemestwentytenstylecss">trunk/wp-content/themes/twentyten/style.css</a></li>
<li><a href="#trunkwpincludesnavmenutemplatephp">trunk/wp-includes/nav-menu-template.php</a></li>
<li><a href="#trunkwpincludesnavmenuphp">trunk/wp-includes/nav-menu.php</a></li>
<li><a href="#trunkwpincludesscriptloaderphp">trunk/wp-includes/script-loader.php</a></li>
<li><a href="#trunkwpincludestaxonomyphp">trunk/wp-includes/taxonomy.php</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkwpadmincssnavmenucss"></a>
<div class="modfile"><h4>Modified: trunk/wp-admin/css/nav-menu.css (13703 => 13704)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-admin/css/nav-menu.css        2010-03-15 14:29:11 UTC (rev 13703)
+++ trunk/wp-admin/css/nav-menu.css        2010-03-15 16:26:46 UTC (rev 13704)
</span><span class="lines">@@ -1 +1 @@
</span><del>-#menu-management{clear:both;}#menu-management .inside{padding:0 10px;}#menu-container .submit{margin:0 0 10px;padding:0;}.submitdelete{color:#f00;text-decoration:underline;font-size:11px;float:left;margin-top:5px;}.submitdelete:hover{background-color:#F00;color:#fff;}.save{float:right;}.button-controls{float:left;}.add-to-menu{float:right;}#create-menu-name{width:159px;}#available-links{margin:15px 0 0;}#available-links dt{display:block;}#add-custom-link .howto{font-size:11px;}#add-custom-link label span{display:block;float:left;margin-top:5px;padding-right:5px;}#menu-item-url,#menu-item-name{float:right;width:220px;}.show-all,.hide-all{cursor:pointer;}.hide-all{display:none;}.quick-search{width:190px;}.list-wrap{display:none;clear:both;}.list-container{max-height:200px;overflow-y:auto;padding:10px 10px 5px;border:1px solid #DFDFDF;-moz-border-radius:4px;}.postbox p.submit{margin-bottom:0;}.list li{display:none;margin:0;margin-bottom:5px;}.list li .item-title{cursor:pointer;display:block;}.list li .item-title input{margin-right:3px;margin-top:-3px;}.list li ul li .item-title{margin-left:14px;}.list li ul li ul li .item-title{margin-left:28px;}.list li ul li ul li ul li .item-title{margin-left:42px;}.list li ul li ul li ul li ul li .item-title{margin-left:56px;}.list li ul li ul li ul li ul li ul li .item-title{margin-left:70px;}.list li ul li ul li ul li ul li ul li ul li .item-title{margin-left:84px;}.list li ul li ul li ul li ul li ul li ul li ul li .item-title{margin-left:98px;}.list li ul li ul li ul li ul li ul li ul li ul li ul li .item-title{margin-left:112px;}#menu-container .inside{padding-bottom:10px;}.menu ul{width:100%;}.menu li{margin:0;}.menu li dl dt{-webkit-border-bottom-left-radius:6px;-webkit-border-bottom-right-radius:6px;-webkit-border-top-left-radius:6px;-webkit-border-top-right-radius:6px;border-bottom-left-radius:6px;border-bottom-right-radius:6px;border-top-left-radius:6px;border-top-right-radius:6px;-moz-border-radius-bottomleft:6px;-moz-border-radius-bottomright:6px;-moz-border-radius-topleft:6px;-moz-border-radius-topright:6px;border:1px solid #E6E6E6;position:relative;padding-left:10px;background-color:#f1f1f1;height:35px;line-height:35px;}.menu li dl dt:hover{cursor:move;}.menu li .item-title{background:url(../images/ico-arrow.png) no-repeat 4px 5px;background-position:center left;padding-left:15px;}.menu li ul li{margin-left:20px;opacity:.7;}.menu li ul li ul li{opacity:.9;}.menu li ul li ul li ul li{opacity:.9;}.menu li ul li ul li ul li ul li{opacity:.95;}.dropzone{height:7px;margin:3px 0 3px 0;}.ui-draggable-dragging{width:600px;}.item-type{text-transform:uppercase;font-size:11px;color:#999;padding-right:10px;}.item-controls{font-size:11px;position:absolute;right:15px;top:-1px;}.item-controls a{text-decoration:none;}.item-controls a:hover{cursor:pointer;}.item-controls .item-delete:hover{color:#f00;}#menu-item-settings{display:none;}#cancel-save{cursor:pointer;}#cancel-save:hover{color:#fff!important;}#update-menu-item{color:#fff!important;}#update-menu-item:hover,#update-menu-item:active,#update-menu-item:focus{color:#eaf2fa!important;border-color:#13455b!important;}.hide{display:none;}
</del><span class="cx">\ No newline at end of file
</span><ins>+#menu-management{clear:both;}#menu-management .inside{padding:0 10px;}#menu-container .submit{margin:0 0 10px;padding:0;}.submitdelete{font-size:11px;}#cancel-save{color:#f00;text-decoration:underline;font-size:11px;margin-left:20px;margin-top:5px;}#cancel-save:hover{background-color:#F00;color:#fff;}.button-controls{float:left;}.add-to-menu{float:right;}#manage-menu .inside{padding:0;}#create-menu-name{width:159px;}#available-links{margin:15px 0 0;}#available-links dt{display:block;}#add-custom-link .howto{font-size:11px;}#add-custom-link label span{display:block;float:left;margin-top:5px;padding-right:5px;}.menu-item-textbox{float:right;width:220px;}.howto span{margin-top:4px;display:block;float:left;}.show-all,.hide-all{cursor:pointer;}.hide-all{display:none;}.quick-search{width:190px;}.list-wrap{display:none;clear:both;}.list-container{max-height:200px;overflow-y:auto;padding:10px 10px 5px;border:1px solid #DFDFDF;-moz-border-radius:4px;}.postbox p.submit{margin-bottom:0;}.list li{display:none;margin:0;margin-bottom:5px;}.list li .menu-item-title{cursor:pointer;display:block;}.list li .menu-item-title input{margin-right:3px;margin-top:-3px;}.list li ul li .menu-item-title{margin-left:14px;}.list li ul li ul li .menu-item-title{margin-left:28px;}.list li ul li ul li ul li .menu-item-title{margin-left:42px;}.list li ul li ul li ul li ul li .menu-item-title{margin-left:56px;}.list li ul li ul li ul li ul li ul li .menu-item-title{margin-left:70px;}.list li ul li ul li ul li ul li ul li ul li .menu-item-title{margin-left:84px;}.list li ul li ul li ul li ul li ul li ul li ul li .menu-item-title{margin-left:98px;}.list li ul li ul li ul li ul li ul li ul li ul li ul li .menu-item-title{margin-left:112px;}#menu-container .inside{padding-bottom:10px;}.menu ul{width:100%;}.menu li{margin:0;}.menu li dl dt{-webkit-border-bottom-left-radius:6px;-webkit-border-bottom-right-radius:6px;-webkit-border-top-left-radius:6px;-webkit-border-top-right-radius:6px;border-bottom-left-radius:6px;border-bottom-right-radius:6px;border-top-left-radius:6px;border-top-right-radius:6px;-moz-border-radius-bottomleft:6px;-moz-border-radius-bottomright:6px;-moz-border-radius-topleft:6px;-moz-border-radius-topright:6px;border:1px solid #E6E6E6;position:relative;padding-left:10px;background-color:#f1f1f1;height:35px;line-height:35px;}.menu li dl dt:hover{cursor:move;}.menu li ul li{margin-left:20px;opacity:.7;}.menu li ul li ul li{opacity:.9;}.menu li ul li ul li ul li{opacity:.9;}.menu li ul li ul li ul li ul li{opacity:.95;}.dropzone{height:7px;margin:3px 0 3px 0;}.ui-draggable-dragging{width:600px;}.item-type{text-transform:uppercase;font-size:11px;color:#999;padding-right:10px;}.item-controls{font-size:11px;position:absolute;right:15px;top:-1px;}.item-controls a{text-decoration:none;}.item-controls a:hover{cursor:pointer;}.item-controls .menu-item-delete:hover{color:#f00;}#menu-item-settings{display:none;}#cancel-save{cursor:pointer;}#cancel-save:hover{color:#fff!important;}#update-menu-item{color:#fff!important;}#update-menu-item:hover,#update-menu-item:active,#update-menu-item:focus{color:#eaf2fa!important;border-color:#13455b!important;}
</ins><span class="cx">\ No newline at end of file
</span></span></pre></div>
<a id="trunkwpadmincssnavmenudevcss"></a>
<div class="modfile"><h4>Modified: trunk/wp-admin/css/nav-menu.dev.css (13703 => 13704)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-admin/css/nav-menu.dev.css        2010-03-15 14:29:11 UTC (rev 13703)
+++ trunk/wp-admin/css/nav-menu.dev.css        2010-03-15 16:26:46 UTC (rev 13704)
</span><span class="lines">@@ -14,19 +14,16 @@
</span><span class="cx"> 
</span><span class="cx"> /* Button Primary Actions */
</span><span class="cx"> #menu-container .submit { margin: 0px 0px 10px; padding: 0px; }
</span><del>-.submitdelete { color: #ff0000; text-decoration: underline; font-size: 11px; float: left; margin-top: 5px; }
-.submitdelete:hover { background-color: #FF0000; color: #fff; }
-.save { float: right; }
</del><span class="cx"> 
</span><ins>+.submitdelete { font-size: 11px; }
+#cancel-save { color: #ff0000; text-decoration: underline; font-size: 11px; margin-left: 20px; margin-top: 5px; }
+#cancel-save:hover { background-color: #FF0000; color: #fff; }
+
</ins><span class="cx"> /* Button Secondary Actions */
</span><span class="cx"> .button-controls { float: left; }
</span><span class="cx"> .add-to-menu { float: right; }
</span><span class="cx"> 
</span><del>-/* CSS for switching the main columns *//*
-#menu-settings-column { clear: none; float: left; }
-#menu-management #post-body { float: right; margin-left: -340px; margin-right: 0px; }
-#menu-management #post-body-content { margin-left: 300px; margin-right: 0px; }
-*/
</del><ins>+#manage-menu .inside { padding: 0px 0px; }
</ins><span class="cx"> 
</span><span class="cx"> /* Create Menu */
</span><span class="cx"> #create-menu-name { width: 159px; }
</span><span class="lines">@@ -36,7 +33,8 @@
</span><span class="cx"> #available-links dt { display: block; }
</span><span class="cx"> #add-custom-link .howto { font-size: 11px; }
</span><span class="cx"> #add-custom-link label span { display: block; float: left; margin-top: 5px; padding-right: 5px; }
</span><del>-#menu-item-url, #menu-item-name { float: right; width: 220px; }
</del><ins>+.menu-item-textbox { float: right; width: 220px; }
+.howto span { margin-top: 4px; display: block; float: left; }
</ins><span class="cx"> 
</span><span class="cx"> /* Pages/Categories */
</span><span class="cx"> .show-all, .hide-all { cursor: pointer; }
</span><span class="lines">@@ -50,17 +48,17 @@
</span><span class="cx"> /* Listings */
</span><span class="cx"> .list li { display: none; margin: 0; margin-bottom: 5px; }
</span><span class="cx"> 
</span><del>-.list li .item-title { cursor: pointer; display: block; }
-.list li .item-title input { margin-right: 3px; margin-top: -3px; }
</del><ins>+.list li .menu-item-title { cursor: pointer; display: block; }
+.list li .menu-item-title input { margin-right: 3px; margin-top: -3px; }
</ins><span class="cx"> 
</span><del>-.list li ul li .item-title  { margin-left: 14px; }
-.list li ul li ul li .item-title  { margin-left: 28px; }
-.list li ul li ul li ul li .item-title  { margin-left: 42px; }
-.list li ul li ul li ul li ul li .item-title  { margin-left: 56px; }
-.list li ul li ul li ul li ul li ul li .item-title  { margin-left: 70px; }
-.list li ul li ul li ul li ul li ul li ul li .item-title  { margin-left: 84px; }
-.list li ul li ul li ul li ul li ul li ul li ul li .item-title  { margin-left: 98px; }
-.list li ul li ul li ul li ul li ul li ul li ul li ul li .item-title  { margin-left: 112px; }
</del><ins>+.list li ul li .menu-item-title  { margin-left: 14px; }
+.list li ul li ul li .menu-item-title  { margin-left: 28px; }
+.list li ul li ul li ul li .menu-item-title  { margin-left: 42px; }
+.list li ul li ul li ul li ul li .menu-item-title  { margin-left: 56px; }
+.list li ul li ul li ul li ul li ul li .menu-item-title  { margin-left: 70px; }
+.list li ul li ul li ul li ul li ul li ul li .menu-item-title  { margin-left: 84px; }
+.list li ul li ul li ul li ul li ul li ul li ul li .menu-item-title  { margin-left: 98px; }
+.list li ul li ul li ul li ul li ul li ul li ul li ul li .menu-item-title  { margin-left: 112px; }
</ins><span class="cx"> 
</span><span class="cx"> /* Menu */
</span><span class="cx"> #menu-container .inside { padding-bottom: 10px; }
</span><span class="lines">@@ -71,9 +69,9 @@
</span><span class="cx"> .menu li dl dt:hover { cursor: move; }
</span><span class="cx"> 
</span><span class="cx"> .menu li .item-title { }
</span><del>-.menu li ul li { margin-left: 20px; opacity: .7;}
-.menu li ul li ul li { opacity: .9;}
-.menu li ul li ul li ul li { opacity: .9;}
</del><ins>+.menu li ul li { margin-left: 20px; opacity: .7; }
+.menu li ul li ul li { opacity: .9; }
+.menu li ul li ul li ul li { opacity: .9; }
</ins><span class="cx"> .menu li ul li ul li ul li ul li { opacity: .95; }
</span><span class="cx"> 
</span><span class="cx"> /* Drag and Drop */
</span><span class="lines">@@ -85,7 +83,7 @@
</span><span class="cx"> .item-controls { font-size: 11px; position: absolute; right: 15px; top: -1px; }
</span><span class="cx"> .item-controls a { text-decoration: none; }
</span><span class="cx"> .item-controls a:hover { cursor: pointer; }
</span><del>-.item-controls .item-delete:hover { color: #ff0000; }
</del><ins>+.item-controls .menu-item-delete:hover { color: #ff0000; }
</ins><span class="cx"> 
</span><span class="cx"> /* Thickbox */
</span><span class="cx"> #menu-item-settings { display: none; }
</span><span class="lines">@@ -94,7 +92,4 @@
</span><span class="cx"> #update-menu-item { color: #fff !important; }
</span><span class="cx"> #update-menu-item:hover,
</span><span class="cx"> #update-menu-item:active,
</span><del>-#update-menu-item:focus { color: #eaf2fa !important; border-color: #13455b !important; }
-
-/* Misc */
-.hide { display: none; }
</del><span class="cx">\ No newline at end of file
</span><ins>+#update-menu-item:focus { color: #eaf2fa !important; border-color: #13455b !important; }
</ins><span class="cx">\ No newline at end of file
</span></span></pre></div>
<a id="trunkwpadminincludesnavmenuphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-admin/includes/nav-menu.php (13703 => 13704)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-admin/includes/nav-menu.php        2010-03-15 14:29:11 UTC (rev 13703)
+++ trunk/wp-admin/includes/nav-menu.php        2010-03-15 16:26:46 UTC (rev 13704)
</span><span class="lines">@@ -1,273 +1,383 @@
</span><span class="cx"> &lt;?php
</span><span class="cx"> 
</span><ins>+/* Register Metaboxes */
+add_meta_box( 'create-menu', __('Create Menu'), 'wp_nav_menu_create_metabox', 'menus', 'side', 'core' );
+add_meta_box( 'add-custom-links', __('Add Custom Links'), 'wp_nav_menu_item_link_metabox', 'menus', 'side', 'default' );
+wp_nav_menu_post_type_metaboxes();
+wp_nav_menu_taxonomy_metaboxes();
+
</ins><span class="cx"> /**
</span><del>- * Displays a list of links and thier sub items.
</del><ins>+ * Creates metaboxes for any post type menu item.
</ins><span class="cx">  *
</span><span class="cx">  * @since 3.0.0
</span><del>- *
- * @param string $counter 
- * @param string $context 
</del><span class="cx">  */
</span><del>-function wp_nav_menu_get_custom_links( $counter, $context ) {
-        $available_links = new WP_Query(  );
</del><ins>+function wp_nav_menu_post_type_metaboxes() {
+        $post_types = get_post_types( array( 'public' =&gt; true ), 'object' );
</ins><span class="cx">         
</span><del>-        $args = array( 'post_status' =&gt; 'any', 'post_type' =&gt; 'nav_menu_item', 'meta_value' =&gt; 'custom' );
-        $link_objects = new WP_Query( $args );
</del><ins>+        if ( !$post_types )
+                return false;
</ins><span class="cx">         
</span><del>-        $items_counter = $counter;
</del><ins>+        foreach ( $post_types as $post_type ) {                
+                $id = sanitize_title_with_dashes( $post_type-&gt;label );
+                
+                // delete_transient( &quot;nav_menu_items_{$post_type-&gt;name}&quot; );
+                // delete_transient( &quot;nav_menu_sub_items_{$post_type-&gt;name}&quot; );
+                
+                add_meta_box( &quot;add-{$id}&quot;, sprintf( __('Add an Existing %s'), $post_type-&gt;singular_label ), 'wp_nav_menu_item_post_type_metabox', 'menus', 'side', 'default', $post_type );
+        }
+}
</ins><span class="cx"> 
</span><del>-        if ( !$link_objects-&gt;posts ) {
-                _e('Not Found');
-                return $items_counter;
-        }
</del><ins>+/**
+ * Creates metaboxes for any taxonomy menu item.
+ *
+ * @since 3.0.0
+ */
+function wp_nav_menu_taxonomy_metaboxes() {
+        $taxonomies = get_taxonomies( array( 'show_ui' =&gt; true ), 'object' );
</ins><span class="cx">         
</span><del>-        // Display Loop
-        foreach ( $link_objects-&gt;posts as $item ) {
-                if ( 0 == $item-&gt;parent ) {
-                        $item = wp_setup_nav_menu_item( $item, 'item', $items_counter );
-                        
-                        switch ( $context ) {
-                                case 'menu':
-                                        ?&gt;
-                                        &lt;li id=&quot;menu-&lt;?php echo $items_counter; ?&gt;&quot; value=&quot;&lt;?php echo $items_counter; ?&gt;&quot;&gt;
-                                                &lt;?php
-                                                        echo wp_get_nav_menu_item( $item, 'menu' );
-                                                        $parentli = $item-&gt;ID;
-                                                        $items_counter++;
-                                                        $items_counter = wp_nav_menu_sub_items( $item-&gt;ID, $items_counter, $parentli, 'categories', 'menu' );
-                                                ?&gt;
-                                        &lt;/li&gt;
-                                        &lt;?php
-                                        break;
-                                
-                                case 'default':
-                                        ?&gt;
-                                        &lt;li&gt;
-                                                &lt;?php
-                                                        echo wp_get_nav_menu_item( $item, 'default' );
-                                                        $parentli = $item-&gt;ID;
-                                                        $items_counter++;
-                                                        $items_counter = wp_nav_menu_sub_items( $item-&gt;ID, $items_counter, $parentli, 'categories', 'default' );
-                                                ?&gt;
-                                        &lt;/li&gt;
-                                        &lt;?php
-                                        break;
-                        }
-                }
</del><ins>+        if ( !$taxonomies )
+                return false;
+        
+        foreach ( $taxonomies as $tax ) {
+                $id = sanitize_title_with_dashes( $tax-&gt;label );
+                
+                // delete_transient( &quot;nav_menu_items_{$tax-&gt;name}&quot; );
+                // delete_transient( &quot;nav_menu_sub_items_{$tax-&gt;name}&quot; );
+                
+                add_meta_box( &quot;add-{$id}&quot;, sprintf( __('Add an Existing %s'), $tax-&gt;singular_label ), 'wp_nav_menu_item_taxonomy_metabox', 'menus', 'side', 'default', $tax );
</ins><span class="cx">         }
</span><del>-        return $items_counter;
</del><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> /**
</span><del>- * Displays a list of pages and thier sub items.
</del><ins>+ * Displays a metabox for managing the active menu being edited.
</ins><span class="cx">  *
</span><span class="cx">  * @since 3.0.0
</span><del>- *
- * @param string $counter 
- * @param string $context 
</del><span class="cx">  */
</span><del>-function wp_nav_menu_get_pages( $counter, $context ) {
-        $pages_args = array(
-                    'child_of' =&gt; 0,
-                        'sort_order' =&gt; 'ASC',
-                        'sort_column' =&gt; 'post_title',
-                        'hierarchical' =&gt; 1,
-                        'exclude' =&gt; '',
-                        'include' =&gt; '',
-                        'meta_key' =&gt; '',
-                        'meta_value' =&gt; '',
-                        'authors' =&gt; '',
-                        'parent' =&gt; -1,
-                        'exclude_tree' =&gt; '',
-                        'number' =&gt; '',
-                        'offset' =&gt; 0 );
</del><ins>+function wp_nav_menu_manage_menu_metabox( $object, $menu ) { ?&gt;
+        &lt;div id=&quot;submitpost&quot; class=&quot;submitbox&quot;&gt;
+                &lt;div id=&quot;minor-publishing&quot;&gt;
+                        &lt;div class=&quot;misc-pub-section misc-pub-section-last&quot;&gt;
+                                &lt;label class=&quot;howto&quot; for=&quot;menu-name&quot;&gt;
+                                        &lt;span&gt;&lt;?php _e('Name'); ?&gt;&lt;/span&gt;
+                                        &lt;input id=&quot;menu-name&quot; name=&quot;menu-name&quot; type=&quot;text&quot; class=&quot;regular-text menu-item-textbox&quot; value=&quot;&lt;?php esc_attr_e( $menu['args'][1] ); ?&gt;&quot; /&gt;
+                                        &lt;br class=&quot;clear&quot; /&gt;
+                                &lt;/label&gt;
+                        &lt;/div&gt;&lt;!--END .misc-pub-section misc-pub-section-last--&gt;
+                        &lt;br class=&quot;clear&quot; /&gt;
+                &lt;/div&gt;&lt;!--END #misc-publishing-actions--&gt;
+                &lt;div id=&quot;major-publishing-actions&quot;&gt;
+                        &lt;div id=&quot;delete-action&quot;&gt;
+                                &lt;a class=&quot;submitdelete deletion&quot; href=&quot;&lt;?php echo wp_nonce_url( admin_url('nav-menus.php?action=delete&amp;amp;menu=' . $menu['args'][0]), 'delete-nav_menu-' . $menu['args'][0] ); ?&gt;&quot;&gt;&lt;?php _e('Delete Menu'); ?&gt;&lt;/a&gt;
+                        &lt;/div&gt;&lt;!--END #delete-action--&gt;
</ins><span class="cx"> 
</span><del>-        // Get all pages
-        $pages_array = get_pages( $pages_args );
</del><ins>+                        &lt;div id=&quot;publishing-action&quot;&gt;
+                                &lt;input class=&quot;button-primary&quot; name=&quot;save_menu&quot; type=&quot;submit&quot; value=&quot;&lt;?php esc_attr_e('Save Menu'); ?&gt;&quot; /&gt;
+                        &lt;/div&gt;&lt;!--END #publishing-action--&gt;
+                        &lt;br class=&quot;clear&quot; /&gt;
+                &lt;/div&gt;&lt;!--END #major-publishing-actions--&gt;
+        &lt;/div&gt;&lt;!--END #submitpost .submitbox--&gt;
+        &lt;?php
+}
</ins><span class="cx"> 
</span><del>-        $items_counter = $counter;
-        $parentli = $items_counter;
</del><ins>+/**
+ * Displays a metabox for creating a new menu.
+ *
+ * @since 3.0.0
+ */
+function wp_nav_menu_create_metabox() { ?&gt;
+        &lt;p&gt;
+                &lt;input type=&quot;text&quot; name=&quot;create-menu-name&quot; id=&quot;create-menu-name&quot; class=&quot;regular-text&quot; value=&quot;&quot;  /&gt;
+                &lt;input type=&quot;submit&quot; name=&quot;create-menu&quot; id=&quot;create-menu&quot; class=&quot;button&quot; value=&quot;&lt;?php esc_attr_e('Create Menu'); ?&gt;&quot; /&gt;
+        &lt;/p&gt;
+        &lt;?php
+}
</ins><span class="cx"> 
</span><del>-        if ( !$pages_array ) {
-                echo __('Not Found');
-                return $items_counter;
</del><ins>+/**
+ * Displays a metabox for the custom links menu item.
+ *
+ * @since 3.0.0
+ */
+function wp_nav_menu_item_link_metabox() {
+        $args = array( 'post_status' =&gt; 'any', 'post_type' =&gt; 'nav_menu_item', 'meta_value' =&gt; 'custom' );        
+        
+        // Cache the query for a day. @todo: Make sure to flush transient when links are updated.
+        $query = get_transient( 'menu_item_query_custom_links' );
+        if ( false == $query ) {
+                $query = new WP_Query( $args );
+                set_transient( 'menu_item_query_custom_links', $query, 86400 );
</ins><span class="cx">         }
</span><ins>+        
+        ?&gt;
+        &lt;p id=&quot;menu-item-url-wrap&quot;&gt;
+                &lt;label class=&quot;howto&quot; for=&quot;menu-item-url&quot;&gt;
+                        &lt;span&gt;&lt;?php _e('URL'); ?&gt;&lt;/span&gt;
+                        &lt;input id=&quot;custom-menu-item-url&quot; name=&quot;custom-menu-item-url&quot; type=&quot;text&quot; class=&quot;code menu-item-textbox&quot; value=&quot;http://&quot; /&gt;
+                &lt;/label&gt;
+        &lt;/p&gt;
+        &lt;br class=&quot;clear&quot; /&gt;
+        &lt;p id=&quot;menu-item-name-wrap&quot;&gt;
+                &lt;label class=&quot;howto&quot; for=&quot;custom-menu-item-name&quot;&gt;
+                        &lt;span&gt;&lt;?php _e('Text'); ?&gt;&lt;/span&gt;
+                        &lt;input id=&quot;custom-menu-item-name&quot; name=&quot;custom-menu-item-name&quot; type=&quot;text&quot; class=&quot;regular-text menu-item-textbox&quot; value=&quot;&lt;?php echo esc_attr( __('Menu Item') ); ?&gt;&quot; /&gt;
+                &lt;/label&gt;
+        &lt;/p&gt;
+        
+        &lt;p class=&quot;button-controls&quot;&gt;
+                &lt;a class=&quot;show-all&quot;&gt;&lt;?php _e('View All'); ?&gt;&lt;/a&gt;
+                &lt;a class=&quot;hide-all&quot;&gt;&lt;?php _e('Hide All'); ?&gt;&lt;/a&gt;
+        &lt;/p&gt;
+        &lt;div id=&quot;available-links&quot; class=&quot;list-wrap&quot;&gt;
+                &lt;div class=&quot;list-container&quot;&gt;
+                        &lt;ul class=&quot;list&quot;&gt;
+                                &lt;?php echo wp_nav_menu_get_items( $query-&gt;posts, 'custom' ); ?&gt;
+                        &lt;/ul&gt;
+                &lt;/div&gt;&lt;!-- /.list-container--&gt;
+        &lt;/div&gt;&lt;!-- /#available-links--&gt;
+        &lt;p class=&quot;add-to-menu&quot;&gt;
+                &lt;a class=&quot;button&quot;&gt;&lt;?php _e('Add to Menu'); ?&gt;&lt;/a&gt;
+        &lt;/p&gt;
+        &lt;div class=&quot;clear&quot;&gt;&lt;/div&gt;
+        &lt;?php
+}
</ins><span class="cx"> 
</span><del>-        // Display Loop
-        foreach ( $pages_array as $post ) {
-                if ( $post-&gt;post_parent == 0 ) {
-                        $post = wp_setup_nav_menu_item( $post, 'page', $items_counter );
-                        if ( $context == 'menu' ) {
-                                ?&gt;
-                                &lt;li id=&quot;menu-&lt;?php echo $items_counter; ?&gt;&quot; value=&quot;&lt;?php echo $items_counter; ?&gt;&quot;&gt;
-                                        &lt;?php
-                                                echo wp_get_nav_menu_item( $post, 'menu', $items_counter );
-                                                $parentli = $post-&gt;ID;
-                                                $items_counter++;
-                                                $items_counter = wp_nav_menu_sub_items( $post-&gt;ID, $items_counter, $parentli, 'pages', 'menu' );
-                                        ?&gt;
-                                &lt;/li&gt;
-                                &lt;?php
-                        } elseif ( $context == 'default' ) {
-                                // Sidebar Menu
-                                ?&gt;
-                                 &lt;li&gt;
-                                        &lt;?php
-                                                echo wp_get_nav_menu_item( $post, 'default' );
-                                                $parentli = $post-&gt;ID;
-                                                $items_counter++;
-                                                $items_counter = wp_nav_menu_sub_items( $post-&gt;ID, $items_counter, $parentli, 'pages', 'default' );
-                                         ?&gt;
-                                &lt;/li&gt;
-                                &lt;?php
</del><ins>+/**
+ * Displays a metabox for a post type menu item.
+ *
+ * @since 3.0.0
+ *
+ * @param string $object Not used.
+ * @param string $post_type The post type object.
+ */
+function wp_nav_menu_item_post_type_metabox( $object, $post_type ) {
+        $args = array( 'post_type' =&gt; $post_type['args']-&gt;name, );
+        
+        if ( 'attachment' == $post_type['args']-&gt;name )
+                $args['post_status'] = 'any';
+        
+        // Cache the query for a day. @todo: Make sure to flush transient when objects are updated.
+        $query = get_transient( &quot;nav_menu_items_{$post_type['args']-&gt;name}&quot; );
+        if ( false == $query ) {
+                $query = new WP_Query( $args );
+                set_transient( &quot;nav_menu_items_{$post_type['args']-&gt;name}&quot;, $query, 86400 );
+        }
+        
+        if ( !$query-&gt;posts )
+                $error = '&lt;li id=&quot;error&quot;&gt;'. sprintf( __( 'No %s exists' ), $post_type['args']-&gt;label ) .'&lt;/li&gt;';
+        
+        $pt_names = '';
+        if ( is_array($query-&gt;posts) ) {
+                foreach ( $query-&gt;posts as $post ) {
+                        if ( $post-&gt;post_title ) {
+                                $pt_names .= htmlentities( $post-&gt;post_title ) .'|';
+                        } else {
+                                $pt_names = sprintf( __('No %s exists'), $post_type['args']-&gt;label );
</ins><span class="cx">                         }
</span><span class="cx">                 }
</span><span class="cx">         }
</span><del>-        return $items_counter;
</del><ins>+        
+        $id = sanitize_title_with_dashes( $post_type['args']-&gt;label );
+        ?&gt;
+        &lt;p class=&quot;quick-search-wrap&quot;&gt;
+                &lt;input type=&quot;text&quot; class=&quot;quick-search regular-text&quot; value=&quot;&quot; /&gt;
+                &lt;a class=&quot;quick-search-submit button-secondary&quot;&gt;&lt;?php _e('Search'); ?&gt;&lt;/a&gt;
+        &lt;/p&gt;
+        
+        &lt;p class=&quot;button-controls&quot;&gt;
+                &lt;a class=&quot;show-all&quot;&gt;&lt;?php _e('View All'); ?&gt;&lt;/a&gt;
+                &lt;a class=&quot;hide-all&quot;&gt;&lt;?php _e('Hide All'); ?&gt;&lt;/a&gt;
+        &lt;/p&gt;
+        
+        &lt;div id=&quot;existing-&lt;?php echo esc_attr( $id ); ?&gt;&quot; class=&quot;list-wrap&quot;&gt;
+                &lt;div class=&quot;list-container&quot;&gt;
+                        &lt;ul class=&quot;list&quot;&gt;
+                                &lt;?php echo isset( $error ) ? $error : wp_nav_menu_get_items( $query-&gt;posts, 'post_type', $post_type['args']-&gt;name ); ?&gt;
+                        &lt;/ul&gt;
+                &lt;/div&gt;&lt;!-- /.list-container--&gt;
+        &lt;/div&gt;&lt;!-- /#existing-categories--&gt;
+        &lt;p class=&quot;add-to-menu&quot;&gt;
+                &lt;a class=&quot;button-secondary&quot;&gt;&lt;?php _e('Add to Menu'); ?&gt;&lt;/a&gt;
+        &lt;/p&gt;
+        &lt;input type=&quot;hidden&quot; class=&quot;autocomplete&quot; name=&quot;autocomplete-&lt;?php echo esc_attr( $post_type['args']-&gt;name ); ?&gt;-names&quot; value=&quot;&lt;?php echo esc_js( $pt_names ); ?&gt;&quot; /&gt;
+        &lt;br class=&quot;clear&quot; /&gt;
+        &lt;script type=&quot;text/javascript&quot; charset=&quot;utf-8&quot;&gt;
+                // &lt;![CDATA[
+                jQuery(document).ready(function(){
+                        wp_nav_menu_autocomplete('&lt;?php echo esc_attr($id); ?&gt;');
+                });
+                // ]]&gt;
+        &lt;/script&gt;
+        &lt;?php
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> /**
</span><del>- * Displays a list of categories and thier sub items.
</del><ins>+ * Displays a metabox for a taxonomy menu item.
</ins><span class="cx">  *
</span><span class="cx">  * @since 3.0.0
</span><span class="cx">  *
</span><del>- * @param string $counter 
- * @param string $context 
</del><ins>+ * @param string $object Not used.
+ * @param string $taxonomy The taxonomy object.
</ins><span class="cx">  */
</span><del>-function wp_nav_menu_get_categories( $counter, $context ) {
-        $category_args = array(
-                        'type'                     =&gt; 'post',
-                        'child_of'                 =&gt; 0,
-                        'orderby'                  =&gt; 'name',
-                        'order'                    =&gt; 'ASC',
-                        'hide_empty'               =&gt; false,
-                        'include_last_update_time' =&gt; false,
-                        'hierarchical'             =&gt; 1,
-                        'exclude'                  =&gt; '',
-                        'include'                  =&gt; '',
-                        'number'                   =&gt; '',
-                        'pad_counts'               =&gt; false );
-
-        $items_counter = $counter;
-
-        // Get all categories
-        $categories_array = get_categories( $category_args );
-
-        if ( !$categories_array ) {
-                _e('Not Found');
-                return $items_counter;
</del><ins>+function wp_nav_menu_item_taxonomy_metabox( $object, $taxonomy ) {
+        $args = array(
+                'child_of' =&gt; 0, 'orderby' =&gt; 'name', 'order' =&gt; 'ASC',
+                'hide_empty' =&gt; false, 'include_last_update_time' =&gt; false, 'hierarchical' =&gt; 1, 'exclude' =&gt; '',
+                'include' =&gt; '', 'number' =&gt; '', 'pad_counts' =&gt; false
+        );
+        
+        // Cache the query for a day. @todo: Make sure to flush transient when terms are updated.
+        $terms = get_transient( &quot;nav_menu_items_{$taxonomy['args']-&gt;name}&quot; );
+        if ( false == $terms ) {
+                $terms = get_terms( $taxonomy['args']-&gt;name, $args );
+                set_transient( &quot;nav_menu_items_{$taxonomy['args']-&gt;name}&quot;, $terms, 86400 );
</ins><span class="cx">         }
</span><del>-
-        // Display Loop
-        foreach ( $categories_array as $cat_item ) {
-                if ( $cat_item-&gt;parent == 0 ) {
-                        $cat_item = wp_setup_nav_menu_item( $cat_item, 'category', $items_counter );
-                        // Custom Menu
-                        if ( $context == 'menu' ) {
-                                ?&gt;
-                                &lt;li id=&quot;menu-&lt;?php echo $items_counter; ?&gt;&quot; value=&quot;&lt;?php echo $items_counter; ?&gt;&quot;&gt;
-                                        &lt;?php
-                                                echo wp_get_nav_menu_item($cat_item, 'menu');
-                                                $parentli = $cat_item-&gt;cat_ID;
-                                                $items_counter++;
-                                                $items_counter = wp_nav_menu_sub_items( $cat_item-&gt;cat_ID, $items_counter, $parentli, 'categories', 'menu' );
-                                        ?&gt;
-                                &lt;/li&gt;
-                                &lt;?php
-                        } elseif ( $context == 'default' ) {
-                                // Sidebar Menu
-                                ?&gt;
-                                &lt;li&gt;
-                                        &lt;?php
-                                                echo wp_get_nav_menu_item( $cat_item, 'default' );
-                                                $parentli = $cat_item-&gt;cat_ID;
-                                                $items_counter++;
-                                                $items_counter = wp_nav_menu_sub_items( $cat_item-&gt;cat_ID, $items_counter, $parentli, 'categories', 'default' );
-                                        ?&gt;
-                                &lt;/li&gt;
-                                &lt;?php
</del><ins>+        
+        if ( !$terms )
+                $error = '&lt;li id=&quot;error&quot;&gt;'. sprintf( __( 'No %s exists' ), $taxonomy['args']-&gt;label ) .'&lt;/li&gt;';
+        
+        $term_names = '';
+        if ( is_array($terms) ) {
+                foreach ( $terms as $term ) {
+                        if ( $term-&gt;name ) {
+                                $term_names .= htmlentities( $term-&gt;name ) .'|';
+                        } else {
+                                $term_names = sprintf( __('No %s exists'), $taxonomy['args']-&gt;label );
</ins><span class="cx">                         }
</span><span class="cx">                 }
</span><span class="cx">         }
</span><del>-        return $items_counter;
</del><ins>+        
+        $id = sanitize_title_with_dashes( $taxonomy['args']-&gt;label );
+        ?&gt;
+        &lt;p class=&quot;quick-search-wrap&quot;&gt;
+                &lt;input type=&quot;text&quot; class=&quot;quick-search regular-text&quot; value=&quot;&quot; /&gt;
+                &lt;a class=&quot;quick-search-submit button-secondary&quot;&gt;&lt;?php _e('Search'); ?&gt;&lt;/a&gt;
+        &lt;/p&gt;
+        
+        &lt;p class=&quot;button-controls&quot;&gt;
+                &lt;a class=&quot;show-all&quot;&gt;&lt;?php _e('View All'); ?&gt;&lt;/a&gt;
+                &lt;a class=&quot;hide-all&quot;&gt;&lt;?php _e('Hide All'); ?&gt;&lt;/a&gt;
+        &lt;/p&gt;
+        
+        &lt;div id=&quot;existing-&lt;?php echo esc_attr( $id ); ?&gt;&quot; class=&quot;list-wrap&quot;&gt;
+                &lt;div class=&quot;list-container&quot;&gt;
+                        &lt;ul class=&quot;list&quot;&gt;
+                                &lt;?php echo isset( $error ) ? $error : wp_nav_menu_get_items( $terms, 'taxonomy', $taxonomy['args']-&gt;name ); ?&gt;
+                        &lt;/ul&gt;
+                &lt;/div&gt;&lt;!-- /.list-container--&gt;
+        &lt;/div&gt;&lt;!-- /#existing-categories--&gt;
+        &lt;p class=&quot;add-to-menu&quot;&gt;
+                &lt;a class=&quot;button-secondary&quot;&gt;&lt;?php _e('Add to Menu'); ?&gt;&lt;/a&gt;
+        &lt;/p&gt;
+        &lt;input type=&quot;hidden&quot; class=&quot;autocomplete&quot; name=&quot;autocomplete-&lt;?php echo esc_attr($taxonomy['args']-&gt;name); ?&gt;-names&quot; value=&quot;&lt;?php echo esc_js( $term_names ); ?&gt;&quot; /&gt;
+        &lt;br class=&quot;clear&quot; /&gt;
+        &lt;script type=&quot;text/javascript&quot; charset=&quot;utf-8&quot;&gt;
+                // &lt;![CDATA[
+                jQuery(document).ready(function(){
+                        wp_nav_menu_autocomplete('&lt;?php echo esc_attr($id); ?&gt;');
+                });
+                // ]]&gt;
+        &lt;/script&gt;
+        &lt;?php
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> /**
</span><del>- * Recursive function that gets sub menu items.
</del><ins>+ * Abstract function for returning all menu items of a menu item type.
</ins><span class="cx">  *
</span><span class="cx">  * @since 3.0.0
</span><span class="cx">  *
</span><del>- * @param string $childof 
- * @param string $items_counter 
- * @param string $parentli 
- * @param string $context 
- * @param string $output_type 
</del><ins>+ * @param string $menu_items Array of objects containing all menu items to be displayed.
+ * @param string $object_type Menu item type.
+ * @param string $object Optional. Menu item type name.
+ * @param string $context Optional. The context for how the menu items should be formatted.
+ * @return string $ouput Menu items.
</ins><span class="cx">  */
</span><del>-function wp_nav_menu_sub_items( $childof, $items_counter, $parentli, $context, $output_type ) {
-        $counter = $items_counter;
</del><ins>+function wp_nav_menu_get_items( $menu_items, $object_type, $object = null, $context = 'frontend' ) {
+        if ( !$menu_items )
+                return __( 'Not Found' );
+                
+        $output = '';
+        $i = 1;
+        foreach ( $menu_items as $menu_item ) {
+                // convert the 'parent' taxonomy property to 'post_parent'
+                // so we don't have to duplicate this entire function.
+                if ( !isset($menu_item-&gt;post_parent) )
+                        $menu_item-&gt;post_parent = $menu_item-&gt;parent;
+                
+                // Cleanest way to get all attachements
+                if ( 'attachment' == $object )
+                        $menu_item-&gt;post_parent = 0;
+                
+                if ( 0 == $menu_item-&gt;post_parent ) {
+                        // Setup the menu item
+                        $menu_item = wp_setup_nav_menu_item( $menu_item, $object_type, $object );                        
+                        $attributes = ( 'backend' == $context ) ? ' id=&quot;menu-item-'. $i .'&quot; value=&quot;'. $i .'&quot;' : '';
+                        
+                        $output .= '&lt;li'. $attributes .'&gt;';
+                        $output .= wp_get_nav_menu_item( $menu_item, $object_type, $object );
+                        $output .= wp_get_nav_menu_sub_items( $menu_item-&gt;ID, $object_type, $object, $context );
+                        $output .= '&lt;/li&gt;';
</ins><span class="cx"> 
</span><del>-        // Custom Menu
-        if ( $output_type == 'menu' ) {
-                $sub_args = array(
-                'child_of' =&gt; $childof,
-                'hide_empty' =&gt; false,
-                'parent' =&gt; $childof);
-        } elseif ( $output_type == 'default' ) {
-                // Sidebar Menu
-                $sub_args = array(
-                'child_of' =&gt; $childof,
-                'hide_empty' =&gt; false,
-                'parent' =&gt; $childof);
</del><ins>+                        ++$i;
+                }
</ins><span class="cx">         }
</span><ins>+        
+        return $output;
+}
</ins><span class="cx"> 
</span><del>-        if ( $context == 'categories' ) {
-                // Get Sub Category Items
-                $item_type = 'category';
-                $sub_array = get_categories($sub_args);
-        } elseif ($context == 'pages') {
-                // Get Sub Page Items
-                $item_type = 'page';
-                $sub_array = get_pages($sub_args);
-        } else {
-                $item_type = 'custom';
-                $sub_array = array();
</del><ins>+/**
+ * Recursive function to retrieve sub menu items.
+ *
+ * @since 3.0.0
+ *
+ * @param string $childof The Parent ID.
+ * @param string $object_type The object type.
+ * @param string $object The object name.
+ * @return string $output sub menu items.
+ */
+function wp_get_nav_menu_sub_items( $childof, $object_type, $object = null, $context = 'frontend' ) {
+        $args = array( 'child_of' =&gt; $childof, 'parent' =&gt; $childof, 'hide_empty' =&gt; false, );
+        
+        switch ( $object_type ) {
+                case 'post_type':
+                        $hierarchical_post_types = get_post_types( array( 'hierarchical' =&gt; true ) );
+                        if ( in_array( $object, $hierarchical_post_types ) ) {
+                                $args['post_type'] = $object;
+                                $sub_menu_items = get_pages( $args );
+                        } else {
+                                $sub_menu_items = array();
+                        }
+                        break;
+                        
+                case 'taxonomy':
+                        if ( is_taxonomy_hierarchical( $object ) ) {
+                                $sub_menu_items = get_terms( $object, $args );
+                        } else {
+                                $sub_menu_items = array();
+                        }
+                        break;
+                
+                default:
+                        $sub_menu_items = array();
+                        break;
</ins><span class="cx">         }
</span><ins>+        
+        $output = '';
+        $i = 1;
+        if ( !empty($sub_menu_items) &amp;&amp; !is_wp_error($sub_menu_items) ) {
+                $output .= '&lt;ul class=&quot;sub-menu menu-item-type-'. $object_type .'&quot;&gt;';
+                foreach ( $sub_menu_items as $menu_item ) {
+                        // Setup the menu item
+                        $menu_item = wp_setup_nav_menu_item( $menu_item, $object_type, $object );
+                        $attributes = ( 'backend' == $context ) ? ' id=&quot;menu-item-'. $i .'&quot; value=&quot;'. $i .'&quot;' : '';
</ins><span class="cx"> 
</span><del>-        if ( $sub_array ) {
-                ?&gt;
-                &lt;ul id=&quot;sub-menu-&lt;?php echo $context ?&gt;&quot;&gt;
-                &lt;?php
-                // Display Loop
-                foreach ( $sub_array as $sub_item ) {
-                        $sub_item = wp_setup_nav_menu_item( $sub_item, $item_type, $counter );
-                        if ( $output_type == 'menu' ) {
-                                ?&gt;
-                                &lt;li id=&quot;menu-&lt;?php echo $counter; ?&gt;&quot; value=&quot;&lt;?php echo $counter; ?&gt;&quot;&gt;
-                                        &lt;?php
-                                                echo wp_get_nav_menu_item( $sub_item, 'menu' );
-                                                $counter++;
-                                                $counter = wp_nav_menu_sub_items( $sub_item-&gt;ID, $counter, $sub_item-&gt;ID, $context, 'menu' );
-                                        ?&gt;
-                                &lt;/li&gt;
-                                &lt;?php
-                        } elseif ( $output_type == 'default' ) {
-                                // Sidebar Menu
-                                ?&gt;
-                                &lt;li&gt;
-                                        &lt;?php
-                                                echo wp_get_nav_menu_item( $sub_item, 'default' );
-                                                //$counter++;
-                                                $counter = wp_nav_menu_sub_items( $sub_item-&gt;ID, $counter, $sub_item-&gt;ID, $context, 'default' );
-                                        ?&gt;
-                                &lt;/li&gt;
</del><ins>+                        $output .= '&lt;li'. $attributes .'&gt;';
+                        $output .= wp_get_nav_menu_item( $menu_item, $object_type, $object );
+                        $output .= wp_get_nav_menu_sub_items( $menu_item-&gt;ID, $object_type, $object );
+                        $output .= '&lt;/li&gt;';
</ins><span class="cx"> 
</span><del>-                                &lt;?php
-                        }
</del><ins>+                        ++$i;
</ins><span class="cx">                 }
</span><del>-                ?&gt;
-                &lt;/ul&gt;
-        &lt;?php
</del><ins>+                $output .= '&lt;/ul&gt;';
</ins><span class="cx">         }
</span><del>-        return $counter;
</del><ins>+        return $output;
</ins><span class="cx"> }
</span><span class="cx"> ?&gt;
</span><span class="cx">\ No newline at end of file
</span></span></pre></div>
<a id="trunkwpadminjsnavmenudefaultitemsdevjs"></a>
<div class="modfile"><h4>Modified: trunk/wp-admin/js/nav-menu-default-items.dev.js (13703 => 13704)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-admin/js/nav-menu-default-items.dev.js        2010-03-15 14:29:11 UTC (rev 13703)
+++ trunk/wp-admin/js/nav-menu-default-items.dev.js        2010-03-15 16:26:46 UTC (rev 13704)
</span><span class="lines">@@ -15,13 +15,26 @@
</span><span class="cx">         
</span><span class="cx">         wp_drag_and_drop();
</span><span class="cx">         
</span><del>-        wp_update_post_data();
</del><ins>+        // Delete AYS
+        $('#update-nav-menu .deletion').click(function(){
+                if ( confirm( navMenuL10n.warnDelete ) ) {
+                        return true;
+                } else {
+                        return false;
+                };
+        });
</ins><span class="cx">         
</span><span class="cx">         // Handle Save Button Clicks
</span><span class="cx">         $('#save_menu').click(function(){
</span><span class="cx">                 return wp_update_post_data();
</span><span class="cx">         });
</span><del>-                
</del><ins>+        
+        // close postboxes that should be closed
+        $('.if-js-closed').removeClass('if-js-closed').addClass('closed');
+        
+        // postboxes setup
+        postboxes.add_postbox_toggles('menus');
+        
</ins><span class="cx">         // Clear the quick search textbox
</span><span class="cx">         $('.quick-search').click(function(){
</span><span class="cx">                 $(this).attr( 'value', '' );
</span><span class="lines">@@ -38,18 +51,14 @@
</span><span class="cx">         });
</span><span class="cx">         
</span><span class="cx">         // Delete menu item
</span><del>-        $('#menu-container .item-delete').live( 'click', function(){
</del><ins>+        $('#menu-container .item-delete').live( 'click', function(e){
</ins><span class="cx">                 return wp_remove_menu_item( $(this).attr('value') );
</span><span class="cx">         });
</span><span class="cx">         
</span><span class="cx">         // Update menu item settings (thickbox)
</span><span class="cx">         $('#update-menu-item').click(function(){
</span><span class="cx">                 wp_update_menu_item();
</span><del>-                tb_remove();
-                
-                // Give feedback to the user
-                var id = $('#edit-item-id').val();
-                $('#menu-' + id + ' dt:first').animate( { backgroundColor: '#FFFF33' }, { duration: 'normal', complete: function() { jQuery(this).css( 'backgroundColor', '' ); }});
</del><ins>+                return tb_remove();
</ins><span class="cx">         });
</span><span class="cx">         
</span><span class="cx">         // Close thickbox
</span><span class="lines">@@ -58,55 +67,32 @@
</span><span class="cx">         });
</span><span class="cx">         
</span><span class="cx">         // Show All Button
</span><del>-        $('.show-all').click(function(){
-                $(this).offsetParent().find('#add-buttons-actions').attr( 'style','margin-bottom: 10px;' );
-                $(this).offsetParent().find('.list-wrap').css( 'display','block' );
-                $(this).siblings('.quick-search').attr( 'value', '' );                
-                $(this).offsetParent().find('.list-wrap li').css( 'display', 'block' );
-                $(this).hide();
-                $(this).siblings('.hide-all').show();
</del><ins>+        $('.show-all').click(function(e){
+                jQuery(e.currentTarget).parent().siblings('.list-wrap').css( 'display', 'block' );
+                jQuery(e.currentTarget).parent().siblings('.list-wrap').find('li').css( 'display', 'block' );
+                jQuery(e.currentTarget).hide();
+                jQuery(e.currentTarget).siblings('.hide-all').show();
</ins><span class="cx">         });
</span><span class="cx">         
</span><span class="cx">         // Hide All Button
</span><del>-        $('.hide-all').click(function(){
-                $(this).offsetParent().find('#add-buttons-actions').attr( 'style','margin-bottom: 0px;' );
-                $(this).offsetParent().find('.list-wrap').css( 'display','none' );
-                $(this).siblings('.quick-search').attr( 'value', 'Search' );
-                $(this).offsetParent().find('.list-wrap li').css( 'display', 'none' );
-                $(this).hide();
-                $(this).siblings('.show-all').show();
</del><ins>+        $('.hide-all').click(function(e){
+                jQuery(e.currentTarget).parent().siblings('.list-wrap').css( 'display', 'none' );
+                jQuery(e.currentTarget).parent().siblings('.list-wrap').find('li').css( 'display', 'none' );
+                jQuery(e.currentTarget).hide();
+                jQuery(e.currentTarget).siblings('.show-all').show();
</ins><span class="cx">         });
</span><span class="cx"> 
</span><del>-        // Add menu item to queue
-        $('.list input').click(function(){
-
-                var item_type = jQuery(this).parent().siblings('.item-type').val();
-                var item_title = jQuery(this).parent().siblings('.item-title').val();
-                var item_url = jQuery(this).parent().siblings('.item-url').val();
-                var item_id = jQuery(this).parent().siblings('.item-dbid').val();
-                var item_parent_id = jQuery(this).parent().siblings('.item-parent').val();
-                var item_description = jQuery(this).parent().siblings('.item-description').val();
-                
-                return wp_update_queue( $(this), item_type, item_title, item_url, item_id, item_parent_id, item_description );
</del><ins>+        // Add menu items into the menu
+        $('.add-to-menu').click(function(e){
+                return wp_add_checked_items_to_menu(e.currentTarget);
</ins><span class="cx">         });
</span><span class="cx"> 
</span><del>-        // Add queued menu items into the menu
-        $('.enqueue a').click(function(){
-                return wp_add_queued_items_to_menu(this);
-        });
-
-        // Create the link, add it to the menu + available links section
-        $('#add-custom-link .add-to-menu a').click(function(){
-                var link_url = $(this).offsetParent().find('#menu-item-url').val();
-                var link_name = $(this).offsetParent().find('#menu-item-name').val();
</del><ins>+        // Create a new link then add it to the menu
+        $('#add-custom-links .add-to-menu a').click(function(e){
+                var link_url = jQuery(e.currentTarget).parent().parent().find('#custom-menu-item-url').val();
+                var link_name = jQuery(e.currentTarget).parent().parent().find('#custom-menu-item-name').val();
</ins><span class="cx">                 
</span><del>-                wp_add_queued_items_to_menu( this );
-                                
-                // Don't save the link if it was left with it's default settings
-                if ( 'http://' == link_url || 'Menu Item' == link_name )
-                        return;
-
-                // and update the Menu with the new link
-                wp_add_item_to_menu( 'custom', link_name, link_url, 0, 0, '' );
</del><ins>+                // Add link to menu
+                wp_add_item_to_menu( 0, '', 'custom', navMenuL10n.custom, 0, link_name, link_url, '', '', '_none', '', '' );
</ins><span class="cx">         });
</span><span class="cx"> });
</span><span class="cx">\ No newline at end of file
</span></span></pre></div>
<a id="trunkwpadminjsnavmenudefaultitemsjs"></a>
<div class="modfile"><h4>Modified: trunk/wp-admin/js/nav-menu-default-items.js (13703 => 13704)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-admin/js/nav-menu-default-items.js        2010-03-15 14:29:11 UTC (rev 13703)
+++ trunk/wp-admin/js/nav-menu-default-items.js        2010-03-15 16:26:46 UTC (rev 13704)
</span><span class="lines">@@ -1 +1 @@
</span><del>-jQuery(document).ready(function(a){wp_drag_and_drop();wp_update_post_data();a(&quot;#save_menu&quot;).click(function(){return wp_update_post_data()});a(&quot;.quick-search&quot;).click(function(){a(this).attr(&quot;value&quot;,&quot;&quot;)});a(&quot;.quick-search-submit&quot;).click(function(){a(this).siblings(&quot;.quick-search&quot;).search()});a(&quot;#menu-container .item-edit&quot;).click(function(){return wp_edit_menu_item(a(this).attr(&quot;value&quot;))});a(&quot;#menu-container .item-delete&quot;).live(&quot;click&quot;,function(){return wp_remove_menu_item(a(this).attr(&quot;value&quot;))});a(&quot;#update-menu-item&quot;).click(function(){wp_update_menu_item();tb_remove();var b=a(&quot;#edit-item-id&quot;).val();a(&quot;#menu-&quot;+b+&quot; dt:first&quot;).animate({backgroundColor:&quot;#FFFF33&quot;},{duration:&quot;normal&quot;,complete:function(){jQuery(this).css(&quot;backgroundColor&quot;,&quot;&quot;)}})});a(&quot;#cancel-save&quot;).click(function(){return tb_remove()});a(&quot;.show-all&quot;).click(function(){a(this).offsetParent().find(&quot;#add-buttons-actions&quot;).attr(&quot;style&quot;,&quot;margin-bottom: 10px;&quot;);a(this).offsetParent().find(&quot;.list-wrap&quot;).css(&quot;display&quot;,&quot;block&quot;);a(this).siblings(&quot;.quick-search&quot;).attr(&quot;value&quot;,&quot;&quot;);a(this).offsetParent().find(&quot;.list-wrap li&quot;).css(&quot;display&quot;,&quot;block&quot;);a(this).hide();a(this).siblings(&quot;.hide-all&quot;).show()});a(&quot;.hide-all&quot;).click(function(){a(this).offsetParent().find(&quot;#add-buttons-actions&quot;).attr(&quot;style&quot;,&quot;margin-bottom: 0px;&quot;);a(this).offsetParent().find(&quot;.list-wrap&quot;).css(&quot;display&quot;,&quot;none&quot;);a(this).siblings(&quot;.quick-search&quot;).attr(&quot;value&quot;,&quot;Search&quot;);a(this).offsetParent().find(&quot;.list-wrap li&quot;).css(&quot;display&quot;,&quot;none&quot;);a(this).hide();a(this).siblings(&quot;.show-all&quot;).show()});a(&quot;.list input&quot;).click(function(){var d=jQuery(this).parent().siblings(&quot;.item-type&quot;).val();var g=jQuery(this).parent().siblings(&quot;.item-title&quot;).val();var c=jQuery(this).parent().siblings(&quot;.item-url&quot;).val();var e=jQuery(this).parent().siblings(&quot;.item-dbid&quot;).val();var b=jQuery(this).parent().siblings(&quot;.item-parent&quot;).val();var f=jQuery(this).parent().siblings(&quot;.item-description&quot;).val();return wp_update_queue(a(this),d,g,c,e,b,f)});a(&quot;.enqueue a&quot;).click(function(){return wp_add_queued_items_to_menu(this)});a(&quot;#add-custom-link .add-to-menu a&quot;).click(function(){var b=a(this).offsetParent().find(&quot;#menu-item-url&quot;).val();var c=a(this).offsetParent().find(&quot;#menu-item-name&quot;).val();wp_add_queued_items_to_menu(this);if(&quot;http://&quot;==b||&quot;Menu Item&quot;==c){return}wp_add_item_to_menu(&quot;custom&quot;,c,b,0,0,&quot;&quot;)})});
</del><span class="cx">\ No newline at end of file
</span><ins>+jQuery(document).ready(function(a){wp_drag_and_drop();a(&quot;#update-nav-menu .deletion&quot;).click(function(){if(confirm(navMenuL10n.warnDelete)){return true}else{return false}});a(&quot;#save_menu&quot;).click(function(){return wp_update_post_data()});a(&quot;.if-js-closed&quot;).removeClass(&quot;if-js-closed&quot;).addClass(&quot;closed&quot;);postboxes.add_postbox_toggles(&quot;menus&quot;);a(&quot;.quick-search&quot;).click(function(){a(this).attr(&quot;value&quot;,&quot;&quot;)});a(&quot;.quick-search-submit&quot;).click(function(){a(this).siblings(&quot;.quick-search&quot;).search()});a(&quot;#menu-container .item-edit&quot;).click(function(){return wp_edit_menu_item(a(this).attr(&quot;value&quot;))});a(&quot;#menu-container .item-delete&quot;).live(&quot;click&quot;,function(b){return wp_remove_menu_item(a(this).attr(&quot;value&quot;))});a(&quot;#update-menu-item&quot;).click(function(){wp_update_menu_item();return tb_remove()});a(&quot;#cancel-save&quot;).click(function(){return tb_remove()});a(&quot;.show-all&quot;).click(function(b){jQuery(b.currentTarget).parent().siblings(&quot;.list-wrap&quot;).css(&quot;display&quot;,&quot;block&quot;);jQuery(b.currentTarget).parent().siblings(&quot;.list-wrap&quot;).find(&quot;li&quot;).css(&quot;display&quot;,&quot;block&quot;);jQuery(b.currentTarget).hide();jQuery(b.currentTarget).siblings(&quot;.hide-all&quot;).show()});a(&quot;.hide-all&quot;).click(function(b){jQuery(b.currentTarget).parent().siblings(&quot;.list-wrap&quot;).css(&quot;display&quot;,&quot;none&quot;);jQuery(b.currentTarget).parent().siblings(&quot;.list-wrap&quot;).find(&quot;li&quot;).css(&quot;display&quot;,&quot;none&quot;);jQuery(b.currentTarget).hide();jQuery(b.currentTarget).siblings(&quot;.show-all&quot;).show()});a(&quot;.add-to-menu&quot;).click(function(b){return wp_add_checked_items_to_menu(b.currentTarget)});a(&quot;#add-custom-links .add-to-menu a&quot;).click(function(d){var b=jQuery(d.currentTarget).parent().parent().find(&quot;#custom-menu-item-url&quot;).val();var c=jQuery(d.currentTarget).parent().parent().find(&quot;#custom-menu-item-name&quot;).val();wp_add_item_to_menu(0,&quot;&quot;,&quot;custom&quot;,navMenuL10n.custom,0,c,b,&quot;&quot;,&quot;&quot;,&quot;_none&quot;,&quot;&quot;,&quot;&quot;)})});
</ins><span class="cx">\ No newline at end of file
</span></span></pre></div>
<a id="trunkwpadminjsnavmenudynamicfunctionsdevjs"></a>
<div class="modfile"><h4>Modified: trunk/wp-admin/js/nav-menu-dynamic-functions.dev.js (13703 => 13704)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-admin/js/nav-menu-dynamic-functions.dev.js        2010-03-15 14:29:11 UTC (rev 13703)
+++ trunk/wp-admin/js/nav-menu-dynamic-functions.dev.js        2010-03-15 16:26:46 UTC (rev 13704)
</span><span class="lines">@@ -8,66 +8,75 @@
</span><span class="cx">  * @subpackage Administration
</span><span class="cx">  */
</span><span class="cx"> 
</span><del>-/**
- * Adds a link to the available links section
- *
- * @param object e - An object recieved via ajax
- */
-function wp_update_links_list(e) {
-        var link = '&lt;li&gt;&lt;dl&gt;&lt;dt&gt;&lt;label class=&quot;item-title&quot;&gt;&lt;input type=&quot;checkbox&quot; id=&quot;link-'+ e.link_id +'&quot; name=&quot;'+ e.link_name +'&quot; value=&quot;'+ e.link_url +'&quot; /&gt;'+ e.link_name +'&lt;/label&gt;&lt;/dt&gt;&lt;/dl&gt;&lt;/li&gt;';
-                
-        // Prepend the link to the available links section
-        jQuery('#available-links .list').prepend( link );
-        
-        // Give feedback to the user
-        jQuery('#available-links .list #link-' + e.link_id).parent().animate( { backgroundColor: '#FFFF33' }, { duration: 'normal', complete: function() { jQuery(this).css( 'backgroundColor', '' ); }});
</del><ins>+function wp_nav_menu_autocomplete( id ) {
+        jQuery('#add-'+ id +' .quick-search').autocomplete(jQuery( '#add-'+ id +' .autocomplete' ).val().split('|'));
+
+        jQuery('#add-'+ id +' .quick-search').result(function(event, data, formatted) {
+                jQuery('#add-'+ id +' .list-wrap').css( 'display', 'block' );
+                jQuery(&quot;#add-&quot;+ id +&quot; .list-wrap li:contains('&quot; + data + &quot;')&quot;).css( 'display', 'block' );
+                jQuery('#add-'+ id +' .show-all').hide();
+                jQuery('#add-'+ id +' .hide-all').show();
+        });
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> /**
</span><span class="cx">  * Populate the thickbox window with the selected menu items
</span><span class="cx">  *
</span><del>- * @param int o - the id of the menu li to edit.
</del><ins>+ * @param int id - the id of the menu li to edit.
</ins><span class="cx">  */
</span><span class="cx"> function wp_edit_menu_item( id ) {
</span><del>-        var itemType = jQuery('#item-type' + id).val();
-        var itemTitle = jQuery('#item-title' + id).val();
-        var itemURL = jQuery('#item-url' + id).val();
-        var itemAttrTitle = jQuery('#item-attr-title' + id).val();
-        var itemTarget = jQuery('#item-target' + id).val();
-        var itemDesc = jQuery('#item-description' + id).val();
</del><ins>+        var item_type = jQuery('#menu-item-type' + id).val();
+        var item_title = jQuery('#menu-item-title' + id).val();
+        var item_link = jQuery('#menu-item-url' + id).val();
+        var item_attr_title = jQuery('#menu-item-attr-title' + id).val();
+        var item_target = jQuery('#menu-item-target' + id).val();
+        var item_description = jQuery('#menu-item-description' + id).val();
+        var item_classes = jQuery('#menu-item-classes' + id).val();
+        var item_xfn = jQuery('#menu-item-xfn' + id).val();
</ins><span class="cx">         
</span><del>-        // Disable the ability to edit the url for page and category items
-        if ( 'page' == itemType || 'category' == itemType )
-                jQuery( '#edit-item-url' ).attr('disabled', 'disabled' );
</del><ins>+        // Only allow custom links to be editable.
+        if ( 'custom' != item_type )
+                jQuery( '#edit-menu-item-url' ).attr('disabled', 'disabled' );
</ins><span class="cx">         
</span><span class="cx">         // Populate the fields for thickbox
</span><del>-        jQuery( '#edit-item-id' ).val(id);
-        jQuery( '#edit-item-title' ).val(itemTitle);
-        jQuery( '#edit-item-url' ).val(itemURL);
-        jQuery( '#edit-item-attr-title' ).val(itemAttrTitle);
-        jQuery( '#edit-item-target' ).val(itemTarget);
-        jQuery( &quot;#edit-item-target option[value='&quot; + itemTarget  + &quot;']&quot; ).attr('selected', 'selected');
-        jQuery( '#edit-item-description' ).val(itemDesc);
</del><ins>+        jQuery( '#edit-menu-item-id' ).val(id);
+        jQuery( '#edit-menu-item-title' ).val(item_title);
+        jQuery( '#edit-menu-item-url' ).val(item_link);
+        jQuery( '#edit-menu-item-attr-title' ).val(item_attr_title);
+        jQuery( '#edit-menu-item-target' ).val(item_target);
+        jQuery( &quot;#edit-menu-item-target option[value='&quot; + item_target  + &quot;']&quot; ).attr('selected', 'selected');
+        jQuery( '#edit-menu-item-description' ).val(item_description);
+        jQuery( '#edit-menu-item-classes' ).val(item_classes);
+        jQuery( '#edit-menu-item-xfn' ).val(item_xfn);
+        
+        // focus
+        jQuery( '#edit-menu-item-title' ).focus();
</ins><span class="cx"> };
</span><span class="cx"> 
</span><span class="cx"> /**
</span><span class="cx">  * Update the values for the menu item being editing
</span><span class="cx">  */
</span><span class="cx"> function wp_update_menu_item() {
</span><del>-        var id = jQuery('#edit-item-id').val();
-        var itemTitle = jQuery('#edit-item-title').val();
-        var itemURL = jQuery('#edit-item-url').val();
-        var itemAttrTitle = jQuery('#edit-item-attr-title').val();
-        var itemTarget = jQuery('#edit-item-target').val();
-        var itemDesc = jQuery('#edit-item-description').val();
</del><ins>+        var id = jQuery('#edit-menu-item-id').val();
+        var item_title = jQuery('#edit-menu-item-title').val();
+        var item_link = jQuery('#edit-menu-item-url').val();
+        var item_attr_title = jQuery('#edit-menu-item-attr-title').val();
+        var item_target = jQuery('#edit-menu-item-target').val();
+        var item_description = jQuery('#edit-menu-item-description').val();
+        var item_classes = jQuery('#edit-menu-item-classes').val();
+        var item_xfn = jQuery('#edit-menu-item-xfn').val();
</ins><span class="cx">         
</span><del>-        // update menu item settings        
-        jQuery('#menu-' + id).find('.item-title:first').html(itemTitle);
-        jQuery('#item-title' + id).val(itemTitle);
-        jQuery('#item-url' + id).val(itemURL);
-        jQuery('#item-attr-title' + id).val(itemAttrTitle);
-        jQuery('#item-target' + id).val(itemTarget);
-        jQuery('#item-description' + id).val(itemDesc);
</del><ins>+        // update menu item settings
+        jQuery('.menu #menu-item' + id).find('span.item-title').html(item_title);
+        jQuery('.menu #menu-item-title' + id).val(item_title);
+        jQuery('.menu #menu-item-url' + id).val(item_link);
+        jQuery('.menu #menu-item-attr-title' + id).val(item_attr_title);
+        jQuery('.menu #menu-item-target' + id).val(item_target);
+        jQuery('.menu #menu-item-description' + id).val(item_description);
+        jQuery('.menu #menu-item-classes' + id).val(item_classes);
+        jQuery('.menu #menu-item-xfn' + id).val(item_xfn);
+        
+        jQuery('.menu #menu-item' + id + ' dt:first').animate( { backgroundColor: '#FFFF33' }, { duration: 'normal', complete: function() { jQuery(this).css( 'backgroundColor', '' ); }});
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> /**
</span><span class="lines">@@ -76,166 +85,100 @@
</span><span class="cx">  * @param int o - the id of the menu li to remove.
</span><span class="cx">  */
</span><span class="cx"> function wp_remove_menu_item( o ) {
</span><del>-        var todelete = document.getElementById('menu-' + o);
</del><ins>+        var todelete = document.getElementById('menu-item' + o);
</ins><span class="cx">         
</span><span class="cx">         if ( todelete ) {
</span><span class="cx">                 // Give some feedback to the user
</span><span class="cx">                 jQuery( todelete ).find('dt').each(function(){
</span><span class="cx">                         jQuery(this).animate( { backgroundColor: '#FF3333' }, { duration: 'normal', complete: function() { jQuery(this).parent().parent().remove() } } );
</span><span class="cx">                 });
</span><del>-                
-                wp_update_post_data();
</del><span class="cx">         }
</span><span class="cx"> };
</span><span class="cx"> 
</span><span class="cx"> /**
</span><del>- * Prepares menu items for POST
- */
-function wp_update_post_data() {
-        var i = 0;
-        
-         jQuery('.menu li').each(function(i) {
-                i = i + 1;
-             var j = jQuery(this).attr('value');
-
-             jQuery(this).find('#item-position' + j).attr('value', i);
-             jQuery(this).attr('id','menu-' + i);
-             jQuery(this).attr('value', i);
-
-             jQuery(this).find('#item-dbid' + j).attr('name','item-dbid' + i);
-             jQuery(this).find('#item-dbid' + j).attr('id','item-dbid' + i);
-
-                jQuery(this).find('#item-postmenu' + j).attr('name','item-postmenu' + i);
-             jQuery(this).find('#item-postmenu' + j).attr('id','item-postmenu' + i);
-
-             var p = jQuery(this).find('#item-parent' + j).parent().parent().parent().attr('value');
-
-                jQuery(this).find('#item-parent' + j).attr('name','item-parent' + i);
-                jQuery(this).find('#item-parent' + j).attr('id','item-parent' + i);
-                
-                if (p) {
-                        // Do nothing
-                } else {
-                        // reset p to be top level
-                        p = 0;
-                }
-
-                jQuery(this).find('#item-parent' + j).attr('value', p);
-
-                jQuery(this).find('#item-title' + j).attr('name','item-title' + i);
-                jQuery(this).find('#item-title' + j).attr('id','item-title' + i);
-
-                jQuery(this).find('#item-url' + j).attr('name','item-url' + i);
-                jQuery(this).find('#item-url' + j).attr('id','item-url' + i);
-
-                jQuery(this).find('#item-description' + j).attr('name','item-description' + i);
-                jQuery(this).find('#item-description' + j).attr('id','item-description' + i);
-
-                jQuery(this).find('#item-attr-title' + j).attr('name','item-attr-title' + i);
-                jQuery(this).find('#item-attr-title' + j).attr('id','item-attr-title' + i);
-
-                jQuery(this).find('#item-target' + j).attr('name','item-target' + i);
-                jQuery(this).find('#item-target' + j).attr('id','item-target' + i);
-
-                jQuery(this).find('#item-position' + j).attr('name', 'item-position' + i);
-                jQuery(this).find('#item-position' + j).attr('id', 'item-position' + i);
-
-                jQuery(this).find('#item-type' + j).attr('name', 'item-type' + i);
-                jQuery(this).find('#item-type' + j).attr('id', 'item-type' + i);
-
-                jQuery('#li-count').attr( 'value', i );
-   });
-};
-
-/**
</del><span class="cx">  * Adds the item to the menu
</span><span class="cx">  *
</span><del>- * @param string id - The menu item's id
- * @param string additemtype - Page, Category, or Custom.
- * @param string itemtext - menu text.
- * @param string itemurl - url of the menu.
- * @param int itemid - menu id.
- * @param int itemparentid - default 0.
- * @param string itemdescription - the description of the menu item.
</del><ins>+ * @param string item_db_id - The menu item's db id.
+ * @param string item_object_id - The menu item's object id.
+ * @param string item_type - The menu item's object type.
+ * @param string item_append - The menu item's nice name.
+ * @param string item_parent_id - The menu item's parent id.
+ * @param string item_title - The menu item title.
+ * @param string item_url - The menu item url
+ * @param string item_description - The menu item description.
+ * @param string item_attr_title - The title attribute.
+ * @param string item_target - The target attribute.
+ * @param string item_classes - Optional. Additional CSS classes for the menu item
+ * @param string item_xfn - Optional. The rel attribute.
</ins><span class="cx">  */
</span><del>-function wp_add_item_to_menu( item_type, item_title, item_url, item_id, item_parent_id, item_description ) {
</del><ins>+function wp_add_item_to_menu( item_db_id, item_object_id, item_type, item_append, item_parent_id, item_title, item_url, item_description, item_attr_title, item_target, item_classes, item_xfn ) {
</ins><span class="cx">         var randomnumber = wp_get_unique_menu_id();
</span><ins>+        var hidden = wp_get_hidden_inputs( randomnumber, item_db_id, item_object_id, item_type, item_append, item_parent_id, item_title, item_url, item_description, item_attr_title, item_target, item_classes, item_xfn );
</ins><span class="cx">         
</span><span class="cx">         // Adds the item in the queue
</span><del>-        jQuery('.menu').append('&lt;li id=&quot;menu-' + randomnumber + '&quot; value=&quot;' + randomnumber + '&quot;&gt;&lt;div class=&quot;dropzone ui-droppable&quot;&gt;&lt;/div&gt;&lt;dl class=&quot;ui-droppable&quot;&gt;&lt;dt&gt;&lt;span class=&quot;item-title&quot;&gt;' + item_title + '&lt;/span&gt;&lt;span class=&quot;item-controls&quot;&gt;&lt;span class=&quot;item-type&quot;&gt;' + item_type + '&lt;/span&gt;&lt;a class=&quot;item-edit thickbox&quot; id=&quot;edit' + randomnumber + '&quot; value=&quot;' + randomnumber +'&quot; onClick=&quot;wp_edit_menu_item('+ randomnumber +')&quot; title=&quot;' + navMenuL10n.thickbox + '&quot; href=&quot;#TB_inline?height=380&amp;width=300&amp;inlineId=menu-item-settings&quot;&gt;' + navMenuL10n.edit + '&lt;/a&gt; | &lt;a class=&quot;item-delete&quot; id=&quot;delete' + randomnumber + '&quot; value=&quot;' + randomnumber +'&quot;&gt;Delete&lt;/a&gt;&lt;/span&gt;&lt;/dt&gt;&lt;/dl&gt;&lt;input type=&quot;hidden&quot; name=&quot;item-postmenu' + randomnumber + '&quot; id=&quot;item-postmenu' + randomnumber + '&quot; value=&quot;' + item_id + '&quot; /&gt;&lt;input type=&quot;hidden&quot; name=&quot;item-parent' + randomnumber + '&quot; id=&quot;item-parent' + randomnumber + '&quot; value=&quot;' + item_parent_id + '&quot; /&gt;&lt;input type=&quot;hidden&quot; name=&quot;item-title' + randomnumber + '&quot; id=&quot;item-title' + randomnumber + '&quot; value=&quot;' + item_title + '&quot; /&gt;&lt;input type=&quot;hidden&quot; name=&quot;item-url' + randomnumber + '&quot; id=&quot;item-url' + randomnumber + '&quot; value=&quot;' + item_url + '&quot; /&gt;&lt;input type=&quot;hidden&quot; name=&quot;item-description' + randomnumber + '&quot; id=&quot;item-description' + randomnumber + '&quot; value=&quot;' + item_description + '&quot; /&gt;&lt;input type=&quot;hidden&quot; name=&quot;item-position' + randomnumber + '&quot; id=&quot;item-position' + randomnumber + '&quot; value=&quot;' + randomnumber + '&quot; /&gt;&lt;input type=&quot;hidden&quot; name=&quot;item-type' + randomnumber + '&quot; id=&quot;item-type' + randomnumber + '&quot; value=&quot;' + item_type + '&quot; /&gt;&lt;input type=&quot;hidden&quot; name=&quot;item-attr-title' + randomnumber + '&quot; id=&quot;item-attr-title' + randomnumber + '&quot; value=&quot;' + item_title + '&quot; /&gt;&lt;input type=&quot;hidden&quot; name=&quot;item-target' + randomnumber + '&quot; id=&quot;item-target' + randomnumber + '&quot; value=&quot;0&quot; /&gt;&lt;/li&gt;');
</del><ins>+        jQuery('.menu').append('&lt;li id=&quot;menu-item' + randomnumber + '&quot; value=&quot;' + randomnumber + '&quot;&gt;&lt;div class=&quot;dropzone ui-droppable&quot;&gt;&lt;/div&gt;&lt;dl class=&quot;ui-droppable&quot;&gt;&lt;dt&gt;&lt;span class=&quot;item-title&quot;&gt;' + item_title + '&lt;/span&gt;&lt;span class=&quot;item-controls&quot;&gt;&lt;span class=&quot;item-type&quot;&gt;' + item_append + '&lt;/span&gt;&lt;a class=&quot;item-edit thickbox&quot; id=&quot;edit' + randomnumber + '&quot; value=&quot;' + randomnumber +'&quot; onClick=&quot;wp_edit_menu_item('+ randomnumber +')&quot; title=&quot;' + navMenuL10n.thickbox + '&quot; href=&quot;#TB_inline?height=540&amp;width=300&amp;inlineId=menu-item-settings&quot;&gt;' + navMenuL10n.edit + '&lt;/a&gt; | &lt;a class=&quot;item-delete&quot; id=&quot;delete' + randomnumber + '&quot; value=&quot;' + randomnumber +'&quot;&gt;Delete&lt;/a&gt;&lt;/span&gt;&lt;/dt&gt;&lt;/dl&gt;' + hidden + '&lt;/li&gt;');
</ins><span class="cx">         
</span><span class="cx">         // Give some feedback to the user
</span><del>-        jQuery( '.menu #menu-' + randomnumber + ' dt:first' ).animate( { backgroundColor: '#FFFF33' }, { duration: 'normal', complete: function() { jQuery(this).css( 'backgroundColor', '' ); }});
</del><ins>+        jQuery( '.menu #menu-item' + randomnumber + ' dt:first' ).animate( { backgroundColor: '#FFFF33' }, { duration: 'normal', complete: function() { jQuery(this).css( 'backgroundColor', '' ); }});
</ins><span class="cx">         
</span><span class="cx">         // Enable drag-n-drop
</span><span class="cx">         wp_drag_and_drop();
</span><span class="cx">         
</span><del>-        wp_update_post_data();
-        
</del><span class="cx">         // Reload thickbox
</span><span class="cx">         tb_init('a.thickbox, area.thickbox, input.thickbox');
</span><span class="cx"> };
</span><span class="cx"> 
</span><del>-/*
- * Queues items in perperation for appendToList
- *
- * @param string type - Page, Category, or Custom.
- * @param string link - menu text.
- * @param string url - url of the menu.
- * @param int id - menu id.
- * @param int parent_id - default 0.
- * @param string description - the description of the menu item.
-*/
-function wp_update_queue( e, item_type, item_title, item_url, item_id, item_parent_id, item_description ) {
-        var randomnumber = wp_get_unique_menu_id();
-        var menu_item_id = jQuery(e).attr('id');
-        
-        if ( jQuery(e).attr('checked') ) {
-                // Add menu item to the queue
-                jQuery('#queue').append('&lt;li id=&quot;menu-' + randomnumber + '&quot; value=&quot;' + randomnumber + '&quot;&gt;&lt;div class=&quot;dropzone ui-droppable&quot;&gt;&lt;/div&gt;&lt;dl class=&quot;ui-droppable&quot;&gt;&lt;dt&gt;&lt;span class=&quot;item-title&quot;&gt;' + item_title + '&lt;/span&gt;&lt;span class=&quot;item-controls&quot;&gt;&lt;span class=&quot;item-type&quot;&gt;' + item_type + '&lt;/span&gt;&lt;a class=&quot;item-edit thickbox&quot; id=&quot;edit' + randomnumber + '&quot; value=&quot;' + randomnumber +'&quot; onClick=&quot;wp_edit_menu_item('+ randomnumber +')&quot; title=&quot;' + navMenuL10n.thickbox + '&quot; href=&quot;#TB_inline?height=380&amp;width=300&amp;inlineId=menu-item-settings&quot;&gt;' + navMenuL10n.edit + '&lt;/a&gt; | &lt;a class=&quot;item-delete&quot; id=&quot;delete' + randomnumber + '&quot; value=&quot;' + randomnumber +'&quot;&gt;Delete&lt;/a&gt;&lt;/span&gt;&lt;/dt&gt;&lt;/dl&gt;&lt;input type=&quot;hidden&quot; name=&quot;item-postmenu' + randomnumber + '&quot; id=&quot;item-postmenu' + randomnumber + '&quot; value=&quot;' + item_id + '&quot; /&gt;&lt;input type=&quot;hidden&quot; name=&quot;item-parent' + randomnumber + '&quot; id=&quot;item-parent' + randomnumber + '&quot; value=&quot;' + item_parent_id + '&quot; /&gt;&lt;input type=&quot;hidden&quot; name=&quot;item-title' + randomnumber + '&quot; id=&quot;item-title' + randomnumber + '&quot; value=&quot;' + item_title + '&quot; /&gt;&lt;input type=&quot;hidden&quot; name=&quot;item-url' + randomnumber + '&quot; id=&quot;item-url' + randomnumber + '&quot; value=&quot;' + item_url + '&quot; /&gt;&lt;input type=&quot;hidden&quot; name=&quot;item-description' + randomnumber + '&quot; id=&quot;item-description' + randomnumber + '&quot; value=&quot;' + item_description + '&quot; /&gt;&lt;input type=&quot;hidden&quot; name=&quot;item-position' + randomnumber + '&quot; id=&quot;item-position' + randomnumber + '&quot; value=&quot;' + randomnumber + '&quot; /&gt;&lt;input type=&quot;hidden&quot; name=&quot;item-type' + randomnumber + '&quot; id=&quot;item-type' + randomnumber + '&quot; value=&quot;' + item_type + '&quot; /&gt;&lt;input type=&quot;hidden&quot; name=&quot;item-attr-title' + randomnumber + '&quot; id=&quot;item-attr-title' + randomnumber + '&quot; value=&quot;' + item_title + '&quot; /&gt;&lt;input type=&quot;hidden&quot; name=&quot;item-target' + randomnumber + '&quot; id=&quot;item-target' + randomnumber + '&quot; value=&quot;0&quot; /&gt;&lt;input type=&quot;hidden&quot; name=&quot;item-id' + randomnumber + '&quot; id=&quot;item-id' + randomnumber + '&quot; value=&quot;'+ menu_item_id +'&quot; /&gt;&lt;/li&gt;');
-                
-        } else {
-                // Remove the item from the queue
-                if ( menu_item_id == jQuery('#queue li input[name^=&quot;item-id&quot;]' ).val() ) {
-                        jQuery('#queue li input[name^=&quot;item-id&quot;]' ).parent().remove()
-                };
-        };
-};
-
</del><span class="cx"> /**
</span><span class="cx">  * Grabs items from the queue and adds them to the menu.
</span><span class="cx">  *
</span><del>- * @param string button - a reference of the button that was clicked
</del><ins>+ * @param string button - a reference to the button that was clicked
</ins><span class="cx">  */
</span><del>-function wp_add_queued_items_to_menu( button ) {        
-        // Grab items in queue
-        var items = jQuery('#queue').children();
</del><ins>+function wp_add_checked_items_to_menu( button ) {
+        // Grab checked items
+        var items = jQuery(button).siblings('.list-wrap').find(':checked');
</ins><span class="cx">         
</span><del>-        // Empty Queue
-        jQuery('#queue').empty();
</del><ins>+        // If nothing was checked, cancel
+        if ( 0 == items.length )
+                return false;
+        
+        // Loop through each item, grab it's hidden data and add it to the menu.
+        jQuery(items).each(function(){
+                var item_type = jQuery(this).parent().siblings('.menu-item-type').val();
</ins><span class="cx">                 
</span><del>-        // Appends HTML to the menu
-        jQuery('.menu').append( items );
-
-        // Give some feedback to the user
-        jQuery(items).each(function(){
-                jQuery(this).find('dt').animate( { backgroundColor: '#FFFF33' }, { duration: 'normal', complete: function() { jQuery(this).css( 'backgroundColor', '' ); }});
</del><ins>+                if ( 'custom' == item_type ) {
+                        var item_attr_title = jQuery(this).parent().siblings('.menu-item-attr-title').val();
+                        var item_target = jQuery(this).parent().siblings('.menu-item-target').val();
+                        var item_classes = jQuery(this).parent().siblings('.menu-item-classes').val();
+                        var item_xfn = jQuery(this).parent().siblings('.menu-item-xfn').val();
+                } else {
+                        var item_attr_title = '';
+                        var item_target = '_none';
+                        var item_classes = '';
+                        var item_xfn = '';
+                };
+                
+                var item_db_id = jQuery(this).parent().siblings('.menu-item-db-id').val();
+                var item_object_id = jQuery(this).parent().siblings('.menu-item-object-id').val();
+                var item_append = jQuery(this).parent().siblings('.menu-item-append').val();
+                var item_parent_id = jQuery(this).parent().siblings('.menu-item-parent-id').val();
+                var item_title = jQuery(this).parent().siblings('.menu-item-title').val();
+                var item_url = jQuery(this).parent().siblings('.menu-item-url').val();
+                var item_description = jQuery(this).parent().siblings('.menu-item-description').val();
+                
+                if ( undefined == item_description ) {
+                        item_description = '';
+                };
+                
+                // Add the menu item to the menu
+                wp_add_item_to_menu( item_db_id, item_object_id, item_type, item_append, item_parent_id, item_title, item_url, item_description, item_attr_title, item_target, item_classes, item_xfn );
+                
+                // uncheck the menu item in the list
+                jQuery(this).attr( 'checked', false );
</ins><span class="cx">         });
</span><del>-        
-        // Uncheck the checkboxes in the list
-        jQuery(button).offsetParent().find('.list-container input').attr('checked', false);
-        
-        wp_update_post_data();
-        
-        // Enable drag-n-drop
-        wp_drag_and_drop();
-        
-        // Reload thickbox
-        tb_init('a.thickbox, area.thickbox, input.thickbox');
</del><span class="cx"> };
</span><span class="cx"> 
</span><span class="cx"> /**
</span><del>- * Allow the items in the Menu to be dragged and dropped.
</del><ins>+ * Makes the menu items drag and droppable.
</ins><span class="cx">  */
</span><span class="cx"> function wp_drag_and_drop() {
</span><span class="cx">         // Make sure all li's have dropzones
</span><span class="lines">@@ -251,7 +194,7 @@
</span><span class="cx">                 opacity: .8,
</span><span class="cx">                 addClasses: false,
</span><span class="cx">                 helper: 'clone',
</span><del>-                zIndex: 100,
</del><ins>+                zIndex: 100
</ins><span class="cx">         });
</span><span class="cx"> 
</span><span class="cx">         // make menu item droppable
</span><span class="lines">@@ -307,6 +250,49 @@
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> /**
</span><ins>+ * Prepares menu items for POST.
+ */
+function wp_update_post_data() {
+        var i = 0;
+        
+         jQuery('.menu li').each(function(i) {
+                i = i + 1;
+             var j = jQuery(this).attr('value');
+
+             jQuery(this).find('#menu-item-position' + j).attr('value', i);
+             jQuery(this).attr('id','menu-item' + i);
+             jQuery(this).attr('value', i);
+                
+             jQuery(this).find('#menu-item-db-id' + j).attr('id','menu-item-db-id' + i);
+             jQuery(this).find('#menu-item-object-id' + j).attr('id','menu-item-object-id' + i);
+                jQuery(this).find('#menu-item-append' + j).attr('id', 'menu-item-append' + i);
+                jQuery(this).find('#menu-item-type' + j).attr('id', 'menu-item-type' + i);
+                jQuery(this).find('#menu-item-position' + j).attr('id', 'menu-item-position' + i);
+
+             var p = jQuery(this).find('#menu-item-parent-id' + j).parent().parent().parent().attr('value');
+                jQuery(this).find('#menu-item-parent-id' + j).attr('id','menu-item-parent-id' + i);
+                if (p) {
+                        // Do nothing
+                } else {
+                        // reset p to be top level
+                        p = 0;
+                }
+                jQuery(this).find('#menu-item-parent-id' + j).attr('value', p);
+                
+                jQuery(this).find('#menu-item-title' + j).attr('id','menu-item-title' + i);
+                jQuery(this).find('#menu-item-url' + j).attr('id','menu-item-url' + i);
+                jQuery(this).find('#menu-item-description' + j).attr('id','menu-item-description' + i);
+                jQuery(this).find('#menu-item-classes' + j).attr('id','menu-item-classes' + i);
+                jQuery(this).find('#menu-item-xfn' + j).attr('id','menu-item-xfn' + i);
+                jQuery(this).find('#menu-item-description' + j).attr('id','menu-item-description' + i);
+                jQuery(this).find('#menu-item-attr-title' + j).attr('id','menu-item-attr-title' + i);
+                jQuery(this).find('#menu-item-target' + j).attr('id','menu-item-target' + i);
+                
+                jQuery('#li-count').attr( 'value', i );
+   });
+};
+
+/**
</ins><span class="cx">  * Gets a unique number based on how many items are in the menu
</span><span class="cx">  */
</span><span class="cx"> function wp_get_unique_menu_id() {
</span><span class="lines">@@ -331,4 +317,40 @@
</span><span class="cx">                 }
</span><span class="cx">         }
</span><span class="cx">         return randomnumber;
</span><ins>+}
+
+/**
+ * Returns all the nessecary hidden inputs for each menu item.
+ * 
+ * @param string item_db_id - The menu item's db id.
+ * @param string item_object_id - The menu item's object id.
+ * @param string item_type - The menu item's object type.
+ * @param string item_append - The menu item's nice name.
+ * @param string item_parent_id - The menu item's parent id.
+ * @param string item_title - The menu item title.
+ * @param string item_url - The menu item url
+ * @param string item_description - The menu item description.
+ * @param string item_attr_title - The title attribute.
+ * @param string item_target - The target attribute.
+ * @param string item_classes - Optional. Additional CSS classes for the menu item
+ * @param string item_xfn - Optional. The rel attribute.
+ */
+function wp_get_hidden_inputs( randomnumber, item_db_id, item_object_id, item_type, item_append, item_parent_id, item_title, item_url, item_description, item_attr_title, item_target, item_classes, item_xfn ) {
+        var hidden = '';
+        
+        hidden += '&lt;input type=&quot;hidden&quot; name=&quot;menu-item-db-id[]&quot; id=&quot;menu-item-db-id' + randomnumber + '&quot; value=&quot;' + item_db_id + '&quot; /&gt;';
+        hidden += '&lt;input type=&quot;hidden&quot; name=&quot;menu-item-object-id[]&quot; id=&quot;menu-item-object-id' + randomnumber + '&quot; value=&quot;' + item_object_id + '&quot; /&gt;';
+        hidden += '&lt;input type=&quot;hidden&quot; name=&quot;menu-item-type[]&quot; id=&quot;menu-item-type' + randomnumber + '&quot; value=&quot;' + item_type + '&quot; /&gt;';
+        hidden += '&lt;input type=&quot;hidden&quot; name=&quot;menu-item-append[]&quot; id=&quot;menu-item-append' + randomnumber + '&quot; value=&quot;' + item_append + '&quot; /&gt;';
+        hidden += '&lt;input type=&quot;hidden&quot; name=&quot;menu-item-parent-id[]&quot; id=&quot;menu-item-parent-id' + randomnumber + '&quot; value=&quot;' + item_parent_id + '&quot; /&gt;';
+        hidden += '&lt;input type=&quot;hidden&quot; name=&quot;menu-item-position[]&quot; id=&quot;menu-item-position' + randomnumber + '&quot; value=&quot;' + randomnumber + '&quot; /&gt;';
+        hidden += '&lt;input type=&quot;hidden&quot; name=&quot;menu-item-title[]&quot; id=&quot;menu-item-title' + randomnumber + '&quot; value=&quot;' + item_title + '&quot; /&gt;';
+        hidden += '&lt;input type=&quot;hidden&quot; name=&quot;menu-item-attr-title[]&quot; id=&quot;menu-item-attr-title' + randomnumber + '&quot; value=&quot;' + item_attr_title + '&quot; /&gt;';
+        hidden += '&lt;input type=&quot;hidden&quot; name=&quot;menu-item-url[]&quot; id=&quot;menu-item-url' + randomnumber + '&quot; value=&quot;' + item_url + '&quot; /&gt;';
+        hidden += '&lt;input type=&quot;hidden&quot; name=&quot;menu-item-target[]&quot; id=&quot;menu-item-target' + randomnumber + '&quot; value=&quot;' + item_target + '&quot; /&gt;';
+        hidden += '&lt;input type=&quot;hidden&quot; name=&quot;menu-item-description[]&quot; id=&quot;menu-item-description' + randomnumber + '&quot; value=&quot;' + item_description + '&quot; /&gt;';
+        hidden += '&lt;input type=&quot;hidden&quot; name=&quot;menu-item-classes[]&quot; id=&quot;menu-item-classes' + randomnumber + '&quot; value=&quot;' + item_classes + '&quot; /&gt;';
+        hidden += '&lt;input type=&quot;hidden&quot; name=&quot;menu-item-xfn[]&quot; id=&quot;menu-item-xfn' + randomnumber + '&quot; value=&quot;' + item_xfn + '&quot; /&gt;';
+        
+        return hidden;
</ins><span class="cx"> }
</span><span class="cx">\ No newline at end of file
</span></span></pre></div>
<a id="trunkwpadminjsnavmenudynamicfunctionsjs"></a>
<div class="modfile"><h4>Modified: trunk/wp-admin/js/nav-menu-dynamic-functions.js (13703 => 13704)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-admin/js/nav-menu-dynamic-functions.js        2010-03-15 14:29:11 UTC (rev 13703)
+++ trunk/wp-admin/js/nav-menu-dynamic-functions.js        2010-03-15 16:26:46 UTC (rev 13704)
</span><span class="lines">@@ -1 +1 @@
</span><del>-function wp_update_links_list(e){var link='&lt;li&gt;&lt;dl&gt;&lt;dt&gt;&lt;label class=&quot;item-title&quot;&gt;&lt;input type=&quot;checkbox&quot; id=&quot;link-'+e.link_id+'&quot; name=&quot;'+e.link_name+'&quot; value=&quot;'+e.link_url+'&quot; /&gt;'+e.link_name+&quot;&lt;/label&gt;&lt;/dt&gt;&lt;/dl&gt;&lt;/li&gt;&quot;;jQuery(&quot;#available-links .list&quot;).prepend(link);jQuery(&quot;#available-links .list #link-&quot;+e.link_id).parent().animate({backgroundColor:&quot;#FFFF33&quot;},{duration:&quot;normal&quot;,complete:function(){jQuery(this).css(&quot;backgroundColor&quot;,&quot;&quot;)}})}function wp_edit_menu_item(id){var itemType=jQuery(&quot;#item-type&quot;+id).val();var itemTitle=jQuery(&quot;#item-title&quot;+id).val();var itemURL=jQuery(&quot;#item-url&quot;+id).val();var itemAttrTitle=jQuery(&quot;#item-attr-title&quot;+id).val();var itemTarget=jQuery(&quot;#item-target&quot;+id).val();var itemDesc=jQuery(&quot;#item-description&quot;+id).val();if(&quot;page&quot;==itemType||&quot;category&quot;==itemType){jQuery(&quot;#edit-item-url&quot;).attr(&quot;disabled&quot;,&quot;disabled&quot;)}jQuery(&quot;#edit-item-id&quot;).val(id);jQuery(&quot;#edit-item-title&quot;).val(itemTitle);jQuery(&quot;#edit-item-url&quot;).val(itemURL);jQuery(&quot;#edit-item-attr-title&quot;).val(itemAttrTitle);jQuery(&quot;#edit-item-target&quot;).val(itemTarget);jQuery(&quot;#edit-item-target option[value='&quot;+itemTarget+&quot;']&quot;).attr(&quot;selected&quot;,&quot;selected&quot;);jQuery(&quot;#edit-item-description&quot;).val(itemDesc)}function wp_update_menu_item(){var id=jQuery(&quot;#edit-item-id&quot;).val();var itemTitle=jQuery(&quot;#edit-item-title&quot;).val();var itemURL=jQuery(&quot;#edit-item-url&quot;).val();var itemAttrTitle=jQuery(&quot;#edit-item-attr-title&quot;).val();var itemTarget=jQuery(&quot;#edit-item-target&quot;).val();var itemDesc=jQuery(&quot;#edit-item-description&quot;).val();jQuery(&quot;#menu-&quot;+id).find(&quot;.item-title:first&quot;).html(itemTitle);jQuery(&quot;#item-title&quot;+id).val(itemTitle);jQuery(&quot;#item-url&quot;+id).val(itemURL);jQuery(&quot;#item-attr-title&quot;+id).val(itemAttrTitle);jQuery(&quot;#item-target&quot;+id).val(itemTarget);jQuery(&quot;#item-description&quot;+id).val(itemDesc)}function wp_remove_menu_item(o){var todelete=document.getElementById(&quot;menu-&quot;+o);if(todelete){jQuery(todelete).find(&quot;dt&quot;).each(function(){jQuery(this).animate({backgroundColor:&quot;#FF3333&quot;},{duration:&quot;normal&quot;,complete:function(){jQuery(this).parent().parent().remove()}})});wp_update_post_data()}}function wp_update_post_data(){var i=0;jQuery(&quot;.menu li&quot;).each(function(i){i=i+1;var j=jQuery(this).attr(&quot;value&quot;);jQuery(this).find(&quot;#item-position&quot;+j).attr(&quot;value&quot;,i);jQuery(this).attr(&quot;id&quot;,&quot;menu-&quot;+i);jQuery(this).attr(&quot;value&quot;,i);jQuery(this).find(&quot;#item-dbid&quot;+j).attr(&quot;name&quot;,&quot;item-dbid&quot;+i);jQuery(this).find(&quot;#item-dbid&quot;+j).attr(&quot;id&quot;,&quot;item-dbid&quot;+i);jQuery(this).find(&quot;#item-postmenu&quot;+j).attr(&quot;name&quot;,&quot;item-postmenu&quot;+i);jQuery(this).find(&quot;#item-postmenu&quot;+j).attr(&quot;id&quot;,&quot;item-postmenu&quot;+i);var p=jQuery(this).find(&quot;#item-parent&quot;+j).parent().parent().parent().attr(&quot;value&quot;);jQuery(this).find(&quot;#item-parent&quot;+j).attr(&quot;name&quot;,&quot;item-parent&quot;+i);jQuery(this).find(&quot;#item-parent&quot;+j).attr(&quot;id&quot;,&quot;item-parent&quot;+i);if(p){}else{p=0}jQuery(this).find(&quot;#item-parent&quot;+j).attr(&quot;value&quot;,p);jQuery(this).find(&quot;#item-title&quot;+j).attr(&quot;name&quot;,&quot;item-title&quot;+i);jQuery(this).find(&quot;#item-title&quot;+j).attr(&quot;id&quot;,&quot;item-title&quot;+i);jQuery(this).find(&quot;#item-url&quot;+j).attr(&quot;name&quot;,&quot;item-url&quot;+i);jQuery(this).find(&quot;#item-url&quot;+j).attr(&quot;id&quot;,&quot;item-url&quot;+i);jQuery(this).find(&quot;#item-description&quot;+j).attr(&quot;name&quot;,&quot;item-description&quot;+i);jQuery(this).find(&quot;#item-description&quot;+j).attr(&quot;id&quot;,&quot;item-description&quot;+i);jQuery(this).find(&quot;#item-attr-title&quot;+j).attr(&quot;name&quot;,&quot;item-attr-title&quot;+i);jQuery(this).find(&quot;#item-attr-title&quot;+j).attr(&quot;id&quot;,&quot;item-attr-title&quot;+i);jQuery(this).find(&quot;#item-target&quot;+j).attr(&quot;name&quot;,&quot;item-target&quot;+i);jQuery(this).find(&quot;#item-target&quot;+j).attr(&quot;id&quot;,&quot;item-target&quot;+i);jQuery(this).find(&quot;#item-position&quot;+j).attr(&quot;name&quot;,&quot;item-position&quot;+i);jQuery(this).find(&quot;#item-position&quot;+j).attr(&quot;id&quot;,&quot;item-position&quot;+i);jQuery(this).find(&quot;#item-type&quot;+j).attr(&quot;name&quot;,&quot;item-type&quot;+i);jQuery(this).find(&quot;#item-type&quot;+j).attr(&quot;id&quot;,&quot;item-type&quot;+i);jQuery(&quot;#li-count&quot;).attr(&quot;value&quot;,i)})}function wp_add_item_to_menu(item_type,item_title,item_url,item_id,item_parent_id,item_description){var randomnumber=wp_get_unique_menu_id();jQuery(&quot;.menu&quot;).append('&lt;li id=&quot;menu-'+randomnumber+'&quot; value=&quot;'+randomnumber+'&quot;&gt;&lt;div class=&quot;dropzone ui-droppable&quot;&gt;&lt;/div&gt;&lt;dl class=&quot;ui-droppable&quot;&gt;&lt;dt&gt;&lt;span class=&quot;item-title&quot;&gt;'+item_title+'&lt;/span&gt;&lt;span class=&quot;item-controls&quot;&gt;&lt;span class=&quot;item-type&quot;&gt;'+item_type+'&lt;/span&gt;&lt;a class=&quot;item-edit thickbox&quot; id=&quot;edit'+randomnumber+'&quot; value=&quot;'+randomnumber+'&quot; onClick=&quot;wp_edit_menu_item('+randomnumber+')&quot; title=&quot;'+navMenuL10n.thickbox+'&quot; href=&quot;#TB_inline?height=380&amp;width=300&amp;inlineId=menu-item-settings&quot;&gt;'+navMenuL10n.edit+'&lt;/a&gt; | &lt;a class=&quot;item-delete&quot; id=&quot;delete'+randomnumber+'&quot; value=&quot;'+randomnumber+'&quot;&gt;Delete&lt;/a&gt;&lt;/span&gt;&lt;/dt&gt;&lt;/dl&gt;&lt;input type=&quot;hidden&quot; name=&quot;item-postmenu'+randomnumber+'&quot; id=&quot;item-postmenu'+randomnumber+'&quot; value=&quot;'+item_id+'&quot; /&gt;&lt;input type=&quot;hidden&quot; name=&quot;item-parent'+randomnumber+'&quot; id=&quot;item-parent'+randomnumber+'&quot; value=&quot;'+item_parent_id+'&quot; /&gt;&lt;input type=&quot;hidden&quot; name=&quot;item-title'+randomnumber+'&quot; id=&quot;item-title'+randomnumber+'&quot; value=&quot;'+item_title+'&quot; /&gt;&lt;input type=&quot;hidden&quot; name=&quot;item-url'+randomnumber+'&quot; id=&quot;item-url'+randomnumber+'&quot; value=&quot;'+item_url+'&quot; /&gt;&lt;input type=&quot;hidden&quot; name=&quot;item-description'+randomnumber+'&quot; id=&quot;item-description'+randomnumber+'&quot; value=&quot;'+item_description+'&quot; /&gt;&lt;input type=&quot;hidden&quot; name=&quot;item-position'+randomnumber+'&quot; id=&quot;item-position'+randomnumber+'&quot; value=&quot;'+randomnumber+'&quot; /&gt;&lt;input type=&quot;hidden&quot; name=&quot;item-type'+randomnumber+'&quot; id=&quot;item-type'+randomnumber+'&quot; value=&quot;'+item_type+'&quot; /&gt;&lt;input type=&quot;hidden&quot; name=&quot;item-attr-title'+randomnumber+'&quot; id=&quot;item-attr-title'+randomnumber+'&quot; value=&quot;'+item_title+'&quot; /&gt;&lt;input type=&quot;hidden&quot; name=&quot;item-target'+randomnumber+'&quot; id=&quot;item-target'+randomnumber+'&quot; value=&quot;0&quot; /&gt;&lt;/li&gt;');jQuery(&quot;.menu #menu-&quot;+randomnumber+&quot; dt:first&quot;).animate({backgroundColor:&quot;#FFFF33&quot;},{duration:&quot;normal&quot;,complete:function(){jQuery(this).css(&quot;backgroundColor&quot;,&quot;&quot;)}});wp_drag_and_drop();wp_update_post_data();tb_init(&quot;a.thickbox, area.thickbox, input.thickbox&quot;)}function wp_update_queue(e,item_type,item_title,item_url,item_id,item_parent_id,item_description){var randomnumber=wp_get_unique_menu_id();var menu_item_id=jQuery(e).attr(&quot;id&quot;);if(jQuery(e).attr(&quot;checked&quot;)){jQuery(&quot;#queue&quot;).append('&lt;li id=&quot;menu-'+randomnumber+'&quot; value=&quot;'+randomnumber+'&quot;&gt;&lt;div class=&quot;dropzone ui-droppable&quot;&gt;&lt;/div&gt;&lt;dl class=&quot;ui-droppable&quot;&gt;&lt;dt&gt;&lt;span class=&quot;item-title&quot;&gt;'+item_title+'&lt;/span&gt;&lt;span class=&quot;item-controls&quot;&gt;&lt;span class=&quot;item-type&quot;&gt;'+item_type+'&lt;/span&gt;&lt;a class=&quot;item-edit thickbox&quot; id=&quot;edit'+randomnumber+'&quot; value=&quot;'+randomnumber+'&quot; onClick=&quot;wp_edit_menu_item('+randomnumber+')&quot; title=&quot;'+navMenuL10n.thickbox+'&quot; href=&quot;#TB_inline?height=380&amp;width=300&amp;inlineId=menu-item-settings&quot;&gt;'+navMenuL10n.edit+'&lt;/a&gt; | &lt;a class=&quot;item-delete&quot; id=&quot;delete'+randomnumber+'&quot; value=&quot;'+randomnumber+'&quot;&gt;Delete&lt;/a&gt;&lt;/span&gt;&lt;/dt&gt;&lt;/dl&gt;&lt;input type=&quot;hidden&quot; name=&quot;item-postmenu'+randomnumber+'&quot; id=&quot;item-postmenu'+randomnumber+'&quot; value=&quot;'+item_id+'&quot; /&gt;&lt;input type=&quot;hidden&quot; name=&quot;item-parent'+randomnumber+'&quot; id=&quot;item-parent'+randomnumber+'&quot; value=&quot;'+item_parent_id+'&quot; /&gt;&lt;input type=&quot;hidden&quot; name=&quot;item-title'+randomnumber+'&quot; id=&quot;item-title'+randomnumber+'&quot; value=&quot;'+item_title+'&quot; /&gt;&lt;input type=&quot;hidden&quot; name=&quot;item-url'+randomnumber+'&quot; id=&quot;item-url'+randomnumber+'&quot; value=&quot;'+item_url+'&quot; /&gt;&lt;input type=&quot;hidden&quot; name=&quot;item-description'+randomnumber+'&quot; id=&quot;item-description'+randomnumber+'&quot; value=&quot;'+item_description+'&quot; /&gt;&lt;input type=&quot;hidden&quot; name=&quot;item-position'+randomnumber+'&quot; id=&quot;item-position'+randomnumber+'&quot; value=&quot;'+randomnumber+'&quot; /&gt;&lt;input type=&quot;hidden&quot; name=&quot;item-type'+randomnumber+'&quot; id=&quot;item-type'+randomnumber+'&quot; value=&quot;'+item_type+'&quot; /&gt;&lt;input type=&quot;hidden&quot; name=&quot;item-attr-title'+randomnumber+'&quot; id=&quot;item-attr-title'+randomnumber+'&quot; value=&quot;'+item_title+'&quot; /&gt;&lt;input type=&quot;hidden&quot; name=&quot;item-target'+randomnumber+'&quot; id=&quot;item-target'+randomnumber+'&quot; value=&quot;0&quot; /&gt;&lt;input type=&quot;hidden&quot; name=&quot;item-id'+randomnumber+'&quot; id=&quot;item-id'+randomnumber+'&quot; value=&quot;'+menu_item_id+'&quot; /&gt;&lt;/li&gt;')}else{if(menu_item_id==jQuery('#queue li input[name^=&quot;item-id&quot;]').val()){jQuery('#queue li input[name^=&quot;item-id&quot;]').parent().remove()}}}function wp_add_queued_items_to_menu(button){var items=jQuery(&quot;#queue&quot;).children();jQuery(&quot;#queue&quot;).empty();jQuery(&quot;.menu&quot;).append(items);jQuery(items).each(function(){jQuery(this).find(&quot;dt&quot;).animate({backgroundColor:&quot;#FFFF33&quot;},{duration:&quot;normal&quot;,complete:function(){jQuery(this).css(&quot;backgroundColor&quot;,&quot;&quot;)}})});jQuery(button).offsetParent().find(&quot;.list-container input&quot;).attr(&quot;checked&quot;,false);wp_update_post_data();wp_drag_and_drop();tb_init(&quot;a.thickbox, area.thickbox, input.thickbox&quot;)}function wp_drag_and_drop(){jQuery(&quot;.menu li&quot;).each(function(){if(!jQuery(this).children(&quot;.dropzone&quot;).attr(&quot;class&quot;)){jQuery(this).prepend('&lt;div class=&quot;dropzone&quot;&gt;&lt;/div&gt;')}});jQuery(&quot;.menu li&quot;).draggable({handle:&quot; &gt; dl&quot;,opacity:0.8,addClasses:false,helper:&quot;clone&quot;,zIndex:100,});jQuery(&quot;.menu li dl, .menu li .dropzone&quot;).droppable({accept:&quot;.menu li&quot;,tolerance:&quot;pointer&quot;,drop:function(e,ui){var li=jQuery(this).parent();var child=!jQuery(this).hasClass(&quot;dropzone&quot;);if(child&amp;&amp;li.children(&quot;ul&quot;).length==0){li.append('&lt;ul class=&quot;sub-menu&quot; /&gt;')}if(child){li.children(&quot;ul&quot;).append(ui.draggable)}else{li.before(ui.draggable)}li.find(&quot;dl,.dropzone&quot;).css({backgroundColor:&quot;&quot;,borderColor:&quot;&quot;});var draggablevalue=ui.draggable.attr(&quot;value&quot;);var droppablevalue=li.attr(&quot;value&quot;);li.find(&quot;#menu-&quot;+draggablevalue).find(&quot;#parent&quot;+draggablevalue).val(droppablevalue);jQuery(this).parent().find(&quot;dt&quot;).removeAttr(&quot;style&quot;);jQuery(this).parent().find(&quot;div:first&quot;).removeAttr(&quot;style&quot;)},over:function(){if(jQuery(this).attr(&quot;class&quot;)==&quot;dropzone ui-droppable&quot;){jQuery(this).parent().find(&quot;div:first&quot;).css(&quot;background&quot;,&quot;none&quot;).css(&quot;height&quot;,&quot;50px&quot;)}else{if(jQuery(this).attr(&quot;class&quot;)==&quot;ui-droppable&quot;){jQuery(this).parent().find(&quot;dt:first&quot;).css(&quot;background&quot;,&quot;#d8d8d8&quot;)}else{}}var parentid=jQuery(this).parent().attr(&quot;id&quot;)},out:function(){jQuery(this).parent().find(&quot;dt&quot;).removeAttr(&quot;style&quot;);jQuery(this).parent().find(&quot;div:first&quot;).removeAttr(&quot;style&quot;);jQuery(this).filter(&quot;.dropzone&quot;).css({borderColor:&quot;&quot;})}})}function wp_get_unique_menu_id(){var count=jQuery(&quot;.menu li&quot;).length+1;var randomnumber=count;var validatetest=0;try{var test=document.getElementById(&quot;menu-&quot;+randomnumber.toString()).value}catch(err){validatetest=1}while(validatetest==0){randomnumber=randomnumber+1;try{var test2=document.getElementById(&quot;menu-&quot;+randomnumber.toString()).value}catch(err){validatetest=1}}return randomnumber};
</del><span class="cx">\ No newline at end of file
</span><ins>+function wp_nav_menu_autocomplete(a){jQuery(&quot;#add-&quot;+a+&quot; .quick-search&quot;).autocomplete(jQuery(&quot;#add-&quot;+a+&quot; .autocomplete&quot;).val().split(&quot;|&quot;));jQuery(&quot;#add-&quot;+a+&quot; .quick-search&quot;).result(function(b,d,c){jQuery(&quot;#add-&quot;+a+&quot; .list-wrap&quot;).css(&quot;display&quot;,&quot;block&quot;);jQuery(&quot;#add-&quot;+a+&quot; .list-wrap li:contains('&quot;+d+&quot;')&quot;).css(&quot;display&quot;,&quot;block&quot;);jQuery(&quot;#add-&quot;+a+&quot; .show-all&quot;).hide();jQuery(&quot;#add-&quot;+a+&quot; .hide-all&quot;).show()})}function wp_edit_menu_item(a){var f=jQuery(&quot;#menu-item-type&quot;+a).val();var b=jQuery(&quot;#menu-item-title&quot;+a).val();var g=jQuery(&quot;#menu-item-url&quot;+a).val();var c=jQuery(&quot;#menu-item-attr-title&quot;+a).val();var d=jQuery(&quot;#menu-item-target&quot;+a).val();var h=jQuery(&quot;#menu-item-description&quot;+a).val();var e=jQuery(&quot;#menu-item-classes&quot;+a).val();var i=jQuery(&quot;#menu-item-xfn&quot;+a).val();if(&quot;custom&quot;!=f){jQuery(&quot;#edit-menu-item-url&quot;).attr(&quot;disabled&quot;,&quot;disabled&quot;)}jQuery(&quot;#edit-menu-item-id&quot;).val(a);jQuery(&quot;#edit-menu-item-title&quot;).val(b);jQuery(&quot;#edit-menu-item-url&quot;).val(g);jQuery(&quot;#edit-menu-item-attr-title&quot;).val(c);jQuery(&quot;#edit-menu-item-target&quot;).val(d);jQuery(&quot;#edit-menu-item-target option[value='&quot;+d+&quot;']&quot;).attr(&quot;selected&quot;,&quot;selected&quot;);jQuery(&quot;#edit-menu-item-description&quot;).val(h);jQuery(&quot;#edit-menu-item-classes&quot;).val(e);jQuery(&quot;#edit-menu-item-xfn&quot;).val(i);jQuery(&quot;#edit-menu-item-title&quot;).focus()}function wp_update_menu_item(){var h=jQuery(&quot;#edit-menu-item-id&quot;).val();var f=jQuery(&quot;#edit-menu-item-title&quot;).val();var b=jQuery(&quot;#edit-menu-item-url&quot;).val();var g=jQuery(&quot;#edit-menu-item-attr-title&quot;).val();var d=jQuery(&quot;#edit-menu-item-target&quot;).val();var c=jQuery(&quot;#edit-menu-item-description&quot;).val();var a=jQuery(&quot;#edit-menu-item-classes&quot;).val();var e=jQuery(&quot;#edit-menu-item-xfn&quot;).val();jQuery(&quot;.menu #menu-item&quot;+h).find(&quot;span.item-title&quot;).html(f);jQuery(&quot;.menu #menu-item-title&quot;+h).val(f);jQuery(&quot;.menu #menu-item-url&quot;+h).val(b);jQuery(&quot;.menu #menu-item-attr-title&quot;+h).val(g);jQuery(&quot;.menu #menu-item-target&quot;+h).val(d);jQuery(&quot;.menu #menu-item-description&quot;+h).val(c);jQuery(&quot;.menu #menu-item-classes&quot;+h).val(a);jQuery(&quot;.menu #menu-item-xfn&quot;+h).val(e);jQuery(&quot;.menu #menu-item&quot;+h+&quot; dt:first&quot;).animate({backgroundColor:&quot;#FFFF33&quot;},{duration:&quot;normal&quot;,complete:function(){jQuery(this).css(&quot;backgroundColor&quot;,&quot;&quot;)}})}function wp_remove_menu_item(b){var a=document.getElementById(&quot;menu-item&quot;+b);if(a){jQuery(a).find(&quot;dt&quot;).each(function(){jQuery(this).animate({backgroundColor:&quot;#FF3333&quot;},{duration:&quot;normal&quot;,complete:function(){jQuery(this).parent().parent().remove()}})})}}function wp_add_item_to_menu(a,k,f,n,l,b,m,h,e,d,c,i){var j=wp_get_unique_menu_id();var g=wp_get_hidden_inputs(j,a,k,f,n,l,b,m,h,e,d,c,i);jQuery(&quot;.menu&quot;).append('&lt;li id=&quot;menu-item'+j+'&quot; value=&quot;'+j+'&quot;&gt;&lt;div class=&quot;dropzone ui-droppable&quot;&gt;&lt;/div&gt;&lt;dl class=&quot;ui-droppable&quot;&gt;&lt;dt&gt;&lt;span class=&quot;item-title&quot;&gt;'+b+'&lt;/span&gt;&lt;span class=&quot;item-controls&quot;&gt;&lt;span class=&quot;item-type&quot;&gt;'+n+'&lt;/span&gt;&lt;a class=&quot;item-edit thickbox&quot; id=&quot;edit'+j+'&quot; value=&quot;'+j+'&quot; onClick=&quot;wp_edit_menu_item('+j+')&quot; title=&quot;'+navMenuL10n.thickbox+'&quot; href=&quot;#TB_inline?height=540&amp;width=300&amp;inlineId=menu-item-settings&quot;&gt;'+navMenuL10n.edit+'&lt;/a&gt; | &lt;a class=&quot;item-delete&quot; id=&quot;delete'+j+'&quot; value=&quot;'+j+'&quot;&gt;Delete&lt;/a&gt;&lt;/span&gt;&lt;/dt&gt;&lt;/dl&gt;'+g+&quot;&lt;/li&gt;&quot;);jQuery(&quot;.menu #menu-item&quot;+j+&quot; dt:first&quot;).animate({backgroundColor:&quot;#FFFF33&quot;},{duration:&quot;normal&quot;,complete:function(){jQuery(this).css(&quot;backgroundColor&quot;,&quot;&quot;)}});wp_drag_and_drop();tb_init(&quot;a.thickbox, area.thickbox, input.thickbox&quot;)}function wp_add_checked_items_to_menu(b){var a=jQuery(b).siblings(&quot;.list-wrap&quot;).find(&quot;:checked&quot;);if(0==a.length){return false}jQuery(a).each(function(){var h=jQuery(this).parent().siblings(&quot;.menu-item-type&quot;).val();if(&quot;custom&quot;==h){var e=jQuery(this).parent().siblings(&quot;.menu-item-attr-title&quot;).val();var f=jQuery(this).parent().siblings(&quot;.menu-item-target&quot;).val();var g=jQuery(this).parent().siblings(&quot;.menu-item-classes&quot;).val();var j=jQuery(this).parent().siblings(&quot;.menu-item-xfn&quot;).val()}else{var e=&quot;&quot;;var f=&quot;_none&quot;;var g=&quot;&quot;;var j=&quot;&quot;}var c=jQuery(this).parent().siblings(&quot;.menu-item-db-id&quot;).val();var k=jQuery(this).parent().siblings(&quot;.menu-item-object-id&quot;).val();var n=jQuery(this).parent().siblings(&quot;.menu-item-append&quot;).val();var l=jQuery(this).parent().siblings(&quot;.menu-item-parent-id&quot;).val();var d=jQuery(this).parent().siblings(&quot;.menu-item-title&quot;).val();var m=jQuery(this).parent().siblings(&quot;.menu-item-url&quot;).val();var i=jQuery(this).parent().siblings(&quot;.menu-item-description&quot;).val();if(undefined==i){i=&quot;&quot;}wp_add_item_to_menu(c,k,h,n,l,d,m,i,e,f,g,j);jQuery(this).attr(&quot;checked&quot;,false)})}function wp_drag_and_drop(){jQuery(&quot;.menu li&quot;).each(function(){if(!jQuery(this).children(&quot;.dropzone&quot;).attr(&quot;class&quot;)){jQuery(this).prepend('&lt;div class=&quot;dropzone&quot;&gt;&lt;/div&gt;')}});jQuery(&quot;.menu li&quot;).draggable({handle:&quot; &gt; dl&quot;,opacity:0.8,addClasses:false,helper:&quot;clone&quot;,zIndex:100});jQuery(&quot;.menu li dl, .menu li .dropzone&quot;).droppable({accept:&quot;.menu li&quot;,tolerance:&quot;pointer&quot;,drop:function(f,d){var a=jQuery(this).parent();var g=!jQuery(this).hasClass(&quot;dropzone&quot;);if(g&amp;&amp;a.children(&quot;ul&quot;).length==0){a.append('&lt;ul class=&quot;sub-menu&quot; /&gt;')}if(g){a.children(&quot;ul&quot;).append(d.draggable)}else{a.before(d.draggable)}a.find(&quot;dl,.dropzone&quot;).css({backgroundColor:&quot;&quot;,borderColor:&quot;&quot;});var c=d.draggable.attr(&quot;value&quot;);var b=a.attr(&quot;value&quot;);a.find(&quot;#menu-&quot;+c).find(&quot;#parent&quot;+c).val(b);jQuery(this).parent().find(&quot;dt&quot;).removeAttr(&quot;style&quot;);jQuery(this).parent().find(&quot;div:first&quot;).removeAttr(&quot;style&quot;)},over:function(){if(jQuery(this).attr(&quot;class&quot;)==&quot;dropzone ui-droppable&quot;){jQuery(this).parent().find(&quot;div:first&quot;).css(&quot;background&quot;,&quot;none&quot;).css(&quot;height&quot;,&quot;50px&quot;)}else{if(jQuery(this).attr(&quot;class&quot;)==&quot;ui-droppable&quot;){jQuery(this).parent().find(&quot;dt:first&quot;).css(&quot;background&quot;,&quot;#d8d8d8&quot;)}else{}}var a=jQuery(this).parent().attr(&quot;id&quot;)},out:function(){jQuery(this).parent().find(&quot;dt&quot;).removeAttr(&quot;style&quot;);jQuery(this).parent().find(&quot;div:first&quot;).removeAttr(&quot;style&quot;);jQuery(this).filter(&quot;.dropzone&quot;).css({borderColor:&quot;&quot;})}})}function wp_update_post_data(){var a=0;jQuery(&quot;.menu li&quot;).each(function(c){c=c+1;var b=jQuery(this).attr(&quot;value&quot;);jQuery(this).find(&quot;#menu-item-position&quot;+b).attr(&quot;value&quot;,c);jQuery(this).attr(&quot;id&quot;,&quot;menu-item&quot;+c);jQuery(this).attr(&quot;value&quot;,c);jQuery(this).find(&quot;#menu-item-db-id&quot;+b).attr(&quot;id&quot;,&quot;menu-item-db-id&quot;+c);jQuery(this).find(&quot;#menu-item-object-id&quot;+b).attr(&quot;id&quot;,&quot;menu-item-object-id&quot;+c);jQuery(this).find(&quot;#menu-item-append&quot;+b).attr(&quot;id&quot;,&quot;menu-item-append&quot;+c);jQuery(this).find(&quot;#menu-item-type&quot;+b).attr(&quot;id&quot;,&quot;menu-item-type&quot;+c);jQuery(this).find(&quot;#menu-item-position&quot;+b).attr(&quot;id&quot;,&quot;menu-item-position&quot;+c);var d=jQuery(this).find(&quot;#menu-item-parent-id&quot;+b).parent().parent().parent().attr(&quot;value&quot;);jQuery(this).find(&quot;#menu-item-parent-id&quot;+b).attr(&quot;id&quot;,&quot;menu-item-parent-id&quot;+c);if(d){}else{d=0}jQuery(this).find(&quot;#menu-item-parent-id&quot;+b).attr(&quot;value&quot;,d);jQuery(this).find(&quot;#menu-item-title&quot;+b).attr(&quot;id&quot;,&quot;menu-item-title&quot;+c);jQuery(this).find(&quot;#menu-item-url&quot;+b).attr(&quot;id&quot;,&quot;menu-item-url&quot;+c);jQuery(this).find(&quot;#menu-item-description&quot;+b).attr(&quot;id&quot;,&quot;menu-item-description&quot;+c);jQuery(this).find(&quot;#menu-item-classes&quot;+b).attr(&quot;id&quot;,&quot;menu-item-classes&quot;+c);jQuery(this).find(&quot;#menu-item-xfn&quot;+b).attr(&quot;id&quot;,&quot;menu-item-xfn&quot;+c);jQuery(this).find(&quot;#menu-item-description&quot;+b).attr(&quot;id&quot;,&quot;menu-item-description&quot;+c);jQuery(this).find(&quot;#menu-item-attr-title&quot;+b).attr(&quot;id&quot;,&quot;menu-item-attr-title&quot;+c);jQuery(this).find(&quot;#menu-item-target&quot;+b).attr(&quot;id&quot;,&quot;menu-item-target&quot;+c);jQuery(&quot;#li-count&quot;).attr(&quot;value&quot;,c)})}function wp_get_unique_menu_id(){var d=jQuery(&quot;.menu li&quot;).length+1;var e=d;var a=0;try{var f=document.getElementById(&quot;menu-&quot;+e.toString()).value}catch(c){a=1}while(a==0){e=e+1;try{var b=document.getElementById(&quot;menu-&quot;+e.toString()).value}catch(c){a=1}}return e}function wp_get_hidden_inputs(j,a,k,f,n,l,b,m,h,e,d,c,i){var g=&quot;&quot;;g+='&lt;input type=&quot;hidden&quot; name=&quot;menu-item-db-id[]&quot; id=&quot;menu-item-db-id'+j+'&quot; value=&quot;'+a+'&quot; /&gt;';g+='&lt;input type=&quot;hidden&quot; name=&quot;menu-item-object-id[]&quot; id=&quot;menu-item-object-id'+j+'&quot; value=&quot;'+k+'&quot; /&gt;';g+='&lt;input type=&quot;hidden&quot; name=&quot;menu-item-type[]&quot; id=&quot;menu-item-type'+j+'&quot; value=&quot;'+f+'&quot; /&gt;';g+='&lt;input type=&quot;hidden&quot; name=&quot;menu-item-append[]&quot; id=&quot;menu-item-append'+j+'&quot; value=&quot;'+n+'&quot; /&gt;';g+='&lt;input type=&quot;hidden&quot; name=&quot;menu-item-parent-id[]&quot; id=&quot;menu-item-parent-id'+j+'&quot; value=&quot;'+l+'&quot; /&gt;';g+='&lt;input type=&quot;hidden&quot; name=&quot;menu-item-position[]&quot; id=&quot;menu-item-position'+j+'&quot; value=&quot;'+j+'&quot; /&gt;';g+='&lt;input type=&quot;hidden&quot; name=&quot;menu-item-title[]&quot; id=&quot;menu-item-title'+j+'&quot; value=&quot;'+b+'&quot; /&gt;';g+='&lt;input type=&quot;hidden&quot; name=&quot;menu-item-attr-title[]&quot; id=&quot;menu-item-attr-title'+j+'&quot; value=&quot;'+e+'&quot; /&gt;';g+='&lt;input type=&quot;hidden&quot; name=&quot;menu-item-url[]&quot; id=&quot;menu-item-url'+j+'&quot; value=&quot;'+m+'&quot; /&gt;';g+='&lt;input type=&quot;hidden&quot; name=&quot;menu-item-target[]&quot; id=&quot;menu-item-target'+j+'&quot; value=&quot;'+d+'&quot; /&gt;';g+='&lt;input type=&quot;hidden&quot; name=&quot;menu-item-description[]&quot; id=&quot;menu-item-description'+j+'&quot; value=&quot;'+h+'&quot; /&gt;';g+='&lt;input type=&quot;hidden&quot; name=&quot;menu-item-classes[]&quot; id=&quot;menu-item-classes'+j+'&quot; value=&quot;'+c+'&quot; /&gt;';g+='&lt;input type=&quot;hidden&quot; name=&quot;menu-item-xfn[]&quot; id=&quot;menu-item-xfn'+j+'&quot; value=&quot;'+i+'&quot; /&gt;';return g};
</ins><span class="cx">\ No newline at end of file
</span></span></pre></div>
<a id="trunkwpadminnavmenusphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-admin/nav-menus.php (13703 => 13704)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-admin/nav-menus.php        2010-03-15 14:29:11 UTC (rev 13703)
+++ trunk/wp-admin/nav-menus.php        2010-03-15 16:26:46 UTC (rev 13704)
</span><span class="lines">@@ -9,170 +9,203 @@
</span><span class="cx">  * @subpackage Administration
</span><span class="cx">  */
</span><span class="cx"> 
</span><del>-require_once('admin.php');
</del><ins>+/** Load WordPress Administration Bootstrap */
+require_once( 'admin.php' );
</ins><span class="cx"> 
</span><del>-/*
-TODO
-        Add caps: edit_menus, delete_menus
-*/
</del><ins>+// Permissions Check
</ins><span class="cx"> if ( ! current_user_can('switch_themes') )
</span><span class="cx">         wp_die( __( 'Cheatin&amp;#8217; uh?' ));
</span><span class="cx"> 
</span><ins>+// Nav Menu CSS
</ins><span class="cx"> wp_admin_css( 'nav-menu' );
</span><ins>+
+// jQuery
</ins><span class="cx"> wp_enqueue_script( 'jquery' );
</span><span class="cx"> wp_enqueue_script( 'jquery-ui-draggable' );
</span><span class="cx"> wp_enqueue_script( 'jquery-ui-droppable' );
</span><span class="cx"> wp_enqueue_script( 'jquery-ui-sortable' );
</span><del>-wp_enqueue_script( 'jquery-ui-dialog' );
</del><ins>+wp_enqueue_script( 'jquery-autocomplete' );
+
+// Nav Menu functions
</ins><span class="cx"> wp_enqueue_script( 'nav-menu-dynamic-functions' );
</span><span class="cx"> wp_enqueue_script( 'nav-menu-default-items' );
</span><del>-wp_enqueue_script( 'jquery-autocomplete' );
</del><span class="cx"> wp_enqueue_script( 'nav-menu-php-functions' );
</span><ins>+
+// Metaboxes
+wp_enqueue_script( 'common' );
+wp_enqueue_script( 'wp-lists' );
+wp_enqueue_script( 'postbox' );
+
+// Thickbox
</ins><span class="cx"> add_thickbox();
</span><span class="cx"> 
</span><del>-require_once( 'admin-header.php' );
</del><ins>+// Load all the nav menu interface functions
</ins><span class="cx"> require_once( ABSPATH . 'wp-admin/includes/nav-menu.php' );
</span><span class="cx"> 
</span><del>-function wp_reset_nav_menu() {
-        wp_nav_menu_setup( true );
-        return true;
-}
-
</del><ins>+// Container for any messages displayed to the user
</ins><span class="cx"> $messages_div = '';
</span><del>-$menu_id_in_edit = 0;
-$updated = false;
-$advanced_option_descriptions = 'no';
</del><span class="cx"> 
</span><del>-// Check which menu is selected and if menu is in edit already
-if ( isset( $_GET['edit-menu'] ) ) {
-        $menu_selected_id = (int) $_GET['edit-menu'];
-        $updated = true;
-} elseif ( isset( $_POST[ 'menu-id-in-edit' ] ) ) {
-        $menu_selected_id = (int) $_POST[ 'menu-id-in-edit' ];
-} else {
-        $menu_selected_id = 0;
-}
</del><ins>+// Container that stores the name of the active menu
+$nav_menu_selected_title = '';
</ins><span class="cx"> 
</span><del>-// Delete a menu
-if ( isset($_GET['delete-menu']) &amp;&amp; $_GET['delete-menu'] &gt; 0 ) {
-        // if ( ! current_user_can('delete_menus') )
-        //         wp_die( __( 'Cheatin&amp;#8217; uh?' ));
</del><ins>+// The menu id of the current menu being edited
+$nav_menu_selected_id = isset( $_REQUEST['menu'] ) ? (int) $_REQUEST['menu'] : 0;
</ins><span class="cx"> 
</span><del>-        $menu_id = (int) $_GET['delete-menu'];
-        check_admin_referer( 'delete_menu-' . $menu_id );
</del><ins>+// Allowed actions: add, update, delete
+$action = isset( $_REQUEST['action'] ) ? $_REQUEST['action'] : 'edit';
</ins><span class="cx"> 
</span><del>-        wp_delete_nav_menu( $menu_id );
-        $messages_div = '&lt;div id=&quot;message&quot; class=&quot;updated fade below-h2&quot;&gt;&lt;p&gt;' . __('Menu successfully deleted.') . '&lt;/p&gt;&lt;/div&gt;';
-        $menu_selected_id = 0;
-        $updated = true;
-}
</del><ins>+switch ( $action ) {
+        case 'delete':
+                check_admin_referer( 'delete-nav_menu-' . $nav_menu_selected_id );
</ins><span class="cx"> 
</span><del>-// Default Menu to show
-$menus = wp_get_nav_menus();
</del><ins>+                if ( is_nav_menu($nav_menu_selected_id) ) {
+                        wp_delete_nav_menu( $nav_menu_selected_id );
+                        $messages_div = '&lt;div id=&quot;message&quot; class=&quot;updated fade below-h2&quot;&gt;&lt;p&gt;' . __('Menu successfully deleted.') . '&lt;/p&gt;&lt;/div&gt;';
+                        $nav_menu_selected_id = 0;
+                }
+                break;
+        
+        case 'update':
+                check_admin_referer( 'update-nav_menu' );
+                
+                // Add Menu
+                if ( isset($_POST['create-menu']) ) {
+                        if ( current_theme_supports('nav-menus') ) {
+                                $add_nav_menu = esc_html( $_POST['create-menu-name'] );
</ins><span class="cx"> 
</span><del>-if ( empty($menus) &amp;&amp; empty($_POST) ) {
-        wp_create_default_nav_menu();
-        $menus = wp_get_nav_menus();
-}
</del><ins>+                                if ( $add_nav_menu ) {
+                                        $add_nav_menu = wp_create_nav_menu( $add_nav_menu );
</ins><span class="cx"> 
</span><del>-if ( ! $menu_selected_id &amp;&amp; ! empty($menus) )
-        $menu_selected_id = $menus[0]-&gt;term_id;
-
-// Get the name of the current Menu
-$menu_title = '';
-$valid_menu = false;
-if ( $menu_selected_id &gt; 0 ) {
-        foreach ( $menus as $menu ) {
-                if ( $menu-&gt;term_id == $menu_selected_id ) {
-                        $menu_title = $menu-&gt;name;
-                        $valid_menu = true;
-                        break;
</del><ins>+                                        if ( is_wp_error( $add_nav_menu ) ) {
+                                                $messages_div = '&lt;div id=&quot;message&quot; class=&quot;error fade below-h2&quot;&gt;&lt;p&gt;' . $add_nav_menu-&gt;get_error_message() . '&lt;/p&gt;&lt;/div&gt;';
+                                        } else {
+                                                $nav_menu_selected_id = $add_nav_menu-&gt;term_id;
+                                                $nav_menu_selected_title = $add_nav_menu-&gt;name;
+                                                $messages_div = '&lt;div id=&quot;message&quot; class=&quot;updated fade below-h2&quot;&gt;&lt;p&gt;' . sprintf( __('The &lt;strong&gt;%s&lt;/strong&gt; menu has been successfully created.'), esc_html( $add_nav_menu-&gt;name ) ) . '&lt;/p&gt;&lt;/div&gt;';
+                                        }
+                                } else {
+                                        $messages_div = '&lt;div id=&quot;message&quot; class=&quot;error fade below-h2&quot;&gt;&lt;p&gt;' . __('Please enter a valid menu name.') . '&lt;/p&gt;&lt;/div&gt;';
+                                }
+                                unset($add_nav_menu);
+                        }
</ins><span class="cx">                 }
</span><del>-        }
-}
</del><ins>+                
+                // Update menu name
+                if ( isset($_POST['menu-name']) ) {
+                        $old_nav_menu = get_term( $nav_menu_selected_id, 'nav_menu', ARRAY_A );
+                        $args = array( 'name' =&gt; $_POST['menu-name'], 'slug' =&gt; null, 'description' =&gt; $old_nav_menu['description'], 'parent' =&gt; $old_nav_menu['parent'], );
+                        $new_nav_menu = wp_update_term( $nav_menu_selected_id, 'nav_menu', $args );
+                }
+                
+                // Update menu items
+                $update_nav_items = isset( $_POST['li-count'] ) ? (int) $_POST['li-count'] : 0;
+                $update_nav_menu = is_nav_menu( $nav_menu_selected_id );
+                
+                if ( !is_wp_error($update_nav_menu) ) {
+                        $menu_items = wp_get_nav_menu_items( $nav_menu_selected_id, array('orderby' =&gt; 'ID', 'output' =&gt; ARRAY_A, 'output_key' =&gt; 'ID') );
+                        $parent_menu_ids = array();
+                        
+                        // Loop through all POST variables
+                        for ( $k = 0; $k &lt; $update_nav_items; $k++ ) {
+                                
+                                $menu_item_db_id                 = isset( $_POST['menu-item-db-id'][$k] )                ? $_POST['menu-item-db-id'][$k]         : 0;
+                                $menu_item_object_id         = isset( $_POST['menu-item-object-id'][$k] )         ? $_POST['menu-item-object-id'][$k] : 0;
+                                $menu_item_parent_id         = isset( $_POST['menu-item-parent-id'][$k] )         ? $_POST['menu-item-parent-id'][$k] : 0;
+                                $menu_item_position         = isset( $_POST['menu-item-position'][$k] )         ? $_POST['menu-item-position'][$k]         : 0;
+                                $menu_item_type                 = isset( $_POST['menu-item-type'][$k] )                         ? $_POST['menu-item-type'][$k]                 : 'custom';
+                                $menu_item_append                 = isset( $_POST['menu-item-append'][$k] )                 ? $_POST['menu-item-append'][$k]        : 'custom';
+                                
+                                $menu_item_title                 = isset( $_POST['menu-item-title'][$k] )                 ? $_POST['menu-item-title'][$k]         : '';
+                                $menu_item_url                         = isset( $_POST['menu-item-url'][$k] )                         ? $_POST['menu-item-url'][$k]                 : '';
+                                $menu_item_description         = isset( $_POST['menu-item-description'][$k] )         ? $_POST['menu-item-description'][$k]: '';
+                                $menu_item_attr_title          = isset( $_POST['menu-item-attr-title'][$k] )         ? $_POST['menu-item-attr-title'][$k] : '';
+                                $menu_item_target                 = isset( $_POST['menu-item-target'][$k] )                 ? $_POST['menu-item-target'][$k]         : 0;
+                                $menu_item_classes                 = isset( $_POST['menu-item-classes'][$k] )                 ? $_POST['menu-item-classes'][$k]         : '';
+                                $menu_item_xfn                         = isset( $_POST['menu-item-xfn'][$k] )                         ? $_POST['menu-item-xfn'][$k]                 : '';
+                                
+                                // Menu item title can't be blank
+                                if ( '' == $menu_item_title )
+                                        continue;
+                                
+                                // Populate the menu item
+                                $post = array( 'post_status' =&gt; 'publish', 'post_type' =&gt; 'nav_menu_item', 'post_author' =&gt; $user_ID,
+                                        'ping_status' =&gt; 0, 'post_parent' =&gt; $menu_item_parent_id, 'menu_order' =&gt; $menu_item_position,
+                                        'post_excerpt' =&gt; $menu_item_attr_title, 'tax_input' =&gt; array( 'nav_menu' =&gt; $update_nav_menu-&gt;name ),
+                                        'post_content' =&gt; $menu_item_description, 'post_title' =&gt; $menu_item_title );
</ins><span class="cx"> 
</span><del>-if ( isset( $_POST['li-count'] ) )
-        $post_counter = $_POST['li-count'];
-else
-        $post_counter = 0;
-
-// Create a new menu. Menus are stored as terms in the 'menu' taxonomy.
-if ( isset( $_POST['create-menu'] ) &amp;&amp; ! $updated ) {
-        $insert_menu_name = $_POST['create-menu-name'];
-
-        if ( $insert_menu_name ) {
-                $menu = wp_create_nav_menu( $insert_menu_name );
-                if ( is_wp_error( $menu ) ) {
-                        $messages_div = '&lt;div id=&quot;message&quot; class=&quot;error fade below-h2&quot;&gt;&lt;p&gt;' . $menu-&gt;get_error_message() . '&lt;/p&gt;&lt;/div&gt;';
-                } else {
-                        $menus[$menu-&gt;term_id] = $menu;
-                        $menu_selected_id = $menu-&gt;term_id;
-                        $menu_id_in_edit = $menu_selected_id;
-                        $menu_title = $menu-&gt;name;
-                        $messages_div = '&lt;div id=&quot;message&quot; class=&quot;updated fade below-h2&quot;&gt;&lt;p&gt;' . sprintf( __('&amp;#8220;%s&amp;#8221; menu has been created.'), esc_html( $menu-&gt;name ) ) . '&lt;/p&gt;&lt;/div&gt;';
-                        $post_counter = 0;
</del><ins>+                                // New menu item
+                                if ( $menu_item_db_id == 0 ) {
+                                        $menu_item_db_id = wp_insert_post( $post );
+                                } elseif ( isset( $menu_items[$menu_item_db_id] ) ) {
+                                        $post['ID'] = $menu_item_db_id;
+                                        wp_update_post( $post );
+                                        unset( $menu_items[$menu_item_db_id] );
+                                }
+                                $parent_menu_ids[$k] = $menu_item_db_id;
+                                
+                                update_post_meta( $menu_item_db_id, 'menu_item_type', $menu_item_type );
+                                update_post_meta( $menu_item_db_id, 'menu_item_append', $menu_item_append );
+                                update_post_meta( $menu_item_db_id, 'menu_item_object_id', $menu_item_object_id );
+                                update_post_meta( $menu_item_db_id, 'menu_item_target', esc_attr($menu_item_target) );
+                                update_post_meta( $menu_item_db_id, 'menu_item_classes', esc_attr($menu_item_classes) );
+                                update_post_meta( $menu_item_db_id, 'menu_item_xfn', esc_attr($menu_item_xfn) );
+                                
+                                // @todo: only save custom link urls.
+                                update_post_meta( $menu_item_db_id, 'menu_item_url', esc_url_raw( $menu_item_url ) );
+                        }
+                        
+                        // Remove menu items from the menu that weren't in $_POST
+                        if ( !empty( $menu_items ) ) {
+                                foreach ( array_keys( $menu_items ) as $menu_item_id ) {
+                                        wp_delete_post( $menu_item_id );
+                                }
+                        }
+                        $messages_div = '&lt;div id=&quot;message&quot; class=&quot;updated fade below-h2&quot;&gt;&lt;p&gt;' . __('The menu has been updated.') . '&lt;/p&gt;&lt;/div&gt;';
</ins><span class="cx">                 }
</span><del>-        } else {
-                $messages_div = '&lt;div id=&quot;message&quot; class=&quot;error fade below-h2&quot;&gt;&lt;p&gt;' . __('Please enter a valid menu name.') . '&lt;/p&gt;&lt;/div&gt;';
-        }
-        $updated = true;
</del><ins>+                break;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-if ( $post_counter &gt; 0 &amp;&amp; $menu_selected_id &gt; 0 &amp;&amp; ! $updated ) {
-        $menu_items = wp_get_nav_menu_items( $menu_selected_id, array('orderby' =&gt; 'ID', 'output' =&gt; ARRAY_A, 'output_key' =&gt; 'ID') );
-        $parent_menu_ids = array();
</del><ins>+// Get all nav menus
+$nav_menus = wp_get_nav_menus();
</ins><span class="cx"> 
</span><del>-        // Loop through all POST variables
-        for ( $k = 1; $k &lt;= $post_counter; $k++ ) {
-                $db_id = isset( $_POST['item-dbid'.$k] )? $_POST['item-dbid'.$k] : 0;
-                $object_id = isset( $_POST['item-postmenu'.$k] )? $_POST['item-postmenu'.$k] : 0;
-                $parent_id = isset( $_POST['item-parent'.$k] )? $_POST['item-parent'.$k] : 0;
-                $custom_title = isset( $_POST['item-title'.$k] )?  $_POST['item-title'.$k] : '';
-                $custom_linkurl = ( isset( $_POST['item-url'.$k] ) &amp;&amp; 'custom' == $_POST['item-type'.$k] ) ? $_POST['item-url'.$k] : '';
-                $custom_description = isset( $_POST['item-description'.$k] )? $_POST['item-description'.$k] : '';
</del><ins>+// Get recently edited nav menu
+$recently_edited = get_user_option( 'nav_menu_recently_edited' );
</ins><span class="cx"> 
</span><del>-                // doesn't seem to be used by UI
-                $position = isset( $_POST['item-position'.$k] )? $_POST['item-position'.$k] : 0;
-                $linktype = isset( $_POST['item-type'.$k] )? $_POST['item-type'.$k] : 'custom';
-                $custom_anchor_title  = isset( $_POST['item-attr-title'.$k] )? $_POST['item-attr-title'.$k] : $custom_title;
-                $new_window = isset( $_POST['item-target'.$k] )? $_POST['item-target'.$k] : 0;
</del><ins>+// If there was no recently edited menu, and $nav_menu_selected_id is a nav menu, update recently edited menu.
+if ( !$recently_edited &amp;&amp; is_nav_menu($nav_menu_selected_id) ) {
+        $recently_edited = $nav_menu_selected_id;
</ins><span class="cx"> 
</span><del>-                $post = array( 'post_status' =&gt; 'publish', 'post_type' =&gt; 'nav_menu_item', 'post_author' =&gt; $user_ID,
-                        'ping_status' =&gt; 0, 'post_parent' =&gt; 0, 'menu_order' =&gt; $position,
-                        'post_excerpt' =&gt; $custom_anchor_title, 'tax_input' =&gt; array( 'nav_menu' =&gt; $menu_title ),
-                        'post_content' =&gt; $custom_description, 'post_title' =&gt; $custom_title );
</del><ins>+// Else if $nav_menu_selected_id is not a menu, but $recently_edited is, grab that one.
+} elseif ( 0 == $nav_menu_selected_id &amp;&amp; is_nav_menu($recently_edited) ) {
+        $nav_menu_selected_id = $recently_edited;
</ins><span class="cx"> 
</span><del>-                if ( $parent_id &gt; 0 &amp;&amp; isset( $parent_menu_ids[$parent_id] ) )
-                        $post['post_parent'] = $parent_menu_ids[$parent_id];
</del><ins>+// Else try to grab the first menu from the menus list
+} elseif ( 0 == $nav_menu_selected_id &amp;&amp; ! empty($nav_menus) ) {
+        $nav_menu_selected_id = $nav_menus[0]-&gt;term_id;        
+}
</ins><span class="cx"> 
</span><del>-                // New menu item
-                if ( $db_id == 0 ) {
-                        $db_id = wp_insert_post( $post );
-                } elseif ( isset( $menu_items[$db_id] ) ) {
-                        $post['ID'] = $db_id;
-                        wp_update_post( $post );
-                        unset( $menu_items[$db_id] );
-                }
-                $parent_menu_ids[ $k ] = $db_id;
</del><ins>+// Update the user's setting
+if ( $nav_menu_selected_id != $recently_edited &amp;&amp; is_nav_menu($nav_menu_selected_id) )
+        update_user_meta( $current_user-&gt;ID, 'nav_menu_recently_edited', $nav_menu_selected_id );
</ins><span class="cx"> 
</span><del>-                update_post_meta( $db_id, 'menu_type', $linktype );
-                update_post_meta( $db_id, 'object_id', $object_id );
-                if ( $new_window )
-                        update_post_meta( $db_id, 'menu_new_window', 1 );
-                else
-                        update_post_meta( $db_id, 'menu_new_window', 0 );
-                if ( $custom_linkurl )
-                        update_post_meta( $db_id, 'menu_link', esc_url_raw( $custom_linkurl ) );
</del><ins>+// If there's a menu, get it's name.
+if ( !$nav_menu_selected_title &amp;&amp; $nav_menu_selected_title = is_nav_menu( $nav_menu_selected_id ) ) {
+        $nav_menu_selected_title = $nav_menu_selected_title-&gt;name;
+}
</ins><span class="cx"> 
</span><ins>+// The user has no menus.
+if ( !is_nav_menu( $nav_menu_selected_id ) ) {
+        if ( current_theme_supports('nav-menus') ) {
+                $messages_div = '&lt;div id=&quot;message&quot; class=&quot;updated&quot;&gt;&lt;p&gt;' . __('You haven\'t setup any menus yet. Create a new menu.') . '&lt;/p&gt;&lt;/div&gt;';
+        } else {
+                $messages_div = '&lt;div id=&quot;message&quot; class=&quot;error&quot;&gt;&lt;p&gt;' . __('The current theme does not support menus.') . '&lt;/p&gt;&lt;/div&gt;';
</ins><span class="cx">         }
</span><del>-        if ( !empty( $menu_items ) ) {
-                foreach ( array_keys( $menu_items ) as $menu_id ) {
-                        wp_delete_post( $menu_id );
-                }
-        }
-        $messages_div = '&lt;div id=&quot;message&quot; class=&quot;updated fade below-h2&quot;&gt;&lt;p&gt;' . __('The menu has been updated.') . '&lt;/p&gt;&lt;/div&gt;';
</del><ins>+} else {
+        add_meta_box( 'manage-menu', __( 'Menu Settings' ), 'wp_nav_menu_manage_menu_metabox', 'menus', 'side', 'high', array( $nav_menu_selected_id, $nav_menu_selected_title ) );
</ins><span class="cx"> }
</span><span class="cx"> 
</span><ins>+// Get the admin header
+require_once( 'admin-header.php' );
</ins><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><span class="lines">@@ -180,266 +213,110 @@
</span><span class="cx">         &lt;?php echo $messages_div; ?&gt;
</span><span class="cx">         &lt;div class=&quot;hide-if-js error&quot;&gt;&lt;p&gt;&lt;?php _e('You do not have JavaScript enabled in your browser. Please enable it to access the Menus functionality.'); ?&gt;&lt;/p&gt;&lt;/div&gt;
</span><span class="cx"> 
</span><del>-        &lt;form onsubmit=&quot;wp_update_post_data();&quot; action=&quot;&lt;?php echo admin_url( 'nav-menus.php' ); ?&gt;&quot; method=&quot;post&quot; enctype=&quot;multipart/form-data&quot;&gt;
-                &lt;?php if ( !empty($menus) &amp;&amp; count($menus) &gt; 1 ) : ?&gt;
-                &lt;ul class=&quot;subsubsub&quot;&gt;
-                        &lt;?php
-                                foreach ( $menus as $menu ) {
-                                        $sep = end( $menus ) == $menu ? '' : ' | ';
-                                        if ( ( $menu_id_in_edit == $menu-&gt;term_id ) || ( $menu_selected_id == $menu-&gt;term_id ) ) { ?&gt;
-                                                &lt;li&gt;&lt;a href='nav-menus.php?edit-menu=&lt;?php echo esc_attr($menu-&gt;term_id); ?&gt;' class=&quot;current&quot;&gt;&lt;?php echo esc_html( $menu-&gt;name ); ?&gt;&lt;/a&gt;&lt;?php echo $sep; ?&gt;&lt;/li&gt;
-                        &lt;?php        } else { ?&gt;
-                                                &lt;li&gt;&lt;a href='nav-menus.php?edit-menu=&lt;?php echo esc_attr($menu-&gt;term_id); ?&gt;'&gt;&lt;?php echo esc_html( $menu-&gt;name ); ?&gt;&lt;/a&gt;&lt;?php echo $sep; ?&gt;&lt;/li&gt;
-                        &lt;?php        }
-                                }
-                        ?&gt;
-                &lt;/ul&gt;
-                &lt;?php endif; ?&gt;
</del><ins>+        &lt;?php if ( !empty($nav_menus) &amp;&amp; count($nav_menus) &gt; 1 ) : ?&gt;
+        &lt;ul class=&quot;subsubsub&quot;&gt;
+                &lt;?php
+                        foreach ( $nav_menus as $_nav_menu ) {
+                                $sep = end( $nav_menus ) == $_nav_menu ? '' : ' | ';
+                                
+                                if ( $nav_menu_selected_id == $_nav_menu-&gt;term_id )
+                                        echo '&lt;li&gt;&lt;a href=&quot;'. admin_url( 'nav-menus.php?action=edit&amp;amp;menu=' . esc_attr($_nav_menu-&gt;term_id) ) .'&quot; class=&quot;current&quot;&gt;'. esc_html( $_nav_menu-&gt;name ) .'&lt;/a&gt;'. $sep .'&lt;/li&gt;';
+                                else
+                                        echo '&lt;li&gt;&lt;a href=&quot;'. admin_url( 'nav-menus.php?action=edit&amp;amp;menu=' . esc_attr($_nav_menu-&gt;term_id) ) .'&quot;&gt;'. esc_html( $_nav_menu-&gt;name ) .'&lt;/a&gt;'. $sep .'&lt;/li&gt;';
+                        }
+                ?&gt;
+        &lt;/ul&gt;
+        &lt;?php endif; ?&gt;
</ins><span class="cx"> 
</span><del>-                &lt;div id=&quot;menu-management&quot; class=&quot;metabox-holder has-right-sidebar&quot;&gt;
</del><ins>+        &lt;div id=&quot;menu-management&quot; class=&quot;metabox-holder has-right-sidebar&quot;&gt;
+                &lt;form id=&quot;update-nav-menu&quot; onsubmit=&quot;wp_update_post_data();&quot; action=&quot;&lt;?php echo admin_url( 'nav-menus.php' ); ?&gt;&quot; method=&quot;post&quot; enctype=&quot;multipart/form-data&quot;&gt;
+                        &lt;?php wp_nonce_field( 'closedpostboxes', 'closedpostboxesnonce', false ); ?&gt;
+                        &lt;?php wp_nonce_field( 'meta-box-order', 'meta-box-order-nonce', false ); ?&gt;
+                        &lt;?php wp_nonce_field( 'update-nav_menu' ); ?&gt;
+                        &lt;input type=&quot;hidden&quot; name=&quot;action&quot; value=&quot;update&quot; /&gt;
+                        &lt;input type=&quot;hidden&quot; name=&quot;li-count&quot; id=&quot;li-count&quot; value=&quot;0&quot; /&gt;
+                        &lt;input type=&quot;hidden&quot; name=&quot;menu&quot; id=&quot;menu&quot; value=&quot;&lt;?php echo esc_attr( $nav_menu_selected_id ); ?&gt;&quot; /&gt;
+                        
</ins><span class="cx">                         &lt;div id=&quot;post-body&quot;&gt;
</span><span class="cx">                                 &lt;div id=&quot;post-body-content&quot;&gt;
</span><del>-                                        &lt;div id=&quot;normal-sortables&quot; class=&quot;meta-box-sortables ui-sortable&quot;&gt;
-                                        &lt;?php if ( $valid_menu and ! empty( $menus ) ) : ?&gt;
</del><ins>+                                        &lt;?php if ( is_nav_menu($nav_menu_selected_id) ) : ?&gt;
</ins><span class="cx">                                                 &lt;div id=&quot;menu-container&quot; class=&quot;postbox&quot;&gt;
</span><del>-                                                        &lt;h3 class=&quot;hndle&quot;&gt;&lt;?php echo esc_html( $menu_title ); ?&gt;&lt;/h3&gt;
</del><ins>+                                                        &lt;h3 class=&quot;hndle&quot;&gt;&lt;?php echo esc_html( $nav_menu_selected_title ); ?&gt;&lt;/h3&gt;
</ins><span class="cx">                                                         &lt;div class=&quot;inside&quot;&gt;
</span><del>-                                                                &lt;input type=&quot;hidden&quot; name=&quot;li-count&quot; id=&quot;li-count&quot; value=&quot;0&quot; /&gt;
-                                                                &lt;input type=&quot;hidden&quot; name=&quot;menu-id-in-edit&quot; id=&quot;menu-id-in-edit&quot; value=&quot;&lt;?php echo esc_attr( $menu_selected_id ); ?&gt;&quot; /&gt;
-                                                                &lt;?php
-                                                                if ( $menu_selected_id &gt; 0 )
-                                                                        echo wp_get_nav_menu( array( 'type' =&gt; 'backend', 'menu' =&gt; $menu_selected_id, 'ul_class' =&gt; 'menu' ) );
-                                                                ?&gt;
-
-                                                                &lt;div id=&quot;queue&quot; class=&quot;hide&quot;&gt;
-                                                                &lt;/div&gt;&lt;!--/#queue--&gt;
</del><ins>+                                                                
+                                                                &lt;?php echo wp_get_nav_menu( array( 'context' =&gt; 'backend', 'menu' =&gt; $nav_menu_selected_id ) ); ?&gt;
+                                                                
</ins><span class="cx">                                                         &lt;/div&gt;&lt;!-- /.inside --&gt;
</span><span class="cx">                                                 &lt;!-- /#nav-menu-canvas .postbox--&gt;
</span><span class="cx">                                                 &lt;/div&gt;
</span><del>-                                                &lt;p&gt;
-                                                        &lt;script type=&quot;text/javascript&quot;&gt;
-                                                                wp_update_post_data();
-                                                        &lt;/script&gt;
-                                                        &lt;a class=&quot;submitdelete deletion&quot; href=&quot;&lt;?php echo wp_nonce_url( admin_url('nav-menus.php?delete-menu=' . $menu_selected_id), 'delete_menu-' . $menu_selected_id ); ?&gt;&quot;&gt;&lt;?php _e('Delete Menu'); ?&gt;&lt;/a&gt;
-                                                        &lt;input class=&quot;button-primary save&quot; name=&quot;save_menu&quot; type=&quot;submit&quot; value=&quot;&lt;?php esc_attr_e('Save All Changes'); ?&gt;&quot; /&gt;
-                                                        &lt;br class=&quot;clear&quot; /&gt;
-                                                &lt;/p&gt;
</del><ins>+                                                &lt;script type=&quot;text/javascript&quot;&gt;
+                                                        wp_update_post_data();
+                                                &lt;/script&gt;
</ins><span class="cx">                                         &lt;?php endif; ?&gt;
</span><del>-                                        &lt;/div&gt;&lt;!-- /#normal-sortables--&gt;
</del><span class="cx">                                 &lt;/div&gt;&lt;!-- /#post-body-content--&gt;
</span><span class="cx">                         &lt;/div&gt;&lt;!--- /#post-body --&gt;
</span><span class="cx">                         &lt;div id=&quot;menu-settings-column&quot; class=&quot;inner-sidebar&quot;&gt;
</span><del>-                                &lt;div id=&quot;side-sortables&quot; class=&quot;meta-box-sortables ui-sortable&quot;&gt;
-
-                                        &lt;div id=&quot;create-menu&quot; class=&quot;postbox&quot;&gt;
-                                                &lt;h3 class=&quot;hndle&quot;&gt;&lt;?php esc_html_e('Create Menu'); ?&gt;&lt;/h3&gt;
-                                                &lt;div class=&quot;inside&quot;&gt;
-                                                        &lt;p&gt;
-                                                                &lt;input type=&quot;text&quot; name=&quot;create-menu-name&quot; id=&quot;create-menu-name&quot; class=&quot;regular-text&quot; value=&quot;&quot;  /&gt;
-                                                                &lt;input type=&quot;submit&quot; name=&quot;create-menu&quot; id=&quot;create-menu&quot; class=&quot;button&quot; value=&quot;&lt;?php esc_attr_e('Create Menu'); ?&gt;&quot; /&gt;
-                                                        &lt;/p&gt;
-                                                &lt;/div&gt;&lt;!-- /.inside--&gt;
-                                        &lt;/div&gt;&lt;!--END #create-menu--&gt;
-
-                                        &lt;div id=&quot;add-custom-link&quot; class=&quot;postbox&quot;&gt;
-                                                &lt;h3 class=&quot;hndle&quot;&gt;&lt;?php esc_html_e('Add a Custom Link'); ?&gt;&lt;/h3&gt;
-                                                &lt;div class=&quot;inside&quot;&gt;
-                                                        &lt;p id=&quot;menu-item-url-wrap&quot;&gt;
-                                                                &lt;label class=&quot;howto&quot; for=&quot;menu-item-url&quot;&gt;
-                                                                        &lt;span&gt;&lt;?php _e('URL'); ?&gt;&lt;/span&gt;
-                                                                        &lt;input id=&quot;menu-item-url&quot; name=&quot;menu-item-url&quot; type=&quot;text&quot; class=&quot;code&quot; value=&quot;http://&quot; /&gt;
-                                                                &lt;/label&gt;
-                                                        &lt;/p&gt;
-                                                        &lt;br class=&quot;clear&quot; /&gt;
-                                                        &lt;p id=&quot;menu-item-name-wrap&quot;&gt;
-                                                                &lt;label class=&quot;howto&quot; for=&quot;custom-menu-item-name&quot;&gt;
-                                                                        &lt;span&gt;&lt;?php _e('Text'); ?&gt;&lt;/span&gt;
-                                                                        &lt;input id=&quot;menu-item-name&quot; type=&quot;text&quot; class=&quot;regular-text&quot; value=&quot;&lt;?php echo esc_attr( __('Menu Item') ); ?&gt;&quot; /&gt;
-                                                                &lt;/label&gt;
-                                                        &lt;/p&gt;
-
-                                                        &lt;p class=&quot;button-controls&quot;&gt;
-                                                                &lt;a class=&quot;show-all&quot;&gt;&lt;?php _e('View All'); ?&gt;&lt;/a&gt;
-                                                                &lt;a class=&quot;hide-all&quot;&gt;&lt;?php _e('Hide All'); ?&gt;&lt;/a&gt;
-                                                        &lt;/p&gt;
-                                                        &lt;div id=&quot;available-links&quot; class=&quot;list-wrap&quot;&gt;
-                                                                &lt;div class=&quot;list-container&quot;&gt;
-                                                                        &lt;ul class=&quot;list&quot;&gt;
-                                                                        &lt;?php $items_counter = wp_nav_menu_get_custom_links( 0, 'default' ); ?&gt;
-                                                                        &lt;/ul&gt;
-                                                                &lt;/div&gt;&lt;!-- /.list-container--&gt;
-                                                        &lt;/div&gt;&lt;!-- /#available-links--&gt;
-                                                        &lt;p class=&quot;add-to-menu&quot;&gt;
-                                                                &lt;a class=&quot;button&quot;&gt;&lt;?php _e('Add to Menu'); ?&gt;&lt;/a&gt;
-                                                        &lt;/p&gt;
-                                                        &lt;br class=&quot;clear&quot; /&gt;
-                                                &lt;/div&gt;&lt;!-- /.inside--&gt;
-                                        &lt;/div&gt;&lt;!-- /#add-custom-link--&gt;
-
-                                        &lt;div id=&quot;add-pages&quot; class=&quot;postbox&quot;&gt;
-                                                &lt;h3 class=&quot;hndle&quot;&gt;&lt;?php esc_html_e('Add an Existing Page'); ?&gt;&lt;/h3&gt;
-                                                &lt;div class=&quot;inside&quot;&gt;
-                                                        &lt;?php
-                                                                $pages_args = array(
-                                                                        'child_of' =&gt; 0, 'sort_order' =&gt; 'ASC', 'sort_column' =&gt; 'post_title', 'hierarchical' =&gt; 1,
-                                                                        'exclude' =&gt; '', 'include' =&gt; '', 'meta_key' =&gt; '', 'meta_value' =&gt; '', 'authors' =&gt; '',
-                                                                        'parent' =&gt; -1, 'exclude_tree' =&gt; '', 'number' =&gt; '', 'offset' =&gt; 0
-                                                                );
-                                                                $page_name = '';
-                                                                $pages_array = get_pages( $pages_args );
-                                                                if ( $pages_array ) {
-                                                                        foreach ( $pages_array as $post ) {
-                                                                                $page_name .= $post-&gt;post_title . '|';
-                                                                        }
-                                                                } else {
-                                                                        $page_name = __('No pages available');
-                                                                }
-                                                        ?&gt;
-                                                        &lt;script type=&quot;text/javascript&quot; charset=&quot;&lt;?php bloginfo('charset'); ?&gt;&quot;&gt;
-                                                                jQuery(document).ready(function(){
-                                                                        var posts = &quot;&lt;?php echo esc_js( $page_name ); ?&gt;&quot;.split('|');
-                                                                        jQuery('#add-pages .quick-search').autocomplete(posts);
-
-
-                                                                        jQuery('#add-pages .quick-search').result(function(event, data, formatted) {
-                                                                                jQuery('#add-pages .list-wrap').css('display','block');
-                                                                                jQuery(&quot;#add-pages .list-wrap li:contains('&quot; + data + &quot;')&quot;).css('display','block');
-                                                                                jQuery('#add-pages .show-all').hide();
-                                                                                jQuery('#add-pages .hide-all').show();
-                                                                        });
-                                                                });
-                                                        &lt;/script&gt;
-                                                        &lt;p&gt;
-                                                                &lt;input type=&quot;text&quot; class=&quot;quick-search regular-text&quot; value=&quot;&quot; /&gt;
-                                                                &lt;a class=&quot;quick-search-submit button&quot;&gt;&lt;?php _e('Search'); ?&gt;&lt;/a&gt;
-                                                        &lt;/p&gt;
-
-                                                        &lt;p class=&quot;button-controls&quot;&gt;
-                                                                &lt;a class=&quot;show-all&quot;&gt;&lt;?php _e('View All'); ?&gt;&lt;/a&gt;
-                                                                &lt;a class=&quot;hide-all&quot;&gt;&lt;?php _e('Hide All'); ?&gt;&lt;/a&gt;
-                                                        &lt;/p&gt;
-
-                                                        &lt;div id=&quot;existing-pages&quot; class=&quot;list-wrap&quot;&gt;
-                                                                &lt;div class=&quot;list-container&quot;&gt;
-                                                                        &lt;ul class=&quot;list&quot;&gt;
-                                                                        &lt;?php $items_counter = wp_nav_menu_get_pages( $items_counter, 'default' ); ?&gt;
-                                                                        &lt;/ul&gt;
-                                                                &lt;/div&gt;&lt;!-- /.list-container--&gt;
-                                                        &lt;/div&gt;&lt;!-- /#existing-pages--&gt;
-                                                        &lt;p class=&quot;add-to-menu enqueue&quot;&gt;
-                                                                &lt;a class=&quot;button&quot;&gt;&lt;?php _e('Add to Menu'); ?&gt;&lt;/a&gt;
-                                                        &lt;/p&gt;
-                                                        &lt;br class=&quot;clear&quot; /&gt;
-                                                &lt;/div&gt;&lt;!-- /.inside--&gt;
-                                        &lt;/div&gt;&lt;!--END #add-pages--&gt;
-
-                                        &lt;div id=&quot;add-categories&quot; class=&quot;postbox&quot;&gt;
-                                                &lt;h3 class=&quot;hndle&quot;&gt;&lt;?php esc_html_e('Add an Existing Category'); ?&gt;&lt;/h3&gt;
-                                                &lt;div class=&quot;inside&quot;&gt;
-                                                        &lt;?php
-                                                                // Custom GET categories query
-                                                                // @todo Use API
-                                                                $categories = $wpdb-&gt;get_results(&quot;SELECT term_id FROM $wpdb-&gt;term_taxonomy WHERE taxonomy = 'category' ORDER BY term_id ASC&quot;);
-                                                                $cat_name = '';
-                                                                if ( $categories ) {
-                                                                        foreach ( $categories as $category ) {
-                                                                                $cat_id = $category-&gt;term_id;
-                                                                                $cat_args = array(
-                                                                                        'orderby' =&gt; 'name',
-                                                                                        'include' =&gt; $cat_id,
-                                                                                        'hierarchical' =&gt; 1,
-                                                                                        'order' =&gt; 'ASC',
-                                                                                );
-                                                                                $category_names = get_categories( $cat_args );
-                                                                                if ( isset( $category_names[0]-&gt;name ) ) {
-                                                                                        $cat_name .= htmlentities( $category_names[0]-&gt;name ).'|';
-                                                                                }
-                                                                        }
-                                                                } else {
-                                                                        $cat_name = __('No categories available');
-                                                                }
-                                                        ?&gt;
-                                                        &lt;script type=&quot;text/javascript&quot; charset=&quot;&lt;?php bloginfo('charset'); ?&gt;&quot;&gt;
-                                                                jQuery(document).ready(function(){
-                                                                        var categories = &quot;&lt;?php echo esc_js($cat_name); ?&gt;&quot;.split('|');
-                                                                        jQuery('#add-categories .quick-search').autocomplete(categories);
-                                                                        jQuery('#add-categories .quick-search').result(function(event, data, formatted) {
-                                                                                jQuery('#add-categories .list-wrap').css('display','block');
-                                                                                jQuery(&quot;#add-categories .list-wrap li:contains('&quot; + data + &quot;')&quot;).css('display','block');
-                                                                                jQuery('#add-categories .show-all').hide();
-                                                                                jQuery('#add-categories .hide-all').show();
-                                                                        });
-                                                                });
-                                                        &lt;/script&gt;
-                                                        &lt;p&gt;
-                                                                &lt;input type=&quot;text&quot; class=&quot;quick-search regular-text&quot; value=&quot;&quot; /&gt;
-                                                                &lt;a class=&quot;quick-search-submit button&quot;&gt;&lt;?php _e('Search'); ?&gt;&lt;/a&gt;
-                                                        &lt;/p&gt;
-
-                                                        &lt;p class=&quot;button-controls&quot;&gt;
-                                                                &lt;a class=&quot;show-all&quot;&gt;&lt;?php _e('View All'); ?&gt;&lt;/a&gt;
-                                                                &lt;a class=&quot;hide-all&quot;&gt;&lt;?php _e('Hide All'); ?&gt;&lt;/a&gt;
-                                                        &lt;/p&gt;
-
-                                                        &lt;div id=&quot;existing-categories&quot; class=&quot;list-wrap&quot;&gt;
-                                                                &lt;div class=&quot;list-container&quot;&gt;
-                                                                        &lt;ul class=&quot;list&quot;&gt;
-                                                                                &lt;?php $items_counter = wp_nav_menu_get_categories( $items_counter, 'default' ); ?&gt;
-                                                                        &lt;/ul&gt;
-                                                                &lt;/div&gt;&lt;!-- /.list-container--&gt;
-                                                        &lt;/div&gt;&lt;!-- /#existing-categories--&gt;
-                                                        &lt;p class=&quot;add-to-menu enqueue&quot;&gt;
-                                                                &lt;a class=&quot;button&quot;&gt;&lt;?php _e('Add to Menu'); ?&gt;&lt;/a&gt;
-                                                        &lt;/p&gt;
-                                                        &lt;br class=&quot;clear&quot; /&gt;
-                                                &lt;/div&gt;&lt;!-- /.inside--&gt;
-                                        &lt;/div&gt;&lt;!--END #add-categories--&gt;
-                                &lt;/div&gt;&lt;!-- /#side-sortables--&gt;
</del><ins>+                                
+                                &lt;?php do_meta_boxes( 'menus', 'side', null ); ?&gt;
+                                
</ins><span class="cx">                         &lt;/div&gt;&lt;!-- /#menu-settings-column --&gt;
</span><del>-                        &lt;br class=&quot;clear&quot; /&gt;
-                &lt;/div&gt;&lt;!-- /.metabox-holder has-right-sidebar--&gt;
-        &lt;/form&gt;
</del><ins>+                &lt;/form&gt;&lt;!--/#update-nav-menu--&gt;
+                &lt;br class=&quot;clear&quot; /&gt;
+        &lt;/div&gt;&lt;!-- /.metabox-holder has-right-sidebar--&gt;
</ins><span class="cx"> &lt;/div&gt;&lt;!-- /.wrap--&gt;
</span><span class="cx"> 
</span><span class="cx"> &lt;div id=&quot;menu-item-settings&quot;&gt;
</span><span class="cx">         &lt;p class=&quot;description&quot;&gt;
</span><del>-                &lt;label for=&quot;edit-item-title&quot;&gt;
</del><ins>+                &lt;label for=&quot;edit-menu-item-title&quot;&gt;
</ins><span class="cx">                         &lt;?php _e( 'Menu Title' ); ?&gt;&lt;br /&gt;
</span><del>-                        &lt;input type=&quot;text&quot; id=&quot;edit-item-title&quot; class=&quot;widefat&quot; name=&quot;edit-item-title&quot; value=&quot;&quot; tabindex=&quot;1&quot; /&gt;
</del><ins>+                        &lt;input type=&quot;text&quot; id=&quot;edit-menu-item-title&quot; class=&quot;widefat&quot; name=&quot;edit-menu-item-title&quot; value=&quot;&quot; tabindex=&quot;1&quot; /&gt;
</ins><span class="cx">                 &lt;/label&gt;
</span><span class="cx">         &lt;/p&gt;
</span><span class="cx">         &lt;p class=&quot;description&quot;&gt;
</span><del>-                &lt;label for=&quot;edit-item-url&quot;&gt;
</del><ins>+                &lt;label for=&quot;edit-menu-item-url&quot;&gt;
</ins><span class="cx">                         &lt;?php _e( 'URL' ); ?&gt;&lt;br /&gt;
</span><del>-                        &lt;input type=&quot;text&quot; id=&quot;edit-item-url&quot; class=&quot;widefat code&quot; name=&quot;edit-item-url&quot; value=&quot;&quot; tabindex=&quot;2&quot; /&gt;
</del><ins>+                        &lt;input type=&quot;text&quot; id=&quot;edit-menu-item-url&quot; class=&quot;widefat code&quot; name=&quot;edit-menu-item-url&quot; value=&quot;&quot; tabindex=&quot;2&quot; /&gt;
</ins><span class="cx">                 &lt;/label&gt;
</span><span class="cx">         &lt;/p&gt;
</span><span class="cx">         &lt;p class=&quot;description&quot;&gt;
</span><del>-                &lt;label for=&quot;edit-item-attr-title&quot;&gt;
-                        &lt;?php _e( 'Attribute Title' ); ?&gt;&lt;br /&gt;
-                        &lt;input type=&quot;text&quot; id=&quot;edit-item-attr-title&quot; class=&quot;widefat&quot; name=&quot;edit-item-attr-title&quot; value=&quot;&quot; tabindex=&quot;3&quot; /&gt;
</del><ins>+                &lt;label for=&quot;edit-menu-item-attr-title&quot;&gt;
+                        &lt;?php _e( 'Title Attribute' ); ?&gt;&lt;br /&gt;
+                        &lt;input type=&quot;text&quot; id=&quot;edit-menu-item-attr-title&quot; class=&quot;widefat&quot; name=&quot;edit-menu-item-attr-title&quot; value=&quot;&quot; tabindex=&quot;3&quot; /&gt;
</ins><span class="cx">                 &lt;/label&gt;
</span><span class="cx">         &lt;/p&gt;
</span><span class="cx">         &lt;p class=&quot;description&quot;&gt;
</span><del>-                &lt;label for=&quot;edit-item-target&quot;&gt;
-                        &lt;?php _e( 'Open Link in a new window' ); ?&gt;&lt;br /&gt;
-                        &lt;select id=&quot;edit-item-target&quot; class=&quot;widefat&quot; name=&quot;edit-item-target&quot;&gt;
-                                &lt;option value=&quot;1&quot;&gt;Yes&lt;/option&gt;
-                                &lt;option value=&quot;0&quot;&gt;No&lt;/option&gt;
</del><ins>+                &lt;label for=&quot;edit-menu-item-target&quot;&gt;
+                        &lt;?php _e( 'Link Target' ); ?&gt;&lt;br /&gt;
+                        &lt;select id=&quot;edit-menu-item-target&quot; class=&quot;widefat&quot; name=&quot;edit-menu-item-target&quot; tabindex=&quot;4&quot;&gt;
+                                &lt;option value=&quot;_self&quot;&gt;Same window or tab&lt;/option&gt;
+                                &lt;option value=&quot;_blank&quot;&gt;New window or tab&lt;/option&gt;
</ins><span class="cx">                         &lt;/select&gt;
</span><span class="cx">                 &lt;/label&gt;
</span><span class="cx">         &lt;/p&gt;
</span><span class="cx">         &lt;p class=&quot;description&quot;&gt;
</span><del>-                &lt;label for=&quot;edit-item-description&quot;&gt;
-                        &lt;?php _e( 'Description' ); ?&gt;&lt;br /&gt;
-                        &lt;textarea id=&quot;edit-item-description&quot; class=&quot;widefat&quot; rows=&quot;3&quot; name=&quot;edit-item-description&quot; tabindex=&quot;4&quot; /&gt;&lt;/textarea&gt;
</del><ins>+                &lt;label for=&quot;edit-menu-item-classes&quot;&gt;
+                        &lt;?php _e( 'CSS Classes (optional)' ); ?&gt;&lt;br /&gt;
+                        &lt;input type=&quot;text&quot; id=&quot;edit-menu-item-classes&quot; class=&quot;widefat code&quot; name=&quot;edit-menu-item-classes&quot; value=&quot;&quot; tabindex=&quot;5&quot; /&gt;
</ins><span class="cx">                 &lt;/label&gt;
</span><span class="cx">         &lt;/p&gt;
</span><ins>+        &lt;p class=&quot;description&quot;&gt;
+                &lt;label for=&quot;edit-menu-item-xfn&quot;&gt;
+                        &lt;?php _e( 'Link Relationship (XFN) (optional)' ); ?&gt;&lt;br /&gt;
+                        &lt;input type=&quot;text&quot; id=&quot;edit-menu-item-xfn&quot; class=&quot;widefat code&quot; name=&quot;edit-menu-item-xfn&quot; value=&quot;&quot; tabindex=&quot;6&quot; /&gt;
+                &lt;/label&gt;
+        &lt;/p&gt;
+        &lt;p class=&quot;description&quot;&gt;
+                &lt;label for=&quot;edit-menu-item-description&quot;&gt;
+                        &lt;?php _e( 'Description (optional)' ); ?&gt;&lt;br /&gt;
+                        &lt;textarea id=&quot;edit-menu-item-description&quot; class=&quot;widefat&quot; rows=&quot;3&quot; name=&quot;edit-menu-item-description&quot; tabindex=&quot;7&quot; /&gt;&lt;/textarea&gt;
+                        &lt;span class=&quot;description&quot;&gt;The description will be displayed in the menu if the current theme supports it.&lt;/span&gt;
+                &lt;/label&gt;
+        &lt;/p&gt;
</ins><span class="cx">         &lt;p&gt;
</span><del>-                &lt;a id=&quot;cancel-save&quot; class=&quot;submitdelete deletion&quot;&gt;&lt;?php _e('Cancel'); ?&gt;&lt;/a&gt;
-                &lt;a id=&quot;update-menu-item&quot; class=&quot;save button-primary&quot; tabindex=&quot;5&quot;&gt;&lt;?php _e('Save Changes'); ?&gt;&lt;/a&gt;
</del><ins>+                &lt;a id=&quot;update-menu-item&quot; class=&quot;save button-primary&quot; tabindex=&quot;8&quot;&gt;&lt;?php _e('Save Changes'); ?&gt;&lt;/a&gt;
+                &lt;a id=&quot;cancel-save&quot; class=&quot;submitdelete deletion&quot; tabindex=&quot;9&quot;&gt;&lt;?php _e('Cancel'); ?&gt;&lt;/a&gt;
</ins><span class="cx">         &lt;/p&gt;
</span><del>-        &lt;input type=&quot;hidden&quot; id=&quot;edit-item-id&quot; name=&quot;edit-item-id&quot; value=&quot;&quot; /&gt;
</del><ins>+        &lt;input type=&quot;hidden&quot; id=&quot;edit-menu-item-id&quot; name=&quot;edit-item-id&quot; value=&quot;&quot; /&gt;
</ins><span class="cx"> &lt;/div&gt;&lt;!-- /#menu-item-settings--&gt;
</span><span class="cx"> 
</span><span class="cx"> &lt;?php include( 'admin-footer.php' ); ?&gt;
</span><span class="cx">\ No newline at end of file
</span></span></pre></div>
<a id="trunkwpcontentthemestwentytenheaderphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-content/themes/twentyten/header.php (13703 => 13704)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-content/themes/twentyten/header.php        2010-03-15 14:29:11 UTC (rev 13703)
+++ trunk/wp-content/themes/twentyten/header.php        2010-03-15 16:26:46 UTC (rev 13704)
</span><span class="lines">@@ -43,7 +43,7 @@
</span><span class="cx"> 
</span><span class="cx">                         &lt;div id=&quot;access&quot;&gt;
</span><span class="cx">                                 &lt;div class=&quot;skip-link screen-reader-text&quot;&gt;&lt;a href=&quot;#content&quot; title=&quot;&lt;?php esc_attr_e( 'Skip to content', 'twentyten' ); ?&gt;&quot;&gt;&lt;?php _e( 'Skip to content', 'twentyten' ); ?&gt;&lt;/a&gt;&lt;/div&gt;
</span><del>-                                &lt;?php wp_nav_menu( 'sort_column=menu_order' ); ?&gt;
</del><ins>+                                &lt;?php wp_nav_menu( 'sort_column=menu_order&amp;container_class=menu-header' ); ?&gt;
</ins><span class="cx">                         &lt;/div&gt;&lt;!-- #access --&gt;
</span><span class="cx">                 &lt;/div&gt;&lt;!-- #masthead --&gt;
</span><span class="cx">         &lt;/div&gt;&lt;!-- #header --&gt;
</span></span></pre></div>
<a id="trunkwpcontentthemestwentytenstylecss"></a>
<div class="modfile"><h4>Modified: trunk/wp-content/themes/twentyten/style.css (13703 => 13704)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-content/themes/twentyten/style.css        2010-03-15 14:29:11 UTC (rev 13703)
+++ trunk/wp-content/themes/twentyten/style.css        2010-03-15 16:26:46 UTC (rev 13704)
</span><span class="lines">@@ -152,7 +152,7 @@
</span><span class="cx"> -------------------------------------------------------------- */
</span><span class="cx"> 
</span><span class="cx"> /* The main theme structure */
</span><del>-#access .menu,
</del><ins>+#access .menu-header,
</ins><span class="cx"> #colophon,
</span><span class="cx"> #branding,
</span><span class="cx"> #main,
</span><span class="lines">@@ -360,15 +360,15 @@
</span><span class="cx">         display:block;
</span><span class="cx">         float:left;
</span><span class="cx"> }
</span><del>-#access .menu {
</del><ins>+#access .menu-header {
</ins><span class="cx">         font-size: 13px;
</span><span class="cx">         margin-left: 12px;
</span><span class="cx"> }
</span><del>-#access .menu ul {
</del><ins>+#access .menu-header ul {
</ins><span class="cx">         list-style: none;
</span><span class="cx">         margin: 0;
</span><span class="cx"> }
</span><del>-#access .menu li {
</del><ins>+#access .menu-header li {
</ins><span class="cx">         float:left;
</span><span class="cx">         position: relative;
</span><span class="cx"> }
</span></span></pre></div>
<a id="trunkwpincludesnavmenutemplatephp"></a>
<div class="modfile"><h4>Modified: trunk/wp-includes/nav-menu-template.php (13703 => 13704)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-includes/nav-menu-template.php        2010-03-15 14:29:11 UTC (rev 13703)
+++ trunk/wp-includes/nav-menu-template.php        2010-03-15 16:26:46 UTC (rev 13704)
</span><span class="lines">@@ -23,8 +23,8 @@
</span><span class="cx">  * @param array $args Arguments
</span><span class="cx">  */
</span><span class="cx"> function wp_nav_menu( $args = array() ) {
</span><del>-        $defaults = array( 'menu' =&gt; '', 'menu_class' =&gt; 'menu', 'format' =&gt; 'div', 'echo' =&gt; true,
-        'fallback_cb' =&gt; 'wp_page_menu', 'link_before' =&gt; '', 'link_after' =&gt; '', 'before_link' =&gt; '', 'after_link' =&gt; '', );
</del><ins>+        $defaults = array( 'menu' =&gt; '', 'container' =&gt; 'div', 'container_class' =&gt; '', 'menu_class' =&gt; 'menu', 'echo' =&gt; true,
+        'fallback_cb' =&gt; 'wp_page_menu', 'before_link' =&gt; '', 'after_link' =&gt; '', 'before_title' =&gt; '', 'after_title' =&gt; '', );
</ins><span class="cx">         
</span><span class="cx">         $args = wp_parse_args( $args, $defaults );
</span><span class="cx">         $args = apply_filters( 'wp_nav_menu_args', $args );
</span><span class="lines">@@ -45,24 +45,27 @@
</span><span class="cx">                 }
</span><span class="cx">         }
</span><span class="cx"> 
</span><del>-        if ( $menu )
</del><ins>+        if ( !is_wp_error($menu) )
</ins><span class="cx">                 $args-&gt;menu = $menu-&gt;term_id;
</span><span class="cx">         $nav_menu = '';
</span><span class="cx"> 
</span><del>-        if ( 'div' == $args-&gt;format ) {
-                if ( $menu )
-                        $nav_menu .= '&lt;div id=&quot;menu-' . $menu-&gt;slug . '&quot; class=&quot;' . esc_attr($args-&gt;menu_class) . '&quot;&gt;';
-                else
-                        $nav_menu .= '&lt;div id=&quot;menu-default&quot;&gt;';
</del><ins>+        if ( 'div' == $args-&gt;container ) {
+                $class = $args-&gt;container_class ? ' class=&quot;' . esc_attr($args-&gt;container_class) . '&quot;' : '';
+                
+                if ( is_nav_menu($menu) ) {
+                        $nav_menu .= '&lt;div id=&quot;menu-' . $menu-&gt;slug . '&quot;'. $class .'&gt;';
+                } else {
+                        $nav_menu .= '&lt;div'. $class .'&gt;';
+                }
</ins><span class="cx">         }
</span><span class="cx"> 
</span><span class="cx">         $nav_menu .= wp_get_nav_menu( $args );
</span><span class="cx"> 
</span><del>-        if ( 'div' == $args-&gt;format )
</del><ins>+        if ( 'div' == $args-&gt;container )
</ins><span class="cx">                 $nav_menu .= '&lt;/div&gt;';
</span><ins>+        
+        $nav_menu = apply_filters( 'wp_nav_menu', $nav_menu, $args );
</ins><span class="cx"> 
</span><del>-        $nav_menu = apply_filters( 'wp_nav_menu', $nav_menu );
-
</del><span class="cx">         if ( $args-&gt;echo )
</span><span class="cx">                 echo $nav_menu;
</span><span class="cx">         else
</span><span class="lines">@@ -80,132 +83,175 @@
</span><span class="cx">  * @return mixed $output False if menu doesn't exists, else, returns the menu.
</span><span class="cx">  **/
</span><span class="cx"> function wp_get_nav_menu( $args = array() ) {
</span><del>-        $defaults = array( 'menu' =&gt; '', 'menu_class' =&gt; 'menu', 'ul_class' =&gt; '', 'format' =&gt; 'div', 'type' =&gt; 'frontend',
-        'fallback_cb' =&gt; '', 'link_before' =&gt; '', 'link_after' =&gt; '', 'before_link' =&gt; '', 'after_link' =&gt; '', );
</del><ins>+        $defaults = array( 'menu' =&gt; '', 'menu_class' =&gt; 'menu', 'context' =&gt; 'frontend',
+        'fallback_cb' =&gt; '', 'before_link' =&gt; '', 'after_link' =&gt; '', 'before_title' =&gt; '', 'after_title' =&gt; '', );
</ins><span class="cx">         
</span><span class="cx">         $args = wp_parse_args( $args, $defaults );
</span><span class="cx">         $args = apply_filters( 'wp_get_nav_menu_args', $args );
</span><span class="cx">         $args = (object) $args;
</span><span class="cx">         
</span><ins>+        // Variable setup
+        $nav_menu = '';
+        $items = '';
+        $current_parent = 0;
+        $parent_stack = array();
+        $parent_menu_order = array();
+        
+        // Get the menu object
</ins><span class="cx">         $menu = wp_get_nav_menu_object( $args-&gt;menu );
</span><span class="cx">         
</span><del>-        // If no menu was found, call the fallback_cb
-        if ( !$menu || is_wp_error($menu) ) {
</del><ins>+        // If the menu exists, get it's items.
+        if ( $menu &amp;&amp; !is_wp_error($menu) )
+                $menu_items = wp_get_nav_menu_items( $menu-&gt;term_id, 'backend' );
+        
+        // If no menu was found or if the menu has no items, call the fallback_cb
+        if ( !$menu || is_wp_error($menu) || ( isset($menu_items) &amp;&amp; empty($menu_items) ) ) {
</ins><span class="cx">                 if ( function_exists($args-&gt;fallback_cb) ) {
</span><span class="cx">                         $_args = array_merge( (array)$args, array('echo' =&gt; false) );
</span><span class="cx">                         return call_user_func( $args-&gt;fallback_cb, $_args );
</span><span class="cx">                 }
</span><span class="cx">         }
</span><span class="cx">         
</span><del>-        $menu_items = wp_get_nav_menu_items( $menu-&gt;term_id );
-        $nav_menu = '';
-        $parent_stack = array();
-        $current_parent = 0;
-        $parent_menu_order = array();
-        
-        // Setup parentage
-        foreach ( $menu_items as $menu_item )
-                $parent_menu_order[ $menu_item-&gt;ID ] = $menu_item-&gt;menu_order;
-        
-        $ul_class = isset($args-&gt;ul_class) ? ' class=&quot;'. $args-&gt;ul_class .'&quot;' : '';
-        $nav_menu .= '&lt;ul'. $ul_class .'&gt;';
-        
-        // Display Loop
-        foreach ( $menu_items as $key =&gt; $menu_item ) :
</del><ins>+        foreach ( $menu_items as $key =&gt; $menu_item ) {
</ins><span class="cx">                 // Setup the $menu_item variables
</span><del>-                $menu_item = wp_setup_nav_menu_item( $menu_item );
</del><ins>+                $menu_item = wp_setup_nav_menu_item( $menu_item, 'frontend' );
</ins><span class="cx"> 
</span><del>-                $maybe_value = 'frontend' == $args-&gt;type ? '' : ' value=&quot;'. $menu_item-&gt;ID .'&quot;';
-                $classes = 'frontend' == $args-&gt;type ? ' class=&quot;menu-item-'. $menu_item-&gt;type . $menu_item-&gt;li_class .'&quot;' : '';
-
-                $nav_menu .= '&lt;li id=&quot;menu-item-'. $menu_item-&gt;ID .'&quot;'. $maybe_value . $classes .'&gt;';
-                $nav_menu .= wp_get_nav_menu_item( $menu_item, $args-&gt;type, $args );
</del><ins>+                $type = sanitize_title_with_dashes( $menu_item-&gt;append );
+                $maybe_value = 'frontend' == $args-&gt;context ? '' : ' value=&quot;'. $menu_item-&gt;ID .'&quot;';
+                $classes = 'frontend' == $args-&gt;context ? ' class=&quot;menu-item-type-'. $type . $menu_item-&gt;li_class .'&quot;' : '';
</ins><span class="cx">                 
</span><ins>+                $items .= '&lt;li id=&quot;menu-item-'. $menu_item-&gt;ID .'&quot;'. $maybe_value . $classes .'&gt;';
+                $items .= wp_get_nav_menu_item( $menu_item, $args-&gt;context, $args );
+                
</ins><span class="cx">                 // Indent children
</span><span class="cx">                 $last_item = ( count( $menu_items ) == $menu_item-&gt;menu_order );
</span><del>-                if ( $last_item || $current_parent != $menu_items[ $key + 1 ]-&gt;post_parent ) {
-                        if ( $last_item || in_array( $menu_items[ $key + 1 ]-&gt;post_parent, $parent_stack ) ) {
-                                $nav_menu .= '&lt;/li&gt;';
-                                while ( !empty( $parent_stack ) &amp;&amp; ($last_item || $menu_items[ $key + 1 ]-&gt;post_parent != $current_parent ) ) {
-                                        $nav_menu .= '&lt;/ul&gt;&lt;/li&gt;';
</del><ins>+                if ( $last_item || $current_parent != $menu_items[$key + 1]-&gt;post_parent ) {
+                        if ( $last_item || in_array( $menu_items[$key + 1]-&gt;post_parent, $parent_stack ) ) {
+                                $items .= '&lt;/li&gt;';
+                                while ( !empty( $parent_stack ) &amp;&amp; ($last_item || $menu_items[$key + 1]-&gt;post_parent != $current_parent ) ) {
+                                        $items .= '&lt;/ul&gt;&lt;/li&gt;';
</ins><span class="cx">                                         $current_parent = array_pop( $parent_stack );
</span><span class="cx">                                 }
</span><span class="cx">                         } else {
</span><span class="cx">                                 array_push( $parent_stack, $current_parent );
</span><span class="cx">                                 $current_parent = $menu_item-&gt;ID;
</span><del>-                                $nav_menu .= '&lt;ul&gt;';
</del><ins>+                                $items .= '&lt;ul class=&quot;sub-menu&quot;&gt;';
</ins><span class="cx">                         }
</span><span class="cx">                 } else {
</span><del>-                        $nav_menu .= '&lt;/li&gt;';
</del><ins>+                        $items .= '&lt;/li&gt;';
</ins><span class="cx">                 }
</span><del>-
-        endforeach;
</del><ins>+        }
</ins><span class="cx">         
</span><ins>+        // CSS class
+        $ul_class = $args-&gt;menu_class ? ' class=&quot;'. $args-&gt;menu_class .'&quot;' : '';
+        $nav_menu .= '&lt;ul'. $ul_class .'&gt;';
+        
+        // Allow plugins to hook into the menu to add their own &lt;li&gt;'s
+        if ( 'frontend' == $args-&gt;context ) {
+                $items = apply_filters( 'wp_nav_menu_items', $items, $args );
+                $items = apply_filters( &quot;wp_nav_menu_{$menu-&gt;slug}_items&quot;, $items, $args );
+                $nav_menu .= $items;
+        } else {
+                $nav_menu .= $items;
+        }
+        
</ins><span class="cx">         $nav_menu .= '&lt;/ul&gt;';
</span><span class="cx">         
</span><span class="cx">         return apply_filters( 'wp_get_nav_menu', $nav_menu );
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> /**
</span><del>- * Returns a menu item.
</del><ins>+ * Returns the menu item formatted based on it's context.
</ins><span class="cx">  *
</span><span class="cx">  * @since 3.0.0
</span><span class="cx">  *
</span><del>- * @param object $menu_item The menu item
- * @param string $context frontend|backend|default
- * @param array $args See wp_get_nav_menu().
- **/
-function wp_get_nav_menu_item( $menu_item, $context, $args = array() ) {
-        $item = '';
</del><ins>+ * @param string $menu_item The menu item to format.
+ * @param string $context The context to which the menu item will be formatted to.
+ * @param string $args Optional. Args used for the 'template' context.
+ * @return string $output The menu formatted menu item.
+ */
+function wp_get_nav_menu_item( $menu_item, $context = 'frontend', $args = array() ) {
+        $output = '';
</ins><span class="cx">         switch ( $context ) {
</span><span class="cx">                 case 'frontend':
</span><del>-                        $attr_title = ( isset($menu_item-&gt;anchor_title) &amp;&amp; '' != $menu_item-&gt;anchor_title ) ? ' title=&quot;'. esc_attr($menu_item-&gt;anchor_title) .'&quot;' : '';
-                        $href = isset($menu_item-&gt;link) ? ' href=&quot;'. esc_url($menu_item-&gt;link) .'&quot;' : '';
</del><ins>+                        $attributes  = ( isset($menu_item-&gt;anchor_title) &amp;&amp; '' != $menu_item-&gt;anchor_title ) ? ' title=&quot;'. esc_attr($menu_item-&gt;anchor_title) .'&quot;' : '';
+                        $attributes .= ( isset($menu_item-&gt;target) &amp;&amp; '' != $menu_item-&gt;target ) ? ' target=&quot;'. esc_attr($menu_item-&gt;target) .'&quot;' : '';
+                        $attributes .= ( isset($menu_item-&gt;classes) &amp;&amp; '' != $menu_item-&gt;classes ) ? ' class=&quot;'. esc_attr($menu_item-&gt;classes) .'&quot;' : '';
+                        $attributes .= ( isset($menu_item-&gt;xfn) &amp;&amp; '' != $menu_item-&gt;xfn ) ? ' rel=&quot;'. esc_attr($menu_item-&gt;xfn) .'&quot;' : '';
+                        $attributes .= ( isset($menu_item-&gt;url) &amp;&amp; '' != $menu_item-&gt;url ) ? ' href=&quot;'. esc_attr($menu_item-&gt;url) .'&quot;' : '';
</ins><span class="cx">                         
</span><del>-                        $item .= '&lt;a'. $attr_title . $href . $menu_item-&gt;target .'&gt;';
-                        $item .= $args-&gt;before_link . esc_html( $menu_item-&gt;title ) . $args-&gt;after_link;
-                        $item .= '&lt;/a&gt;';
</del><ins>+                        $output .= esc_html( $args-&gt;before_link );
+                        $output .= '&lt;a'. $attributes .'&gt;';
+                        $output .= esc_html( $args-&gt;before_title . $menu_item-&gt;title . $args-&gt;after_title );
+                        $output .= '&lt;/a&gt;';
+                        $output .= esc_html( $args-&gt;after_link );
</ins><span class="cx">                         
</span><span class="cx">                         break;
</span><span class="cx">                 
</span><span class="cx">                 case 'backend':
</span><del>-                        $item .= '&lt;dl&gt;&lt;dt&gt;';
-                        $item .= '&lt;span class=&quot;item-title&quot;&gt;'. esc_html($menu_item-&gt;title) .'&lt;/span&gt;';
-                        $item .= '&lt;span class=&quot;item-controls&quot;&gt;';
-                        $item .= '&lt;span class=&quot;item-type&quot;&gt;'. esc_html($menu_item-&gt;type) .'&lt;/span&gt;';
</del><ins>+                        $output .= '&lt;dl&gt;&lt;dt&gt;';
+                        $output .= '&lt;span class=&quot;item-title&quot;&gt;'. esc_html($menu_item-&gt;title) .'&lt;/span&gt;';
+                        $output .= '&lt;span class=&quot;item-controls&quot;&gt;';
+                        $output .= '&lt;span class=&quot;item-type&quot;&gt;'. esc_html($menu_item-&gt;append) .'&lt;/span&gt;';
</ins><span class="cx">                         
</span><span class="cx">                         // Actions
</span><del>-                        $item .= '&lt;a class=&quot;item-edit thickbox&quot; id=&quot;edit'. esc_attr( $menu_item-&gt;menu_order ) .'&quot; value=&quot;'. esc_attr( $menu_item-&gt;menu_order ) .'&quot; title=&quot;'. __('Edit Menu Item') .'&quot; href=&quot;#TB_inline?height=380&amp;width=300&amp;inlineId=menu-item-settings&quot;&gt;'. __('Edit') .'&lt;/a&gt; | ';
-                        $item .= '&lt;a class=&quot;item-delete&quot; id=&quot;delete'. esc_attr( $menu_item-&gt;menu_order ) .'&quot; value=&quot;'. esc_attr( $menu_item-&gt;menu_order ) .'&quot;&gt;'. __('Delete') .'&lt;/a&gt;';
</del><ins>+                        $output .= '&lt;a class=&quot;item-edit thickbox&quot; id=&quot;edit'. esc_attr( $menu_item-&gt;menu_order ) .'&quot; value=&quot;'. esc_attr( $menu_item-&gt;menu_order ) .'&quot; title=&quot;'. __('Edit Menu Item') .'&quot; href=&quot;#TB_inline?height=540&amp;width=300&amp;inlineId=menu-item-settings&quot;&gt;'. __('Edit') .'&lt;/a&gt; | ';
+                        $output .= '&lt;a class=&quot;item-delete&quot; id=&quot;delete'. esc_attr( $menu_item-&gt;menu_order ) .'&quot; value=&quot;'. esc_attr( $menu_item-&gt;menu_order ) .'&quot;&gt;'. __('Delete') .'&lt;/a&gt;';
</ins><span class="cx">                         
</span><del>-                        $item .= '&lt;/dt&gt;&lt;/dl&gt;';
</del><ins>+                        $output .= '&lt;/dt&gt;&lt;/dl&gt;';
</ins><span class="cx">                         
</span><span class="cx">                         // Menu Item Settings
</span><del>-                        $item .= '&lt;input type=&quot;hidden&quot; id=&quot;item-dbid'. esc_attr( $menu_item-&gt;menu_order ) .'&quot; name=&quot;item-dbid'. esc_attr( $menu_item-&gt;menu_order ) .'&quot; value=&quot;'. esc_attr( $menu_item-&gt;ID ) .'&quot; /&gt;';
-                        $item .= '&lt;input type=&quot;hidden&quot; id=&quot;item-postmenu'. esc_attr( $menu_item-&gt;menu_order ) .'&quot; name=&quot;item-postmenu'. esc_attr( $menu_item-&gt;menu_order ) .'&quot; value=&quot;'. esc_attr( get_post_meta( $menu_item-&gt;ID, 'object_id', true ) ) .'&quot; /&gt;';
-                        $item .= '&lt;input type=&quot;hidden&quot; id=&quot;item-parent'. esc_attr( $menu_item-&gt;menu_order ) .'&quot; name=&quot;item-parent'. esc_attr( $menu_item-&gt;menu_order ) .'&quot; value=&quot;'. esc_attr( $menu_item-&gt;parent_item ) .'&quot; /&gt;';
-                        $item .= '&lt;input type=&quot;hidden&quot; id=&quot;item-position'. esc_attr( $menu_item-&gt;menu_order ) .'&quot; name=&quot;item-position'. esc_attr( $menu_item-&gt;menu_order ) .'&quot; value=&quot;'. esc_attr( $menu_item-&gt;menu_order ) .'&quot; /&gt;';
-                        $item .= '&lt;input type=&quot;hidden&quot; id=&quot;item-type'. esc_attr( $menu_item-&gt;menu_order ) .'&quot; name=&quot;item-type'. esc_attr( $menu_item-&gt;menu_order ) .'&quot; value=&quot;'. esc_attr( get_post_meta( $menu_item-&gt;ID, 'menu_type', true ) ) .'&quot; /&gt;';
-                        $item .= '&lt;input type=&quot;hidden&quot; id=&quot;item-title'. esc_attr( $menu_item-&gt;menu_order ) .'&quot; name=&quot;item-title'. esc_attr( $menu_item-&gt;menu_order ) .'&quot; value=&quot;'. esc_attr( $menu_item-&gt;title ) .'&quot; /&gt;';
-                        $item .= '&lt;input type=&quot;hidden&quot; id=&quot;item-url'. esc_attr( $menu_item-&gt;menu_order ) .'&quot; name=&quot;item-url'. esc_attr( $menu_item-&gt;menu_order ) .'&quot; value=&quot;'. esc_attr( $menu_item-&gt;link ) .'&quot; /&gt;';
-                        $item .= '&lt;input type=&quot;hidden&quot; id=&quot;item-description'. esc_attr( $menu_item-&gt;menu_order ) .'&quot; name=&quot;item-description'. esc_attr( $menu_item-&gt;menu_order ) .'&quot; value=&quot;'. esc_attr( $menu_item-&gt;description ) .'&quot; /&gt;';
-                        $item .= '&lt;input type=&quot;hidden&quot; id=&quot;item-attr-title'. esc_attr( $menu_item-&gt;menu_order ) .'&quot; name=&quot;item-attr-title'. esc_attr( $menu_item-&gt;menu_order ) .'&quot; value=&quot;'.esc_attr( $menu_item-&gt;post_excerpt )  .'&quot; /&gt;';
-                        $item .= '&lt;input type=&quot;hidden&quot; id=&quot;item-target'. esc_attr( $menu_item-&gt;menu_order ) .'&quot; name=&quot;item-target'. esc_attr( $menu_item-&gt;menu_order ) .'&quot; value=&quot;'. esc_attr( get_post_meta( $menu_item-&gt;ID, 'menu_new_window', true ) ? '1' : '0' ) .'&quot; /&gt;';
</del><ins>+                        $output .= '&lt;input type=&quot;hidden&quot; name=&quot;menu-item-db-id[]&quot; id=&quot;menu-item-db-id'. esc_attr( $menu_item-&gt;menu_order ) .'&quot; value=&quot;'. esc_attr( $menu_item-&gt;ID ) .'&quot; /&gt;';
+                        $output .= '&lt;input type=&quot;hidden&quot; name=&quot;menu-item-object-id[]&quot; id=&quot;menu-item-object-id'. esc_attr( $menu_item-&gt;menu_order ) .'&quot; value=&quot;'. esc_attr( $menu_item-&gt;object_id ) .'&quot; /&gt;';
+                        $output .= '&lt;input type=&quot;hidden&quot; name=&quot;menu-item-parent-id[]&quot; id=&quot;menu-item-parent-id'. esc_attr( $menu_item-&gt;menu_order ) .'&quot; value=&quot;'. esc_attr( $menu_item-&gt;post_parent ) .'&quot; /&gt;';
+                        $output .= '&lt;input type=&quot;hidden&quot; name=&quot;menu-item-position[]&quot; id=&quot;menu-item-position'. esc_attr( $menu_item-&gt;menu_order ) .'&quot; value=&quot;'. esc_attr( $menu_item-&gt;menu_order ) .'&quot; /&gt;';
+                        $output .= '&lt;input type=&quot;hidden&quot; name=&quot;menu-item-type[]&quot; id=&quot;menu-item-type'. esc_attr( $menu_item-&gt;menu_order ) .'&quot; value=&quot;'. esc_attr( $menu_item-&gt;type ) .'&quot; /&gt;';
+                        $output .= '&lt;input type=&quot;hidden&quot; name=&quot;menu-item-append[]&quot; id=&quot;menu-item-append'. esc_attr( $menu_item-&gt;menu_order ) .'&quot; value=&quot;'. esc_attr( $menu_item-&gt;append ) .'&quot; /&gt;';
+                        $output .= '&lt;input type=&quot;hidden&quot; name=&quot;menu-item-title[]&quot; id=&quot;menu-item-title'. esc_attr( $menu_item-&gt;menu_order ) .'&quot; value=&quot;'. esc_attr( $menu_item-&gt;title ) .'&quot; /&gt;';
+                        $output .= '&lt;input type=&quot;hidden&quot; name=&quot;menu-item-url[]&quot; id=&quot;menu-item-url'. esc_attr( $menu_item-&gt;menu_order ) .'&quot; value=&quot;'. esc_attr( $menu_item-&gt;url ) .'&quot; /&gt;';
+                        $output .= '&lt;input type=&quot;hidden&quot; name=&quot;menu-item-description[]&quot; id=&quot;menu-item-description'. esc_attr( $menu_item-&gt;menu_order ) .'&quot; value=&quot;'. esc_attr( $menu_item-&gt;description ) .'&quot; /&gt;';
+                        $output .= '&lt;input type=&quot;hidden&quot; name=&quot;menu-item-classes[]&quot; id=&quot;menu-item-classes'. esc_attr( $menu_item-&gt;menu_order ) .'&quot; value=&quot;'. esc_attr( $menu_item-&gt;classes ) .'&quot; /&gt;';
+                        $output .= '&lt;input type=&quot;hidden&quot; name=&quot;menu-item-xfn[]&quot; id=&quot;menu-item-xfn'. esc_attr( $menu_item-&gt;menu_order ) .'&quot; value=&quot;'. esc_attr( $menu_item-&gt;xfn ) .'&quot; /&gt;';
+                        $output .= '&lt;input type=&quot;hidden&quot; name=&quot;menu-item-attr-title[]&quot; id=&quot;menu-item-attr-title'. esc_attr( $menu_item-&gt;menu_order ) .'&quot; value=&quot;'.esc_attr( $menu_item-&gt;post_excerpt )  .'&quot; /&gt;';
+                        $output .= '&lt;input type=&quot;hidden&quot; name=&quot;menu-item-target[]&quot; id=&quot;menu-item-target'. esc_attr( $menu_item-&gt;menu_order ) .'&quot; value=&quot;'. esc_attr( $menu_item-&gt;target ) .'&quot; /&gt;';
</ins><span class="cx">                         break;
</span><ins>+                
+                case 'custom':
+                        $menu_id = 'menu-item-' . $menu_item-&gt;db_id;
+                        $output .= '&lt;label class=&quot;menu-item-title&quot;&gt;&lt;input type=&quot;checkbox&quot; id=&quot;'. esc_attr( $menu_id ) .'&quot; name=&quot;'. esc_attr( $menu_item-&gt;title ) .'&quot; value=&quot;'. esc_attr( $menu_item-&gt;url ) .'&quot; /&gt;'. $menu_item-&gt;title .'&lt;/label&gt;';
</ins><span class="cx">                         
</span><del>-                case 'default':
-                        $menu_id = 'menu-item-' . $menu_item-&gt;ID;
-                        $item .= '&lt;label class=&quot;item-title&quot;&gt;&lt;input type=&quot;checkbox&quot; id=&quot;'. esc_attr($menu_id) .'&quot; name=&quot;'. esc_attr( $menu_item-&gt;title ) .'&quot; value=&quot;'. esc_attr( $menu_item-&gt;link ) .'&quot; /&gt;'. $menu_item-&gt;title .'&lt;/label&gt;';
</del><ins>+                        // Menu item hidden fields
+                        $output .= '&lt;input type=&quot;hidden&quot; class=&quot;menu-item-db-id&quot; value=&quot;'. esc_attr( $menu_item-&gt;db_id ) .'&quot; /&gt;';
+                        $output .= '&lt;input type=&quot;hidden&quot; class=&quot;menu-item-object-id&quot; value=&quot;'. esc_attr( $menu_item-&gt;object_id ) .'&quot; /&gt;';
+                        $output .= '&lt;input type=&quot;hidden&quot; class=&quot;menu-item-parent-id&quot; value=&quot;'. esc_attr( $menu_item-&gt;parent_id ) .'&quot; /&gt;';
+                        $output .= '&lt;input type=&quot;hidden&quot; class=&quot;menu-item-type&quot; value=&quot;'. esc_attr( $menu_item-&gt;type ) .'&quot; /&gt;';
+                        $output .= '&lt;input type=&quot;hidden&quot; class=&quot;menu-item-append&quot; value=&quot;'. esc_attr( $menu_item-&gt;append ) .'&quot; /&gt;';
+                        $output .= '&lt;input type=&quot;hidden&quot; class=&quot;menu-item-title&quot; value=&quot;'. esc_attr( $menu_item-&gt;title ) .'&quot; /&gt;';
+                        $output .= '&lt;input type=&quot;hidden&quot; class=&quot;menu-item-url&quot; value=&quot;'. esc_attr( $menu_item-&gt;url ) .'&quot; /&gt;';
+                        $output .= '&lt;input type=&quot;hidden&quot; class=&quot;menu-item-target&quot; value=&quot;'. esc_attr( $menu_item-&gt;target ) .'&quot; /&gt;';
+                        $output .= '&lt;input type=&quot;hidden&quot; class=&quot;menu-item-attr_title&quot; value=&quot;'. esc_attr( $menu_item-&gt;attr_title ) .'&quot; /&gt;';
+                        $output .= '&lt;input type=&quot;hidden&quot; class=&quot;menu-item-description&quot; value=&quot;'. esc_attr( $menu_item-&gt;description ) .'&quot; /&gt;';
+                        $output .= '&lt;input type=&quot;hidden&quot; class=&quot;menu-item-classes&quot; value=&quot;'. esc_attr( $menu_item-&gt;classes ) .'&quot; /&gt;';
+                        $output .= '&lt;input type=&quot;hidden&quot; class=&quot;menu-item-xfn&quot; value=&quot;'. esc_attr( $menu_item-&gt;xfn ) .'&quot; /&gt;';
+                        break;
+                
+                case 'taxonomy':
+                case 'post_type':
+                        $menu_id = 'menu-item-' . $menu_item-&gt;db_id;
+                        $output .= '&lt;label class=&quot;menu-item-title&quot;&gt;&lt;input type=&quot;checkbox&quot; id=&quot;'. esc_attr( $menu_id ) .'&quot; name=&quot;'. esc_attr( $menu_item-&gt;title ) .'&quot; value=&quot;'. esc_attr( $menu_item-&gt;url ) .'&quot; /&gt;'. $menu_item-&gt;title .'&lt;/label&gt;';
</ins><span class="cx">                         
</span><del>-                        // Menu Item Settings
-                        $item .= '&lt;input type=&quot;hidden&quot; class=&quot;item-type&quot; value=&quot;'. esc_attr( $menu_item-&gt;type ) .'&quot; /&gt;';
-                        $item .= '&lt;input type=&quot;hidden&quot; class=&quot;item-title&quot; value=&quot;'. esc_attr( $menu_item-&gt;title ) .'&quot; /&gt;';
-                        $item .= '&lt;input type=&quot;hidden&quot; class=&quot;item-url&quot; value=&quot;'. esc_attr( $menu_item-&gt;link ) .'&quot; /&gt;';
-                        $item .= '&lt;input type=&quot;hidden&quot; class=&quot;item-dbid&quot; value=&quot;'. esc_attr( $menu_item-&gt;ID ) .'&quot; /&gt;';
-                        $item .= '&lt;input type=&quot;hidden&quot; class=&quot;item-parent&quot; value=&quot;'. esc_attr( $menu_item-&gt;parent_item ) .'&quot; /&gt;';
-                        $item .= '&lt;input type=&quot;hidden&quot; class=&quot;item-description&quot; value=&quot;'. esc_attr( $menu_item-&gt;description ) .'&quot; /&gt;';
</del><ins>+                        // Menu item hidden fields
+                        $output .= '&lt;input type=&quot;hidden&quot; class=&quot;menu-item-db-id&quot; value=&quot;0&quot; /&gt;';
+                        $output .= '&lt;input type=&quot;hidden&quot; class=&quot;menu-item-object-id&quot; value=&quot;'. esc_attr( $menu_item-&gt;object_id ) .'&quot; /&gt;';
+                        $output .= '&lt;input type=&quot;hidden&quot; class=&quot;menu-item-parent-id&quot; value=&quot;'. esc_attr( $menu_item-&gt;parent_id ) .'&quot; /&gt;';
+                        $output .= '&lt;input type=&quot;hidden&quot; class=&quot;menu-item-type&quot; value=&quot;'. esc_attr( $menu_item-&gt;type ) .'&quot; /&gt;';
+                        $output .= '&lt;input type=&quot;hidden&quot; class=&quot;menu-item-append&quot; value=&quot;'. esc_attr( $menu_item-&gt;append ) .'&quot; /&gt;';
+                        $output .= '&lt;input type=&quot;hidden&quot; class=&quot;menu-item-title&quot; value=&quot;'. esc_attr( $menu_item-&gt;title ) .'&quot; /&gt;';
+                        $output .= '&lt;input type=&quot;hidden&quot; class=&quot;menu-item-url&quot; value=&quot;'. esc_attr( $menu_item-&gt;url ) .'&quot; /&gt;';
+                        $output .= '&lt;input type=&quot;hidden&quot; class=&quot;menu-item-append&quot; value=&quot;'. esc_attr( $menu_item-&gt;append ) .'&quot; /&gt;';
</ins><span class="cx">                         break;
</span><span class="cx">         }
</span><del>-        return apply_filters( 'wp_get_nav_menu_item', $item );
</del><ins>+        
+        return $output;
</ins><span class="cx"> }
</span><span class="cx"> ?&gt;
</span><span class="cx">\ No newline at end of file
</span></span></pre></div>
<a id="trunkwpincludesnavmenuphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-includes/nav-menu.php (13703 => 13704)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-includes/nav-menu.php        2010-03-15 14:29:11 UTC (rev 13703)
+++ trunk/wp-includes/nav-menu.php        2010-03-15 16:26:46 UTC (rev 13704)
</span><span class="lines">@@ -49,17 +49,6 @@
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> /**
</span><del>- * Returns all Navigation Menu objects.
- *
- * @since 3.0.0
- *
- * @return array menu objects
- */
-function wp_get_nav_menus() {
-        return get_terms( 'nav_menu', array( 'hide_empty' =&gt; false, 'orderby' =&gt; 'id' ) );
-}
-
-/**
</del><span class="cx">  * Creates a navigation menu.
</span><span class="cx">  *
</span><span class="cx">  * Optional args:
</span><span class="lines">@@ -113,33 +102,18 @@
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> /**
</span><del>- * Creates a nav menu named 'Menu 1'.
</del><ins>+ * Returns all Navigation Menu objects.
</ins><span class="cx">  *
</span><del>- * This function is called if the user doesn't have any nav menus.
- * It grabs the first 14 pages, and creates a new default menu.
- *
</del><span class="cx">  * @since 3.0.0
</span><ins>+ *
+ * @return array menu objects
</ins><span class="cx">  */
</span><del>-function wp_create_default_nav_menu() {
-        $menu = wp_create_nav_menu( __('Menu 1'), array('slug' =&gt; 'menu-1') );
-
-        if ( is_wp_error($menu) )
-                return;
-
-        $pages = get_pages( array('parent' =&gt; 0, 'number' =&gt; 15) );
-        $counter = 1;
-        foreach ( $pages as $page ) {
-                $item = array( 'post_status' =&gt; 'publish', 'post_type' =&gt; 'nav_menu_item', 'menu_order' =&gt; $counter, 'tax_input' =&gt; array( 'nav_menu' =&gt; $menu-&gt;name), 'post_title' =&gt; addslashes($page-&gt;post_title) );
-                $item_id = wp_insert_post($item, true);
-                update_post_meta( $item_id, 'menu_type', 'page' );
-                update_post_meta( $item_id, 'object_id', $page-&gt;ID );
-                update_post_meta( $item_id, 'menu_new_window', 0 );
-                $counter++;
-        }
</del><ins>+function wp_get_nav_menus() {
+        return get_terms( 'nav_menu', array( 'hide_empty' =&gt; false, 'orderby' =&gt; 'id' ) );
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> /**
</span><del>- * Returns the menu items of a navigation menu.
</del><ins>+ * Returns all menu items of a navigation menu.
</ins><span class="cx">  *
</span><span class="cx">  * @since 3.0.0
</span><span class="cx">  *
</span><span class="lines">@@ -179,110 +153,91 @@
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> /**
</span><del>- * Returns a menu item with all it's nessecary data populated.
</del><ins>+ * Adds all the nav menu properties to the $menu_item.
</ins><span class="cx">  *
</span><span class="cx">  * @since 3.0.0
</span><span class="cx">  *
</span><del>- * @param string $menu_item Menu item.
- * @param string $type item|category|page.
- * @param string $position position of the menu item.
- * @return $menu_item
</del><ins>+ * @param string $menu_item The menu item to modify
+ * @param string $menu_item_type The menu item type (template, custom, post_type, taxonomy).
+ * @param string $menu_item_object Optional. The menu item object type (post type or taxonomy).
+ * @return object $menu_item The modtified menu item.
</ins><span class="cx">  */
</span><del>-function wp_setup_nav_menu_item( $menu_item, $type = 'item', $position = 0 ) {
-        global $parent_menu_order;
</del><ins>+function wp_setup_nav_menu_item( $menu_item, $menu_item_type = null, $menu_item_object = '' ) {
+        global $wp_query;
+        
+        switch ( $menu_item_type ) {
+                case 'frontend':
+                        $menu_item-&gt;db_id = (int) $menu_item-&gt;ID;
+                        $menu_item-&gt;object_id = get_post_meta( $menu_item-&gt;ID, 'menu_item_object_id', true );
+                        $menu_item-&gt;parent_id = (int) $menu_item-&gt;post_parent;
+                        $menu_item-&gt;type = get_post_meta( $menu_item-&gt;ID, 'menu_item_type', true );
+                        $menu_item-&gt;append = _x( get_post_meta( $menu_item-&gt;ID, 'menu_item_append', true ), 'nav menu item type' );
+                        
+                        $menu_item-&gt;title = $menu_item-&gt;post_title;
+                        $menu_item-&gt;url = get_post_meta( $menu_item-&gt;ID, 'menu_item_url', true );
+                        $menu_item-&gt;target = get_post_meta( $menu_item-&gt;ID, 'menu_item_target', true );
+                        
+                        $menu_item-&gt;attr_title = strip_tags( $menu_item-&gt;post_excerpt );
+                        $menu_item-&gt;description = strip_tags( $menu_item-&gt;post_content );
+                        
+                        $menu_item-&gt;classes = get_post_meta( $menu_item-&gt;ID, 'menu_item_classes', true );;
+                        $menu_item-&gt;xfn = get_post_meta( $menu_item-&gt;ID, 'menu_item_xfn', true );
+                        $menu_item-&gt;li_class = ( $menu_item-&gt;object_id == $wp_query-&gt;get_queried_object_id() ) ? ' current_page_item' : '';
+                        break;
+                        
+                case 'custom':
+                        $menu_item-&gt;db_id = (int) $menu_item-&gt;ID;
+                        $menu_item-&gt;object_id = (int) $menu_item-&gt;ID;
+                        $menu_item-&gt;parent_id = (int) $menu_item-&gt;post_parent;
+                        $menu_item-&gt;type = 'custom'; //$menu_item_type
+                        $menu_item-&gt;append = _x( 'Custom', 'nav menu item type' );
+                        
+                        $menu_item-&gt;attr_title = strip_tags( $menu_item-&gt;post_excerpt );
+                        $menu_item-&gt;description = strip_tags( $menu_item-&gt;post_content );
</ins><span class="cx"> 
</span><del>-        if ( 'item' == $type ) {
-                $menu_item-&gt;type = get_post_meta( $menu_item-&gt;ID, 'menu_type', true );
-                $menu_item-&gt;object_id = get_post_meta( $menu_item-&gt;ID, 'object_id', true );
-                $menu_item-&gt;target = ( get_post_meta( $menu_item-&gt;ID, 'menu_new_window', true ) ) ? 'target=&quot;_blank&quot;' : '';
-                if ( isset( $parent_menu_order[ $menu_item-&gt;post_parent ] ) )
-                        $menu_item-&gt;parent_item = $parent_menu_order[ $menu_item-&gt;post_parent ];
-                else
-                        $menu_item-&gt;parent_item = 0;
-        } elseif ( 'category' == $type ) {
-                $menu_item-&gt;type = $type;
-                $menu_item-&gt;object_id = $menu_item-&gt;term_id;
-                $menu_item-&gt;ID = $menu_item-&gt;term_id;
-                $menu_item-&gt;parent_item = $menu_item-&gt;parent;
-                $menu_item-&gt;menu_order = $position;
-        } elseif ( 'page' == $type ) {
-                $menu_item-&gt;type = $type;
-                $menu_item-&gt;object_id = $menu_item-&gt;ID;
-                $menu_item-&gt;parent_item = $menu_item-&gt;post_parent;
-                $menu_item-&gt;menu_order = $position;
-        }
</del><ins>+                        $menu_item-&gt;title = $menu_item-&gt;post_title;
+                        $menu_item-&gt;url = get_post_meta( $menu_item-&gt;ID, 'menu_item_url', true );
+                        $menu_item-&gt;target = get_post_meta( $menu_item-&gt;ID, 'menu_item_target', true );
+                        break;
+                        
+                case 'post_type':
+                        $menu_item-&gt;db_id = 0;
+                        $menu_item-&gt;object_id = (int) $menu_item-&gt;ID;
+                        $menu_item-&gt;parent_id = (int) $menu_item-&gt;post_parent;
+                        $menu_item-&gt;type = $menu_item_type;
+                        
+                        $object = get_post_type_object( $menu_item_object );
+                        $menu_item-&gt;append = _x( $object-&gt;singular_label, 'nav menu item type' );
</ins><span class="cx"> 
</span><del>-        switch ( $menu_item-&gt;type ) {
-                case 'page' :
-                        $menu_item-&gt;link = get_page_link( $menu_item-&gt;object_id );
-
-                        if ( $menu_item-&gt;post_title == '' )
-                                $menu_item-&gt;title = get_the_title( $menu_item-&gt;object_id );
-                        else
-                                $menu_item-&gt;title = $menu_item-&gt;post_title;
-
-                        if ( $menu_item-&gt;post_content == '' )
-                                $menu_item-&gt;description = get_post_meta( $menu_item-&gt;ID, 'page-description', true );
-                        else
-                                $menu_item-&gt;description = $menu_item-&gt;post_content;
-                        $menu_item-&gt;append = _x('Page', 'menu nav item type');
</del><ins>+                        $menu_item-&gt;title = $menu_item-&gt;post_title;
+                        $menu_item-&gt;url = get_post_permalink( $menu_item-&gt;ID );
+                        $menu_item-&gt;target = '_none';
+                        
+                        $menu_item-&gt;attr_title = '';
+                        $menu_item-&gt;description = strip_tags( $menu_item-&gt;post_content );
</ins><span class="cx">                         break;
</span><del>-                case 'category' :
-                        $menu_item-&gt;link = get_category_link( $menu_item-&gt;object_id );
</del><ins>+                        
+                case 'taxonomy':
+                        $menu_item-&gt;ID = $menu_item-&gt;term_id;
+                        $menu_item-&gt;db_id = 0;
+                        $menu_item-&gt;object_id = (int) $menu_item-&gt;term_id;
+                        $menu_item-&gt;parent_id = (int) $menu_item-&gt;parent;
+                        $menu_item-&gt;type = $menu_item_type;
+                        
+                        $object = get_taxonomy( $menu_item_object );
+                        $menu_item-&gt;append = _x( $object-&gt;singular_label, 'nav menu item type' );
</ins><span class="cx"> 
</span><del>-                        if ( empty($menu_item-&gt;post_title) ) {
-                                $title_raw = get_category( $menu_item-&gt;object_id );
-                                $menu_item-&gt;title =  $title_raw-&gt;cat_name;
-                        } else {
-                                $menu_item-&gt;title = $menu_item-&gt;post_title;
-                        }
-
-                        if ( empty($menu_item-&gt;post_content) )
-                                $menu_item-&gt;description = strip_tags( category_description( $menu_item-&gt;object_id ) );
-                        else
-                                $menu_item-&gt;description = $menu_item-&gt;post_content;
-                        $menu_item-&gt;append = _x('Category', 'menu nav item type');
</del><ins>+                        $menu_item-&gt;title = $menu_item-&gt;name;
+                        $menu_item-&gt;url = get_term_link( $menu_item, $menu_item_object );
+                        $menu_item-&gt;target = '_none';
+                        $menu_item-&gt;attr_title = '';
+                        $menu_item-&gt;description = strip_tags( $menu_item-&gt;description );
</ins><span class="cx">                         break;
</span><del>-                case 'custom' :
-                default :
-                        $menu_item-&gt;link = esc_url_raw( get_post_meta( $menu_item-&gt;ID, 'menu_link', true ) );
-                        $menu_item-&gt;title =  $menu_item-&gt;post_title;
-                        $menu_item-&gt;description = $menu_item-&gt;post_content;
-                        $menu_item-&gt;append = _x('Custom', 'menu nav item type');
-                        break;
</del><span class="cx">         }
</span><del>-
-        $menu_item-&gt;li_class = '';
-        global $wp_query;
</del><span class="cx">         
</span><del>-        if ( $menu_item-&gt;object_id == $wp_query-&gt;get_queried_object_id() )
-                $menu_item-&gt;li_class = ' current_page_item';
-
-        $menu_item-&gt;anchor_title = '';
-/* @todo: update to use tax/post data
-
-                        //SET anchor title
-                        if (isset($wp_custom_nav_menu_items-&gt;custom_anchor_title)) {
-                                $anchor_title = $wp_custom_nav_menu_items-&gt;custom_anchor_title;
-                        }
-                        else {
-                                $anchor_title = $title;
-                        }
-
-                        if ($queried_id == $wp_custom_nav_menu_items-&gt;post_id) {
-                                $li_class = 'class=&quot;current_page_item&quot;';
-                        }
-
-                        if (isset($wp_custom_nav_menu_items-&gt;new_window)) {
-                                if ($wp_custom_nav_menu_items-&gt;new_window &gt; 0) {
-                                        $target = 'target=&quot;_blank&quot;';
-                                }
-                                else {
-                                        $target = '';
-                                }
-                        }
-*/
-
</del><ins>+        $menu_item-&gt;classes = get_post_meta( $menu_item-&gt;ID, 'menu_item_classes', true );
+        $menu_item-&gt;xfn = get_post_meta( $menu_item-&gt;ID, 'menu_item_xfn', true );
+        
</ins><span class="cx">         return $menu_item;
</span><span class="cx"> }
</span><del>-?&gt;
</del><ins>+?&gt;
</ins><span class="cx">\ No newline at end of file
</span></span></pre></div>
<a id="trunkwpincludesscriptloaderphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-includes/script-loader.php (13703 => 13704)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-includes/script-loader.php        2010-03-15 14:29:11 UTC (rev 13703)
+++ trunk/wp-includes/script-loader.php        2010-03-15 16:26:46 UTC (rev 13704)
</span><span class="lines">@@ -397,14 +397,15 @@
</span><span class="cx">                 ) );
</span><span class="cx"> 
</span><span class="cx">                 // Custom Navigation
</span><del>-                $scripts-&gt;add( 'nav-menu-default-items', &quot;/wp-admin/js/nav-menu-default-items$suffix.js&quot;, false, '20100223' );
-                $scripts-&gt;add( 'nav-menu-dynamic-functions', &quot;/wp-admin/js/nav-menu-dynamic-functions$suffix.js&quot;, false, '20100225b' );
</del><ins>+                $scripts-&gt;add( 'nav-menu-default-items', &quot;/wp-admin/js/nav-menu-default-items$suffix.js&quot;, false, '20100315' );
+                $scripts-&gt;add( 'nav-menu-dynamic-functions', &quot;/wp-admin/js/nav-menu-dynamic-functions$suffix.js&quot;, false, '20100315' );
</ins><span class="cx">                 $scripts-&gt;localize( 'nav-menu-dynamic-functions', 'navMenuL10n', array(
</span><span class="cx">                         'custom' =&gt; _x('Custom', 'menu nav item type'),
</span><span class="cx">                         'page' =&gt; _x('Page', 'menu nav item type'),
</span><span class="cx">                         'category' =&gt; _x('Category', 'menu nav item type'),
</span><span class="cx">                         'thickbox' =&gt; _x('Edit Menu Item', 'Thickbox Title'),
</span><span class="cx">                         'edit' =&gt; _x('Edit', 'menu item edit text'),
</span><ins>+                        'warnDelete' =&gt; __( &quot;You are about to permanently delete this menu. \n 'Cancel' to stop, 'OK' to delete.&quot; ),
</ins><span class="cx">                 ) );
</span><span class="cx">                 
</span><span class="cx">                 $scripts-&gt;add( 'nav-menu-php-functions', &quot;/wp-admin/js/nav-menu-php-functions$suffix.js&quot;, false, '20100220' );
</span></span></pre></div>
<a id="trunkwpincludestaxonomyphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-includes/taxonomy.php (13703 => 13704)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-includes/taxonomy.php        2010-03-15 14:29:11 UTC (rev 13703)
+++ trunk/wp-includes/taxonomy.php        2010-03-15 16:26:46 UTC (rev 13704)
</span><span class="lines">@@ -160,7 +160,7 @@
</span><span class="cx">  */
</span><span class="cx"> function is_taxonomy( $taxonomy ) {
</span><span class="cx">         global $wp_taxonomies;
</span><del>-
</del><ins>+                
</ins><span class="cx">         return isset($wp_taxonomies[$taxonomy]);
</span><span class="cx"> }
</span><span class="cx"> 
</span></span></pre>
</div>
</div>

</body>
</html>