<!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>[13512] trunk: Menu enhancements.</title>
</head>
<body>
<div id="msg">
<dl>
<dt>Revision</dt> <dd><a href="http://trac.wordpress.org/changeset/13512">13512</a></dd>
<dt>Author</dt> <dd>ryan</dd>
<dt>Date</dt> <dd>2010-02-28 20:00:49 +0000 (Sun, 28 Feb 2010)</dd>
</dl>
<h3>Log Message</h3>
<pre>Menu enhancements. Props ptahdunbar. fixes <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="#trunkwpincludesdefaultwidgetsphp">trunk/wp-includes/default-widgets.php</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>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkwpadmincssnavmenucss"></a>
<div class="modfile"><h4>Modified: trunk/wp-admin/css/nav-menu.css (13511 => 13512)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-admin/css/nav-menu.css        2010-02-28 19:49:31 UTC (rev 13511)
+++ trunk/wp-admin/css/nav-menu.css        2010-02-28 20:00:49 UTC (rev 13512)
</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{margin:0;}.list dt{display:none;margin:0;overflow:hidden;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{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;}
</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 (13511 => 13512)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-admin/css/nav-menu.dev.css        2010-02-28 19:49:31 UTC (rev 13511)
+++ trunk/wp-admin/css/nav-menu.dev.css        2010-02-28 20:00:49 UTC (rev 13512)
</span><span class="lines">@@ -22,7 +22,7 @@
</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 columns *//*
</del><ins>+/* CSS for switching the main columns *//*
</ins><span class="cx"> #menu-settings-column { clear: none; float: left; }
</span><span class="cx"> #menu-management #post-body { float: right; margin-left: -340px; margin-right: 0px; }
</span><span class="cx"> #menu-management #post-body-content { margin-left: 300px; margin-right: 0px; }
</span><span class="lines">@@ -48,8 +48,7 @@
</span><span class="cx"> .postbox p.submit { margin-bottom: 0; }
</span><span class="cx">
</span><span class="cx"> /* Listings */
</span><del>-.list li { margin: 0; }
-.list dt { display: none; margin: 0; overflow: hidden; margin-bottom: 5px; }
</del><ins>+.list li { display: none; margin: 0; margin-bottom: 5px; }
</ins><span class="cx">
</span><span class="cx"> .list li .item-title { cursor: pointer; display: block; }
</span><span class="cx"> .list li .item-title input { margin-right: 3px; margin-top: -3px; }
</span><span class="lines">@@ -66,16 +65,16 @@
</span><span class="cx"> /* Menu */
</span><span class="cx"> #menu-container .inside { padding-bottom: 10px; }
</span><span class="cx">
</span><del>-#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; }
</del><ins>+.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; }
</ins><span class="cx">
</span><del>-#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; }
</del><ins>+.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; }
</ins><span class="cx">
</span><span class="cx"> /* Drag and Drop */
</span><span class="cx"> .dropzone { height: 7px; margin: 3px 0 3px 0; }
</span></span></pre></div>
<a id="trunkwpadminincludesnavmenuphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-admin/includes/nav-menu.php (13511 => 13512)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-admin/includes/nav-menu.php        2010-02-28 19:49:31 UTC (rev 13511)
+++ trunk/wp-admin/includes/nav-menu.php        2010-02-28 20:00:49 UTC (rev 13512)
</span><span class="lines">@@ -1,16 +1,72 @@
</span><span class="cx"> <?php
</span><span class="cx">
</span><del>-/*-----------------------------------------------------------------------------------*/
-/* Custom Navigation Functions */
-/* wp_custom_navigation_output() displays the menu in the back/frontend
-/* wp_custom_nav_get_pages()
-/* wp_custom_nav_get_categories()
-/* wp_custom_navigation_default_sub_items() is a recursive sub menu item function
-/*-----------------------------------------------------------------------------------*/
</del><ins>+/**
+ * Displays a list of links and thier sub items.
+ *
+ * @since 3.0.0
+ *
+ * @param string $counter
+ * @param string $context
+ */
+function wp_nav_menu_get_custom_links( $counter, $context ) {
+        $available_links = new WP_Query( );
+        
+        $args = array( 'post_status' => 'any', 'post_type' => 'nav_menu_item', 'meta_value' => 'custom' );
+        $link_objects = new WP_Query( $args );
+        
+        $items_counter = $counter;
</ins><span class="cx">
</span><del>-// Outputs All Pages and Sub Items
-function wp_nav_menu_get_pages($counter, $type) {
</del><ins>+        if ( !$link_objects->posts ) {
+                _e('Not Found');
+                return $items_counter;
+        }
+        
+        // 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;
+                        }
+                }
+        }
+        return $items_counter;
+}
</ins><span class="cx">
</span><ins>+/**
+ * Displays a list of pages and thier sub items.
+ *
+ * @since 3.0.0
+ *
+ * @param string $counter
+ * @param string $context
+ */
+function wp_nav_menu_get_pages( $counter, $context ) {
</ins><span class="cx">         $pages_args = array(
</span><span class="cx">                  'child_of' => 0,
</span><span class="cx">                         'sort_order' => 'ASC',
</span><span class="lines">@@ -26,8 +82,8 @@
</span><span class="cx">                         'number' => '',
</span><span class="cx">                         'offset' => 0 );
</span><span class="cx">
</span><del>-        //GET all pages
-        $pages_array = get_pages($pages_args);
</del><ins>+        // Get all pages
+        $pages_array = get_pages( $pages_args );
</ins><span class="cx">
</span><span class="cx">         $items_counter = $counter;
</span><span class="cx">         $parentli = $items_counter;
</span><span class="lines">@@ -40,43 +96,45 @@
</span><span class="cx">         // Display Loop
</span><span class="cx">         foreach ( $pages_array as $post ) {
</span><span class="cx">                 if ( $post->post_parent == 0 ) {
</span><del>-                        $post = wp_setup_nav_menu_item($post, 'page', $items_counter);
-                        if ( $type == 'menu' ) {
</del><ins>+                        $post = wp_setup_nav_menu_item( $post, 'page', $items_counter );
+                        if ( $context == 'menu' ) {
</ins><span class="cx">                                 ?>
</span><del>-
</del><span class="cx">                                 <li id="menu-<?php echo $items_counter; ?>" value="<?php echo $items_counter; ?>">
</span><span class="cx">                                         <?php
</span><del>-                                                wp_print_nav_menu_item($post, 'menu', $items_counter);
</del><ins>+                                                echo wp_get_nav_menu_item( $post, 'menu', $items_counter );
</ins><span class="cx">                                                 $parentli = $post->ID;
</span><span class="cx">                                                 $items_counter++;
</span><del>-                                                $items_counter = wp_custom_navigation_default_sub_items($post->ID, $items_counter, $parentli, 'pages', 'menu');
</del><ins>+                                                $items_counter = wp_nav_menu_sub_items( $post->ID, $items_counter, $parentli, 'pages', 'menu' );
</ins><span class="cx">                                         ?>
</span><span class="cx">                                 </li>
</span><del>-
</del><span class="cx">                                 <?php
</span><del>-                        } elseif ( $type == 'default' ) {
</del><ins>+                        } elseif ( $context == 'default' ) {
</ins><span class="cx">                                 // Sidebar Menu
</span><span class="cx">                                 ?>
</span><span class="cx">                                  <li>
</span><span class="cx">                                         <?php
</span><del>-                                                wp_print_nav_menu_item($post, 'default');
</del><ins>+                                                echo wp_get_nav_menu_item( $post, 'default' );
</ins><span class="cx">                                                 $parentli = $post->ID;
</span><span class="cx">                                                 $items_counter++;
</span><del>-                                                $items_counter = wp_nav_menu_sub_items($post->ID, $items_counter, $parentli, 'pages', 'default');
</del><ins>+                                                $items_counter = wp_nav_menu_sub_items( $post->ID, $items_counter, $parentli, 'pages', 'default' );
</ins><span class="cx">                                          ?>
</span><span class="cx">                                 </li>
</span><del>-
</del><span class="cx">                                 <?php
</span><span class="cx">                         }
</span><span class="cx">                 }
</span><span class="cx">         }
</span><del>-
</del><span class="cx">         return $items_counter;
</span><span class="cx"> }
</span><span class="cx">
</span><del>-// Outputs All Categories and Sub Items
-function wp_nav_menu_get_categories($counter, $type) {
-
</del><ins>+/**
+ * Displays a list of categories and thier sub items.
+ *
+ * @since 3.0.0
+ *
+ * @param string $counter
+ * @param string $context
+ */
+function wp_nav_menu_get_categories( $counter, $context ) {
</ins><span class="cx">         $category_args = array(
</span><span class="cx">                         'type' => 'post',
</span><span class="cx">                         'child_of' => 0,
</span><span class="lines">@@ -93,7 +151,7 @@
</span><span class="cx">         $items_counter = $counter;
</span><span class="cx">
</span><span class="cx">         // Get all categories
</span><del>-        $categories_array = get_categories($category_args);
</del><ins>+        $categories_array = get_categories( $category_args );
</ins><span class="cx">
</span><span class="cx">         if ( !$categories_array ) {
</span><span class="cx">                 _e('Not Found');
</span><span class="lines">@@ -103,46 +161,49 @@
</span><span class="cx">         // Display Loop
</span><span class="cx">         foreach ( $categories_array as $cat_item ) {
</span><span class="cx">                 if ( $cat_item->parent == 0 ) {
</span><del>-                        $cat_item = wp_setup_nav_menu_item($cat_item, 'category', $items_counter);
</del><ins>+                        $cat_item = wp_setup_nav_menu_item( $cat_item, 'category', $items_counter );
</ins><span class="cx">                         // Custom Menu
</span><del>-                        if ( $type == 'menu' ) {
</del><ins>+                        if ( $context == 'menu' ) {
</ins><span class="cx">                                 ?>
</span><del>-
</del><span class="cx">                                 <li id="menu-<?php echo $items_counter; ?>" value="<?php echo $items_counter; ?>">
</span><span class="cx">                                         <?php
</span><del>-                                                wp_print_nav_menu_item($cat_item, 'menu');
</del><ins>+                                                echo wp_get_nav_menu_item($cat_item, 'menu');
</ins><span class="cx">                                                 $parentli = $cat_item->cat_ID;
</span><span class="cx">                                                 $items_counter++;
</span><del>-                                                $items_counter = wp_nav_menu_sub_items($cat_item->cat_ID, $items_counter, $parentli, 'categories', 'menu');
</del><ins>+                                                $items_counter = wp_nav_menu_sub_items( $cat_item->cat_ID, $items_counter, $parentli, 'categories', 'menu' );
</ins><span class="cx">                                         ?>
</span><del>-
</del><span class="cx">                                 </li>
</span><del>-
</del><span class="cx">                                 <?php
</span><del>-                        } elseif ( $type == 'default' ) {
</del><ins>+                        } elseif ( $context == 'default' ) {
</ins><span class="cx">                                 // Sidebar Menu
</span><span class="cx">                                 ?>
</span><span class="cx">                                 <li>
</span><span class="cx">                                         <?php
</span><del>-                                                wp_print_nav_menu_item($cat_item, 'default');
</del><ins>+                                                echo wp_get_nav_menu_item( $cat_item, 'default' );
</ins><span class="cx">                                                 $parentli = $cat_item->cat_ID;
</span><span class="cx">                                                 $items_counter++;
</span><del>-                                                $items_counter = wp_nav_menu_sub_items($cat_item->cat_ID, $items_counter, $parentli, 'categories', 'default');
</del><ins>+                                                $items_counter = wp_nav_menu_sub_items( $cat_item->cat_ID, $items_counter, $parentli, 'categories', 'default' );
</ins><span class="cx">                                         ?>
</span><del>-
</del><span class="cx">                                 </li>
</span><del>-
</del><span class="cx">                                 <?php
</span><span class="cx">                         }
</span><span class="cx">                 }
</span><span class="cx">         }
</span><del>-
</del><span class="cx">         return $items_counter;
</span><span class="cx"> }
</span><span class="cx">
</span><del>-//RECURSIVE Sub Menu Items of default categories and pages
-function wp_nav_menu_sub_items($childof, $items_counter, $parentli, $type, $output_type) {
-
</del><ins>+/**
+ * Recursive function that gets sub menu items.
+ *
+ * @since 3.0.0
+ *
+ * @param string $childof
+ * @param string $items_counter
+ * @param string $parentli
+ * @param string $context
+ * @param string $output_type
+ */
+function wp_nav_menu_sub_items( $childof, $items_counter, $parentli, $context, $output_type ) {
</ins><span class="cx">         $counter = $items_counter;
</span><span class="cx">
</span><span class="cx">         // Custom Menu
</span><span class="lines">@@ -159,11 +220,11 @@
</span><span class="cx">                 'parent' => $childof);
</span><span class="cx">         }
</span><span class="cx">
</span><del>-        if ( $type == 'categories' ) {
</del><ins>+        if ( $context == 'categories' ) {
</ins><span class="cx">                 // Get Sub Category Items
</span><span class="cx">                 $item_type = 'category';
</span><span class="cx">                 $sub_array = get_categories($sub_args);
</span><del>-        } elseif ($type == 'pages') {
</del><ins>+        } elseif ($context == 'pages') {
</ins><span class="cx">                 // Get Sub Page Items
</span><span class="cx">                 $item_type = 'page';
</span><span class="cx">                 $sub_array = get_pages($sub_args);
</span><span class="lines">@@ -172,25 +233,21 @@
</span><span class="cx">                 $sub_array = array();
</span><span class="cx">         }
</span><span class="cx">
</span><del>-
</del><span class="cx">         if ( $sub_array ) {
</span><span class="cx">                 ?>
</span><del>-                <ul id="sub-menu-<?php echo $type ?>">
-
</del><ins>+                <ul id="sub-menu-<?php echo $context ?>">
</ins><span class="cx">                 <?php
</span><span class="cx">                 // Display Loop
</span><span class="cx">                 foreach ( $sub_array as $sub_item ) {
</span><del>-                        $sub_item = wp_setup_nav_menu_item($sub_item, $item_type, $counter);
-
</del><ins>+                        $sub_item = wp_setup_nav_menu_item( $sub_item, $item_type, $counter );
</ins><span class="cx">                         if ( $output_type == 'menu' ) {
</span><span class="cx">                                 ?>
</span><span class="cx">                                 <li id="menu-<?php echo $counter; ?>" value="<?php echo $counter; ?>">
</span><span class="cx">                                         <?php
</span><del>-                                                wp_print_nav_menu_item($sub_item, 'menu');
</del><ins>+                                                echo wp_get_nav_menu_item( $sub_item, 'menu' );
</ins><span class="cx">                                                 $counter++;
</span><del>-                                                $counter = wp_nav_menu_sub_items($sub_item->ID, $counter, $sub_item->ID, $type, 'menu');
</del><ins>+                                                $counter = wp_nav_menu_sub_items( $sub_item->ID, $counter, $sub_item->ID, $context, 'menu' );
</ins><span class="cx">                                         ?>
</span><del>-
</del><span class="cx">                                 </li>
</span><span class="cx">                                 <?php
</span><span class="cx">                         } elseif ( $output_type == 'default' ) {
</span><span class="lines">@@ -198,9 +255,9 @@
</span><span class="cx">                                 ?>
</span><span class="cx">                                 <li>
</span><span class="cx">                                         <?php
</span><del>-                                                wp_print_nav_menu_item($sub_item, 'default');
</del><ins>+                                                echo wp_get_nav_menu_item( $sub_item, 'default' );
</ins><span class="cx">                                                 //$counter++;
</span><del>-                                                $counter = wp_nav_menu_sub_items($sub_item->ID, $counter, $sub_item->ID, $type, 'default');
</del><ins>+                                                $counter = wp_nav_menu_sub_items( $sub_item->ID, $counter, $sub_item->ID, $context, 'default' );
</ins><span class="cx">                                         ?>
</span><span class="cx">                                 </li>
</span><span class="cx">
</span><span class="lines">@@ -208,29 +265,9 @@
</span><span class="cx">                         }
</span><span class="cx">                 }
</span><span class="cx">                 ?>
</span><del>-
</del><span class="cx">                 </ul>
</span><del>-
</del><span class="cx">         <?php
</span><span class="cx">         }
</span><del>-
</del><span class="cx">         return $counter;
</span><span class="cx"> }
</span><del>-/*
-function wp_nav_menu_setup($override = false) {
-        // Custom Navigation Menu Setup
-
-        // Override for menu descriptions
-        update_option('wp_settings_nav_menu_advanced_options', 'yes');
-
-        $menus = wp_get_nav_menus();
-         if ( !empty( $menus ) ) {
-                foreach ( $menus as $menu ) {
-                        wp_delete_nav_menu( $menu->term_id );
-                }
-        }
-
-        wp_create_nav_menu( __('Main') );
-}
-/**/
</del><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 (13511 => 13512)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-admin/js/nav-menu-default-items.dev.js        2010-02-28 19:49:31 UTC (rev 13511)
+++ trunk/wp-admin/js/nav-menu-default-items.dev.js        2010-02-28 20:00:49 UTC (rev 13512)
</span><span class="lines">@@ -13,9 +13,13 @@
</span><span class="cx"> */
</span><span class="cx"> jQuery(document).ready(function($){
</span><span class="cx">         
</span><ins>+        wp_drag_and_drop();
+        
+        wp_update_post_data();
+        
</ins><span class="cx">         // Handle Save Button Clicks
</span><span class="cx">         $('#save_menu').click(function(){
</span><del>-                wp_update_post_data();
</del><ins>+                return wp_update_post_data();
</ins><span class="cx">         });
</span><span class="cx">                 
</span><span class="cx">         // Clear the quick search textbox
</span><span class="lines">@@ -30,12 +34,12 @@
</span><span class="cx">         
</span><span class="cx">         // Edit menu item
</span><span class="cx">         $('#menu-container .item-edit').click(function(){
</span><del>-                wp_edit_menu_item( $(this).attr('value') );
</del><ins>+                return wp_edit_menu_item( $(this).attr('value') );
</ins><span class="cx">         });
</span><span class="cx">         
</span><span class="cx">         // Delete menu item
</span><span class="cx">         $('#menu-container .item-delete').live( 'click', function(){
</span><del>-                wp_remove_menu_item( $(this).attr('value') );
</del><ins>+                return wp_remove_menu_item( $(this).attr('value') );
</ins><span class="cx">         });
</span><span class="cx">         
</span><span class="cx">         // Update menu item settings (thickbox)
</span><span class="lines">@@ -50,7 +54,7 @@
</span><span class="cx">         
</span><span class="cx">         // Close thickbox
</span><span class="cx">         $('#cancel-save').click(function(){
</span><del>-                tb_remove();
</del><ins>+                return tb_remove();
</ins><span class="cx">         });
</span><span class="cx">         
</span><span class="cx">         // Show All Button
</span><span class="lines">@@ -58,7 +62,7 @@
</span><span class="cx">                 $(this).offsetParent().find('#add-buttons-actions').attr( 'style','margin-bottom: 10px;' );
</span><span class="cx">                 $(this).offsetParent().find('.list-wrap').css( 'display','block' );
</span><span class="cx">                 $(this).siblings('.quick-search').attr( 'value', '' );                
</span><del>-                $(this).offsetParent().find('.list-wrap dt').css( 'display', 'block' );
</del><ins>+                $(this).offsetParent().find('.list-wrap li').css( 'display', 'block' );
</ins><span class="cx">                 $(this).hide();
</span><span class="cx">                 $(this).siblings('.hide-all').show();
</span><span class="cx">         });
</span><span class="lines">@@ -68,31 +72,35 @@
</span><span class="cx">                 $(this).offsetParent().find('#add-buttons-actions').attr( 'style','margin-bottom: 0px;' );
</span><span class="cx">                 $(this).offsetParent().find('.list-wrap').css( 'display','none' );
</span><span class="cx">                 $(this).siblings('.quick-search').attr( 'value', 'Search' );
</span><del>-                $(this).offsetParent().find('.list-wrap dt').css( 'display', 'none' );
</del><ins>+                $(this).offsetParent().find('.list-wrap li').css( 'display', 'none' );
</ins><span class="cx">                 $(this).hide();
</span><span class="cx">                 $(this).siblings('.show-all').show();
</span><span class="cx">         });
</span><span class="cx">         
</span><ins>+        // 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-id').val();
+                var item_parent_id = jQuery(this).parent().siblings('.item-parent-id').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 );
+        });
+        
</ins><span class="cx">         // Add queued menu items into the menu
</span><span class="cx">         $('.enqueue a').click(function(){
</span><del>-                wp_add_queued_items_to_menu(this);
</del><ins>+                return wp_add_queued_items_to_menu(this);
</ins><span class="cx">         });
</span><span class="cx">         
</span><span class="cx">         // Create the link, add it to the menu + available links section
</span><span class="cx">         $('#add-custom-link .add-to-menu a').click(function(){
</span><span class="cx">                 var link_url = $(this).offsetParent().find('#menu-item-url').val();
</span><span class="cx">                 var link_name = $(this).offsetParent().find('#menu-item-name').val();
</span><del>-                var links = $(this).offsetParent().find('#available-links input:checked');
</del><span class="cx">                 
</span><del>-                // If links are checked in the available links section, add them to the menu
-                if ( links ) {
-                        for (var i = 0; i < links.length; i++) {
-                                wp_add_item_to_menu( 'Custom', links[i].name, links[i].value, links[i].id.substring( 5, links[i].id.length ), 0, '' );
-                        };
-                        
-                        // Reset the checkboxes;
-                        $(links).attr('checked', false);
-                };
</del><ins>+                wp_add_queued_items_to_menu( this );
</ins><span class="cx">                                 
</span><span class="cx">                 // Don't save the link if it was left with it's default settings
</span><span class="cx">                 if ( 'http://' == link_url || 'Menu Item' == link_name )
</span><span class="lines">@@ -119,72 +127,4 @@
</span><span class="cx">                         wp_add_item_to_menu( 'Custom', params.link_name, params.link_url, params.link_id, 0, '' );
</span><span class="cx">                 }, 'json');
</span><span class="cx">         });
</span><del>-        
-        // Add dropzones
- $('#menu li').prepend('<div class="dropzone"></div>');
-
-        // Make menu items draggable
-        $('#menu li').draggable({
-                 handle: ' > dl',
-                 opacity: .8,
-                 addClasses: false,
-                 helper: 'clone',
-                 zIndex: 100
-        });
-
-        // Make items droppable
-        $('#menu dl, #menu .dropzone').droppable({
-                accept: '#menu li',
-                tolerance: 'pointer',
-                
-                drop: function(e, ui) {
-                        var li = $(this).parent();
-                        var child = !$(this).hasClass('dropzone');
-                        
-                        // Add UL to first child
-         if ( child && li.children('ul').length == 0 ) {
-         li.append('<ul id="sub-menu" />');
-         }
-         // Make it draggable
-         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);
-                        $(this).parent().find('dt').removeAttr('style');
-                        
-                        $(this).parent().find('div:first').removeAttr('style');
-         },
-         
-                over: function() {
-                 
-                 if ( 'dropzone ui-droppable' == $(this).attr('class') ) {
-                                // Add child
-                         $(this).parent().find('dt:first').css('background', 'none').css('height', '50px');
-                                
-                 } else if ($(this).attr('class') == 'ui-droppable') {
-                                // Add above
-                         $(this).parent().find('dt:first').css('background', '#d8d8d8');
-                                
-                 } else {
-                                // do nothing
-                 }
-                 var parentid = $(this).parent().attr('id');
-         },
-         out: function() {
-         $(this).parent().find('dt').removeAttr('style');
-         $(this).parent().find('div:first').removeAttr('style');
-         $(this).filter('.dropzone').css({ borderColor: '' });
-         },
-         deactivate: function() {
-                        //
-         }
-        });
</del><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 (13511 => 13512)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-admin/js/nav-menu-default-items.js        2010-02-28 19:49:31 UTC (rev 13511)
+++ trunk/wp-admin/js/nav-menu-default-items.js        2010-02-28 20:00:49 UTC (rev 13512)
</span><span class="lines">@@ -1 +1 @@
</span><del>-jQuery(document).ready(function($){$("#save_menu").click(function(){wp_update_post_data()});$(".quick-search").click(function(){$(this).attr("value","")});$(".quick-search-submit").click(function(){$(this).siblings(".quick-search").search()});$("#menu-container .item-edit").click(function(){wp_edit_menu_item($(this).attr("value"))});$("#menu-container .item-delete").live("click",function(){wp_remove_menu_item($(this).attr("value"))});$("#update-menu-item").click(function(){wp_update_menu_item();tb_remove();var id=$("#edit-item-id").val();$("#menu-"+id+" dt:first").animate({backgroundColor:"#FFFF33"},{duration:"normal",complete:function(){jQuery(this).css("backgroundColor","")}})});$("#cancel-save").click(function(){tb_remove()});$(".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 dt").css("display","block");$(this).hide();$(this).siblings(".hide-all").show()});$(".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 dt").css("display","none");$(this).hide();$(this).siblings(".show-all").show()});$(".enqueue a").click(function(){wp_add_queued_items_to_menu(this)});$("#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();var links=$(this).offsetParent().find("#available-links input:checked");if(links){for(var i=0;i<links.length;i++){wp_add_item_to_menu("Custom",links[i].name,links[i].value,links[i].id.substring(5,links[i].id.length),0,"")}$(links).attr("checked",false)}if("http://"==link_url||"Menu Item"==link_name){return}params={action:"add-menu-link",link_url:link_url,link_name:link_name,};$.post(ajaxurl,params,function(response){if(null==response||"-1"==response){return false}params.link_id=response;wp_add_item_to_menu("Custom",params.link_name,params.link_url,params.link_id,0,"")},"json")});$("#menu li").prepend('<div class="dropzone"></div>');$("#menu li").draggable({handle:" > dl",opacity:0.8,addClasses:false,helper:"clone",zIndex:100});$("#menu dl, #menu .dropzone").droppable({accept:"#menu li",tolerance:"pointer",drop:function(e,ui){var li=$(this).parent();var child=!$(this).hasClass("dropzone");if(child&&li.children("ul").length==0){li.append('<ul id="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);$(this).parent().find("dt").removeAttr("style");$(this).parent().find("div:first").removeAttr("style")},over:function(){if("dropzone ui-droppable"==$(this).attr("class")){$(this).parent().find("dt:first").css("background","none").css("height","50px")}else{if($(this).attr("class")=="ui-droppable"){$(this).parent().find("dt:first").css("background","#d8d8d8")}else{}}var parentid=$(this).parent().attr("id")},out:function(){$(this).parent().find("dt").removeAttr("style");$(this).parent().find("div:first").removeAttr("style");$(this).filter(".dropzone").css({borderColor:""})},deactivate:function(){}})});
</del><span class="cx">\ No newline at end of file
</span><ins>+jQuery(document).ready(function($){wp_drag_and_drop();wp_update_post_data();$("#save_menu").click(function(){return wp_update_post_data()});$(".quick-search").click(function(){$(this).attr("value","")});$(".quick-search-submit").click(function(){$(this).siblings(".quick-search").search()});$("#menu-container .item-edit").click(function(){return wp_edit_menu_item($(this).attr("value"))});$("#menu-container .item-delete").live("click",function(){return wp_remove_menu_item($(this).attr("value"))});$("#update-menu-item").click(function(){wp_update_menu_item();tb_remove();var id=$("#edit-item-id").val();$("#menu-"+id+" dt:first").animate({backgroundColor:"#FFFF33"},{duration:"normal",complete:function(){jQuery(this).css("backgroundColor","")}})});$("#cancel-save").click(function(){return tb_remove()});$(".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()});$(".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()});$(".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-id").val();var item_parent_id=jQuery(this).parent().siblings(".item-parent-id").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)});$(".enqueue a").click(function(){return wp_add_queued_items_to_menu(this)});$("#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();wp_add_queued_items_to_menu(this);if("http://"==link_url||"Menu Item"==link_name){return}params={action:"add-menu-link",link_url:link_url,link_name:link_name,};$.post(ajaxurl,params,function(response){if(null==response||"-1"==response){return false}params.link_id=response;wp_add_item_to_menu("Custom",params.link_name,params.link_url,params.link_id,0,"")},"json")})});
</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 (13511 => 13512)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-admin/js/nav-menu-dynamic-functions.dev.js        2010-02-28 19:49:31 UTC (rev 13511)
+++ trunk/wp-admin/js/nav-menu-dynamic-functions.dev.js        2010-02-28 20:00:49 UTC (rev 13512)
</span><span class="lines">@@ -24,43 +24,21 @@
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> /**
</span><del>- * Removes a menu item from current menu
- *
- * @param int o - the id of the menu li to remove.
- */
-function wp_remove_menu_item( o ) {
-        var todelete = document.getElementById('menu-' + o);
-        
-        if ( todelete ) {
-                // Give some feedback to the user
-                jQuery( todelete ).find('dt').each(function(){
-                        jQuery(this).animate( { backgroundColor: '#FF3333' }, { duration: 'normal', complete: function() { jQuery(this).parent().parent().remove() } } );
-                });
-                
-                wp_update_post_data();
-        }
-};
-
-/**
</del><span class="cx"> * Populate the thickbox window with the selected menu items
</span><span class="cx"> *
</span><span class="cx"> * @param int o - the id of the menu li to edit.
</span><span class="cx"> */
</span><span class="cx"> function wp_edit_menu_item( id ) {
</span><del>-        console.log('wp_edit_menu_item');
-        
</del><ins>+        var itemType = jQuery('#item-type' + id).val();
</ins><span class="cx">         var itemTitle = jQuery('#item-title' + id).val();
</span><span class="cx">         var itemURL = jQuery('#item-url' + id).val();
</span><span class="cx">         var itemAttrTitle = jQuery('#item-attr-title' + id).val();
</span><span class="cx">         var itemTarget = jQuery('#item-target' + id).val();
</span><span class="cx">         var itemDesc = jQuery('#item-description' + id).val();
</span><span class="cx">         
</span><del>-        console.log(id);
-        console.log(itemTitle);
-        console.log(itemURL);
-        console.log(itemAttrTitle);
-        console.log(itemTarget);
-        console.log(itemDesc);
</del><ins>+        // Disable the ability to edit the url for page and category items
+        if ( 'page' == itemType || 'category' == itemType )
+                jQuery( '#edit-item-url' ).attr('disabled', 'disabled' );
</ins><span class="cx">         
</span><span class="cx">         // Populate the fields for thickbox
</span><span class="cx">         jQuery( '#edit-item-id' ).val(id);
</span><span class="lines">@@ -83,13 +61,6 @@
</span><span class="cx">         var itemTarget = jQuery('#edit-item-target').val();
</span><span class="cx">         var itemDesc = jQuery('#edit-item-description').val();
</span><span class="cx">         
</span><del>-        console.log(id);
-        console.log(itemTitle);
-        console.log(itemURL);
-        console.log(itemAttrTitle);
-        console.log(itemTarget);
-        console.log(itemDesc);
-        
</del><span class="cx">         // update menu item settings        
</span><span class="cx">         jQuery('#menu-' + id).find('.item-title:first').html(itemTitle);
</span><span class="cx">         jQuery('#item-title' + id).val(itemTitle);
</span><span class="lines">@@ -100,29 +71,47 @@
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> /**
</span><ins>+ * Removes a menu item from current menu
+ *
+ * @param int o - the id of the menu li to remove.
+ */
+function wp_remove_menu_item( o ) {
+        var todelete = document.getElementById('menu-' + o);
+        
+        if ( todelete ) {
+                // Give some feedback to the user
+                jQuery( todelete ).find('dt').each(function(){
+                        jQuery(this).animate( { backgroundColor: '#FF3333' }, { duration: 'normal', complete: function() { jQuery(this).parent().parent().remove() } } );
+                });
+                
+                wp_update_post_data();
+        }
+};
+
+/**
</ins><span class="cx"> * Prepares menu items for POST
</span><span class="cx"> */
</span><span class="cx"> function wp_update_post_data() {
</span><span class="cx">         var i = 0;
</span><span class="cx">         
</span><del>-         jQuery('#menu li').each(function(i) {
</del><ins>+         jQuery('.menu li').each(function(i) {
</ins><span class="cx">                 i = i + 1;
</span><span class="cx">         var j = jQuery(this).attr('value');
</span><span class="cx">
</span><del>-         jQuery(this).find('#position' + j).attr('value', i);
</del><ins>+         jQuery(this).find('#item-position' + j).attr('value', i);
</ins><span class="cx">         jQuery(this).attr('id','menu-' + i);
</span><span class="cx">         jQuery(this).attr('value', i);
</span><span class="cx">
</span><del>-         jQuery(this).find('#dbid' + j).attr('name','dbid' + i);
-         jQuery(this).find('#dbid' + j).attr('id','dbid' + i);
</del><ins>+         jQuery(this).find('#item-dbid' + j).attr('name','item-dbid' + i);
+         jQuery(this).find('#item-dbid' + j).attr('id','item-dbid' + i);
</ins><span class="cx">
</span><del>-                jQuery(this).find('#postmenu' + j).attr('name','postmenu' + i);
-         jQuery(this).find('#postmenu' + j).attr('id','postmenu' + i);
</del><ins>+                jQuery(this).find('#item-postmenu' + j).attr('name','item-postmenu' + i);
+         jQuery(this).find('#item-postmenu' + j).attr('id','item-postmenu' + i);
</ins><span class="cx">
</span><del>-         var p = jQuery(this).find('#parent' + j).parent().parent().parent().attr('value');
</del><ins>+         var p = jQuery(this).find('#item-parent' + j).parent().parent().parent().attr('value');
</ins><span class="cx">
</span><del>-                jQuery(this).find('#parent' + j).attr('name','parent' + i);
-                jQuery(this).find('#parent' + j).attr('id','parent' + i);
</del><ins>+                jQuery(this).find('#item-parent' + j).attr('name','item-parent' + i);
+                jQuery(this).find('#item-parent' + j).attr('id','item-parent' + i);
</ins><span class="cx">                 
</span><span class="cx">                 if (p) {
</span><span class="cx">                         // Do nothing
</span><span class="lines">@@ -131,7 +120,7 @@
</span><span class="cx">                         p = 0;
</span><span class="cx">                 }
</span><span class="cx">
</span><del>-                jQuery(this).find('#parent' + j).attr('value', p);
</del><ins>+                jQuery(this).find('#item-parent' + j).attr('value', p);
</ins><span class="cx">
</span><span class="cx">                 jQuery(this).find('#item-title' + j).attr('name','item-title' + i);
</span><span class="cx">                 jQuery(this).find('#item-title' + j).attr('id','item-title' + i);
</span><span class="lines">@@ -148,11 +137,11 @@
</span><span class="cx">                 jQuery(this).find('#item-target' + j).attr('name','item-target' + i);
</span><span class="cx">                 jQuery(this).find('#item-target' + j).attr('id','item-target' + i);
</span><span class="cx">
</span><del>-                jQuery(this).find('#position' + j).attr('name', 'position' + i);
-                jQuery(this).find('#position' + j).attr('id', 'position' + i);
</del><ins>+                jQuery(this).find('#item-position' + j).attr('name', 'item-position' + i);
+                jQuery(this).find('#item-position' + j).attr('id', 'item-position' + i);
</ins><span class="cx">
</span><del>-                jQuery(this).find('#linktype' + j).attr('name', 'linktype' + i);
-                jQuery(this).find('#linktype' + j).attr('id', 'linktype' + i);
</del><ins>+                jQuery(this).find('#item-type' + j).attr('name', 'item-type' + i);
+                jQuery(this).find('#item-type' + j).attr('id', 'item-type' + i);
</ins><span class="cx">
</span><span class="cx">                 jQuery('#li-count').attr( 'value', i );
</span><span class="cx"> });
</span><span class="lines">@@ -169,30 +158,20 @@
</span><span class="cx"> * @param int itemparentid - default 0.
</span><span class="cx"> * @param string itemdescription - the description of the menu item.
</span><span class="cx"> */
</span><del>-function wp_add_item_to_menu( additemtype, itemtext, itemurl, itemid, itemparentid, itemdescription ) {
-        var inputvaluevarname = '';
-        var inputvaluevarurl = '';
-        var inputitemid = '';
-        var inputparentid= '';
-        var inputdescription = '';
</del><ins>+function wp_add_item_to_menu( item_type, item_title, item_url, item_id, item_parent_id, item_description ) {
</ins><span class="cx">         var randomnumber = wp_get_unique_menu_id();
</span><del>-
-        inputvaluevarname = htmlentities(itemtext.toString());
-        inputvaluevarurl = itemurl.toString();
-        inputitemid = itemid;
-        inputparentid = itemparentid;
-        inputlinktype = 'custom';
-        inputdescription = htmlentities(itemdescription.toString());
</del><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">' + inputvaluevarname + '</span><span class="item-controls"><span class="item-type">' + additemtype + '</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><a class="hide" href="' + inputvaluevarurl + '">' + inputvaluevarname + '</a><input type="hidden" name="postmenu' + randomnumber + '" id="postmenu' + randomnumber + '" value="' + inputitemid + '" /><input type="hidden" name="parent' + randomnumber + '" id="parent' + randomnumber + '" value="' + inputparentid + '" /><input type="hidden" name="item-title' + randomnumber + '" id="item-title' + randomnumber + '" value="' + inputvaluevarname + '" /><input type="hidden" name="item-url' + randomnumber + '" id="item-url' + randomnumber + '" value="' + inputvaluevarurl + '" /><input type="hidden" name="item-description' + randomnumber + '" id="item-description' + randomnumber + '" value="' + inputdescription + '" /><input type="hidden" name="position' + randomnumber + '" id="position' + randomnumber + '" value="' + randomnumber + '" /><input type="hidden" name="linktype' + randomnumber + '" id="linktype' + randomnumber + '" value="' + inputlinktype + '" /><input type="hidden" name="item-attr-title' + randomnumber + '" id="item-attr-title' + randomnumber + '" value="' + inputvaluevarname + '" /><input type="hidden" name="item-target' + randomnumber + '" id="item-target' + randomnumber + '" value="0" /></li>');
</del><ins>+        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>');
</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-' + 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><ins>+        wp_update_post_data();
+        
</ins><span class="cx">         // Reload thickbox
</span><span class="cx">         tb_init('a.thickbox, area.thickbox, input.thickbox');
</span><span class="cx"> };
</span><span class="lines">@@ -200,55 +179,26 @@
</span><span class="cx"> /*
</span><span class="cx"> * Queues items in perperation for appendToList
</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 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.
</ins><span class="cx"> */
</span><del>-function wp_update_queue( additemtype, itemtext, itemurl, itemid, itemparentid, itemdescription ) {
-        var inputvaluevarname = '';
-        var inputvaluevarurl = '';
-        var inputitemid = '';
-        var inputparentid= '';
-        var inputdescription = '';
</del><ins>+function wp_update_queue( e, item_type, item_title, item_url, item_id, item_parent_id, item_description ) {
</ins><span class="cx">         var randomnumber = wp_get_unique_menu_id();
</span><del>-
-        if ( additemtype == navMenuL10n.page ) {
-                inputvaluevarname = htmlentities(itemtext.toString());
-                inputvaluevarurl = itemurl.toString();
-                inputitemid = itemid.toString();
-                inputparentid = '0';
-                inputlinktype = 'page';
-                inputdescription = htmlentities(itemdescription.toString());
-
-        } else if ( additemtype == navMenuL10n.category ) {
-                inputvaluevarname = htmlentities(itemtext.toString());
-                inputvaluevarurl = itemurl.toString();
-                inputitemid = itemid.toString();
-                inputparentid = '0';
-                inputlinktype = 'category';
-                inputdescription = htmlentities(itemdescription.toString());
-        }
-                        
-        // Adds or removes the item from the queue
-        if ( jQuery(menu_item_id = '#menu-item-' + inputitemid).attr('checked') ) {
-                
</del><ins>+        var menu_item_id = jQuery(e).attr('id');
+        
+        if ( jQuery(e).attr('checked') ) {
</ins><span class="cx">                 // Add menu item to the queue
</span><del>-                jQuery('#queue').append('<li id="menu-' + randomnumber + '" value="' + randomnumber + '"><div class="dropzone ui-droppable"></div><dl class="ui-droppable"><dt><span class="item-title">' + inputvaluevarname + '</span><span class="item-controls"><span class="item-type">' + additemtype + '</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><a class="hide" href="' + inputvaluevarurl + '">' + inputvaluevarname + '</a><input type="hidden" name="postmenu' + randomnumber + '" id="postmenu' + randomnumber + '" value="' + inputitemid + '" /><input type="hidden" name="parent' + randomnumber + '" id="parent' + randomnumber + '" value="' + inputparentid + '" /><input type="hidden" name="item-title' + randomnumber + '" id="item-title' + randomnumber + '" value="' + inputvaluevarname + '" /><input type="hidden" name="item-url' + randomnumber + '" id="item-url' + randomnumber + '" value="' + inputvaluevarurl + '" /><input type="hidden" name="item-description' + randomnumber + '" id="item-description' + randomnumber + '" value="' + inputdescription + '" /><input type="hidden" name="position' + randomnumber + '" id="position' + randomnumber + '" value="' + randomnumber + '" /><input type="hidden" name="linktype' + randomnumber + '" id="linktype' + randomnumber + '" value="' + inputlinktype + '" /><input type="hidden" name="item-attr-title' + randomnumber + '" id="item-attr-title' + randomnumber + '" value="' + inputvaluevarname + '" /><input type="hidden" name="item-target' + randomnumber + '" id="item-target' + randomnumber + '" value="0" /></li>');
-        } else {
</del><ins>+                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>');
</ins><span class="cx">                 
</span><del>-                // Get the item in the queue
-                for ( var i = 0; i < jQuery('#queue li input[name^="postmenu"]').length; i++ ) {
-                        if ( itemid == jQuery('#queue li input[name^="postmenu"]')[i].value ) {
-                                var menu_queue_id = jQuery('#queue li input[name^="postmenu"]')[i].name.substring( 8, jQuery('#queue li input[name^="postmenu"]')[i].name.length );
-                        };
</del><ins>+        } 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()
</ins><span class="cx">                 };
</span><del>-                
-                // Removes the item from the queue
-                jQuery('#queue li#menu-' + menu_queue_id).remove();
</del><span class="cx">         };
</span><span class="cx"> };
</span><span class="cx">
</span><span class="lines">@@ -265,7 +215,7 @@
</span><span class="cx">         jQuery('#queue').empty();
</span><span class="cx">                 
</span><span class="cx">         // Appends HTML to the menu
</span><del>-        jQuery('#menu').append( items );
</del><ins>+        jQuery('.menu').append( items );
</ins><span class="cx">
</span><span class="cx">         // Give some feedback to the user
</span><span class="cx">         jQuery(items).each(function(){
</span><span class="lines">@@ -288,18 +238,25 @@
</span><span class="cx"> * Allow the items in the Menu to be dragged and dropped.
</span><span class="cx"> */
</span><span class="cx"> function wp_drag_and_drop() {
</span><ins>+        // Make sure all li's have dropzones
+        jQuery('.menu li').each(function(){
+                if ( !jQuery(this).children('.dropzone').attr('class') ) {
+                        jQuery(this).prepend('<div class="dropzone"></div>');
+                };
+        });
+
</ins><span class="cx">         // make menu item draggable
</span><del>-        jQuery('#menu li').draggable({
</del><ins>+        jQuery('.menu li').draggable({
</ins><span class="cx">                 handle: ' > dl',
</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><del>-        jQuery('#menu li dl, #menu li .dropzone').droppable({
-                accept: '#menu li',
</del><ins>+        jQuery('.menu li dl, .menu li .dropzone').droppable({
+                accept: '.menu li',
</ins><span class="cx">                 tolerance: 'pointer',
</span><span class="cx">                 drop: function(e, ui) {
</span><span class="cx">                         var li = jQuery(this).parent();
</span><span class="lines">@@ -307,7 +264,7 @@
</span><span class="cx">                         
</span><span class="cx">                         // Append UL to first child
</span><span class="cx">                         if ( child && li.children('ul').length == 0 ) {
</span><del>-                                li.append( '<ul/>' );
</del><ins>+                                li.append( '<ul class="sub-menu" />' );
</ins><span class="cx">                         }
</span><span class="cx">                         // Make it draggable
</span><span class="cx">                         if ( child ) {
</span><span class="lines">@@ -322,18 +279,18 @@
</span><span class="cx">                         var droppablevalue = li.attr('value');
</span><span class="cx">                         
</span><span class="cx">                         li.find('#menu-' + draggablevalue).find('#parent' + draggablevalue).val(droppablevalue);
</span><del>-                        jQuery(this).parent().find("dt").removeAttr('style');
-                        jQuery(this).parent().find("div:first").removeAttr('style');
</del><ins>+                        jQuery(this).parent().find('dt').removeAttr('style');
+                        jQuery(this).parent().find('div:first').removeAttr('style');
</ins><span class="cx">
</span><span class="cx">                 },
</span><span class="cx">                 over: function() {
</span><span class="cx">                          // Add child
</span><span class="cx">                          if ( jQuery(this).attr('class') == 'dropzone ui-droppable' ) {
</span><del>-                                 jQuery(this).parent().find("div:first").css('background', 'none').css('height', '50px');
</del><ins>+                                 jQuery(this).parent().find('div:first').css('background', 'none').css('height', '50px');
</ins><span class="cx">                          }
</span><span class="cx">                          // Add above
</span><span class="cx">                          else if ( jQuery(this).attr('class') == 'ui-droppable' ) {
</span><del>-                                 jQuery(this).parent().find("dt:first").css('background', '#d8d8d8');
</del><ins>+                                 jQuery(this).parent().find('dt:first').css('background', '#d8d8d8');
</ins><span class="cx">                          } else {
</span><span class="cx">                                         // do nothing
</span><span class="cx">                          }
</span><span class="lines">@@ -341,8 +298,8 @@
</span><span class="cx">
</span><span class="cx">                  },
</span><span class="cx">                  out: function() {
</span><del>-                 jQuery(this).parent().find("dt").removeAttr('style');
-                 jQuery(this).parent().find("div:first").removeAttr('style');
</del><ins>+                 jQuery(this).parent().find('dt').removeAttr('style');
+                 jQuery(this).parent().find('div:first').removeAttr('style');
</ins><span class="cx">                  jQuery(this).filter('.dropzone').css({ borderColor: '' });
</span><span class="cx">                  }
</span><span class="cx">                 }
</span><span class="lines">@@ -353,7 +310,7 @@
</span><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><del>-        var count = document.getElementById('menu').getElementsByTagName('li').length + 1;
</del><ins>+        var count = jQuery('.menu li').length + 1;
</ins><span class="cx">         var randomnumber = count;
</span><span class="cx">         var validatetest = 0;
</span><span class="cx">
</span></span></pre></div>
<a id="trunkwpadminjsnavmenudynamicfunctionsjs"></a>
<div class="modfile"><h4>Modified: trunk/wp-admin/js/nav-menu-dynamic-functions.js (13511 => 13512)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-admin/js/nav-menu-dynamic-functions.js        2010-02-28 19:49:31 UTC (rev 13511)
+++ trunk/wp-admin/js/nav-menu-dynamic-functions.js        2010-02-28 20:00:49 UTC (rev 13512)
</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_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_edit_menu_item(id){console.log("wp_edit_menu_item");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();console.log(id);console.log(itemTitle);console.log(itemURL);console.log(itemAttrTitle);console.log(itemTarget);console.log(itemDesc);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();console.log(id);console.log(itemTitle);console.log(itemURL);console.log(itemAttrTitle);console.log(itemTarget);console.log(itemDesc);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_update_post_data(){var i=0;jQuery("#menu li").each(function(i){i=i+1;var j=jQuery(this).attr("value");jQuery(this).find("#position"+j).attr("value",i);jQuery(this).attr("id","menu-"+i);jQuery(this).attr("value",i);jQuery(this).find("#dbid"+j).attr("name","dbid"+i);jQuery(this).find("#dbid"+j).attr("id","dbid"+i);jQuery(this).find("#postmenu"+j).attr("name","postmenu"+i);jQuery(this).find("#postmenu"+j).attr("id","postmenu"+i);var p=jQuery(this).find("#parent"+j).parent().parent().parent().attr("value");jQuery(this).find("#parent"+j).attr("name","parent"+i);jQuery(this).find("#parent"+j).attr("id","parent"+i);if(p){}else{p=0}jQuery(this).find("#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("#position"+j).attr("name","position"+i);jQuery(this).find("#position"+j).attr("id","position"+i);jQuery(this).find("#linktype"+j).attr("name","linktype"+i);jQuery(this).find("#linktype"+j).attr("id","linktype"+i);jQuery("#li-count").attr("value",i)})}function wp_add_item_to_menu(additemtype,itemtext,itemurl,itemid,itemparentid,itemdescription){var inputvaluevarname="";var inputvaluevarurl="";var inputitemid="";var inputparentid="";var inputdescription="";var randomnumber=wp_get_unique_menu_id();inputvaluevarname=htmlentities(itemtext.toString());inputvaluevarurl=itemurl.toString();inputitemid=itemid;inputparentid=itemparentid;inputlinktype="custom";inputdescription=htmlentities(itemdescription.toString());jQuery("#menu").append('<li id="menu-'+randomnumber+'" value="'+randomnumber+'"><div class="dropzone ui-droppable"></div><dl class="ui-droppable"><dt><span class="item-title">'+inputvaluevarname+'</span><span class="item-controls"><span class="item-type">'+additemtype+'</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><a class="hide" href="'+inputvaluevarurl+'">'+inputvaluevarname+'</a><input type="hidden" name="postmenu'+randomnumber+'" id="postmenu'+randomnumber+'" value="'+inputitemid+'" /><input type="hidden" name="parent'+randomnumber+'" id="parent'+randomnumber+'" value="'+inputparentid+'" /><input type="hidden" name="item-title'+randomnumber+'" id="item-title'+randomnumber+'" value="'+inputvaluevarname+'" /><input type="hidden" name="item-url'+randomnumber+'" id="item-url'+randomnumber+'" value="'+inputvaluevarurl+'" /><input type="hidden" name="item-description'+randomnumber+'" id="item-description'+randomnumber+'" value="'+inputdescription+'" /><input type="hidden" name="position'+randomnumber+'" id="position'+randomnumber+'" value="'+randomnumber+'" /><input type="hidden" name="linktype'+randomnumber+'" id="linktype'+randomnumber+'" value="'+inputlinktype+'" /><input type="hidden" name="item-attr-title'+randomnumber+'" id="item-attr-title'+randomnumber+'" value="'+inputvaluevarname+'" /><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();tb_init("a.thickbox, area.thickbox, input.thickbox")}function wp_update_queue(additemtype,itemtext,itemurl,itemid,itemparentid,itemdescription){var inputvaluevarname="";var inputvaluevarurl="";var inputitemid="";var inputparentid="";var inputdescription="";var randomnumber=wp_get_unique_menu_id();if(additemtype==navMenuL10n.page){inputvaluevarname=htmlentities(itemtext.toString());inputvaluevarurl=itemurl.toString();inputitemid=itemid.toString();inputparentid="0";inputlinktype="page";inputdescription=htmlentities(itemdescription.toString())}else{if(additemtype==navMenuL10n.category){inputvaluevarname=htmlentities(itemtext.toString());inputvaluevarurl=itemurl.toString();inputitemid=itemid.toString();inputparentid="0";inputlinktype="category";inputdescription=htmlentities(itemdescription.toString())}}if(jQuery(menu_item_id="#menu-item-"+inputitemid).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">'+inputvaluevarname+'</span><span class="item-controls"><span class="item-type">'+additemtype+'</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><a class="hide" href="'+inputvaluevarurl+'">'+inputvaluevarname+'</a><input type="hidden" name="postmenu'+randomnumber+'" id="postmenu'+randomnumber+'" value="'+inputitemid+'" /><input type="hidden" name="parent'+randomnumber+'" id="parent'+randomnumber+'" value="'+inputparentid+'" /><input type="hidden" name="item-title'+randomnumber+'" id="item-title'+randomnumber+'" value="'+inputvaluevarname+'" /><input type="hidden" name="item-url'+randomnumber+'" id="item-url'+randomnumber+'" value="'+inputvaluevarurl+'" /><input type="hidden" name="item-description'+randomnumber+'" id="item-description'+randomnumber+'" value="'+inputdescription+'" /><input type="hidden" name="position'+randomnumber+'" id="position'+randomnumber+'" value="'+randomnumber+'" /><input type="hidden" name="linktype'+randomnumber+'" id="linktype'+randomnumber+'" value="'+inputlinktype+'" /><input type="hidden" name="item-attr-title'+randomnumber+'" id="item-attr-title'+randomnumber+'" value="'+inputvaluevarname+'" /><input type="hidden" name="item-target'+randomnumber+'" id="item-target'+randomnumber+'" value="0" /></li>')}else{for(var i=0;i<jQuery('#queue li input[name^="postmenu"]').length;i++){if(itemid==jQuery('#queue li input[name^="postmenu"]')[i].value){var menu_queue_id=jQuery('#queue li input[name^="postmenu"]')[i].name.substring(8,jQuery('#queue li input[name^="postmenu"]')[i].name.length)}}jQuery("#queue li#menu-"+menu_queue_id).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").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/>")}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=document.getElementById("menu").getElementsByTagName("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_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};
</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 (13511 => 13512)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-admin/nav-menus.php        2010-02-28 19:49:31 UTC (rev 13511)
+++ trunk/wp-admin/nav-menus.php        2010-02-28 20:00:49 UTC (rev 13512)
</span><span class="lines">@@ -43,9 +43,6 @@
</span><span class="cx"> $updated = false;
</span><span class="cx"> $advanced_option_descriptions = 'no';
</span><span class="cx">
</span><del>-// Get all menu link items
-$available_links = new WP_Query( array( 'post_status' => 'any', 'post_type' => 'nav_menu_item', 'meta_key' => 'menu_type', 'meta_value' => 'custom' ) );
-
</del><span class="cx"> // Check which menu is selected and if menu is in edit already
</span><span class="cx"> if ( isset( $_GET['edit-menu'] ) ) {
</span><span class="cx">         $menu_selected_id = (int) $_GET['edit-menu'];
</span><span class="lines">@@ -127,16 +124,16 @@
</span><span class="cx">         
</span><span class="cx">         // Loop through all POST variables
</span><span class="cx">         for ( $k = 1; $k <= $post_counter; $k++ ) {
</span><del>-                $db_id = isset( $_POST['dbid'.$k] )? $_POST['dbid'.$k] : 0;
-                $object_id = isset( $_POST['postmenu'.$k] )? $_POST['postmenu'.$k] : 0;
-                $parent_id = isset( $_POST['parent'.$k] )? $_POST['parent'.$k] : 0;
</del><ins>+                $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;
</ins><span class="cx">                 $custom_title = isset( $_POST['item-title'.$k] )? $_POST['item-title'.$k] : '';
</span><span class="cx">                 $custom_linkurl = ( isset( $_POST['item-url'.$k] ) && 'custom' == $_POST['linktype'.$k] ) ? $_POST['item-url'.$k] : '';
</span><span class="cx">                 $custom_description = isset( $_POST['item-description'.$k] )? $_POST['item-description'.$k] : '';
</span><ins>+                
</ins><span class="cx">                 // doesn't seem to be used by UI
</span><del>-                $icon = isset( $_POST['icon'.$k] )? $_POST['icon'.$k] : 0;
-                $position = isset( $_POST['position'.$k] )? $_POST['position'.$k] : 0;
-                $linktype = isset( $_POST['linktype'.$k] )? $_POST['linktype'.$k] : 'custom';
</del><ins>+                $position = isset( $_POST['item-position'.$k] )? $_POST['item-position'.$k] : 0;
+                $linktype = isset( $_POST['item-type'.$k] )? $_POST['item-type'.$k] : 'custom';
</ins><span class="cx">                 $custom_anchor_title = isset( $_POST['item-attr-title'.$k] )? $_POST['item-attr-title'.$k] : $custom_title;
</span><span class="cx">                 $new_window = isset( $_POST['item-target'.$k] )? $_POST['item-target'.$k] : 0;
</span><span class="cx">
</span><span class="lines">@@ -209,14 +206,10 @@
</span><span class="cx">                                                         <div class="inside">
</span><span class="cx">                                                                 <input type="hidden" name="li-count" id="li-count" value="0" />
</span><span class="cx">                                                                 <input type="hidden" name="menu-id-in-edit" id="menu-id-in-edit" value="<?php echo esc_attr( $menu_selected_id ); ?>" />
</span><del>-
-                                                                <ul id="menu">
</del><span class="cx">                                                                 <?php
</span><del>-                                                                if ( $menu_selected_id > 0 ) {
-                                                                        wp_print_nav_menu( array( 'type' => 'backend', 'name' => $menu_title, 'id' => $menu_selected_id ) );
-                                                                }
</del><ins>+                                                                if ( $menu_selected_id > 0 )
+                                                                        echo wp_get_nav_menu( array( 'type' => 'backend', 'menu' => $menu_selected_id, 'ul_class' => 'menu' ) );
</ins><span class="cx">                                                                 ?>
</span><del>-                                                                </ul><!-- /#menu-->
</del><span class="cx">                                                                 
</span><span class="cx">                                                                 <div id="queue" class="hide">
</span><span class="cx">                                                                 </div><!--/#queue-->
</span><span class="lines">@@ -265,7 +258,6 @@
</span><span class="cx">                                                                 </label>
</span><span class="cx">                                                         </p>
</span><span class="cx">                                                         
</span><del>-                                        <?php if ( $available_links->posts ) : ?>
</del><span class="cx">                                                         <p class="button-controls">
</span><span class="cx">                                                                 <a class="show-all button"><?php _e('View All'); ?></a>
</span><span class="cx">                                                                 <a class="hide-all button"><?php _e('Hide All'); ?></a>
</span><span class="lines">@@ -273,24 +265,10 @@
</span><span class="cx">                                                         <div id="available-links" class="list-wrap">
</span><span class="cx">                                                                 <div class="list-container">
</span><span class="cx">                                                                         <ul class="list">
</span><del>-                                                                        <?php
-                                                                        foreach ( $available_links->posts as $link ) :
-                                                                        $url = get_post_meta( $link->ID, 'menu_link' );
-                                                                        ?>
-                                                                                <li>
-                                                                                        <dl>
-                                                                                                <dt>
-                                                                                                        <label class="item-title"><input type="checkbox" id="link-<?php echo esc_attr($link->ID); ?>" name="<?php echo esc_attr($link->post_title); ?>" value="<?php echo esc_attr($url[0]); ?>" /><?php echo esc_html($link->post_title); ?></label>
-                                                                                                </dt>
-                                                                                        </dl>
-                                                                                </li>
-                                                                        <?php
-                                                                        endforeach;
-                                                                        ?>
</del><ins>+                                                                        <?php $items_counter = wp_nav_menu_get_custom_links( 0, 'default' ); ?>
</ins><span class="cx">                                                                         </ul>
</span><span class="cx">                                                                 </div><!-- /.list-container-->
</span><span class="cx">                                                         </div><!-- /#available-links-->
</span><del>-                                        <?php endif; ?>
</del><span class="cx">                                                         <p class="add-to-menu">
</span><span class="cx">                                                                 <a class="button"><?php _e('Add to Menu'); ?></a>
</span><span class="cx">                                                         </p>
</span><span class="lines">@@ -325,7 +303,7 @@
</span><span class="cx">                                                                         
</span><span class="cx">                                                                         jQuery('#add-pages .quick-search').result(function(event, data, formatted) {
</span><span class="cx">                                                                                 jQuery('#add-pages .list-wrap').css('display','block');
</span><del>-                                                                                jQuery("#add-pages .list-wrap dt:contains('" + data + "')").css('display','block');
</del><ins>+                                                                                jQuery("#add-pages .list-wrap li:contains('" + data + "')").css('display','block');
</ins><span class="cx">                                                                                 jQuery('#add-pages .show-all').hide();
</span><span class="cx">                                                                                 jQuery('#add-pages .hide-all').show();
</span><span class="cx">                                                                         });
</span><span class="lines">@@ -344,7 +322,7 @@
</span><span class="cx">                                                         <div id="existing-pages" class="list-wrap">
</span><span class="cx">                                                                 <div class="list-container">
</span><span class="cx">                                                                         <ul class="list">
</span><del>-                                                                        <?php $items_counter = wp_nav_menu_get_pages( 0, 'default' ); ?>
</del><ins>+                                                                        <?php $items_counter = wp_nav_menu_get_pages( $items_counter, 'default' ); ?>
</ins><span class="cx">                                                                         </ul>
</span><span class="cx">                                                                 </div><!-- /.list-container-->
</span><span class="cx">                                                         </div><!-- /#existing-pages-->
</span><span class="lines">@@ -387,7 +365,7 @@
</span><span class="cx">                                                                         jQuery('#add-categories .quick-search').autocomplete(categories);
</span><span class="cx">                                                                         jQuery('#add-categories .quick-search').result(function(event, data, formatted) {
</span><span class="cx">                                                                                 jQuery('#add-categories .list-wrap').css('display','block');
</span><del>-                                                                                jQuery("#add-categories .list-wrap dt:contains('" + data + "')").css('display','block');
</del><ins>+                                                                                jQuery("#add-categories .list-wrap li:contains('" + data + "')").css('display','block');
</ins><span class="cx">                                                                                 jQuery('#add-categories .show-all').hide();
</span><span class="cx">                                                                                 jQuery('#add-categories .hide-all').show();
</span><span class="cx">                                                                         });
</span></span></pre></div>
<a id="trunkwpcontentthemestwentytenheaderphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-content/themes/twentyten/header.php (13511 => 13512)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-content/themes/twentyten/header.php        2010-02-28 19:49:31 UTC (rev 13511)
+++ trunk/wp-content/themes/twentyten/header.php        2010-02-28 20:00:49 UTC (rev 13512)
</span><span class="lines">@@ -1,8 +1,8 @@
</span><span class="cx"> <!DOCTYPE html>
</span><span class="cx"> <html <?php language_attributes(); ?>>
</span><span class="cx"> <head>
</span><del>-        <title><?php
-                if ( is_single() ) {
</del><ins>+ <title><?php
+ if ( is_single() ) {
</ins><span class="cx">                         single_post_title(); echo ' | '; bloginfo('name');
</span><span class="cx">                 } elseif ( is_home() || is_front_page() ) {
</span><span class="cx">                         bloginfo('name'); echo ' | '; bloginfo('description'); twentyten_the_page_number();
</span><span class="lines">@@ -15,7 +15,7 @@
</span><span class="cx">                 } else {
</span><span class="cx">                         wp_title(''); echo ' | '; bloginfo('name'); twentyten_the_page_number();
</span><span class="cx">                 }
</span><del>-        ?></title>
</del><ins>+ ?></title>
</ins><span class="cx">
</span><span class="cx">         <meta http-equiv="content-type" content="<?php bloginfo('html_type'); ?>; charset=<?php bloginfo('charset'); ?>" />
</span><span class="cx">
</span></span></pre></div>
<a id="trunkwpincludesdefaultwidgetsphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-includes/default-widgets.php (13511 => 13512)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-includes/default-widgets.php        2010-02-28 19:49:31 UTC (rev 13511)
+++ trunk/wp-includes/default-widgets.php        2010-02-28 20:00:49 UTC (rev 13512)
</span><span class="lines">@@ -1044,231 +1044,62 @@
</span><span class="cx"> class WP_Nav_Menu_Widget extends WP_Widget {
</span><span class="cx">
</span><span class="cx">         function WP_Nav_Menu_Widget() {
</span><del>-                $widget_ops = array('description' => __('Use this widget to add one of your navigation menus as a widget.') );
-                parent::WP_Widget( false, __('Navigation Menu'), $widget_ops );
</del><ins>+                $widget_ops = array( 'description' => __('Use this widget to add one of your navigation menus as a widget.') );
+                parent::WP_Widget( 'nav_menu', __('Navigation Menu'), $widget_ops );
</ins><span class="cx">         }
</span><del>-
</del><ins>+        
</ins><span class="cx">         function widget($args, $instance) {
</span><del>-                $navmenu = $instance['navmenu'];
-                $navtitle = $instance['navtitle'];
-                $navdeveloper = strtolower($instance['navdeveloper']);
-                $navdiv = strtolower($instance['navdiv']);
-                $navul = strtolower($instance['navul']);
-                $navdivid = $instance['navdivid'];
-                $navdivclass = $instance['navdivclass'];
-                $navulid = $instance['navulid'];
-                $navulclass = $instance['navulclass'];
-
-                // Override for menu descriptions
-                $advanced_option_descriptions = get_option('wp_settings_nav_menu_advanced_options');
-                if ( $advanced_option_descriptions == 'no' ) {
-                        $navwidgetdescription = 2;
-                } else {
-                        $navwidgetdescription = $instance['navwidgetdescription'];
-                }
-
</del><span class="cx">                 // Get menu
</span><del>-                if ( $navmenu > 0 ) {
-                        $custom_menu = get_term( (int) $nav_menu, 'nav_menu' );
-                        $wp_custom_nav_menu_name = $custom_menu->name;
-                        $menuexists = true;
-                } else {
-                        $menuexists = false;
-                }
-
-                if ( $navdeveloper == 'yes' ) {
-                        // DISPLAY Custom DIV
-                        if ( $navdiv == 'yes' ) {
-                        ?>
-                                <div id="<?php echo $navdivid; ?>" class="<?php echo $navdivclass; ?>">
-                        <?php
-                                }
-                        } else {
-                                //DISPLAY default DIV
-                                ?>
-                                <div class="widget">
-                                <?php
-                        }
-                ?>
-
-                <h3><?php echo $navtitle; ?></h3>
-                <?php
-                if ( $menuexists ) {
-                        if ( $navdeveloper == 'yes' ) {
-                                //DISPLAY Custom UL
-                                if ( $navul == 'yes' ) {
-                                        ?>
-                                        <ul id="<?php echo $navulid; ?>" class="<?php echo $navulclass; ?>">
-                                        <?php
-                                }
-                        } else {
-                                // DISPLAY default UL
-                                ?>
-                                <ul class="menu">
-                                <?php
-                        }
-                        wp_nav_menu( array('id' => $navmenu, 'name' => $wp_custom_nav_menu_name, 'desc' => $navwidgetdescription, 'format' => 'widget') );
-                        if ( $navdeveloper == 'yes' ) {
-                                // DISPLAY Custom UL
-                                if ( $navul == 'yes' ) {
-                                        ?>
-                                        </ul>
-                                        <?php
-                                }
-                        } else {
-                                // DISPLAY default UL
-                                ?>
-                                </ul>
-                                <?php
-                        }
-                } else {
-                        _e('You have not setup the custom navigation widget correctly, please check your settings in the backend.');
-                }
-
-                //DEVELOPER settings enabled
-                if ($navdeveloper == 'yes') {
-                        // DISPLAY Custom DIV
-                        if ( $navdiv == 'yes' ) {
-                                ?>
-                                </div>
-                                <?php
-                        }
-                } else {
-                        // DISPLAY default DIV
-                        ?>
-                        </div>
-                        <?php
-                }
-                ?><!-- /#nav-container -->
-                <?php
</del><ins>+                $nav_menu = wp_get_nav_menu_object( $instance['nav_menu'] );
+                
+                if ( !$nav_menu )
+                        return;                
+                
+                echo $args['before_widget'];
+                
+                if ( isset($instance['title']) )
+                        echo $args['before_title'] . $instance['title'] . $args['after_title'];
+                
+                wp_nav_menu( array( 'menu' => $nav_menu ) );
+                
+                echo $args['after_widget'];
</ins><span class="cx">         }
</span><span class="cx">
</span><del>-        function update($new_instance, $old_instance) {
-                return $new_instance;
</del><ins>+        function update( $new_instance, $old_instance ) {
+                $instance['title'] = strip_tags( stripslashes($new_instance['title']) );
+                $instance['nav_menu'] = (int) $new_instance['nav_menu'];
+                return $instance;
</ins><span class="cx">         }
</span><span class="cx">
</span><del>-        function form($instance) {
-                $navmenu = esc_attr($instance['navmenu']);
-                $navtitle = esc_attr($instance['navtitle']);
-                $navdeveloper = esc_attr($instance['navdeveloper']);
-                $navdiv = esc_attr($instance['navdiv']);
-                $navul = esc_attr($instance['navul']);
-                $navdivid = esc_attr($instance['navdivid']);
-                $navdivclass = esc_attr($instance['navdivclass']);
-                $navulid = esc_attr($instance['navulid']);
-                $navulclass = esc_attr($instance['navulclass']);
-                $navwidgetdescription = esc_attr($instance['navwidgetdescription']);
-
-                global $wpdb;
-
</del><ins>+        function form( $instance ) {
+                $title = isset( $instance['title'] ) ? $instance['title'] : '';
+                $nav_menu = isset( $instance['nav_menu'] ) ? $instance['nav_menu'] : '';
+                
</ins><span class="cx">                 // Get menus
</span><del>-                $custom_menus = get_terms( 'nav_menu', array( 'hide_empty' => false ) );
-
-                if ( !$custom_menus) {
-                ?>
-                        <p>
-                         <label><?php printf(__('No menus have been created yet. <a href="%s">Creat some</a>.'), admin_url('nav-menus.php')); ?></label>
-                        </p>
-                <?php
</del><ins>+                $menus = get_terms( 'nav_menu', array( 'hide_empty' => false ) );
+                
+                // If no menus exists, direct the user to go and create some.
+                if ( !$menus ) {
+                        echo '<p>'. sprintf( __('No menus have been created yet. <a href="%s">Creat some</a>.'), admin_url('nav-menus.php') ) .'</p>';
</ins><span class="cx">                         return;
</span><span class="cx">                 }
</span><span class="cx">                 ?>
</span><del>-
</del><span class="cx">                 <p>
</span><del>-                        <label for="<?php echo $this->get_field_id('navmenu'); ?>"><?php _e('Select Menu:'); ?></label>
-
-                        <select id="<?php echo $this->get_field_id('navmenu'); ?>" name="<?php echo $this->get_field_name('navmenu'); ?>">
-                                <?php
-                                foreach ( $custom_menus as $menu ) {
-                                        if ( $navmenu == $menu->term_id )
-                                                $selected_option = 'selected="selected"';
-                                        else
-                                                $selected_option = '';
-                                        ?>
-                                        <option value="<?php echo $menu->term_id; ?>" <?php echo $selected_option; ?>><?php echo $menu->name; ?></option>
-                                        <?php
-                                }
-                                ?>
-                        </select>
</del><ins>+                        <label for="<?php echo $this->get_field_id('title'); ?>"><?php _e('Title:') ?></label>
+                        <input type="text" class="widefat" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" value="<?php echo $title; ?>" />
</ins><span class="cx">                 </p>
</span><del>-
</del><span class="cx">                 <p>
</span><del>-                        <label for="<?php echo $this->get_field_id('navtitle'); ?>"><?php _e('Title:'); ?></label>
-                        <input type="text" name="<?php echo $this->get_field_name('navtitle'); ?>" value="<?php echo $navtitle; ?>" class="widefat" id="<?php echo $this->get_field_id('navtitle'); ?>" />
-                </p>
-
-                <?php $checked = strtolower($navdeveloper); ?>
-                <p>
-                        <label for="<?php echo $this->get_field_id('navdeveloper'); ?>"><?php _e('Advanced Options:'); ?></label><br />
-                        <span class="checkboxes">
-                                <label>Yes</label><input type="radio" id="<?php echo $this->get_field_name('navdeveloper'); ?>" name="<?php echo $this->get_field_name('navdeveloper'); ?>" value="yes" <?php if ($checked=='yes') { echo 'checked="checked"'; } ?> />
-                                <label>No</label><input type="radio" id="<?php echo $this->get_field_name('navdeveloper'); ?>" name="<?php echo $this->get_field_name('navdeveloper'); ?>" value="no" <?php if ($checked=='yes') { } else { echo 'checked="checked"'; } ?> />
-                        </span><!-- /.checkboxes -->
-                </p>
-
</del><ins>+                        <label for="<?php echo $this->get_field_id('nav_menu'); ?>"><?php _e('Select Menu:'); ?></label>
+                        <select id="<?php echo $this->get_field_id('nav_menu'); ?>" name="<?php echo $this->get_field_name('nav_menu'); ?>">
</ins><span class="cx">                 <?php
</span><del>-                // Advanced settings
-                if ( $checked == 'yes' ) :
</del><ins>+                        foreach ( $menus as $menu ) {
+                                $selected = $nav_menu == $menu->term_id ? ' selected="selected"' : '';
+                                echo '<option'. $selected .' value="'. $menu->term_id .'">'. $menu->name .'</option>';
+                        }
</ins><span class="cx">                 ?>
</span><del>-                <p>
-                <?php $checked = strtolower($navdiv); ?>
-                        <label for="<?php echo $this->get_field_id('navdiv'); ?>"><?php _e('Wrap in container DIV:'); ?></label><br />
-                        <span class="checkboxes">
-                                <label>Yes</label><input type="radio" id="<?php echo $this->get_field_name('navdiv'); ?>" name="<?php echo $this->get_field_name('navdiv'); ?>" value="yes" <?php if ($checked=='yes') { echo 'checked="checked"'; } ?> />
-                                <label>No</label><input type="radio" id="<?php echo $this->get_field_name('navdiv'); ?>" name="<?php echo $this->get_field_name('navdiv'); ?>" value="no" <?php if ($checked=='yes') { } else { echo 'checked="checked"'; } ?> />
-                        </span><!-- /.checkboxes -->
</del><ins>+                        </select>
</ins><span class="cx">                 </p>
</span><span class="cx">                 <?php
</span><del>-                if ( $checked == 'yes' ) {
-                ?>
-
-                        <p>
-                                <label for="<?php echo $this->get_field_id('navdivid'); ?>"><?php _e('DIV id:'); ?></label>
-                                <input type="text" name="<?php echo $this->get_field_name('navdivid'); ?>" value="<?php echo $navdivid; ?>" class="widefat" id="<?php echo $this->get_field_id('navdivid'); ?>" />
-                        </p>
-                        <p>
-                                <label for="<?php echo $this->get_field_id('navdivclass'); ?>"><?php _e('DIV class:'); ?></label>
-                                <input type="text" name="<?php echo $this->get_field_name('navdivclass'); ?>" value="<?php echo $navdivclass; ?>" class="widefat" id="<?php echo $this->get_field_id('navdivclass'); ?>" />
-                        </p>
-                <?php
-                }
-                
-                $checked = strtolower($navul);
-                ?>
-
-                <p>
-                        <label for="<?php echo $this->get_field_id('navul'); ?>"><?php _e('Wrap in container UL:'); ?></label><br />
-                        <span class="checkboxes">
-                                <label>Yes</label><input type="radio" id="<?php echo $this->get_field_name('navul'); ?>" name="<?php echo $this->get_field_name('navul'); ?>" value="yes" <?php if ($checked=='yes') { echo 'checked="checked"'; } ?> />
-                                <label>No</label><input type="radio" id="<?php echo $this->get_field_name('navul'); ?>" name="<?php echo $this->get_field_name('navul'); ?>" value="no" <?php if ($checked=='yes') { } else { echo 'checked="checked"'; } ?> />
-                        </span><!-- /.checkboxes -->
-                </p>
-
-                <?php
-                if ( $checked == 'yes' ) {
-                ?>
-                        <p>
-                                <label for="<?php echo $this->get_field_id('navulid'); ?>"><?php _e('UL id:'); ?></label>
-                                <input type="text" name="<?php echo $this->get_field_name('navulid'); ?>" value="<?php echo $navulid; ?>" class="widefat" id="<?php echo $this->get_field_id('navulid'); ?>" />
-                        </p>
-                        <p>
-                                <label for="<?php echo $this->get_field_id('navulclass'); ?>"><?php _e('UL class:'); ?></label>
-                                <input type="text" name="<?php echo $this->get_field_name('navulclass'); ?>" value="<?php echo $navulclass; ?>" class="widefat" id="<?php echo $this->get_field_id('navulclass'); ?>" />
-                        </p>
-                <?php
-                }
-                $advanced_option_descriptions = get_option('wp_settings_nav_menu_advanced_options');
-                ?>
-                <p <?php if ($advanced_option_descriptions == 'no') { ?>style="display:none;"<?php } ?>>
-                 <?php $checked = strtolower($navwidgetdescription); ?>
-                        <label for="<?php echo $this->get_field_id('navwidgetdescription'); ?>"><?php _e('Show Top Level Descriptions:'); ?></label><br />
-                        <span class="checkboxes">
-                                <label>Yes</label><input type="radio" id="<?php echo $this->get_field_name('navwidgetdescription'); ?>" name="<?php echo $this->get_field_name('navwidgetdescription'); ?>" value="1" <?php if ($checked=='1') { echo 'checked="checked"'; } ?> />
-                                <label>No</label><input type="radio" id="<?php echo $this->get_field_name('navwidgetdescription'); ?>" name="<?php echo $this->get_field_name('navwidgetdescription'); ?>" value="2" <?php if ($checked=='1') { } else { echo 'checked="checked"'; } ?> />
-                        </span><!-- /.checkboxes -->
-                </p>
-                <?php
-                endif;
</del><span class="cx">         }
</span><span class="cx"> }
</span><span class="cx">
</span></span></pre></div>
<a id="trunkwpincludesnavmenutemplatephp"></a>
<div class="modfile"><h4>Modified: trunk/wp-includes/nav-menu-template.php (13511 => 13512)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-includes/nav-menu-template.php        2010-02-28 19:49:31 UTC (rev 13511)
+++ trunk/wp-includes/nav-menu-template.php        2010-02-28 20:00:49 UTC (rev 13512)
</span><span class="lines">@@ -1,7 +1,6 @@
</span><span class="cx"> <?php
</span><del>-
</del><span class="cx"> /**
</span><del>- * Outputs a navigation menu.
</del><ins>+ * Displays a navigation menu.
</ins><span class="cx"> *
</span><span class="cx"> * Optional $args contents:
</span><span class="cx"> *
</span><span class="lines">@@ -10,29 +9,33 @@
</span><span class="cx"> * menu_class - CSS class to use for the div container of the menu list. Defaults to 'menu'.
</span><span class="cx"> * format - Whether to format the ul. Defaults to 'div'.
</span><span class="cx"> * fallback_cb - If the menu doesn't exists, a callback function will fire. Defaults to 'wp_page_menu'.
</span><ins>+ * before_link - Output text before the link.
+ * after_link - Output text after the link.
+ * before_title - Output text before the link text.
+ * before_title - Output text after the link text.
+ * echo - Whether to echo the menu or return it. Defaults to echo.
</ins><span class="cx"> *
</span><span class="cx"> * TODO:
</span><span class="cx"> * show_home - If you set this argument, then it will display the link to the home page. The show_home argument really just needs to be set to the value of the text of the link.
</span><del>- * link_before - Text before show_home argument text.
- * link_after - Text after show_home argument text.
- * echo - Whether to echo the menu or return it. Defaults to echo.
</del><span class="cx"> *
</span><span class="cx"> * @since 3.0.0
</span><span class="cx"> *
</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( 'id' => '', 'slug' => '', 'menu_class' => 'menu', 'format' => 'div', 'fallback_cb' => 'wp_page_menu', 'echo' => true, 'link_before' => '', 'link_after' => '' );
</del><ins>+        $defaults = array( 'menu' => '', 'menu_class' => 'menu', 'format' => 'div', 'echo' => true,
+        'fallback_cb' => 'wp_page_menu', 'link_before' => '', 'link_after' => '', 'before_link' => '', 'after_link' => '', );
+        
</ins><span class="cx">         $args = wp_parse_args( $args, $defaults );
</span><ins>+        $args = apply_filters( 'wp_nav_menu_args', $args );
</ins><span class="cx">         $args = (object) $args;
</span><span class="cx">         
</span><del>-        // Get the menu
-        $menu = null;
-        if ( !empty($args->id) ) {
-                $menu = wp_get_nav_menu( $args->id );
-        } elseif ( !empty($args->slug) ) {
-                $menu = get_term_by( 'slug', $args->slug, 'nav_menu' );
-        } else {
</del><ins>+        // Get the nav menu
+        $menu = wp_get_nav_menu_object( $args->menu );
+                
+        // If we couldn't find a menu based off the name, id or slug,
+        // get the first menu that has items.
+        if ( !$menu ) {
</ins><span class="cx">                 $menus = wp_get_nav_menus();
</span><span class="cx">                 foreach ( $menus as $menu_maybe ) {
</span><span class="cx">                         if ( wp_get_nav_menu_items($menu_maybe->term_id) ) {
</span><span class="lines">@@ -42,137 +45,157 @@
</span><span class="cx">                 }
</span><span class="cx">         }
</span><span class="cx">         
</span><del>-        // If the menu doesn't exists, call the fallback_cb
-        if ( !$menu || is_wp_error($menu) )
-                return call_user_func($args->fallback_cb, $args );
-
</del><ins>+        $args->menu = $menu->term_id;
+        $nav_menu = '';
+        
</ins><span class="cx">         if ( 'div' == $args->format )
</span><del>-                echo '<div class="' . esc_attr($args->menu_class) . '"><ul>';
-
-        $args->id = $menu->term_id;
-
-        wp_print_nav_menu($args);
-                
</del><ins>+                $nav_menu .= '<div id="menu-'. $menu->slug .'" class="' . esc_attr($args->menu_class) . '">';
+        
+        $nav_menu .= wp_get_nav_menu( $args );
+        
</ins><span class="cx">         if ( 'div' == $args->format )
</span><del>-                echo '</ul></div>';
</del><ins>+                $nav_menu .= '</div>';
+        
+        $nav_menu = apply_filters( 'wp_nav_menu', $nav_menu );
+        
+        return $args->echo ? print $nav_menu : $nav_menu;
</ins><span class="cx"> }
</span><span class="cx">
</span><del>-function wp_print_nav_menu( $args = array() ) {
-                // Defaults
-                $defaults = array( 'type' => 'frontend', 'name' => 'Menu 1', 'id' => 0, 'desc' => 2, 'before_title' => '', 'after_title' => '');
-
-                $args = wp_parse_args($args, $defaults);
-                extract($args, EXTR_SKIP);
-
-                $menu_items = wp_get_nav_menu_items( $id );
-
-                $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;
</del><ins>+/**
+ * Returns a Navigation Menu.
+ *
+ * See wp_nav_menu() for args.
+ *
+ * @since 3.0.0
+ *
+ * @param array $args Arguments
+ * @return mixed $output False if menu doesn't exists, else, returns the menu.
+ **/
+function wp_get_nav_menu( $args = array() ) {
+        $defaults = array( 'menu' => '', 'menu_class' => 'menu', 'ul_class' => '', 'format' => 'div', 'type' => 'frontend',
+        'fallback_cb' => '', 'link_before' => '', 'link_after' => '', 'before_link' => '', 'after_link' => '', );
+        
+        $args = wp_parse_args( $args, $defaults );
+        $args = apply_filters( 'wp_get_nav_menu_args', $args );
+        $args = (object) $args;
+        
+        $menu = wp_get_nav_menu_object( $args->menu );
+        
+        // If no menu was found, call the fallback_cb
+        if ( !$menu || is_wp_error($menu) ) {
+                if ( function_exists($args->fallback_cb) )
+                        return call_user_func( $args->fallback_cb, $args );
+        }
+        
+        $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 ) :
+                // Setup the $menu_item variables
+                $menu_item = wp_setup_nav_menu_item( $menu_item );
+                
+                $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 );
+                
+                // Indent children
+                $last_item = ( count( $menu_items ) == $menu_item->menu_order );
+                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>';
+                                        $current_parent = array_pop( $parent_stack );
+                                }
+                        } else {
+                                array_push( $parent_stack, $current_parent );
+                                $current_parent = $menu_item->ID;
+                                $nav_menu .= '<ul>';
+                        }
+                } else {
+                        $nav_menu .= '</li>';
</ins><span class="cx">                 }
</span><del>-
-         // Display Loop
-                foreach ( $menu_items as $key => $menu_item ) {
-                        $menu_item = wp_setup_nav_menu_item($menu_item);
-                        // List Items
-                        ?><li id="menu-<?php echo $menu_item->ID; ?>" value="<?php echo $menu_item->ID; ?>" <?php echo $menu_item->li_class; ?>><?php
-                        wp_print_nav_menu_item($menu_item, $type, $args);
-                        // Indent children
-                        $last_item = ( count( $menu_items ) == $menu_item->menu_order );
-                        if ( $last_item || $current_parent != $menu_items[ $key + 1 ]->post_parent ) {
-                                if ( $last_item || in_array( $menu_items[ $key + 1 ]->post_parent, $parent_stack ) ) { ?>
-                </li>
-<?php                                        while ( !empty( $parent_stack ) && ($last_item || $menu_items[ $key + 1 ]->post_parent != $current_parent ) ) { ?>
-                        </ul>
-                </li>
-<?php                                        $current_parent = array_pop( $parent_stack );
-                                        } ?>
-<?php                                } else {
-                                        array_push( $parent_stack, $current_parent );
-                                        $current_parent = $menu_item->ID; ?>
-                        <ul>
-<?php                                }
-                        } else { ?>
-                </li>
-<?php                }
-        }
</del><ins>+                
+        endforeach;
+        
+        $nav_menu .= '</ul>';
+        
+        return apply_filters( 'wp_get_nav_menu', $nav_menu );
</ins><span class="cx"> }
</span><span class="cx">
</span><del>-function wp_print_nav_menu_item( $menu_item, $context, $args = array() ) {
</del><ins>+/**
+ * Returns a menu item.
+ *
+ * @since 3.0.0
+ *
+ * @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 = '';
</ins><span class="cx">         switch ( $context ) {
</span><ins>+                case 'frontend':
+                        $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) .'"' : '';
+                        
+                        $item .= '<a'. $attr_title . $href . $menu_item->target .'>';
+                        $item .= $args->before_link . esc_html( $menu_item->title ) . $args->after_link;
+                        $item .= '</a>';
+                        
+                        break;
+                
</ins><span class="cx">                 case 'backend':
</span><del>-                case 'menu':
-?>
-                                                <dl>
-                                                        <dt>
-                                                                <span class="item-title"><?php echo esc_html($menu_item->title); ?></span>
-                                                                <span class="item-controls">
-                                                                        <span class="item-type"><?php echo esc_html($menu_item->type); ?></span>
-                                                                        <a class="item-edit thickbox" id="edit<?php echo esc_attr( $menu_item->menu_order ); ?>" value="<?php echo esc_attr( $menu_item->menu_order ); ?>" title="<?php _e('Edit Menu Item'); ?>" href="#TB_inline?height=380&width=300&inlineId=menu-item-settings"><?php _e('Edit'); ?></a> |
-                                                                        <a class="item-delete" id="delete<?php echo esc_attr( $menu_item->menu_order ); ?>" value="<?php echo esc_attr( $menu_item->menu_order ); ?>"><?php _e('Delete'); ?></a>
-                                                                </span>
-                                                        </dt>
-                                                </dl>
-                                                <?php if ( 'backend' == $context ) { ?>
-                                                <a><span class=""></span></a>
-                                                <?php } else { ?>
-                                                <a class="hide" href="<?php echo $menu_item->link; ?>"><?php echo esc_html( $menu_item->title ); ?></a>
-                                                <?php } ?>
-                                                <input type="hidden" name="dbid<?php echo esc_attr( $menu_item->menu_order ); ?>" id="dbid<?php echo esc_attr( $menu_item->menu_order ); ?>" value="<?php echo esc_attr( $menu_item->ID ); ?>" />
-                                                <input type="hidden" name="postmenu<?php echo esc_attr( $menu_item->menu_order ); ?>" id="postmenu<?php echo esc_attr( $menu_item->menu_order ); ?>" value="<?php echo esc_attr( get_post_meta( $menu_item->ID, 'object_id', true ) ); ?>" />
-                                                <input type="hidden" name="parent<?php echo esc_attr( $menu_item->menu_order ); ?>" id="parent<?php echo esc_attr( $menu_item->menu_order ); ?>" value="<?php echo esc_attr( $menu_item->parent_item ); ?>" />
-                                                <input type="hidden" name="icon<?php echo esc_attr( $menu_item->menu_order ); ?>" id="icon<?php echo esc_attr( $menu_item->menu_order ); ?>" value="0" />
-                                                <input type="hidden" name="position<?php echo esc_attr( $menu_item->menu_order ); ?>" id="position<?php echo esc_attr( $menu_item->menu_order ); ?>" value="<?php echo esc_attr( $menu_item->menu_order ); ?>" />
-                                                <input type="hidden" name="linktype<?php echo esc_attr( $menu_item->menu_order ); ?>" id="linktype<?php echo esc_attr( $menu_item->menu_order ); ?>" value="<?php echo esc_attr( get_post_meta( $menu_item->ID, 'menu_type', true ) ); ?>" />
-                                                <input type="hidden" name="item-title<?php echo esc_attr( $menu_item->menu_order ); ?>" id="item-title<?php echo esc_attr( $menu_item->menu_order ); ?>" value="<?php echo esc_attr( $menu_item->title ); ?>" />
-                                                <input type="hidden" name="item-url<?php echo esc_attr( $menu_item->menu_order ); ?>" id="item-url<?php echo esc_attr( $menu_item->menu_order ); ?>" value="<?php echo esc_attr( $menu_item->link ); ?>" />
-                                                <input type="hidden" name="item-description<?php echo esc_attr( $menu_item->menu_order ); ?>" id="item-description<?php echo esc_attr( $menu_item->menu_order ); ?>" value="<?php echo esc_attr( $menu_item->description ); ?>" />
-                                                <input type="hidden" name="item-attr-title<?php echo esc_attr( $menu_item->menu_order ); ?>" id="item-attr-title<?php echo esc_attr( $menu_item->menu_order ); ?>" value="<?php echo esc_attr( $menu_item->post_excerpt ); ?>" />
-                                                <input type="hidden" name="item-target<?php echo esc_attr( $menu_item->menu_order ); ?>" id="item-target<?php echo esc_attr( $menu_item->menu_order ); ?>" value="<?php echo ( get_post_meta( $menu_item->ID, 'menu_new_window', true ) ? '1' : '0' ); ?>" />
-<?php
-                break;
-
-                case 'frontend':
-                        // Override for menu descriptions
-                        $advanced_option_descriptions = get_option('wp_settings_nav_menu_advanced_options');
-                        if ( $advanced_option_descriptions == 'no' )
-                                $args['desc'] = 2;
-?>
-                        <a title="<?php echo esc_attr( $menu_item->anchor_title ); ?>" href="<?php echo esc_url( $menu_item->link ); ?>" <?php echo $menu_item->target; ?>><?php echo $args['before_title'] . esc_html( $menu_item->title ) . $args['after_title']; ?><?php
-
-                                                        if ( $advanced_option_descriptions == 'no' ) {
-                                                                // 2 widget override do NOT display descriptions
-                                                                // 1 widget override display descriptions
-                                                                // 0 widget override not set
-                                                                if ( ($args['desc'] == 1) || ($args['desc'] == 0) ) {
-                                                                        ?><span class="nav-description"><?php echo $menu_item->description; ?></span><?php
-                                                                }
-                                                        } else {
-                                                                // 2 widget override do NOT display descriptions
-                                                                // 1 widget override display descriptions
-                                                                // 0 widget override not set
-                                                                if ( $args['desc'] == 1 ) {
-                                                                        ?><span class="nav-description"><?php echo $menu_item->description; ?></span><?php
-                                                                }
-                                                        }
-                                                ?></a>
-<?php
-                break;
-
</del><ins>+                        $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>';
+                        
+                        // Actions
+                        $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>';
+                        
+                        $item .= '</dt></dl>';
+                        
+                        // Menu Item Settings
+                        $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' ) .'" />';
+                        break;
+                        
</ins><span class="cx">                 case 'default':
</span><span class="cx">                         $menu_id = 'menu-item-' . $menu_item->ID;
</span><del>-?>
-                                        <dl>
-                                                <dt>
-                                                        <label class="item-title"><input type="checkbox" id="<?php echo esc_attr($menu_id); ?>" onclick="wp_update_queue('<?php echo esc_js( $menu_item->append ); ?>','<?php echo esc_js( $menu_item->title ); ?>','<?php echo esc_js( $menu_item->link ); ?>','<?php echo esc_js( $menu_item->ID ); ?>','<?php echo esc_js( $menu_item->parent_item ); ?>','<?php echo esc_js( $menu_item->description ); ?>')" name="<?php echo esc_attr( $menu_item->title ); ?>" value="<?php echo esc_attr( $menu_item->link ); ?>" /><?php echo $menu_item->title; ?></label>
-                                                </dt>
-                                        </dl>
-<?php
-                break;
</del><ins>+                        $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>';
+                        
+                        // Menu Item Settings
+                        $item .= '<input type="hidden" class="item-type" value="'. esc_attr( $menu_item->append ) .'" />';
+                        $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 ) .'" />';
+                        break;
</ins><span class="cx">         }
</span><ins>+        return apply_filters( 'wp_get_nav_menu_item', $item );
</ins><span class="cx"> }
</span><del>-
</del><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 (13511 => 13512)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-includes/nav-menu.php        2010-02-28 19:49:31 UTC (rev 13511)
+++ trunk/wp-includes/nav-menu.php        2010-02-28 20:00:49 UTC (rev 13512)
</span><span class="lines">@@ -7,22 +7,65 @@
</span><span class="cx"> * @since 3.0.0
</span><span class="cx"> */
</span><span class="cx">
</span><del>-// Deletes a nav menu
-function wp_delete_nav_menu( $menu_id ) {
-        $menu_id = (int) $menu_id;
-        if ( !$menu_id )
-                return false;
</del><ins>+/**
+ * Returns a Navigation Menu object
+ *
+ * @since 3.0.0
+ *
+ * @param string $menu Menu id
+ * @return mixed $menu|false
+ */
+function wp_get_nav_menu_object( $menu ) {
+        return is_nav_menu( $menu );
+}
</ins><span class="cx">
</span><del>-        $menu_objects = get_objects_in_term( $menu_id, 'nav_menu' );
-        if ( !empty( $menu_objects ) ) {
-                foreach ( $menu_objects as $item ) {
-                        wp_delete_post( $item );
-                }
</del><ins>+/**
+ * Check if Menu exists.
+ *
+ * Returns the menu object, or false if the term doesn't exist.
+ *
+ * @since 3.0.0
+ *
+ * @param int|string $menu The menu to check
+ * @return mixed Menu Object, if exists.
+ */
+function is_nav_menu( $menu ) {
+        if ( $menu ) {
+                $menu = get_term( $menu, 'nav_menu' );
+        } elseif ( !$menu ) {
+                $menu = get_term_by( 'slug', $menu, 'nav_menu' );
+        } elseif( !$menu ) {
+                $menu = get_term_by( 'name', $menu, 'nav_menu' );
+        } else {
+                $menu = false;
</ins><span class="cx">         }
</span><del>-        wp_delete_term( $menu_id, 'nav_menu' );
</del><ins>+                
+        return $menu;
</ins><span class="cx"> }
</span><span class="cx">
</span><del>-// Creates a new nav menu
</del><ins>+/**
+ * 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' ) );
+}
+
+/**
+ * Creates a navigation menu.
+ *
+ * Optional args:
+ * slug - the url friendly version of the nav menu.
+ *
+ * @since 3.0.0
+ *
+ * @param string $menu_name Menu Name
+ * @param string $args Optional.
+ * @return mixed Menu object|WP_Error
+ */
</ins><span class="cx"> function wp_create_nav_menu( $menu_name, $args = array() ) {
</span><span class="cx">         $menu_exists = get_term_by( 'name', $menu_name, 'nav_menu' );
</span><span class="cx">
</span><span class="lines">@@ -39,10 +82,39 @@
</span><span class="cx">         if ( is_wp_error($menu) )
</span><span class="cx">                 return $menu;
</span><span class="cx">
</span><del>-        return get_term( $menu['term_id'], 'nav_menu');
</del><ins>+        return get_term( $menu['term_id'], 'nav_menu') ;
</ins><span class="cx"> }
</span><span class="cx">
</span><del>-// Creates a default menu if none exists
</del><ins>+/**
+ * Deletes a navigation menu.
+ *
+ * @since 3.0.0
+ *
+ * @param string $menu name|id|slug
+ * @return bool true on success, else false.
+ */
+function wp_delete_nav_menu( $menu ) {
+        $menu = wp_get_nav_menu_object( $menu );
+        if ( !$menu )
+                return false;
+
+        $menu_objects = get_objects_in_term( $menu->term_id, 'nav_menu' );
+        if ( !empty( $menu_objects ) ) {
+                foreach ( $menu_objects as $item ) {
+                        wp_delete_post( $item );
+                }
+        }
+        wp_delete_term( $menu_id, 'nav_menu' );
+}
+
+/**
+ * Creates a nav menu named 'Menu 1'.
+ *
+ * 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.
+ *
+ * @since 3.0.0
+ */
</ins><span class="cx"> function wp_create_default_nav_menu() {
</span><span class="cx">         $menu = wp_create_nav_menu( __('Menu 1'), array('slug' => 'menu-1') );
</span><span class="cx">
</span><span class="lines">@@ -61,23 +133,26 @@
</span><span class="cx">         }
</span><span class="cx"> }
</span><span class="cx">
</span><del>-// Get nav menu by id
-function wp_get_nav_menu( $menu ) {
-        return get_term( (int) $menu, 'nav_menu' );
-}
-
-// Get all nav menus
-function wp_get_nav_menus() {
-        return get_terms( 'nav_menu', array( 'hide_empty' => false, 'orderby' => 'id' ) );
-}
-
-// Get the nav menu items
</del><ins>+/**
+ * Returns the menu items of a navigation menu.
+ *
+ * @since 3.0.0
+ *
+ * @param string $menu menu name, id, or slug
+ * @param string $args
+ * @return mixed $items array of menu items, else false.
+ */
</ins><span class="cx"> function wp_get_nav_menu_items( $menu, $args = array() ) {
</span><del>-        $items = get_objects_in_term( (int) $menu, 'nav_menu' );
</del><ins>+        $menu = wp_get_nav_menu_object( $menu );
+        
+        if ( !$menu )
+                return false;
+        
+        $items = get_objects_in_term( $menu->term_id, 'nav_menu' );
</ins><span class="cx">
</span><span class="cx">         if ( ! empty( $items ) ) {
</span><span class="cx">                 $defaults = array( 'orderby' => 'menu_order', 'post_type' => 'nav_menu_item', 'post_status' => 'publish', 'output' => ARRAY_A, 'output_key' => 'menu_order' );
</span><del>-                $args = wp_parse_args($args, $defaults);
</del><ins>+                $args = wp_parse_args( $args, $defaults );
</ins><span class="cx">                 if ( count( $items ) > 1 )        
</span><span class="cx">                         $args['include'] = implode( ',', $items );
</span><span class="cx">                 else
</span><span class="lines">@@ -90,21 +165,30 @@
</span><span class="cx">                         foreach ( $items as $item ) {
</span><span class="cx">                                 $output[$item->$args['output_key']] = $item;
</span><span class="cx">                         }
</span><del>-                        unset($items);
-                        ksort($output);
</del><ins>+                        unset( $items );
+                        ksort( $output );
</ins><span class="cx">                         return $output;
</span><span class="cx">                 }
</span><span class="cx">         }
</span><span class="cx">         return $items;
</span><span class="cx"> }
</span><span class="cx">
</span><del>-// wp_setup_nav_menu_item()
-function wp_setup_nav_menu_item($menu_item, $type = 'item', $position = 0) {
</del><ins>+/**
+ * Returns a menu item with all it's nessecary data populated.
+ *
+ * @since 3.0.0
+ *
+ * @param string $menu_item Menu item.
+ * @param string $type item|category|page.
+ * @param string $position position of the menu item.
+ * @return $menu_item
+ */
+function wp_setup_nav_menu_item( $menu_item, $type = 'item', $position = 0 ) {
</ins><span class="cx">         global $parent_menu_order;
</span><span class="cx">
</span><span class="cx">         if ( 'item' == $type ) {
</span><del>-                $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);
</del><ins>+                $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 );
</ins><span class="cx">                 $menu_item->target = ( get_post_meta( $menu_item->ID, 'menu_new_window', true ) ) ? 'target="_blank"' : '';
</span><span class="cx">                 if ( isset( $parent_menu_order[ $menu_item->post_parent ] ) )
</span><span class="cx">                         $menu_item->parent_item = $parent_menu_order[ $menu_item->post_parent ];
</span><span class="lines">@@ -165,8 +249,9 @@
</span><span class="cx">
</span><span class="cx">         $menu_item->li_class = '';
</span><span class="cx">         global $wp_query;
</span><del>-        if ( $menu_item->ID == $wp_query->get_queried_object_id() )
-                $menu_item->li_class = 'class="current_page_item"';
</del><ins>+        
+        if ( $menu_item->object_id == $wp_query->get_queried_object_id() )
+                $menu_item->li_class = ' current_page_item';
</ins><span class="cx">
</span><span class="cx">         $menu_item->anchor_title = '';
</span><span class="cx"> /* @todo: update to use tax/post data
</span><span class="lines">@@ -195,5 +280,4 @@
</span><span class="cx">
</span><span class="cx">         return $menu_item;
</span><span class="cx"> }
</span><del>-
</del><span class="cx"> ?>
</span><span class="cx">\ No newline at end of file
</span></span></pre>
</div>
</div>
</body>
</html>