<!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"> <?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' => true ), 'object' );
</ins><span class="cx">         
</span><del>-        $args = array( 'post_status' => 'any', 'post_type' => 'nav_menu_item', 'meta_value' => '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->label );
+                
+                // delete_transient( "nav_menu_items_{$post_type->name}" );
+                // delete_transient( "nav_menu_sub_items_{$post_type->name}" );
+                
+                add_meta_box( "add-{$id}", sprintf( __('Add an Existing %s'), $post_type->singular_label ), 'wp_nav_menu_item_post_type_metabox', 'menus', 'side', 'default', $post_type );
+        }
+}
</ins><span class="cx">
</span><del>-        if ( !$link_objects->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' => true ), 'object' );
</ins><span class="cx">         
</span><del>-        // Display Loop
-        foreach ( $link_objects->posts as $item ) {
-                if ( 0 == $item->parent ) {
-                        $item = wp_setup_nav_menu_item( $item, 'item', $items_counter );
-                        
-                        switch ( $context ) {
-                                case 'menu':
-                                        ?>
-                                        <li id="menu-<?php echo $items_counter; ?>" value="<?php echo $items_counter; ?>">
-                                                <?php
-                                                        echo wp_get_nav_menu_item( $item, 'menu' );
-                                                        $parentli = $item->ID;
-                                                        $items_counter++;
-                                                        $items_counter = wp_nav_menu_sub_items( $item->ID, $items_counter, $parentli, 'categories', 'menu' );
-                                                ?>
-                                        </li>
-                                        <?php
-                                        break;
-                                
-                                case 'default':
-                                        ?>
-                                        <li>
-                                                <?php
-                                                        echo wp_get_nav_menu_item( $item, 'default' );
-                                                        $parentli = $item->ID;
-                                                        $items_counter++;
-                                                        $items_counter = wp_nav_menu_sub_items( $item->ID, $items_counter, $parentli, 'categories', 'default' );
-                                                ?>
-                                        </li>
-                                        <?php
-                                        break;
-                        }
-                }
</del><ins>+        if ( !$taxonomies )
+                return false;
+        
+        foreach ( $taxonomies as $tax ) {
+                $id = sanitize_title_with_dashes( $tax->label );
+                
+                // delete_transient( "nav_menu_items_{$tax->name}" );
+                // delete_transient( "nav_menu_sub_items_{$tax->name}" );
+                
+                add_meta_box( "add-{$id}", sprintf( __('Add an Existing %s'), $tax->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' => 0,
-                        'sort_order' => 'ASC',
-                        'sort_column' => 'post_title',
-                        'hierarchical' => 1,
-                        'exclude' => '',
-                        'include' => '',
-                        'meta_key' => '',
-                        'meta_value' => '',
-                        'authors' => '',
-                        'parent' => -1,
-                        'exclude_tree' => '',
-                        'number' => '',
-                        'offset' => 0 );
</del><ins>+function wp_nav_menu_manage_menu_metabox( $object, $menu ) { ?>
+        <div id="submitpost" class="submitbox">
+                <div id="minor-publishing">
+                        <div class="misc-pub-section misc-pub-section-last">
+                                <label class="howto" for="menu-name">
+                                        <span><?php _e('Name'); ?></span>
+                                        <input id="menu-name" name="menu-name" type="text" class="regular-text menu-item-textbox" value="<?php esc_attr_e( $menu['args'][1] ); ?>" />
+                                        <br class="clear" />
+                                </label>
+                        </div><!--END .misc-pub-section misc-pub-section-last-->
+                        <br class="clear" />
+                </div><!--END #misc-publishing-actions-->
+                <div id="major-publishing-actions">
+                        <div id="delete-action">
+                                <a class="submitdelete deletion" href="<?php echo wp_nonce_url( admin_url('nav-menus.php?action=delete&amp;menu=' . $menu['args'][0]), 'delete-nav_menu-' . $menu['args'][0] ); ?>"><?php _e('Delete Menu'); ?></a>
+                        </div><!--END #delete-action-->
</ins><span class="cx">
</span><del>-        // Get all pages
-        $pages_array = get_pages( $pages_args );
</del><ins>+                        <div id="publishing-action">
+                                <input class="button-primary" name="save_menu" type="submit" value="<?php esc_attr_e('Save Menu'); ?>" />
+                        </div><!--END #publishing-action-->
+                        <br class="clear" />
+                </div><!--END #major-publishing-actions-->
+        </div><!--END #submitpost .submitbox-->
+        <?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() { ?>
+        <p>
+                <input type="text" name="create-menu-name" id="create-menu-name" class="regular-text" value="" />
+                <input type="submit" name="create-menu" id="create-menu" class="button" value="<?php esc_attr_e('Create Menu'); ?>" />
+        </p>
+        <?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' => 'any', 'post_type' => 'nav_menu_item', 'meta_value' => '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>+        
+        ?>
+        <p id="menu-item-url-wrap">
+                <label class="howto" for="menu-item-url">
+                        <span><?php _e('URL'); ?></span>
+                        <input id="custom-menu-item-url" name="custom-menu-item-url" type="text" class="code menu-item-textbox" value="http://" />
+                </label>
+        </p>
+        <br class="clear" />
+        <p id="menu-item-name-wrap">
+                <label class="howto" for="custom-menu-item-name">
+                        <span><?php _e('Text'); ?></span>
+                        <input id="custom-menu-item-name" name="custom-menu-item-name" type="text" class="regular-text menu-item-textbox" value="<?php echo esc_attr( __('Menu Item') ); ?>" />
+                </label>
+        </p>
+        
+        <p class="button-controls">
+                <a class="show-all"><?php _e('View All'); ?></a>
+                <a class="hide-all"><?php _e('Hide All'); ?></a>
+        </p>
+        <div id="available-links" class="list-wrap">
+                <div class="list-container">
+                        <ul class="list">
+                                <?php echo wp_nav_menu_get_items( $query->posts, 'custom' ); ?>
+                        </ul>
+                </div><!-- /.list-container-->
+        </div><!-- /#available-links-->
+        <p class="add-to-menu">
+                <a class="button"><?php _e('Add to Menu'); ?></a>
+        </p>
+        <div class="clear"></div>
+        <?php
+}
</ins><span class="cx">
</span><del>-        // Display Loop
-        foreach ( $pages_array as $post ) {
-                if ( $post->post_parent == 0 ) {
-                        $post = wp_setup_nav_menu_item( $post, 'page', $items_counter );
-                        if ( $context == 'menu' ) {
-                                ?>
-                                <li id="menu-<?php echo $items_counter; ?>" value="<?php echo $items_counter; ?>">
-                                        <?php
-                                                echo wp_get_nav_menu_item( $post, 'menu', $items_counter );
-                                                $parentli = $post->ID;
-                                                $items_counter++;
-                                                $items_counter = wp_nav_menu_sub_items( $post->ID, $items_counter, $parentli, 'pages', 'menu' );
-                                        ?>
-                                </li>
-                                <?php
-                        } elseif ( $context == 'default' ) {
-                                // Sidebar Menu
-                                ?>
-                                 <li>
-                                        <?php
-                                                echo wp_get_nav_menu_item( $post, 'default' );
-                                                $parentli = $post->ID;
-                                                $items_counter++;
-                                                $items_counter = wp_nav_menu_sub_items( $post->ID, $items_counter, $parentli, 'pages', 'default' );
-                                         ?>
-                                </li>
-                                <?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' => $post_type['args']->name, );
+        
+        if ( 'attachment' == $post_type['args']->name )
+                $args['post_status'] = 'any';
+        
+        // Cache the query for a day. @todo: Make sure to flush transient when objects are updated.
+        $query = get_transient( "nav_menu_items_{$post_type['args']->name}" );
+        if ( false == $query ) {
+                $query = new WP_Query( $args );
+                set_transient( "nav_menu_items_{$post_type['args']->name}", $query, 86400 );
+        }
+        
+        if ( !$query->posts )
+                $error = '<li id="error">'. sprintf( __( 'No %s exists' ), $post_type['args']->label ) .'</li>';
+        
+        $pt_names = '';
+        if ( is_array($query->posts) ) {
+                foreach ( $query->posts as $post ) {
+                        if ( $post->post_title ) {
+                                $pt_names .= htmlentities( $post->post_title ) .'|';
+                        } else {
+                                $pt_names = sprintf( __('No %s exists'), $post_type['args']->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']->label );
+        ?>
+        <p class="quick-search-wrap">
+                <input type="text" class="quick-search regular-text" value="" />
+                <a class="quick-search-submit button-secondary"><?php _e('Search'); ?></a>
+        </p>
+        
+        <p class="button-controls">
+                <a class="show-all"><?php _e('View All'); ?></a>
+                <a class="hide-all"><?php _e('Hide All'); ?></a>
+        </p>
+        
+        <div id="existing-<?php echo esc_attr( $id ); ?>" class="list-wrap">
+                <div class="list-container">
+                        <ul class="list">
+                                <?php echo isset( $error ) ? $error : wp_nav_menu_get_items( $query->posts, 'post_type', $post_type['args']->name ); ?>
+                        </ul>
+                </div><!-- /.list-container-->
+        </div><!-- /#existing-categories-->
+        <p class="add-to-menu">
+                <a class="button-secondary"><?php _e('Add to Menu'); ?></a>
+        </p>
+        <input type="hidden" class="autocomplete" name="autocomplete-<?php echo esc_attr( $post_type['args']->name ); ?>-names" value="<?php echo esc_js( $pt_names ); ?>" />
+        <br class="clear" />
+        <script type="text/javascript" charset="utf-8">
+                // <![CDATA[
+                jQuery(document).ready(function(){
+                        wp_nav_menu_autocomplete('<?php echo esc_attr($id); ?>');
+                });
+                // ]]>
+        </script>
+        <?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' => 'post',
-                        'child_of' => 0,
-                        'orderby' => 'name',
-                        'order' => 'ASC',
-                        'hide_empty' => false,
-                        'include_last_update_time' => false,
-                        'hierarchical' => 1,
-                        'exclude' => '',
-                        'include' => '',
-                        'number' => '',
-                        'pad_counts' => 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' => 0, 'orderby' => 'name', 'order' => 'ASC',
+                'hide_empty' => false, 'include_last_update_time' => false, 'hierarchical' => 1, 'exclude' => '',
+                'include' => '', 'number' => '', 'pad_counts' => false
+        );
+        
+        // Cache the query for a day. @todo: Make sure to flush transient when terms are updated.
+        $terms = get_transient( "nav_menu_items_{$taxonomy['args']->name}" );
+        if ( false == $terms ) {
+                $terms = get_terms( $taxonomy['args']->name, $args );
+                set_transient( "nav_menu_items_{$taxonomy['args']->name}", $terms, 86400 );
</ins><span class="cx">         }
</span><del>-
-        // Display Loop
-        foreach ( $categories_array as $cat_item ) {
-                if ( $cat_item->parent == 0 ) {
-                        $cat_item = wp_setup_nav_menu_item( $cat_item, 'category', $items_counter );
-                        // Custom Menu
-                        if ( $context == 'menu' ) {
-                                ?>
-                                <li id="menu-<?php echo $items_counter; ?>" value="<?php echo $items_counter; ?>">
-                                        <?php
-                                                echo wp_get_nav_menu_item($cat_item, 'menu');
-                                                $parentli = $cat_item->cat_ID;
-                                                $items_counter++;
-                                                $items_counter = wp_nav_menu_sub_items( $cat_item->cat_ID, $items_counter, $parentli, 'categories', 'menu' );
-                                        ?>
-                                </li>
-                                <?php
-                        } elseif ( $context == 'default' ) {
-                                // Sidebar Menu
-                                ?>
-                                <li>
-                                        <?php
-                                                echo wp_get_nav_menu_item( $cat_item, 'default' );
-                                                $parentli = $cat_item->cat_ID;
-                                                $items_counter++;
-                                                $items_counter = wp_nav_menu_sub_items( $cat_item->cat_ID, $items_counter, $parentli, 'categories', 'default' );
-                                        ?>
-                                </li>
-                                <?php
</del><ins>+        
+        if ( !$terms )
+                $error = '<li id="error">'. sprintf( __( 'No %s exists' ), $taxonomy['args']->label ) .'</li>';
+        
+        $term_names = '';
+        if ( is_array($terms) ) {
+                foreach ( $terms as $term ) {
+                        if ( $term->name ) {
+                                $term_names .= htmlentities( $term->name ) .'|';
+                        } else {
+                                $term_names = sprintf( __('No %s exists'), $taxonomy['args']->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']->label );
+        ?>
+        <p class="quick-search-wrap">
+                <input type="text" class="quick-search regular-text" value="" />
+                <a class="quick-search-submit button-secondary"><?php _e('Search'); ?></a>
+        </p>
+        
+        <p class="button-controls">
+                <a class="show-all"><?php _e('View All'); ?></a>
+                <a class="hide-all"><?php _e('Hide All'); ?></a>
+        </p>
+        
+        <div id="existing-<?php echo esc_attr( $id ); ?>" class="list-wrap">
+                <div class="list-container">
+                        <ul class="list">
+                                <?php echo isset( $error ) ? $error : wp_nav_menu_get_items( $terms, 'taxonomy', $taxonomy['args']->name ); ?>
+                        </ul>
+                </div><!-- /.list-container-->
+        </div><!-- /#existing-categories-->
+        <p class="add-to-menu">
+                <a class="button-secondary"><?php _e('Add to Menu'); ?></a>
+        </p>
+        <input type="hidden" class="autocomplete" name="autocomplete-<?php echo esc_attr($taxonomy['args']->name); ?>-names" value="<?php echo esc_js( $term_names ); ?>" />
+        <br class="clear" />
+        <script type="text/javascript" charset="utf-8">
+                // <![CDATA[
+                jQuery(document).ready(function(){
+                        wp_nav_menu_autocomplete('<?php echo esc_attr($id); ?>');
+                });
+                // ]]>
+        </script>
+        <?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->post_parent) )
+                        $menu_item->post_parent = $menu_item->parent;
+                
+                // Cleanest way to get all attachements
+                if ( 'attachment' == $object )
+                        $menu_item->post_parent = 0;
+                
+                if ( 0 == $menu_item->post_parent ) {
+                        // Setup the menu item
+                        $menu_item = wp_setup_nav_menu_item( $menu_item, $object_type, $object );                        
+                        $attributes = ( 'backend' == $context ) ? ' id="menu-item-'. $i .'" value="'. $i .'"' : '';
+                        
+                        $output .= '<li'. $attributes .'>';
+                        $output .= wp_get_nav_menu_item( $menu_item, $object_type, $object );
+                        $output .= wp_get_nav_menu_sub_items( $menu_item->ID, $object_type, $object, $context );
+                        $output .= '</li>';
</ins><span class="cx">
</span><del>-        // Custom Menu
-        if ( $output_type == 'menu' ) {
-                $sub_args = array(
-                'child_of' => $childof,
-                'hide_empty' => false,
-                'parent' => $childof);
-        } elseif ( $output_type == 'default' ) {
-                // Sidebar Menu
-                $sub_args = array(
-                'child_of' => $childof,
-                'hide_empty' => false,
-                'parent' => $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' => $childof, 'parent' => $childof, 'hide_empty' => false, );
+        
+        switch ( $object_type ) {
+                case 'post_type':
+                        $hierarchical_post_types = get_post_types( array( 'hierarchical' => 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) && !is_wp_error($sub_menu_items) ) {
+                $output .= '<ul class="sub-menu menu-item-type-'. $object_type .'">';
+                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="menu-item-'. $i .'" value="'. $i .'"' : '';
</ins><span class="cx">
</span><del>-        if ( $sub_array ) {
-                ?>
-                <ul id="sub-menu-<?php echo $context ?>">
-                <?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' ) {
-                                ?>
-                                <li id="menu-<?php echo $counter; ?>" value="<?php echo $counter; ?>">
-                                        <?php
-                                                echo wp_get_nav_menu_item( $sub_item, 'menu' );
-                                                $counter++;
-                                                $counter = wp_nav_menu_sub_items( $sub_item->ID, $counter, $sub_item->ID, $context, 'menu' );
-                                        ?>
-                                </li>
-                                <?php
-                        } elseif ( $output_type == 'default' ) {
-                                // Sidebar Menu
-                                ?>
-                                <li>
-                                        <?php
-                                                echo wp_get_nav_menu_item( $sub_item, 'default' );
-                                                //$counter++;
-                                                $counter = wp_nav_menu_sub_items( $sub_item->ID, $counter, $sub_item->ID, $context, 'default' );
-                                        ?>
-                                </li>
</del><ins>+                        $output .= '<li'. $attributes .'>';
+                        $output .= wp_get_nav_menu_item( $menu_item, $object_type, $object );
+                        $output .= wp_get_nav_menu_sub_items( $menu_item->ID, $object_type, $object );
+                        $output .= '</li>';
</ins><span class="cx">
</span><del>-                                <?php
-                        }
</del><ins>+                        ++$i;
</ins><span class="cx">                 }
</span><del>-                ?>
-                </ul>
-        <?php
</del><ins>+                $output .= '</ul>';
</ins><span class="cx">         }
</span><del>-        return $counter;
</del><ins>+        return $output;
</ins><span class="cx"> }
</span><span class="cx"> ?>
</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("#save_menu").click(function(){return wp_update_post_data()});a(".quick-search").click(function(){a(this).attr("value","")});a(".quick-search-submit").click(function(){a(this).siblings(".quick-search").search()});a("#menu-container .item-edit").click(function(){return wp_edit_menu_item(a(this).attr("value"))});a("#menu-container .item-delete").live("click",function(){return wp_remove_menu_item(a(this).attr("value"))});a("#update-menu-item").click(function(){wp_update_menu_item();tb_remove();var b=a("#edit-item-id").val();a("#menu-"+b+" dt:first").animate({backgroundColor:"#FFFF33"},{duration:"normal",complete:function(){jQuery(this).css("backgroundColor","")}})});a("#cancel-save").click(function(){return tb_remove()});a(".show-all").click(function(){a(this).offsetParent().find("#add-buttons-actions").attr("style","margin-bottom: 10px;");a(this).offsetParent().find(".list-wrap").css("display","block");a(this).siblings(".quick-search").attr("value","");a(this).offsetParent().find(".list-wrap li").css("display","block");a(this).hide();a(this).siblings(".hide-all").show()});a(".hide-all").click(function(){a(this).offsetParent().find("#add-buttons-actions").attr("style","margin-bottom: 0px;");a(this).offsetParent().find(".list-wrap").css("display","none");a(this).siblings(".quick-search").attr("value","Search");a(this).offsetParent().find(".list-wrap li").css("display","none");a(this).hide();a(this).siblings(".show-all").show()});a(".list input").click(function(){var d=jQuery(this).parent().siblings(".item-type").val();var g=jQuery(this).parent().siblings(".item-title").val();var c=jQuery(this).parent().siblings(".item-url").val();var e=jQuery(this).parent().siblings(".item-dbid").val();var b=jQuery(this).parent().siblings(".item-parent").val();var f=jQuery(this).parent().siblings(".item-description").val();return wp_update_queue(a(this),d,g,c,e,b,f)});a(".enqueue a").click(function(){return wp_add_queued_items_to_menu(this)});a("#add-custom-link .add-to-menu a").click(function(){var b=a(this).offsetParent().find("#menu-item-url").val();var c=a(this).offsetParent().find("#menu-item-name").val();wp_add_queued_items_to_menu(this);if("http://"==b||"Menu Item"==c){return}wp_add_item_to_menu("custom",c,b,0,0,"")})});
</del><span class="cx">\ No newline at end of file
</span><ins>+jQuery(document).ready(function(a){wp_drag_and_drop();a("#update-nav-menu .deletion").click(function(){if(confirm(navMenuL10n.warnDelete)){return true}else{return false}});a("#save_menu").click(function(){return wp_update_post_data()});a(".if-js-closed").removeClass("if-js-closed").addClass("closed");postboxes.add_postbox_toggles("menus");a(".quick-search").click(function(){a(this).attr("value","")});a(".quick-search-submit").click(function(){a(this).siblings(".quick-search").search()});a("#menu-container .item-edit").click(function(){return wp_edit_menu_item(a(this).attr("value"))});a("#menu-container .item-delete").live("click",function(b){return wp_remove_menu_item(a(this).attr("value"))});a("#update-menu-item").click(function(){wp_update_menu_item();return tb_remove()});a("#cancel-save").click(function(){return tb_remove()});a(".show-all").click(function(b){jQuery(b.currentTarget).parent().siblings(".list-wrap").css("display","block");jQuery(b.currentTarget).parent().siblings(".list-wrap").find("li").css("display","block");jQuery(b.currentTarget).hide();jQuery(b.currentTarget).siblings(".hide-all").show()});a(".hide-all").click(function(b){jQuery(b.currentTarget).parent().siblings(".list-wrap").css("display","none");jQuery(b.currentTarget).parent().siblings(".list-wrap").find("li").css("display","none");jQuery(b.currentTarget).hide();jQuery(b.currentTarget).siblings(".show-all").show()});a(".add-to-menu").click(function(b){return wp_add_checked_items_to_menu(b.currentTarget)});a("#add-custom-links .add-to-menu a").click(function(d){var b=jQuery(d.currentTarget).parent().parent().find("#custom-menu-item-url").val();var c=jQuery(d.currentTarget).parent().parent().find("#custom-menu-item-name").val();wp_add_item_to_menu(0,"","custom",navMenuL10n.custom,0,c,b,"","","_none","","")})});
</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 = '<li><dl><dt><label class="item-title"><input type="checkbox" id="link-'+ e.link_id +'" name="'+ e.link_name +'" value="'+ e.link_url +'" />'+ e.link_name +'</label></dt></dl></li>';
-                
-        // 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("#add-"+ id +" .list-wrap li:contains('" + data + "')").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( "#edit-item-target option[value='" + itemTarget + "']" ).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( "#edit-menu-item-target option[value='" + item_target + "']" ).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('<li id="menu-' + randomnumber + '" value="' + randomnumber + '"><div class="dropzone ui-droppable"></div><dl class="ui-droppable"><dt><span class="item-title">' + item_title + '</span><span class="item-controls"><span class="item-type">' + item_type + '</span><a class="item-edit thickbox" id="edit' + randomnumber + '" value="' + randomnumber +'" onClick="wp_edit_menu_item('+ randomnumber +')" title="' + navMenuL10n.thickbox + '" href="#TB_inline?height=380&width=300&inlineId=menu-item-settings">' + navMenuL10n.edit + '</a> | <a class="item-delete" id="delete' + randomnumber + '" value="' + randomnumber +'">Delete</a></span></dt></dl><input type="hidden" name="item-postmenu' + randomnumber + '" id="item-postmenu' + randomnumber + '" value="' + item_id + '" /><input type="hidden" name="item-parent' + randomnumber + '" id="item-parent' + randomnumber + '" value="' + item_parent_id + '" /><input type="hidden" name="item-title' + randomnumber + '" id="item-title' + randomnumber + '" value="' + item_title + '" /><input type="hidden" name="item-url' + randomnumber + '" id="item-url' + randomnumber + '" value="' + item_url + '" /><input type="hidden" name="item-description' + randomnumber + '" id="item-description' + randomnumber + '" value="' + item_description + '" /><input type="hidden" name="item-position' + randomnumber + '" id="item-position' + randomnumber + '" value="' + randomnumber + '" /><input type="hidden" name="item-type' + randomnumber + '" id="item-type' + randomnumber + '" value="' + item_type + '" /><input type="hidden" name="item-attr-title' + randomnumber + '" id="item-attr-title' + randomnumber + '" value="' + item_title + '" /><input type="hidden" name="item-target' + randomnumber + '" id="item-target' + randomnumber + '" value="0" /></li>');
</del><ins>+        jQuery('.menu').append('<li id="menu-item' + randomnumber + '" value="' + randomnumber + '"><div class="dropzone ui-droppable"></div><dl class="ui-droppable"><dt><span class="item-title">' + item_title + '</span><span class="item-controls"><span class="item-type">' + item_append + '</span><a class="item-edit thickbox" id="edit' + randomnumber + '" value="' + randomnumber +'" onClick="wp_edit_menu_item('+ randomnumber +')" title="' + navMenuL10n.thickbox + '" href="#TB_inline?height=540&width=300&inlineId=menu-item-settings">' + navMenuL10n.edit + '</a> | <a class="item-delete" id="delete' + randomnumber + '" value="' + randomnumber +'">Delete</a></span></dt></dl>' + hidden + '</li>');
</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('<li id="menu-' + randomnumber + '" value="' + randomnumber + '"><div class="dropzone ui-droppable"></div><dl class="ui-droppable"><dt><span class="item-title">' + item_title + '</span><span class="item-controls"><span class="item-type">' + item_type + '</span><a class="item-edit thickbox" id="edit' + randomnumber + '" value="' + randomnumber +'" onClick="wp_edit_menu_item('+ randomnumber +')" title="' + navMenuL10n.thickbox + '" href="#TB_inline?height=380&width=300&inlineId=menu-item-settings">' + navMenuL10n.edit + '</a> | <a class="item-delete" id="delete' + randomnumber + '" value="' + randomnumber +'">Delete</a></span></dt></dl><input type="hidden" name="item-postmenu' + randomnumber + '" id="item-postmenu' + randomnumber + '" value="' + item_id + '" /><input type="hidden" name="item-parent' + randomnumber + '" id="item-parent' + randomnumber + '" value="' + item_parent_id + '" /><input type="hidden" name="item-title' + randomnumber + '" id="item-title' + randomnumber + '" value="' + item_title + '" /><input type="hidden" name="item-url' + randomnumber + '" id="item-url' + randomnumber + '" value="' + item_url + '" /><input type="hidden" name="item-description' + randomnumber + '" id="item-description' + randomnumber + '" value="' + item_description + '" /><input type="hidden" name="item-position' + randomnumber + '" id="item-position' + randomnumber + '" value="' + randomnumber + '" /><input type="hidden" name="item-type' + randomnumber + '" id="item-type' + randomnumber + '" value="' + item_type + '" /><input type="hidden" name="item-attr-title' + randomnumber + '" id="item-attr-title' + randomnumber + '" value="' + item_title + '" /><input type="hidden" name="item-target' + randomnumber + '" id="item-target' + randomnumber + '" value="0" /><input type="hidden" name="item-id' + randomnumber + '" id="item-id' + randomnumber + '" value="'+ menu_item_id +'" /></li>');
-                
-        } else {
-                // Remove the item from the queue
-                if ( menu_item_id == jQuery('#queue li input[name^="item-id"]' ).val() ) {
-                        jQuery('#queue li input[name^="item-id"]' ).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 += '<input type="hidden" name="menu-item-db-id[]" id="menu-item-db-id' + randomnumber + '" value="' + item_db_id + '" />';
+        hidden += '<input type="hidden" name="menu-item-object-id[]" id="menu-item-object-id' + randomnumber + '" value="' + item_object_id + '" />';
+        hidden += '<input type="hidden" name="menu-item-type[]" id="menu-item-type' + randomnumber + '" value="' + item_type + '" />';
+        hidden += '<input type="hidden" name="menu-item-append[]" id="menu-item-append' + randomnumber + '" value="' + item_append + '" />';
+        hidden += '<input type="hidden" name="menu-item-parent-id[]" id="menu-item-parent-id' + randomnumber + '" value="' + item_parent_id + '" />';
+        hidden += '<input type="hidden" name="menu-item-position[]" id="menu-item-position' + randomnumber + '" value="' + randomnumber + '" />';
+        hidden += '<input type="hidden" name="menu-item-title[]" id="menu-item-title' + randomnumber + '" value="' + item_title + '" />';
+        hidden += '<input type="hidden" name="menu-item-attr-title[]" id="menu-item-attr-title' + randomnumber + '" value="' + item_attr_title + '" />';
+        hidden += '<input type="hidden" name="menu-item-url[]" id="menu-item-url' + randomnumber + '" value="' + item_url + '" />';
+        hidden += '<input type="hidden" name="menu-item-target[]" id="menu-item-target' + randomnumber + '" value="' + item_target + '" />';
+        hidden += '<input type="hidden" name="menu-item-description[]" id="menu-item-description' + randomnumber + '" value="' + item_description + '" />';
+        hidden += '<input type="hidden" name="menu-item-classes[]" id="menu-item-classes' + randomnumber + '" value="' + item_classes + '" />';
+        hidden += '<input type="hidden" name="menu-item-xfn[]" id="menu-item-xfn' + randomnumber + '" value="' + item_xfn + '" />';
+        
+        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='<li><dl><dt><label class="item-title"><input type="checkbox" id="link-'+e.link_id+'" name="'+e.link_name+'" value="'+e.link_url+'" />'+e.link_name+"</label></dt></dl></li>";jQuery("#available-links .list").prepend(link);jQuery("#available-links .list #link-"+e.link_id).parent().animate({backgroundColor:"#FFFF33"},{duration:"normal",complete:function(){jQuery(this).css("backgroundColor","")}})}function wp_edit_menu_item(id){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();if("page"==itemType||"category"==itemType){jQuery("#edit-item-url").attr("disabled","disabled")}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("#edit-item-target option[value='"+itemTarget+"']").attr("selected","selected");jQuery("#edit-item-description").val(itemDesc)}function wp_update_menu_item(){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();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)}function wp_remove_menu_item(o){var todelete=document.getElementById("menu-"+o);if(todelete){jQuery(todelete).find("dt").each(function(){jQuery(this).animate({backgroundColor:"#FF3333"},{duration:"normal",complete:function(){jQuery(this).parent().parent().remove()}})});wp_update_post_data()}}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){}else{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)})}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(".menu").append('<li id="menu-'+randomnumber+'" value="'+randomnumber+'"><div class="dropzone ui-droppable"></div><dl class="ui-droppable"><dt><span class="item-title">'+item_title+'</span><span class="item-controls"><span class="item-type">'+item_type+'</span><a class="item-edit thickbox" id="edit'+randomnumber+'" value="'+randomnumber+'" onClick="wp_edit_menu_item('+randomnumber+')" title="'+navMenuL10n.thickbox+'" href="#TB_inline?height=380&width=300&inlineId=menu-item-settings">'+navMenuL10n.edit+'</a> | <a class="item-delete" id="delete'+randomnumber+'" value="'+randomnumber+'">Delete</a></span></dt></dl><input type="hidden" name="item-postmenu'+randomnumber+'" id="item-postmenu'+randomnumber+'" value="'+item_id+'" /><input type="hidden" name="item-parent'+randomnumber+'" id="item-parent'+randomnumber+'" value="'+item_parent_id+'" /><input type="hidden" name="item-title'+randomnumber+'" id="item-title'+randomnumber+'" value="'+item_title+'" /><input type="hidden" name="item-url'+randomnumber+'" id="item-url'+randomnumber+'" value="'+item_url+'" /><input type="hidden" name="item-description'+randomnumber+'" id="item-description'+randomnumber+'" value="'+item_description+'" /><input type="hidden" name="item-position'+randomnumber+'" id="item-position'+randomnumber+'" value="'+randomnumber+'" /><input type="hidden" name="item-type'+randomnumber+'" id="item-type'+randomnumber+'" value="'+item_type+'" /><input type="hidden" name="item-attr-title'+randomnumber+'" id="item-attr-title'+randomnumber+'" value="'+item_title+'" /><input type="hidden" name="item-target'+randomnumber+'" id="item-target'+randomnumber+'" value="0" /></li>');jQuery(".menu #menu-"+randomnumber+" dt:first").animate({backgroundColor:"#FFFF33"},{duration:"normal",complete:function(){jQuery(this).css("backgroundColor","")}});wp_drag_and_drop();wp_update_post_data();tb_init("a.thickbox, area.thickbox, input.thickbox")}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")){jQuery("#queue").append('<li id="menu-'+randomnumber+'" value="'+randomnumber+'"><div class="dropzone ui-droppable"></div><dl class="ui-droppable"><dt><span class="item-title">'+item_title+'</span><span class="item-controls"><span class="item-type">'+item_type+'</span><a class="item-edit thickbox" id="edit'+randomnumber+'" value="'+randomnumber+'" onClick="wp_edit_menu_item('+randomnumber+')" title="'+navMenuL10n.thickbox+'" href="#TB_inline?height=380&width=300&inlineId=menu-item-settings">'+navMenuL10n.edit+'</a> | <a class="item-delete" id="delete'+randomnumber+'" value="'+randomnumber+'">Delete</a></span></dt></dl><input type="hidden" name="item-postmenu'+randomnumber+'" id="item-postmenu'+randomnumber+'" value="'+item_id+'" /><input type="hidden" name="item-parent'+randomnumber+'" id="item-parent'+randomnumber+'" value="'+item_parent_id+'" /><input type="hidden" name="item-title'+randomnumber+'" id="item-title'+randomnumber+'" value="'+item_title+'" /><input type="hidden" name="item-url'+randomnumber+'" id="item-url'+randomnumber+'" value="'+item_url+'" /><input type="hidden" name="item-description'+randomnumber+'" id="item-description'+randomnumber+'" value="'+item_description+'" /><input type="hidden" name="item-position'+randomnumber+'" id="item-position'+randomnumber+'" value="'+randomnumber+'" /><input type="hidden" name="item-type'+randomnumber+'" id="item-type'+randomnumber+'" value="'+item_type+'" /><input type="hidden" name="item-attr-title'+randomnumber+'" id="item-attr-title'+randomnumber+'" value="'+item_title+'" /><input type="hidden" name="item-target'+randomnumber+'" id="item-target'+randomnumber+'" value="0" /><input type="hidden" name="item-id'+randomnumber+'" id="item-id'+randomnumber+'" value="'+menu_item_id+'" /></li>')}else{if(menu_item_id==jQuery('#queue li input[name^="item-id"]').val()){jQuery('#queue li input[name^="item-id"]').parent().remove()}}}function wp_add_queued_items_to_menu(button){var items=jQuery("#queue").children();jQuery("#queue").empty();jQuery(".menu").append(items);jQuery(items).each(function(){jQuery(this).find("dt").animate({backgroundColor:"#FFFF33"},{duration:"normal",complete:function(){jQuery(this).css("backgroundColor","")}})});jQuery(button).offsetParent().find(".list-container input").attr("checked",false);wp_update_post_data();wp_drag_and_drop();tb_init("a.thickbox, area.thickbox, input.thickbox")}function wp_drag_and_drop(){jQuery(".menu li").each(function(){if(!jQuery(this).children(".dropzone").attr("class")){jQuery(this).prepend('<div class="dropzone"></div>')}});jQuery(".menu li").draggable({handle:" > dl",opacity:0.8,addClasses:false,helper:"clone",zIndex:100,});jQuery(".menu li dl, .menu li .dropzone").droppable({accept:".menu li",tolerance:"pointer",drop:function(e,ui){var li=jQuery(this).parent();var child=!jQuery(this).hasClass("dropzone");if(child&&li.children("ul").length==0){li.append('<ul class="sub-menu" />')}if(child){li.children("ul").append(ui.draggable)}else{li.before(ui.draggable)}li.find("dl,.dropzone").css({backgroundColor:"",borderColor:""});var draggablevalue=ui.draggable.attr("value");var droppablevalue=li.attr("value");li.find("#menu-"+draggablevalue).find("#parent"+draggablevalue).val(droppablevalue);jQuery(this).parent().find("dt").removeAttr("style");jQuery(this).parent().find("div:first").removeAttr("style")},over:function(){if(jQuery(this).attr("class")=="dropzone ui-droppable"){jQuery(this).parent().find("div:first").css("background","none").css("height","50px")}else{if(jQuery(this).attr("class")=="ui-droppable"){jQuery(this).parent().find("dt:first").css("background","#d8d8d8")}else{}}var parentid=jQuery(this).parent().attr("id")},out:function(){jQuery(this).parent().find("dt").removeAttr("style");jQuery(this).parent().find("div:first").removeAttr("style");jQuery(this).filter(".dropzone").css({borderColor:""})}})}function wp_get_unique_menu_id(){var count=jQuery(".menu li").length+1;var randomnumber=count;var validatetest=0;try{var test=document.getElementById("menu-"+randomnumber.toString()).value}catch(err){validatetest=1}while(validatetest==0){randomnumber=randomnumber+1;try{var test2=document.getElementById("menu-"+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("#add-"+a+" .quick-search").autocomplete(jQuery("#add-"+a+" .autocomplete").val().split("|"));jQuery("#add-"+a+" .quick-search").result(function(b,d,c){jQuery("#add-"+a+" .list-wrap").css("display","block");jQuery("#add-"+a+" .list-wrap li:contains('"+d+"')").css("display","block");jQuery("#add-"+a+" .show-all").hide();jQuery("#add-"+a+" .hide-all").show()})}function wp_edit_menu_item(a){var f=jQuery("#menu-item-type"+a).val();var b=jQuery("#menu-item-title"+a).val();var g=jQuery("#menu-item-url"+a).val();var c=jQuery("#menu-item-attr-title"+a).val();var d=jQuery("#menu-item-target"+a).val();var h=jQuery("#menu-item-description"+a).val();var e=jQuery("#menu-item-classes"+a).val();var i=jQuery("#menu-item-xfn"+a).val();if("custom"!=f){jQuery("#edit-menu-item-url").attr("disabled","disabled")}jQuery("#edit-menu-item-id").val(a);jQuery("#edit-menu-item-title").val(b);jQuery("#edit-menu-item-url").val(g);jQuery("#edit-menu-item-attr-title").val(c);jQuery("#edit-menu-item-target").val(d);jQuery("#edit-menu-item-target option[value='"+d+"']").attr("selected","selected");jQuery("#edit-menu-item-description").val(h);jQuery("#edit-menu-item-classes").val(e);jQuery("#edit-menu-item-xfn").val(i);jQuery("#edit-menu-item-title").focus()}function wp_update_menu_item(){var h=jQuery("#edit-menu-item-id").val();var f=jQuery("#edit-menu-item-title").val();var b=jQuery("#edit-menu-item-url").val();var g=jQuery("#edit-menu-item-attr-title").val();var d=jQuery("#edit-menu-item-target").val();var c=jQuery("#edit-menu-item-description").val();var a=jQuery("#edit-menu-item-classes").val();var e=jQuery("#edit-menu-item-xfn").val();jQuery(".menu #menu-item"+h).find("span.item-title").html(f);jQuery(".menu #menu-item-title"+h).val(f);jQuery(".menu #menu-item-url"+h).val(b);jQuery(".menu #menu-item-attr-title"+h).val(g);jQuery(".menu #menu-item-target"+h).val(d);jQuery(".menu #menu-item-description"+h).val(c);jQuery(".menu #menu-item-classes"+h).val(a);jQuery(".menu #menu-item-xfn"+h).val(e);jQuery(".menu #menu-item"+h+" dt:first").animate({backgroundColor:"#FFFF33"},{duration:"normal",complete:function(){jQuery(this).css("backgroundColor","")}})}function wp_remove_menu_item(b){var a=document.getElementById("menu-item"+b);if(a){jQuery(a).find("dt").each(function(){jQuery(this).animate({backgroundColor:"#FF3333"},{duration:"normal",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(".menu").append('<li id="menu-item'+j+'" value="'+j+'"><div class="dropzone ui-droppable"></div><dl class="ui-droppable"><dt><span class="item-title">'+b+'</span><span class="item-controls"><span class="item-type">'+n+'</span><a class="item-edit thickbox" id="edit'+j+'" value="'+j+'" onClick="wp_edit_menu_item('+j+')" title="'+navMenuL10n.thickbox+'" href="#TB_inline?height=540&width=300&inlineId=menu-item-settings">'+navMenuL10n.edit+'</a> | <a class="item-delete" id="delete'+j+'" value="'+j+'">Delete</a></span></dt></dl>'+g+"</li>");jQuery(".menu #menu-item"+j+" dt:first").animate({backgroundColor:"#FFFF33"},{duration:"normal",complete:function(){jQuery(this).css("backgroundColor","")}});wp_drag_and_drop();tb_init("a.thickbox, area.thickbox, input.thickbox")}function wp_add_checked_items_to_menu(b){var a=jQuery(b).siblings(".list-wrap").find(":checked");if(0==a.length){return false}jQuery(a).each(function(){var h=jQuery(this).parent().siblings(".menu-item-type").val();if("custom"==h){var e=jQuery(this).parent().siblings(".menu-item-attr-title").val();var f=jQuery(this).parent().siblings(".menu-item-target").val();var g=jQuery(this).parent().siblings(".menu-item-classes").val();var j=jQuery(this).parent().siblings(".menu-item-xfn").val()}else{var e="";var f="_none";var g="";var j=""}var c=jQuery(this).parent().siblings(".menu-item-db-id").val();var k=jQuery(this).parent().siblings(".menu-item-object-id").val();var n=jQuery(this).parent().siblings(".menu-item-append").val();var l=jQuery(this).parent().siblings(".menu-item-parent-id").val();var d=jQuery(this).parent().siblings(".menu-item-title").val();var m=jQuery(this).parent().siblings(".menu-item-url").val();var i=jQuery(this).parent().siblings(".menu-item-description").val();if(undefined==i){i=""}wp_add_item_to_menu(c,k,h,n,l,d,m,i,e,f,g,j);jQuery(this).attr("checked",false)})}function wp_drag_and_drop(){jQuery(".menu li").each(function(){if(!jQuery(this).children(".dropzone").attr("class")){jQuery(this).prepend('<div class="dropzone"></div>')}});jQuery(".menu li").draggable({handle:" > dl",opacity:0.8,addClasses:false,helper:"clone",zIndex:100});jQuery(".menu li dl, .menu li .dropzone").droppable({accept:".menu li",tolerance:"pointer",drop:function(f,d){var a=jQuery(this).parent();var g=!jQuery(this).hasClass("dropzone");if(g&&a.children("ul").length==0){a.append('<ul class="sub-menu" />')}if(g){a.children("ul").append(d.draggable)}else{a.before(d.draggable)}a.find("dl,.dropzone").css({backgroundColor:"",borderColor:""});var c=d.draggable.attr("value");var b=a.attr("value");a.find("#menu-"+c).find("#parent"+c).val(b);jQuery(this).parent().find("dt").removeAttr("style");jQuery(this).parent().find("div:first").removeAttr("style")},over:function(){if(jQuery(this).attr("class")=="dropzone ui-droppable"){jQuery(this).parent().find("div:first").css("background","none").css("height","50px")}else{if(jQuery(this).attr("class")=="ui-droppable"){jQuery(this).parent().find("dt:first").css("background","#d8d8d8")}else{}}var a=jQuery(this).parent().attr("id")},out:function(){jQuery(this).parent().find("dt").removeAttr("style");jQuery(this).parent().find("div:first").removeAttr("style");jQuery(this).filter(".dropzone").css({borderColor:""})}})}function wp_update_post_data(){var a=0;jQuery(".menu li").each(function(c){c=c+1;var b=jQuery(this).attr("value");jQuery(this).find("#menu-item-position"+b).attr("value",c);jQuery(this).attr("id","menu-item"+c);jQuery(this).attr("value",c);jQuery(this).find("#menu-item-db-id"+b).attr("id","menu-item-db-id"+c);jQuery(this).find("#menu-item-object-id"+b).attr("id","menu-item-object-id"+c);jQuery(this).find("#menu-item-append"+b).attr("id","menu-item-append"+c);jQuery(this).find("#menu-item-type"+b).attr("id","menu-item-type"+c);jQuery(this).find("#menu-item-position"+b).attr("id","menu-item-position"+c);var d=jQuery(this).find("#menu-item-parent-id"+b).parent().parent().parent().attr("value");jQuery(this).find("#menu-item-parent-id"+b).attr("id","menu-item-parent-id"+c);if(d){}else{d=0}jQuery(this).find("#menu-item-parent-id"+b).attr("value",d);jQuery(this).find("#menu-item-title"+b).attr("id","menu-item-title"+c);jQuery(this).find("#menu-item-url"+b).attr("id","menu-item-url"+c);jQuery(this).find("#menu-item-description"+b).attr("id","menu-item-description"+c);jQuery(this).find("#menu-item-classes"+b).attr("id","menu-item-classes"+c);jQuery(this).find("#menu-item-xfn"+b).attr("id","menu-item-xfn"+c);jQuery(this).find("#menu-item-description"+b).attr("id","menu-item-description"+c);jQuery(this).find("#menu-item-attr-title"+b).attr("id","menu-item-attr-title"+c);jQuery(this).find("#menu-item-target"+b).attr("id","menu-item-target"+c);jQuery("#li-count").attr("value",c)})}function wp_get_unique_menu_id(){var d=jQuery(".menu li").length+1;var e=d;var a=0;try{var f=document.getElementById("menu-"+e.toString()).value}catch(c){a=1}while(a==0){e=e+1;try{var b=document.getElementById("menu-"+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="";g+='<input type="hidden" name="menu-item-db-id[]" id="menu-item-db-id'+j+'" value="'+a+'" />';g+='<input type="hidden" name="menu-item-object-id[]" id="menu-item-object-id'+j+'" value="'+k+'" />';g+='<input type="hidden" name="menu-item-type[]" id="menu-item-type'+j+'" value="'+f+'" />';g+='<input type="hidden" name="menu-item-append[]" id="menu-item-append'+j+'" value="'+n+'" />';g+='<input type="hidden" name="menu-item-parent-id[]" id="menu-item-parent-id'+j+'" value="'+l+'" />';g+='<input type="hidden" name="menu-item-position[]" id="menu-item-position'+j+'" value="'+j+'" />';g+='<input type="hidden" name="menu-item-title[]" id="menu-item-title'+j+'" value="'+b+'" />';g+='<input type="hidden" name="menu-item-attr-title[]" id="menu-item-attr-title'+j+'" value="'+e+'" />';g+='<input type="hidden" name="menu-item-url[]" id="menu-item-url'+j+'" value="'+m+'" />';g+='<input type="hidden" name="menu-item-target[]" id="menu-item-target'+j+'" value="'+d+'" />';g+='<input type="hidden" name="menu-item-description[]" id="menu-item-description'+j+'" value="'+h+'" />';g+='<input type="hidden" name="menu-item-classes[]" id="menu-item-classes'+j+'" value="'+c+'" />';g+='<input type="hidden" name="menu-item-xfn[]" id="menu-item-xfn'+j+'" value="'+i+'" />';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&#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']) && $_GET['delete-menu'] > 0 ) {
-        // if ( ! current_user_can('delete_menus') )
-        //         wp_die( __( 'Cheatin&#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 = '<div id="message" class="updated fade below-h2"><p>' . __('Menu successfully deleted.') . '</p></div>';
-        $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 = '<div id="message" class="updated fade below-h2"><p>' . __('Menu successfully deleted.') . '</p></div>';
+                        $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) && 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 && ! empty($menus) )
-        $menu_selected_id = $menus[0]->term_id;
-
-// Get the name of the current Menu
-$menu_title = '';
-$valid_menu = false;
-if ( $menu_selected_id > 0 ) {
-        foreach ( $menus as $menu ) {
-                if ( $menu->term_id == $menu_selected_id ) {
-                        $menu_title = $menu->name;
-                        $valid_menu = true;
-                        break;
</del><ins>+                                        if ( is_wp_error( $add_nav_menu ) ) {
+                                                $messages_div = '<div id="message" class="error fade below-h2"><p>' . $add_nav_menu->get_error_message() . '</p></div>';
+                                        } else {
+                                                $nav_menu_selected_id = $add_nav_menu->term_id;
+                                                $nav_menu_selected_title = $add_nav_menu->name;
+                                                $messages_div = '<div id="message" class="updated fade below-h2"><p>' . sprintf( __('The <strong>%s</strong> menu has been successfully created.'), esc_html( $add_nav_menu->name ) ) . '</p></div>';
+                                        }
+                                } else {
+                                        $messages_div = '<div id="message" class="error fade below-h2"><p>' . __('Please enter a valid menu name.') . '</p></div>';
+                                }
+                                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' => $_POST['menu-name'], 'slug' => null, 'description' => $old_nav_menu['description'], 'parent' => $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' => 'ID', 'output' => ARRAY_A, 'output_key' => 'ID') );
+                        $parent_menu_ids = array();
+                        
+                        // Loop through all POST variables
+                        for ( $k = 0; $k < $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' => 'publish', 'post_type' => 'nav_menu_item', 'post_author' => $user_ID,
+                                        'ping_status' => 0, 'post_parent' => $menu_item_parent_id, 'menu_order' => $menu_item_position,
+                                        'post_excerpt' => $menu_item_attr_title, 'tax_input' => array( 'nav_menu' => $update_nav_menu->name ),
+                                        'post_content' => $menu_item_description, 'post_title' => $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'] ) && ! $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 = '<div id="message" class="error fade below-h2"><p>' . $menu->get_error_message() . '</p></div>';
-                } else {
-                        $menus[$menu->term_id] = $menu;
-                        $menu_selected_id = $menu->term_id;
-                        $menu_id_in_edit = $menu_selected_id;
-                        $menu_title = $menu->name;
-                        $messages_div = '<div id="message" class="updated fade below-h2"><p>' . sprintf( __('&#8220;%s&#8221; menu has been created.'), esc_html( $menu->name ) ) . '</p></div>';
-                        $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 = '<div id="message" class="updated fade below-h2"><p>' . __('The menu has been updated.') . '</p></div>';
</ins><span class="cx">                 }
</span><del>-        } else {
-                $messages_div = '<div id="message" class="error fade below-h2"><p>' . __('Please enter a valid menu name.') . '</p></div>';
-        }
-        $updated = true;
</del><ins>+                break;
</ins><span class="cx"> }
</span><span class="cx">
</span><del>-if ( $post_counter > 0 && $menu_selected_id > 0 && ! $updated ) {
-        $menu_items = wp_get_nav_menu_items( $menu_selected_id, array('orderby' => 'ID', 'output' => ARRAY_A, 'output_key' => '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 <= $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] ) && '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 && is_nav_menu($nav_menu_selected_id) ) {
+        $recently_edited = $nav_menu_selected_id;
</ins><span class="cx">
</span><del>-                $post = array( 'post_status' => 'publish', 'post_type' => 'nav_menu_item', 'post_author' => $user_ID,
-                        'ping_status' => 0, 'post_parent' => 0, 'menu_order' => $position,
-                        'post_excerpt' => $custom_anchor_title, 'tax_input' => array( 'nav_menu' => $menu_title ),
-                        'post_content' => $custom_description, 'post_title' => $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 && is_nav_menu($recently_edited) ) {
+        $nav_menu_selected_id = $recently_edited;
</ins><span class="cx">
</span><del>-                if ( $parent_id > 0 && 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 && ! empty($nav_menus) ) {
+        $nav_menu_selected_id = $nav_menus[0]->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 && is_nav_menu($nav_menu_selected_id) )
+        update_user_meta( $current_user->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 && $nav_menu_selected_title = is_nav_menu( $nav_menu_selected_id ) ) {
+        $nav_menu_selected_title = $nav_menu_selected_title->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 = '<div id="message" class="updated"><p>' . __('You haven\'t setup any menus yet. Create a new menu.') . '</p></div>';
+        } else {
+                $messages_div = '<div id="message" class="error"><p>' . __('The current theme does not support menus.') . '</p></div>';
</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 = '<div id="message" class="updated fade below-h2"><p>' . __('The menu has been updated.') . '</p></div>';
</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"> ?>
</span><span class="cx"> <div class="wrap">
</span><span class="cx">         <?php screen_icon(); ?>
</span><span class="lines">@@ -180,266 +213,110 @@
</span><span class="cx">         <?php echo $messages_div; ?>
</span><span class="cx">         <div class="hide-if-js error"><p><?php _e('You do not have JavaScript enabled in your browser. Please enable it to access the Menus functionality.'); ?></p></div>
</span><span class="cx">
</span><del>-        <form onsubmit="wp_update_post_data();" action="<?php echo admin_url( 'nav-menus.php' ); ?>" method="post" enctype="multipart/form-data">
-                <?php if ( !empty($menus) && count($menus) > 1 ) : ?>
-                <ul class="subsubsub">
-                        <?php
-                                foreach ( $menus as $menu ) {
-                                        $sep = end( $menus ) == $menu ? '' : ' | ';
-                                        if ( ( $menu_id_in_edit == $menu->term_id ) || ( $menu_selected_id == $menu->term_id ) ) { ?>
-                                                <li><a href='nav-menus.php?edit-menu=<?php echo esc_attr($menu->term_id); ?>' class="current"><?php echo esc_html( $menu->name ); ?></a><?php echo $sep; ?></li>
-                        <?php        } else { ?>
-                                                <li><a href='nav-menus.php?edit-menu=<?php echo esc_attr($menu->term_id); ?>'><?php echo esc_html( $menu->name ); ?></a><?php echo $sep; ?></li>
-                        <?php        }
-                                }
-                        ?>
-                </ul>
-                <?php endif; ?>
</del><ins>+        <?php if ( !empty($nav_menus) && count($nav_menus) > 1 ) : ?>
+        <ul class="subsubsub">
+                <?php
+                        foreach ( $nav_menus as $_nav_menu ) {
+                                $sep = end( $nav_menus ) == $_nav_menu ? '' : ' | ';
+                                
+                                if ( $nav_menu_selected_id == $_nav_menu->term_id )
+                                        echo '<li><a href="'. admin_url( 'nav-menus.php?action=edit&amp;menu=' . esc_attr($_nav_menu->term_id) ) .'" class="current">'. esc_html( $_nav_menu->name ) .'</a>'. $sep .'</li>';
+                                else
+                                        echo '<li><a href="'. admin_url( 'nav-menus.php?action=edit&amp;menu=' . esc_attr($_nav_menu->term_id) ) .'">'. esc_html( $_nav_menu->name ) .'</a>'. $sep .'</li>';
+                        }
+                ?>
+        </ul>
+        <?php endif; ?>
</ins><span class="cx">
</span><del>-                <div id="menu-management" class="metabox-holder has-right-sidebar">
</del><ins>+        <div id="menu-management" class="metabox-holder has-right-sidebar">
+                <form id="update-nav-menu" onsubmit="wp_update_post_data();" action="<?php echo admin_url( 'nav-menus.php' ); ?>" method="post" enctype="multipart/form-data">
+                        <?php wp_nonce_field( 'closedpostboxes', 'closedpostboxesnonce', false ); ?>
+                        <?php wp_nonce_field( 'meta-box-order', 'meta-box-order-nonce', false ); ?>
+                        <?php wp_nonce_field( 'update-nav_menu' ); ?>
+                        <input type="hidden" name="action" value="update" />
+                        <input type="hidden" name="li-count" id="li-count" value="0" />
+                        <input type="hidden" name="menu" id="menu" value="<?php echo esc_attr( $nav_menu_selected_id ); ?>" />
+                        
</ins><span class="cx">                         <div id="post-body">
</span><span class="cx">                                 <div id="post-body-content">
</span><del>-                                        <div id="normal-sortables" class="meta-box-sortables ui-sortable">
-                                        <?php if ( $valid_menu and ! empty( $menus ) ) : ?>
</del><ins>+                                        <?php if ( is_nav_menu($nav_menu_selected_id) ) : ?>
</ins><span class="cx">                                                 <div id="menu-container" class="postbox">
</span><del>-                                                        <h3 class="hndle"><?php echo esc_html( $menu_title ); ?></h3>
</del><ins>+                                                        <h3 class="hndle"><?php echo esc_html( $nav_menu_selected_title ); ?></h3>
</ins><span class="cx">                                                         <div class="inside">
</span><del>-                                                                <input type="hidden" name="li-count" id="li-count" value="0" />
-                                                                <input type="hidden" name="menu-id-in-edit" id="menu-id-in-edit" value="<?php echo esc_attr( $menu_selected_id ); ?>" />
-                                                                <?php
-                                                                if ( $menu_selected_id > 0 )
-                                                                        echo wp_get_nav_menu( array( 'type' => 'backend', 'menu' => $menu_selected_id, 'ul_class' => 'menu' ) );
-                                                                ?>
-
-                                                                <div id="queue" class="hide">
-                                                                </div><!--/#queue-->
</del><ins>+                                                                
+                                                                <?php echo wp_get_nav_menu( array( 'context' => 'backend', 'menu' => $nav_menu_selected_id ) ); ?>
+                                                                
</ins><span class="cx">                                                         </div><!-- /.inside -->
</span><span class="cx">                                                 <!-- /#nav-menu-canvas .postbox-->
</span><span class="cx">                                                 </div>
</span><del>-                                                <p>
-                                                        <script type="text/javascript">
-                                                                wp_update_post_data();
-                                                        </script>
-                                                        <a class="submitdelete deletion" href="<?php echo wp_nonce_url( admin_url('nav-menus.php?delete-menu=' . $menu_selected_id), 'delete_menu-' . $menu_selected_id ); ?>"><?php _e('Delete Menu'); ?></a>
-                                                        <input class="button-primary save" name="save_menu" type="submit" value="<?php esc_attr_e('Save All Changes'); ?>" />
-                                                        <br class="clear" />
-                                                </p>
</del><ins>+                                                <script type="text/javascript">
+                                                        wp_update_post_data();
+                                                </script>
</ins><span class="cx">                                         <?php endif; ?>
</span><del>-                                        </div><!-- /#normal-sortables-->
</del><span class="cx">                                 </div><!-- /#post-body-content-->
</span><span class="cx">                         </div><!--- /#post-body -->
</span><span class="cx">                         <div id="menu-settings-column" class="inner-sidebar">
</span><del>-                                <div id="side-sortables" class="meta-box-sortables ui-sortable">
-
-                                        <div id="create-menu" class="postbox">
-                                                <h3 class="hndle"><?php esc_html_e('Create Menu'); ?></h3>
-                                                <div class="inside">
-                                                        <p>
-                                                                <input type="text" name="create-menu-name" id="create-menu-name" class="regular-text" value="" />
-                                                                <input type="submit" name="create-menu" id="create-menu" class="button" value="<?php esc_attr_e('Create Menu'); ?>" />
-                                                        </p>
-                                                </div><!-- /.inside-->
-                                        </div><!--END #create-menu-->
-
-                                        <div id="add-custom-link" class="postbox">
-                                                <h3 class="hndle"><?php esc_html_e('Add a Custom Link'); ?></h3>
-                                                <div class="inside">
-                                                        <p id="menu-item-url-wrap">
-                                                                <label class="howto" for="menu-item-url">
-                                                                        <span><?php _e('URL'); ?></span>
-                                                                        <input id="menu-item-url" name="menu-item-url" type="text" class="code" value="http://" />
-                                                                </label>
-                                                        </p>
-                                                        <br class="clear" />
-                                                        <p id="menu-item-name-wrap">
-                                                                <label class="howto" for="custom-menu-item-name">
-                                                                        <span><?php _e('Text'); ?></span>
-                                                                        <input id="menu-item-name" type="text" class="regular-text" value="<?php echo esc_attr( __('Menu Item') ); ?>" />
-                                                                </label>
-                                                        </p>
-
-                                                        <p class="button-controls">
-                                                                <a class="show-all"><?php _e('View All'); ?></a>
-                                                                <a class="hide-all"><?php _e('Hide All'); ?></a>
-                                                        </p>
-                                                        <div id="available-links" class="list-wrap">
-                                                                <div class="list-container">
-                                                                        <ul class="list">
-                                                                        <?php $items_counter = wp_nav_menu_get_custom_links( 0, 'default' ); ?>
-                                                                        </ul>
-                                                                </div><!-- /.list-container-->
-                                                        </div><!-- /#available-links-->
-                                                        <p class="add-to-menu">
-                                                                <a class="button"><?php _e('Add to Menu'); ?></a>
-                                                        </p>
-                                                        <br class="clear" />
-                                                </div><!-- /.inside-->
-                                        </div><!-- /#add-custom-link-->
-
-                                        <div id="add-pages" class="postbox">
-                                                <h3 class="hndle"><?php esc_html_e('Add an Existing Page'); ?></h3>
-                                                <div class="inside">
-                                                        <?php
-                                                                $pages_args = array(
-                                                                        'child_of' => 0, 'sort_order' => 'ASC', 'sort_column' => 'post_title', 'hierarchical' => 1,
-                                                                        'exclude' => '', 'include' => '', 'meta_key' => '', 'meta_value' => '', 'authors' => '',
-                                                                        'parent' => -1, 'exclude_tree' => '', 'number' => '', 'offset' => 0
-                                                                );
-                                                                $page_name = '';
-                                                                $pages_array = get_pages( $pages_args );
-                                                                if ( $pages_array ) {
-                                                                        foreach ( $pages_array as $post ) {
-                                                                                $page_name .= $post->post_title . '|';
-                                                                        }
-                                                                } else {
-                                                                        $page_name = __('No pages available');
-                                                                }
-                                                        ?>
-                                                        <script type="text/javascript" charset="<?php bloginfo('charset'); ?>">
-                                                                jQuery(document).ready(function(){
-                                                                        var posts = "<?php echo esc_js( $page_name ); ?>".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("#add-pages .list-wrap li:contains('" + data + "')").css('display','block');
-                                                                                jQuery('#add-pages .show-all').hide();
-                                                                                jQuery('#add-pages .hide-all').show();
-                                                                        });
-                                                                });
-                                                        </script>
-                                                        <p>
-                                                                <input type="text" class="quick-search regular-text" value="" />
-                                                                <a class="quick-search-submit button"><?php _e('Search'); ?></a>
-                                                        </p>
-
-                                                        <p class="button-controls">
-                                                                <a class="show-all"><?php _e('View All'); ?></a>
-                                                                <a class="hide-all"><?php _e('Hide All'); ?></a>
-                                                        </p>
-
-                                                        <div id="existing-pages" class="list-wrap">
-                                                                <div class="list-container">
-                                                                        <ul class="list">
-                                                                        <?php $items_counter = wp_nav_menu_get_pages( $items_counter, 'default' ); ?>
-                                                                        </ul>
-                                                                </div><!-- /.list-container-->
-                                                        </div><!-- /#existing-pages-->
-                                                        <p class="add-to-menu enqueue">
-                                                                <a class="button"><?php _e('Add to Menu'); ?></a>
-                                                        </p>
-                                                        <br class="clear" />
-                                                </div><!-- /.inside-->
-                                        </div><!--END #add-pages-->
-
-                                        <div id="add-categories" class="postbox">
-                                                <h3 class="hndle"><?php esc_html_e('Add an Existing Category'); ?></h3>
-                                                <div class="inside">
-                                                        <?php
-                                                                // Custom GET categories query
-                                                                // @todo Use API
-                                                                $categories = $wpdb->get_results("SELECT term_id FROM $wpdb->term_taxonomy WHERE taxonomy = 'category' ORDER BY term_id ASC");
-                                                                $cat_name = '';
-                                                                if ( $categories ) {
-                                                                        foreach ( $categories as $category ) {
-                                                                                $cat_id = $category->term_id;
-                                                                                $cat_args = array(
-                                                                                        'orderby' => 'name',
-                                                                                        'include' => $cat_id,
-                                                                                        'hierarchical' => 1,
-                                                                                        'order' => 'ASC',
-                                                                                );
-                                                                                $category_names = get_categories( $cat_args );
-                                                                                if ( isset( $category_names[0]->name ) ) {
-                                                                                        $cat_name .= htmlentities( $category_names[0]->name ).'|';
-                                                                                }
-                                                                        }
-                                                                } else {
-                                                                        $cat_name = __('No categories available');
-                                                                }
-                                                        ?>
-                                                        <script type="text/javascript" charset="<?php bloginfo('charset'); ?>">
-                                                                jQuery(document).ready(function(){
-                                                                        var categories = "<?php echo esc_js($cat_name); ?>".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("#add-categories .list-wrap li:contains('" + data + "')").css('display','block');
-                                                                                jQuery('#add-categories .show-all').hide();
-                                                                                jQuery('#add-categories .hide-all').show();
-                                                                        });
-                                                                });
-                                                        </script>
-                                                        <p>
-                                                                <input type="text" class="quick-search regular-text" value="" />
-                                                                <a class="quick-search-submit button"><?php _e('Search'); ?></a>
-                                                        </p>
-
-                                                        <p class="button-controls">
-                                                                <a class="show-all"><?php _e('View All'); ?></a>
-                                                                <a class="hide-all"><?php _e('Hide All'); ?></a>
-                                                        </p>
-
-                                                        <div id="existing-categories" class="list-wrap">
-                                                                <div class="list-container">
-                                                                        <ul class="list">
-                                                                                <?php $items_counter = wp_nav_menu_get_categories( $items_counter, 'default' ); ?>
-                                                                        </ul>
-                                                                </div><!-- /.list-container-->
-                                                        </div><!-- /#existing-categories-->
-                                                        <p class="add-to-menu enqueue">
-                                                                <a class="button"><?php _e('Add to Menu'); ?></a>
-                                                        </p>
-                                                        <br class="clear" />
-                                                </div><!-- /.inside-->
-                                        </div><!--END #add-categories-->
-                                </div><!-- /#side-sortables-->
</del><ins>+                                
+                                <?php do_meta_boxes( 'menus', 'side', null ); ?>
+                                
</ins><span class="cx">                         </div><!-- /#menu-settings-column -->
</span><del>-                        <br class="clear" />
-                </div><!-- /.metabox-holder has-right-sidebar-->
-        </form>
</del><ins>+                </form><!--/#update-nav-menu-->
+                <br class="clear" />
+        </div><!-- /.metabox-holder has-right-sidebar-->
</ins><span class="cx"> </div><!-- /.wrap-->
</span><span class="cx">
</span><span class="cx"> <div id="menu-item-settings">
</span><span class="cx">         <p class="description">
</span><del>-                <label for="edit-item-title">
</del><ins>+                <label for="edit-menu-item-title">
</ins><span class="cx">                         <?php _e( 'Menu Title' ); ?><br />
</span><del>-                        <input type="text" id="edit-item-title" class="widefat" name="edit-item-title" value="" tabindex="1" />
</del><ins>+                        <input type="text" id="edit-menu-item-title" class="widefat" name="edit-menu-item-title" value="" tabindex="1" />
</ins><span class="cx">                 </label>
</span><span class="cx">         </p>
</span><span class="cx">         <p class="description">
</span><del>-                <label for="edit-item-url">
</del><ins>+                <label for="edit-menu-item-url">
</ins><span class="cx">                         <?php _e( 'URL' ); ?><br />
</span><del>-                        <input type="text" id="edit-item-url" class="widefat code" name="edit-item-url" value="" tabindex="2" />
</del><ins>+                        <input type="text" id="edit-menu-item-url" class="widefat code" name="edit-menu-item-url" value="" tabindex="2" />
</ins><span class="cx">                 </label>
</span><span class="cx">         </p>
</span><span class="cx">         <p class="description">
</span><del>-                <label for="edit-item-attr-title">
-                        <?php _e( 'Attribute Title' ); ?><br />
-                        <input type="text" id="edit-item-attr-title" class="widefat" name="edit-item-attr-title" value="" tabindex="3" />
</del><ins>+                <label for="edit-menu-item-attr-title">
+                        <?php _e( 'Title Attribute' ); ?><br />
+                        <input type="text" id="edit-menu-item-attr-title" class="widefat" name="edit-menu-item-attr-title" value="" tabindex="3" />
</ins><span class="cx">                 </label>
</span><span class="cx">         </p>
</span><span class="cx">         <p class="description">
</span><del>-                <label for="edit-item-target">
-                        <?php _e( 'Open Link in a new window' ); ?><br />
-                        <select id="edit-item-target" class="widefat" name="edit-item-target">
-                                <option value="1">Yes</option>
-                                <option value="0">No</option>
</del><ins>+                <label for="edit-menu-item-target">
+                        <?php _e( 'Link Target' ); ?><br />
+                        <select id="edit-menu-item-target" class="widefat" name="edit-menu-item-target" tabindex="4">
+                                <option value="_self">Same window or tab</option>
+                                <option value="_blank">New window or tab</option>
</ins><span class="cx">                         </select>
</span><span class="cx">                 </label>
</span><span class="cx">         </p>
</span><span class="cx">         <p class="description">
</span><del>-                <label for="edit-item-description">
-                        <?php _e( 'Description' ); ?><br />
-                        <textarea id="edit-item-description" class="widefat" rows="3" name="edit-item-description" tabindex="4" /></textarea>
</del><ins>+                <label for="edit-menu-item-classes">
+                        <?php _e( 'CSS Classes (optional)' ); ?><br />
+                        <input type="text" id="edit-menu-item-classes" class="widefat code" name="edit-menu-item-classes" value="" tabindex="5" />
</ins><span class="cx">                 </label>
</span><span class="cx">         </p>
</span><ins>+        <p class="description">
+                <label for="edit-menu-item-xfn">
+                        <?php _e( 'Link Relationship (XFN) (optional)' ); ?><br />
+                        <input type="text" id="edit-menu-item-xfn" class="widefat code" name="edit-menu-item-xfn" value="" tabindex="6" />
+                </label>
+        </p>
+        <p class="description">
+                <label for="edit-menu-item-description">
+                        <?php _e( 'Description (optional)' ); ?><br />
+                        <textarea id="edit-menu-item-description" class="widefat" rows="3" name="edit-menu-item-description" tabindex="7" /></textarea>
+                        <span class="description">The description will be displayed in the menu if the current theme supports it.</span>
+                </label>
+        </p>
</ins><span class="cx">         <p>
</span><del>-                <a id="cancel-save" class="submitdelete deletion"><?php _e('Cancel'); ?></a>
-                <a id="update-menu-item" class="save button-primary" tabindex="5"><?php _e('Save Changes'); ?></a>
</del><ins>+                <a id="update-menu-item" class="save button-primary" tabindex="8"><?php _e('Save Changes'); ?></a>
+                <a id="cancel-save" class="submitdelete deletion" tabindex="9"><?php _e('Cancel'); ?></a>
</ins><span class="cx">         </p>
</span><del>-        <input type="hidden" id="edit-item-id" name="edit-item-id" value="" />
</del><ins>+        <input type="hidden" id="edit-menu-item-id" name="edit-item-id" value="" />
</ins><span class="cx"> </div><!-- /#menu-item-settings-->
</span><span class="cx">
</span><span class="cx"> <?php include( 'admin-footer.php' ); ?>
</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">                         <div id="access">
</span><span class="cx">                                 <div class="skip-link screen-reader-text"><a href="#content" title="<?php esc_attr_e( 'Skip to content', 'twentyten' ); ?>"><?php _e( 'Skip to content', 'twentyten' ); ?></a></div>
</span><del>-                                <?php wp_nav_menu( 'sort_column=menu_order' ); ?>
</del><ins>+                                <?php wp_nav_menu( 'sort_column=menu_order&container_class=menu-header' ); ?>
</ins><span class="cx">                         </div><!-- #access -->
</span><span class="cx">                 </div><!-- #masthead -->
</span><span class="cx">         </div><!-- #header -->
</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' => '', 'menu_class' => 'menu', 'format' => 'div', 'echo' => true,
-        'fallback_cb' => 'wp_page_menu', 'link_before' => '', 'link_after' => '', 'before_link' => '', 'after_link' => '', );
</del><ins>+        $defaults = array( 'menu' => '', 'container' => 'div', 'container_class' => '', 'menu_class' => 'menu', 'echo' => true,
+        'fallback_cb' => 'wp_page_menu', 'before_link' => '', 'after_link' => '', 'before_title' => '', 'after_title' => '', );
</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->menu = $menu->term_id;
</span><span class="cx">         $nav_menu = '';
</span><span class="cx">
</span><del>-        if ( 'div' == $args->format ) {
-                if ( $menu )
-                        $nav_menu .= '<div id="menu-' . $menu->slug . '" class="' . esc_attr($args->menu_class) . '">';
-                else
-                        $nav_menu .= '<div id="menu-default">';
</del><ins>+        if ( 'div' == $args->container ) {
+                $class = $args->container_class ? ' class="' . esc_attr($args->container_class) . '"' : '';
+                
+                if ( is_nav_menu($menu) ) {
+                        $nav_menu .= '<div id="menu-' . $menu->slug . '"'. $class .'>';
+                } else {
+                        $nav_menu .= '<div'. $class .'>';
+                }
</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->format )
</del><ins>+        if ( 'div' == $args->container )
</ins><span class="cx">                 $nav_menu .= '</div>';
</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->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' => '', 'menu_class' => 'menu', 'ul_class' => '', 'format' => 'div', 'type' => 'frontend',
-        'fallback_cb' => '', 'link_before' => '', 'link_after' => '', 'before_link' => '', 'after_link' => '', );
</del><ins>+        $defaults = array( 'menu' => '', 'menu_class' => 'menu', 'context' => 'frontend',
+        'fallback_cb' => '', 'before_link' => '', 'after_link' => '', 'before_title' => '', 'after_title' => '', );
</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->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 && !is_wp_error($menu) )
+                $menu_items = wp_get_nav_menu_items( $menu->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) && empty($menu_items) ) ) {
</ins><span class="cx">                 if ( function_exists($args->fallback_cb) ) {
</span><span class="cx">                         $_args = array_merge( (array)$args, array('echo' => false) );
</span><span class="cx">                         return call_user_func( $args->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->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->ID ] = $menu_item->menu_order;
-        
-        $ul_class = isset($args->ul_class) ? ' class="'. $args->ul_class .'"' : '';
-        $nav_menu .= '<ul'. $ul_class .'>';
-        
-        // Display Loop
-        foreach ( $menu_items as $key => $menu_item ) :
</del><ins>+        foreach ( $menu_items as $key => $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->type ? '' : ' value="'. $menu_item->ID .'"';
-                $classes = 'frontend' == $args->type ? ' class="menu-item-'. $menu_item->type . $menu_item->li_class .'"' : '';
-
-                $nav_menu .= '<li id="menu-item-'. $menu_item->ID .'"'. $maybe_value . $classes .'>';
-                $nav_menu .= wp_get_nav_menu_item( $menu_item, $args->type, $args );
</del><ins>+                $type = sanitize_title_with_dashes( $menu_item->append );
+                $maybe_value = 'frontend' == $args->context ? '' : ' value="'. $menu_item->ID .'"';
+                $classes = 'frontend' == $args->context ? ' class="menu-item-type-'. $type . $menu_item->li_class .'"' : '';
</ins><span class="cx">                 
</span><ins>+                $items .= '<li id="menu-item-'. $menu_item->ID .'"'. $maybe_value . $classes .'>';
+                $items .= wp_get_nav_menu_item( $menu_item, $args->context, $args );
+                
</ins><span class="cx">                 // Indent children
</span><span class="cx">                 $last_item = ( count( $menu_items ) == $menu_item->menu_order );
</span><del>-                if ( $last_item || $current_parent != $menu_items[ $key + 1 ]->post_parent ) {
-                        if ( $last_item || in_array( $menu_items[ $key + 1 ]->post_parent, $parent_stack ) ) {
-                                $nav_menu .= '</li>';
-                                while ( !empty( $parent_stack ) && ($last_item || $menu_items[ $key + 1 ]->post_parent != $current_parent ) ) {
-                                        $nav_menu .= '</ul></li>';
</del><ins>+                if ( $last_item || $current_parent != $menu_items[$key + 1]->post_parent ) {
+                        if ( $last_item || in_array( $menu_items[$key + 1]->post_parent, $parent_stack ) ) {
+                                $items .= '</li>';
+                                while ( !empty( $parent_stack ) && ($last_item || $menu_items[$key + 1]->post_parent != $current_parent ) ) {
+                                        $items .= '</ul></li>';
</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->ID;
</span><del>-                                $nav_menu .= '<ul>';
</del><ins>+                                $items .= '<ul class="sub-menu">';
</ins><span class="cx">                         }
</span><span class="cx">                 } else {
</span><del>-                        $nav_menu .= '</li>';
</del><ins>+                        $items .= '</li>';
</ins><span class="cx">                 }
</span><del>-
-        endforeach;
</del><ins>+        }
</ins><span class="cx">         
</span><ins>+        // CSS class
+        $ul_class = $args->menu_class ? ' class="'. $args->menu_class .'"' : '';
+        $nav_menu .= '<ul'. $ul_class .'>';
+        
+        // Allow plugins to hook into the menu to add their own <li>'s
+        if ( 'frontend' == $args->context ) {
+                $items = apply_filters( 'wp_nav_menu_items', $items, $args );
+                $items = apply_filters( "wp_nav_menu_{$menu->slug}_items", $items, $args );
+                $nav_menu .= $items;
+        } else {
+                $nav_menu .= $items;
+        }
+        
</ins><span class="cx">         $nav_menu .= '</ul>';
</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->anchor_title) && '' != $menu_item->anchor_title ) ? ' title="'. esc_attr($menu_item->anchor_title) .'"' : '';
-                        $href = isset($menu_item->link) ? ' href="'. esc_url($menu_item->link) .'"' : '';
</del><ins>+                        $attributes = ( isset($menu_item->anchor_title) && '' != $menu_item->anchor_title ) ? ' title="'. esc_attr($menu_item->anchor_title) .'"' : '';
+                        $attributes .= ( isset($menu_item->target) && '' != $menu_item->target ) ? ' target="'. esc_attr($menu_item->target) .'"' : '';
+                        $attributes .= ( isset($menu_item->classes) && '' != $menu_item->classes ) ? ' class="'. esc_attr($menu_item->classes) .'"' : '';
+                        $attributes .= ( isset($menu_item->xfn) && '' != $menu_item->xfn ) ? ' rel="'. esc_attr($menu_item->xfn) .'"' : '';
+                        $attributes .= ( isset($menu_item->url) && '' != $menu_item->url ) ? ' href="'. esc_attr($menu_item->url) .'"' : '';
</ins><span class="cx">                         
</span><del>-                        $item .= '<a'. $attr_title . $href . $menu_item->target .'>';
-                        $item .= $args->before_link . esc_html( $menu_item->title ) . $args->after_link;
-                        $item .= '</a>';
</del><ins>+                        $output .= esc_html( $args->before_link );
+                        $output .= '<a'. $attributes .'>';
+                        $output .= esc_html( $args->before_title . $menu_item->title . $args->after_title );
+                        $output .= '</a>';
+                        $output .= esc_html( $args->after_link );
</ins><span class="cx">                         
</span><span class="cx">                         break;
</span><span class="cx">                 
</span><span class="cx">                 case 'backend':
</span><del>-                        $item .= '<dl><dt>';
-                        $item .= '<span class="item-title">'. esc_html($menu_item->title) .'</span>';
-                        $item .= '<span class="item-controls">';
-                        $item .= '<span class="item-type">'. esc_html($menu_item->type) .'</span>';
</del><ins>+                        $output .= '<dl><dt>';
+                        $output .= '<span class="item-title">'. esc_html($menu_item->title) .'</span>';
+                        $output .= '<span class="item-controls">';
+                        $output .= '<span class="item-type">'. esc_html($menu_item->append) .'</span>';
</ins><span class="cx">                         
</span><span class="cx">                         // Actions
</span><del>-                        $item .= '<a class="item-edit thickbox" id="edit'. esc_attr( $menu_item->menu_order ) .'" value="'. esc_attr( $menu_item->menu_order ) .'" title="'. __('Edit Menu Item') .'" href="#TB_inline?height=380&width=300&inlineId=menu-item-settings">'. __('Edit') .'</a> | ';
-                        $item .= '<a class="item-delete" id="delete'. esc_attr( $menu_item->menu_order ) .'" value="'. esc_attr( $menu_item->menu_order ) .'">'. __('Delete') .'</a>';
</del><ins>+                        $output .= '<a class="item-edit thickbox" id="edit'. esc_attr( $menu_item->menu_order ) .'" value="'. esc_attr( $menu_item->menu_order ) .'" title="'. __('Edit Menu Item') .'" href="#TB_inline?height=540&width=300&inlineId=menu-item-settings">'. __('Edit') .'</a> | ';
+                        $output .= '<a class="item-delete" id="delete'. esc_attr( $menu_item->menu_order ) .'" value="'. esc_attr( $menu_item->menu_order ) .'">'. __('Delete') .'</a>';
</ins><span class="cx">                         
</span><del>-                        $item .= '</dt></dl>';
</del><ins>+                        $output .= '</dt></dl>';
</ins><span class="cx">                         
</span><span class="cx">                         // Menu Item Settings
</span><del>-                        $item .= '<input type="hidden" id="item-dbid'. esc_attr( $menu_item->menu_order ) .'" name="item-dbid'. esc_attr( $menu_item->menu_order ) .'" value="'. esc_attr( $menu_item->ID ) .'" />';
-                        $item .= '<input type="hidden" id="item-postmenu'. esc_attr( $menu_item->menu_order ) .'" name="item-postmenu'. esc_attr( $menu_item->menu_order ) .'" value="'. esc_attr( get_post_meta( $menu_item->ID, 'object_id', true ) ) .'" />';
-                        $item .= '<input type="hidden" id="item-parent'. esc_attr( $menu_item->menu_order ) .'" name="item-parent'. esc_attr( $menu_item->menu_order ) .'" value="'. esc_attr( $menu_item->parent_item ) .'" />';
-                        $item .= '<input type="hidden" id="item-position'. esc_attr( $menu_item->menu_order ) .'" name="item-position'. esc_attr( $menu_item->menu_order ) .'" value="'. esc_attr( $menu_item->menu_order ) .'" />';
-                        $item .= '<input type="hidden" id="item-type'. esc_attr( $menu_item->menu_order ) .'" name="item-type'. esc_attr( $menu_item->menu_order ) .'" value="'. esc_attr( get_post_meta( $menu_item->ID, 'menu_type', true ) ) .'" />';
-                        $item .= '<input type="hidden" id="item-title'. esc_attr( $menu_item->menu_order ) .'" name="item-title'. esc_attr( $menu_item->menu_order ) .'" value="'. esc_attr( $menu_item->title ) .'" />';
-                        $item .= '<input type="hidden" id="item-url'. esc_attr( $menu_item->menu_order ) .'" name="item-url'. esc_attr( $menu_item->menu_order ) .'" value="'. esc_attr( $menu_item->link ) .'" />';
-                        $item .= '<input type="hidden" id="item-description'. esc_attr( $menu_item->menu_order ) .'" name="item-description'. esc_attr( $menu_item->menu_order ) .'" value="'. esc_attr( $menu_item->description ) .'" />';
-                        $item .= '<input type="hidden" id="item-attr-title'. esc_attr( $menu_item->menu_order ) .'" name="item-attr-title'. esc_attr( $menu_item->menu_order ) .'" value="'.esc_attr( $menu_item->post_excerpt ) .'" />';
-                        $item .= '<input type="hidden" id="item-target'. esc_attr( $menu_item->menu_order ) .'" name="item-target'. esc_attr( $menu_item->menu_order ) .'" value="'. esc_attr( get_post_meta( $menu_item->ID, 'menu_new_window', true ) ? '1' : '0' ) .'" />';
</del><ins>+                        $output .= '<input type="hidden" name="menu-item-db-id[]" id="menu-item-db-id'. esc_attr( $menu_item->menu_order ) .'" value="'. esc_attr( $menu_item->ID ) .'" />';
+                        $output .= '<input type="hidden" name="menu-item-object-id[]" id="menu-item-object-id'. esc_attr( $menu_item->menu_order ) .'" value="'. esc_attr( $menu_item->object_id ) .'" />';
+                        $output .= '<input type="hidden" name="menu-item-parent-id[]" id="menu-item-parent-id'. esc_attr( $menu_item->menu_order ) .'" value="'. esc_attr( $menu_item->post_parent ) .'" />';
+                        $output .= '<input type="hidden" name="menu-item-position[]" id="menu-item-position'. esc_attr( $menu_item->menu_order ) .'" value="'. esc_attr( $menu_item->menu_order ) .'" />';
+                        $output .= '<input type="hidden" name="menu-item-type[]" id="menu-item-type'. esc_attr( $menu_item->menu_order ) .'" value="'. esc_attr( $menu_item->type ) .'" />';
+                        $output .= '<input type="hidden" name="menu-item-append[]" id="menu-item-append'. esc_attr( $menu_item->menu_order ) .'" value="'. esc_attr( $menu_item->append ) .'" />';
+                        $output .= '<input type="hidden" name="menu-item-title[]" id="menu-item-title'. esc_attr( $menu_item->menu_order ) .'" value="'. esc_attr( $menu_item->title ) .'" />';
+                        $output .= '<input type="hidden" name="menu-item-url[]" id="menu-item-url'. esc_attr( $menu_item->menu_order ) .'" value="'. esc_attr( $menu_item->url ) .'" />';
+                        $output .= '<input type="hidden" name="menu-item-description[]" id="menu-item-description'. esc_attr( $menu_item->menu_order ) .'" value="'. esc_attr( $menu_item->description ) .'" />';
+                        $output .= '<input type="hidden" name="menu-item-classes[]" id="menu-item-classes'. esc_attr( $menu_item->menu_order ) .'" value="'. esc_attr( $menu_item->classes ) .'" />';
+                        $output .= '<input type="hidden" name="menu-item-xfn[]" id="menu-item-xfn'. esc_attr( $menu_item->menu_order ) .'" value="'. esc_attr( $menu_item->xfn ) .'" />';
+                        $output .= '<input type="hidden" name="menu-item-attr-title[]" id="menu-item-attr-title'. esc_attr( $menu_item->menu_order ) .'" value="'.esc_attr( $menu_item->post_excerpt ) .'" />';
+                        $output .= '<input type="hidden" name="menu-item-target[]" id="menu-item-target'. esc_attr( $menu_item->menu_order ) .'" value="'. esc_attr( $menu_item->target ) .'" />';
</ins><span class="cx">                         break;
</span><ins>+                
+                case 'custom':
+                        $menu_id = 'menu-item-' . $menu_item->db_id;
+                        $output .= '<label class="menu-item-title"><input type="checkbox" id="'. esc_attr( $menu_id ) .'" name="'. esc_attr( $menu_item->title ) .'" value="'. esc_attr( $menu_item->url ) .'" />'. $menu_item->title .'</label>';
</ins><span class="cx">                         
</span><del>-                case 'default':
-                        $menu_id = 'menu-item-' . $menu_item->ID;
-                        $item .= '<label class="item-title"><input type="checkbox" id="'. esc_attr($menu_id) .'" name="'. esc_attr( $menu_item->title ) .'" value="'. esc_attr( $menu_item->link ) .'" />'. $menu_item->title .'</label>';
</del><ins>+                        // Menu item hidden fields
+                        $output .= '<input type="hidden" class="menu-item-db-id" value="'. esc_attr( $menu_item->db_id ) .'" />';
+                        $output .= '<input type="hidden" class="menu-item-object-id" value="'. esc_attr( $menu_item->object_id ) .'" />';
+                        $output .= '<input type="hidden" class="menu-item-parent-id" value="'. esc_attr( $menu_item->parent_id ) .'" />';
+                        $output .= '<input type="hidden" class="menu-item-type" value="'. esc_attr( $menu_item->type ) .'" />';
+                        $output .= '<input type="hidden" class="menu-item-append" value="'. esc_attr( $menu_item->append ) .'" />';
+                        $output .= '<input type="hidden" class="menu-item-title" value="'. esc_attr( $menu_item->title ) .'" />';
+                        $output .= '<input type="hidden" class="menu-item-url" value="'. esc_attr( $menu_item->url ) .'" />';
+                        $output .= '<input type="hidden" class="menu-item-target" value="'. esc_attr( $menu_item->target ) .'" />';
+                        $output .= '<input type="hidden" class="menu-item-attr_title" value="'. esc_attr( $menu_item->attr_title ) .'" />';
+                        $output .= '<input type="hidden" class="menu-item-description" value="'. esc_attr( $menu_item->description ) .'" />';
+                        $output .= '<input type="hidden" class="menu-item-classes" value="'. esc_attr( $menu_item->classes ) .'" />';
+                        $output .= '<input type="hidden" class="menu-item-xfn" value="'. esc_attr( $menu_item->xfn ) .'" />';
+                        break;
+                
+                case 'taxonomy':
+                case 'post_type':
+                        $menu_id = 'menu-item-' . $menu_item->db_id;
+                        $output .= '<label class="menu-item-title"><input type="checkbox" id="'. esc_attr( $menu_id ) .'" name="'. esc_attr( $menu_item->title ) .'" value="'. esc_attr( $menu_item->url ) .'" />'. $menu_item->title .'</label>';
</ins><span class="cx">                         
</span><del>-                        // Menu Item Settings
-                        $item .= '<input type="hidden" class="item-type" value="'. esc_attr( $menu_item->type ) .'" />';
-                        $item .= '<input type="hidden" class="item-title" value="'. esc_attr( $menu_item->title ) .'" />';
-                        $item .= '<input type="hidden" class="item-url" value="'. esc_attr( $menu_item->link ) .'" />';
-                        $item .= '<input type="hidden" class="item-dbid" value="'. esc_attr( $menu_item->ID ) .'" />';
-                        $item .= '<input type="hidden" class="item-parent" value="'. esc_attr( $menu_item->parent_item ) .'" />';
-                        $item .= '<input type="hidden" class="item-description" value="'. esc_attr( $menu_item->description ) .'" />';
</del><ins>+                        // Menu item hidden fields
+                        $output .= '<input type="hidden" class="menu-item-db-id" value="0" />';
+                        $output .= '<input type="hidden" class="menu-item-object-id" value="'. esc_attr( $menu_item->object_id ) .'" />';
+                        $output .= '<input type="hidden" class="menu-item-parent-id" value="'. esc_attr( $menu_item->parent_id ) .'" />';
+                        $output .= '<input type="hidden" class="menu-item-type" value="'. esc_attr( $menu_item->type ) .'" />';
+                        $output .= '<input type="hidden" class="menu-item-append" value="'. esc_attr( $menu_item->append ) .'" />';
+                        $output .= '<input type="hidden" class="menu-item-title" value="'. esc_attr( $menu_item->title ) .'" />';
+                        $output .= '<input type="hidden" class="menu-item-url" value="'. esc_attr( $menu_item->url ) .'" />';
+                        $output .= '<input type="hidden" class="menu-item-append" value="'. esc_attr( $menu_item->append ) .'" />';
</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"> ?>
</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' => false, 'orderby' => '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' => 'menu-1') );
-
-        if ( is_wp_error($menu) )
-                return;
-
-        $pages = get_pages( array('parent' => 0, 'number' => 15) );
-        $counter = 1;
-        foreach ( $pages as $page ) {
-                $item = array( 'post_status' => 'publish', 'post_type' => 'nav_menu_item', 'menu_order' => $counter, 'tax_input' => array( 'nav_menu' => $menu->name), 'post_title' => addslashes($page->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->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' => false, 'orderby' => '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->db_id = (int) $menu_item->ID;
+                        $menu_item->object_id = get_post_meta( $menu_item->ID, 'menu_item_object_id', true );
+                        $menu_item->parent_id = (int) $menu_item->post_parent;
+                        $menu_item->type = get_post_meta( $menu_item->ID, 'menu_item_type', true );
+                        $menu_item->append = _x( get_post_meta( $menu_item->ID, 'menu_item_append', true ), 'nav menu item type' );
+                        
+                        $menu_item->title = $menu_item->post_title;
+                        $menu_item->url = get_post_meta( $menu_item->ID, 'menu_item_url', true );
+                        $menu_item->target = get_post_meta( $menu_item->ID, 'menu_item_target', true );
+                        
+                        $menu_item->attr_title = strip_tags( $menu_item->post_excerpt );
+                        $menu_item->description = strip_tags( $menu_item->post_content );
+                        
+                        $menu_item->classes = get_post_meta( $menu_item->ID, 'menu_item_classes', true );;
+                        $menu_item->xfn = get_post_meta( $menu_item->ID, 'menu_item_xfn', true );
+                        $menu_item->li_class = ( $menu_item->object_id == $wp_query->get_queried_object_id() ) ? ' current_page_item' : '';
+                        break;
+                        
+                case 'custom':
+                        $menu_item->db_id = (int) $menu_item->ID;
+                        $menu_item->object_id = (int) $menu_item->ID;
+                        $menu_item->parent_id = (int) $menu_item->post_parent;
+                        $menu_item->type = 'custom'; //$menu_item_type
+                        $menu_item->append = _x( 'Custom', 'nav menu item type' );
+                        
+                        $menu_item->attr_title = strip_tags( $menu_item->post_excerpt );
+                        $menu_item->description = strip_tags( $menu_item->post_content );
</ins><span class="cx">
</span><del>-        if ( 'item' == $type ) {
-                $menu_item->type = get_post_meta( $menu_item->ID, 'menu_type', true );
-                $menu_item->object_id = get_post_meta( $menu_item->ID, 'object_id', true );
-                $menu_item->target = ( get_post_meta( $menu_item->ID, 'menu_new_window', true ) ) ? 'target="_blank"' : '';
-                if ( isset( $parent_menu_order[ $menu_item->post_parent ] ) )
-                        $menu_item->parent_item = $parent_menu_order[ $menu_item->post_parent ];
-                else
-                        $menu_item->parent_item = 0;
-        } elseif ( 'category' == $type ) {
-                $menu_item->type = $type;
-                $menu_item->object_id = $menu_item->term_id;
-                $menu_item->ID = $menu_item->term_id;
-                $menu_item->parent_item = $menu_item->parent;
-                $menu_item->menu_order = $position;
-        } elseif ( 'page' == $type ) {
-                $menu_item->type = $type;
-                $menu_item->object_id = $menu_item->ID;
-                $menu_item->parent_item = $menu_item->post_parent;
-                $menu_item->menu_order = $position;
-        }
</del><ins>+                        $menu_item->title = $menu_item->post_title;
+                        $menu_item->url = get_post_meta( $menu_item->ID, 'menu_item_url', true );
+                        $menu_item->target = get_post_meta( $menu_item->ID, 'menu_item_target', true );
+                        break;
+                        
+                case 'post_type':
+                        $menu_item->db_id = 0;
+                        $menu_item->object_id = (int) $menu_item->ID;
+                        $menu_item->parent_id = (int) $menu_item->post_parent;
+                        $menu_item->type = $menu_item_type;
+                        
+                        $object = get_post_type_object( $menu_item_object );
+                        $menu_item->append = _x( $object->singular_label, 'nav menu item type' );
</ins><span class="cx">
</span><del>-        switch ( $menu_item->type ) {
-                case 'page' :
-                        $menu_item->link = get_page_link( $menu_item->object_id );
-
-                        if ( $menu_item->post_title == '' )
-                                $menu_item->title = get_the_title( $menu_item->object_id );
-                        else
-                                $menu_item->title = $menu_item->post_title;
-
-                        if ( $menu_item->post_content == '' )
-                                $menu_item->description = get_post_meta( $menu_item->ID, 'page-description', true );
-                        else
-                                $menu_item->description = $menu_item->post_content;
-                        $menu_item->append = _x('Page', 'menu nav item type');
</del><ins>+                        $menu_item->title = $menu_item->post_title;
+                        $menu_item->url = get_post_permalink( $menu_item->ID );
+                        $menu_item->target = '_none';
+                        
+                        $menu_item->attr_title = '';
+                        $menu_item->description = strip_tags( $menu_item->post_content );
</ins><span class="cx">                         break;
</span><del>-                case 'category' :
-                        $menu_item->link = get_category_link( $menu_item->object_id );
</del><ins>+                        
+                case 'taxonomy':
+                        $menu_item->ID = $menu_item->term_id;
+                        $menu_item->db_id = 0;
+                        $menu_item->object_id = (int) $menu_item->term_id;
+                        $menu_item->parent_id = (int) $menu_item->parent;
+                        $menu_item->type = $menu_item_type;
+                        
+                        $object = get_taxonomy( $menu_item_object );
+                        $menu_item->append = _x( $object->singular_label, 'nav menu item type' );
</ins><span class="cx">
</span><del>-                        if ( empty($menu_item->post_title) ) {
-                                $title_raw = get_category( $menu_item->object_id );
-                                $menu_item->title = $title_raw->cat_name;
-                        } else {
-                                $menu_item->title = $menu_item->post_title;
-                        }
-
-                        if ( empty($menu_item->post_content) )
-                                $menu_item->description = strip_tags( category_description( $menu_item->object_id ) );
-                        else
-                                $menu_item->description = $menu_item->post_content;
-                        $menu_item->append = _x('Category', 'menu nav item type');
</del><ins>+                        $menu_item->title = $menu_item->name;
+                        $menu_item->url = get_term_link( $menu_item, $menu_item_object );
+                        $menu_item->target = '_none';
+                        $menu_item->attr_title = '';
+                        $menu_item->description = strip_tags( $menu_item->description );
</ins><span class="cx">                         break;
</span><del>-                case 'custom' :
-                default :
-                        $menu_item->link = esc_url_raw( get_post_meta( $menu_item->ID, 'menu_link', true ) );
-                        $menu_item->title = $menu_item->post_title;
-                        $menu_item->description = $menu_item->post_content;
-                        $menu_item->append = _x('Custom', 'menu nav item type');
-                        break;
</del><span class="cx">         }
</span><del>-
-        $menu_item->li_class = '';
-        global $wp_query;
</del><span class="cx">         
</span><del>-        if ( $menu_item->object_id == $wp_query->get_queried_object_id() )
-                $menu_item->li_class = ' current_page_item';
-
-        $menu_item->anchor_title = '';
-/* @todo: update to use tax/post data
-
-                        //SET anchor title
-                        if (isset($wp_custom_nav_menu_items->custom_anchor_title)) {
-                                $anchor_title = $wp_custom_nav_menu_items->custom_anchor_title;
-                        }
-                        else {
-                                $anchor_title = $title;
-                        }
-
-                        if ($queried_id == $wp_custom_nav_menu_items->post_id) {
-                                $li_class = 'class="current_page_item"';
-                        }
-
-                        if (isset($wp_custom_nav_menu_items->new_window)) {
-                                if ($wp_custom_nav_menu_items->new_window > 0) {
-                                        $target = 'target="_blank"';
-                                }
-                                else {
-                                        $target = '';
-                                }
-                        }
-*/
-
</del><ins>+        $menu_item->classes = get_post_meta( $menu_item->ID, 'menu_item_classes', true );
+        $menu_item->xfn = get_post_meta( $menu_item->ID, 'menu_item_xfn', true );
+        
</ins><span class="cx">         return $menu_item;
</span><span class="cx"> }
</span><del>-?>
</del><ins>+?>
</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->add( 'nav-menu-default-items', "/wp-admin/js/nav-menu-default-items$suffix.js", false, '20100223' );
-                $scripts->add( 'nav-menu-dynamic-functions', "/wp-admin/js/nav-menu-dynamic-functions$suffix.js", false, '20100225b' );
</del><ins>+                $scripts->add( 'nav-menu-default-items', "/wp-admin/js/nav-menu-default-items$suffix.js", false, '20100315' );
+                $scripts->add( 'nav-menu-dynamic-functions', "/wp-admin/js/nav-menu-dynamic-functions$suffix.js", false, '20100315' );
</ins><span class="cx">                 $scripts->localize( 'nav-menu-dynamic-functions', 'navMenuL10n', array(
</span><span class="cx">                         'custom' => _x('Custom', 'menu nav item type'),
</span><span class="cx">                         'page' => _x('Page', 'menu nav item type'),
</span><span class="cx">                         'category' => _x('Category', 'menu nav item type'),
</span><span class="cx">                         'thickbox' => _x('Edit Menu Item', 'Thickbox Title'),
</span><span class="cx">                         'edit' => _x('Edit', 'menu item edit text'),
</span><ins>+                        'warnDelete' => __( "You are about to permanently delete this menu. \n 'Cancel' to stop, 'OK' to delete." ),
</ins><span class="cx">                 ) );
</span><span class="cx">                 
</span><span class="cx">                 $scripts->add( 'nav-menu-php-functions', "/wp-admin/js/nav-menu-php-functions$suffix.js", 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>