Ticket #12713: new-menu-wireframe.2.diff

File new-menu-wireframe.2.diff, 156.5 KB (added by filosofo, 3 years ago)
Line 
1Index: wp-includes/nav-menu-template.php
2===================================================================
3--- wp-includes/nav-menu-template.php   (revision 14247)
4+++ wp-includes/nav-menu-template.php   (working copy)
5@@ -8,6 +8,160 @@
6  */
7 
8 /**
9+ * Create HTML list of nav menu items.
10+ *
11+ * @package WordPress
12+ * @since 3.0.0
13+ * @uses Walker
14+ */
15+class Walker_Nav_Menu extends Walker {
16+       /**
17+        * @see Walker::$tree_type
18+        * @since 3.0.0
19+        * @var string
20+        */
21+       var $tree_type = array( 'post_type', 'taxonomy', 'custom' );
22+
23+       /**
24+        * @see Walker::$db_fields
25+        * @since 3.0.0
26+        * @todo Decouple this.
27+        * @var array
28+        */
29+       var $db_fields = array( 'parent' => 'post_parent', 'id' => 'object_id' );
30+
31+       /**
32+        * @see Walker::start_lvl()
33+        * @since 3.0.0
34+        *
35+        * @param string $output Passed by reference. Used to append additional content.
36+        * @param int $depth Depth of page. Used for padding.
37+        */
38+       function start_lvl(&$output, $depth) {
39+               $indent = str_repeat("\t", $depth);
40+               $output .= "\n$indent<ul class=\"sub-menu\">\n";
41+       }
42+
43+       /**
44+        * @see Walker::end_lvl()
45+        * @since 3.0.0
46+        *
47+        * @param string $output Passed by reference. Used to append additional content.
48+        * @param int $depth Depth of page. Used for padding.
49+        */
50+       function end_lvl(&$output, $depth) {
51+               $indent = str_repeat("\t", $depth);
52+               $output .= "$indent</ul>\n";
53+       }
54+
55+       /**
56+        * @see Walker::start_el()
57+        * @since 3.0.0
58+        *
59+        * @param string $output Passed by reference. Used to append additional content.
60+        * @param object $item Menu item data object.
61+        * @param int $depth Depth of menu item. Used for padding.
62+        * @param int $current_page Menu item ID.
63+        * @param object $args
64+        */
65+       function start_el(&$output, $item, $depth, $args) {
66+               global $wp_query;
67+               $indent = ( $depth ) ? str_repeat( "\t", $depth ) : '';
68+
69+               $classes = $value = '';
70+
71+               $classes = array( 'menu-item', 'menu-item-type-'. $item->type, $item->classes );
72+
73+               if ( 'custom' != $item->object )
74+                       $classes[] = 'menu-item-object-'. $item->object;
75+
76+               if ( $item->object_id == $wp_query->get_queried_object_id() )
77+                       $classes[] = 'current-menu-item';
78+
79+               // @todo add classes for parent/child relationships
80+
81+               $classes = join( ' ', apply_filters( 'nav_menu_css_class', array_filter( $classes ), $item ) );
82+               $classes = ' class="' . esc_attr( $classes ) . '"';
83+
84+               $output .= $indent . '<li id="menu-item-'. $item->ID . '"' . $value . $classes .'>';
85+               
86+               $attributes  = ! empty( $item->attr_title ) ? ' title="'  . esc_attr( $item->attr_title ) .'"' : '';
87+               $attributes .= ! empty( $item->target )     ? ' target="' . esc_attr( $item->target     ) .'"' : '';
88+               $attributes .= ! empty( $item->xfn )        ? ' rel="'    . esc_attr( $item->xfn        ) .'"' : '';
89+               $attributes .= ! empty( $item->url )        ? ' href="'   . esc_attr( $item->url        ) .'"' : '';
90+
91+               $item_output = $args->before;
92+               $item_output .= '<a'. $attributes .'>';
93+               $item_output .= $args->link_before . apply_filters( 'the_title', $item->title ) . $args->link_after;
94+               $item_output .= '</a>';
95+               $item_output .= $args->after;
96+       
97+               $output .= apply_filters( 'wp_get_nav_menu_item', $item_output, $args );
98+       }
99+
100+       /**
101+        * @see Walker::end_el()
102+        * @since 3.0.0
103+        *
104+        * @param string $output Passed by reference. Used to append additional content.
105+        * @param object $item Page data object. Not used.
106+        * @param int $depth Depth of page. Not Used.
107+        */
108+       function end_el(&$output, $item, $depth) {
109+               $output .= "</li>\n";
110+       }
111+}
112+
113+/**
114+ * Create HTML list of nav menu input items.
115+ *
116+ * @package WordPress
117+ * @since 3.0.0
118+ * @uses Walker_Nav_Menu
119+ */
120+class Walker_Nav_Menu_Checklist extends Walker_Nav_Menu  {
121+
122+       /**
123+        * @see Walker::start_el()
124+        * @since 3.0.0
125+        *
126+        * @param string $output Passed by reference. Used to append additional content.
127+        * @param object $item Menu item data object.
128+        * @param int $depth Depth of menu item. Used for padding.
129+        * @param int $current_page Menu item ID.
130+        * @param object $args
131+        */
132+       function start_el(&$output, $item, $depth, $args) {
133+               static $_placeholder;
134+               $_placeholder = 0 > $_placeholder ? $_placeholder - 1 : -1;
135+               $possible_object_id = isset( $item->post_type ) && 'nav_menu_item' == $item->post_type ? $item->object_id : $_placeholder;
136+               $possible_db_id = ( ! empty( $item->ID ) ) && ( 0 < $possible_object_id ) ? (int) $item->ID : 0;
137+
138+               $indent = ( $depth ) ? str_repeat( "\t", $depth ) : '';
139+
140+               $output .= $indent . '<li>';
141+               $output .= '<label class="menu-item-title">';
142+               $output .= '<input type="checkbox" name="menu-item[' . $possible_object_id . '][menu-item-object-id]" value="'. esc_attr( $item->object_id ) .'" />';
143+               $output .= $item->title .'</label>';
144+
145+               // Menu item hidden fields
146+               $output .= '<input type="hidden" class="menu-item-db-id" name="menu-item[' . $possible_object_id . '][menu-item-db-id]" value="' . $possible_db_id . '" />';
147+               $output .= '<input type="hidden" class="menu-item-object" name="menu-item[' . $possible_object_id . '][menu-item-object]" value="'. esc_attr( $item->object ) .'" />';
148+               $output .= '<input type="hidden" class="menu-item-parent-id" name="menu-item[' . $possible_object_id . '][menu-item-parent-id]" value="'. esc_attr( $item->post_parent ) .'" />';
149+               $output .= '<input type="hidden" class="menu-item-type" name="menu-item[' . $possible_object_id . '][menu-item-type]" value="'. esc_attr( $item->type ) .'" />';
150+               $output .= '<input type="hidden" class="menu-item-append" name="menu-item[' . $possible_object_id . '][menu-item-append]" value="'. esc_attr( $item->append ) .'" />';
151+               $output .= '<input type="hidden" class="menu-item-title" name="menu-item[' . $possible_object_id . '][menu-item-title]" value="'. esc_attr( $item->title ) .'" />';
152+               $output .= '<input type="hidden" class="menu-item-url" name="menu-item[' . $possible_object_id . '][menu-item-url]" value="'. esc_attr( $item->url ) .'" />';
153+               $output .= '<input type="hidden" class="menu-item-append" name="menu-item[' . $possible_object_id . '][menu-item-append]" value="'. esc_attr( $item->append ) .'" />';
154+               $output .= '<input type="hidden" class="menu-item-target" name="menu-item[' . $possible_object_id . '][menu-item-target]" value="'. esc_attr( $item->target ) .'" />';
155+               $output .= '<input type="hidden" class="menu-item-attr_title" name="menu-item[' . $possible_object_id . '][menu-item-attr_title]" value="'. esc_attr( $item->attr_title ) .'" />';
156+               $output .= '<input type="hidden" class="menu-item-description" name="menu-item[' . $possible_object_id . '][menu-item-description]" value="'. esc_attr( $item->description ) .'" />';
157+               $output .= '<input type="hidden" class="menu-item-classes" name="menu-item[' . $possible_object_id . '][menu-item-classes]" value="'. esc_attr( $item->classes ) .'" />';
158+               $output .= '<input type="hidden" class="menu-item-xfn" name="menu-item[' . $possible_object_id . '][menu-item-xfn]" value="'. esc_attr( $item->xfn ) .'" />';
159+       }
160+}
161+
162+/**
163  * Displays a navigation menu.
164  *
165  * Optional $args contents:
166@@ -17,9 +171,6 @@
167  * menu_class - CSS class to use for the div container of the menu list. Defaults to 'menu'.
168  * format - Whether to format the ul. Defaults to 'div'.
169  * fallback_cb - If the menu doesn't exists, a callback function will fire. Defaults to 'wp_page_menu'.
170- * container - Type of container tag. Avalible options div, p, or nav. Defaults to 'div'.
171- * container_class - Chooses a class for the container.
172- * container_id - Chooses an id for the container.
173  * before - Text before the link text.
174  * after - Text after the link text.
175  * link_before - Text before the link.
176@@ -33,7 +184,7 @@
177  * @param array $args Arguments
178  */
179 function wp_nav_menu( $args = array() ) {
180-       $defaults = array( 'menu' => '', 'container' => 'div', 'container_class' => '', 'container_id' => '', 'menu_class' => 'menu', 'echo' => true,
181+       $defaults = array( 'menu' => '', 'container' => 'div', 'container_class' => '', 'menu_class' => 'menu', 'echo' => true,
182        'fallback_cb' => 'wp_page_menu', 'before' => '', 'after' => '', 'link_before' => '', 'link_after' => '',
183        'depth' => 0, 'walker' => '', 'context' => 'frontend' );
184 
185@@ -46,7 +197,7 @@
186 
187        // If we couldn't find a menu based off the name, id or slug,
188        // get the first menu that has items.
189-       if ( !$menu ) {
190+       if ( ! $menu ) {
191                $menus = wp_get_nav_menus();
192                foreach ( $menus as $menu_maybe ) {
193                        if ( wp_get_nav_menu_items($menu_maybe->term_id) ) {
194@@ -56,9 +207,9 @@
195                }
196        }
197       
198-       // If the menu exists, get it's items.
199-       if ( $menu && !is_wp_error($menu) )
200-               $menu_items = wp_get_nav_menu_items( $menu->term_id, $args->context );
201+       // If the menu exists, get its items.
202+       if ( $menu && ! is_wp_error($menu) )
203+               $menu_items = wp_get_nav_menu_items( $menu->term_id );
204 
205        // If no menu was found or if the menu has no items, call the fallback_cb
206        if ( !$menu || is_wp_error($menu) || ( isset($menu_items) && empty($menu_items) ) ) {
207@@ -73,15 +224,15 @@
208 
209        if ( in_array( $args->container, $container_allowedtags ) ) {
210                $class = $args->container_class ? ' class="' . esc_attr($args->container_class) . '"' : ' class="menu-'. $menu->slug .'-container"';
211-               $container_id = $args->container_id ? ' id="' . esc_attr($args->container_id) . '"' : '' ;
212-               $nav_menu .= '<'. $args->container . $class . $container_id .'>';
213+               $nav_menu .= '<'. $args->container . $class .'>';
214        }
215 
216        // Set up the $menu_item variables
217+       $sorted_menu_items = array();
218        foreach ( (array) $menu_items as $key => $menu_item )
219-               $menu_items[$menu_item->menu_order] = wp_setup_nav_menu_item( $menu_item, 'frontend' );
220+               $sorted_menu_items[$menu_item->menu_order] = wp_setup_nav_menu_item( $menu_item );
221 
222-       $items .= walk_nav_menu_tree( $menu_items, $args->depth, $args );
223+       $items .= walk_nav_menu_tree( $sorted_menu_items, $args->depth, $args );
224 
225        // Attributes   
226        $attributes  = ' id="menu-' . $menu->slug . '"';
227@@ -112,83 +263,17 @@
228 }
229 
230 /**
231- * Returns the menu item formatted based on it's context.
232+ * Retrieve the HTML list content for nav menu items.
233  *
234- * @since 3.0.0
235- *
236- * @param string $menu_item The menu item to format.
237- * @param string $context The context to which the menu item will be formatted to.
238- * @param string $args Optional. Args used for the 'template' context.
239- * @return string $output The menu formatted menu item.
240+ * @uses Walker_Nav_Menu to create HTML list content.
241+ * @since 2.1.0
242+ * @see Walker::walk() for parameters and return description.
243  */
244-function wp_get_nav_menu_item( $menu_item, $context = 'frontend', $args = array() ) {
245-       $output = '';
246-       switch ( $context ) {
247-               case 'frontend':
248-                       $attributes  = ! empty( $menu_item->attr_title ) ? ' title="'  . esc_attr( $menu_item->attr_title ) .'"' : '';
249-                       $attributes .= ! empty( $menu_item->target )     ? ' target="' . esc_attr( $menu_item->target     ) .'"' : '';
250-                       $attributes .= ! empty( $menu_item->xfn )        ? ' rel="'    . esc_attr( $menu_item->xfn        ) .'"' : '';
251-                       $attributes .= ! empty( $menu_item->url )        ? ' href="'   . esc_attr( $menu_item->url        ) .'"' : '';
252+function walk_nav_menu_tree( $items, $depth, $r ) {
253+       $walker = ( empty($r->walker) ) ? new Walker_Nav_Menu : $r->walker;
254+       $args = array( $items, $depth, $r );
255 
256-                       $output .= $args->before;
257-                       $output .= '<a'. $attributes .'>';
258-                       $output .= $args->link_before . apply_filters( 'the_title', $menu_item->title ) . $args->link_after;
259-                       $output .= '</a>';
260-                       $output .= $args->after;
261+       return call_user_func_array( array(&$walker, 'walk'), $args );
262+}
263 
264-                       break;
265-
266-               case 'backend':
267-                       $output .= '<dl><dt>';
268-                       $output .= '<span class="item-title">'. esc_html( $menu_item->title ) .'</span>';
269-                       $output .= '<span class="item-controls">';
270-                       $output .= '<span class="item-type">'. esc_html( $menu_item->append ) .'</span>';
271-
272-                       // Actions
273-                       $output .= '<a class="item-edit thickbox" id="edit-'. esc_attr( $menu_item->ID ) .'" value="'. esc_attr( $menu_item->ID ) .'" title="'. __('Edit Menu Item') .'" href="#TB_inline?height=540&width=300&inlineId=menu-item-settings">'. __('Edit') .'</a> | ';
274-                       $output .= '<a class="item-delete" id="delete-'. esc_attr( $menu_item->ID ) .'" value="'. esc_attr( $menu_item->ID ) .'">'. __('Delete') .'</a>';
275-
276-                       $output .= '</span></dt></dl>';
277-
278-                       // Menu Item Settings
279-                       $output .= '<input type="hidden" name="menu-item-db-id[]" value="'. esc_attr( $menu_item->ID ) .'" />';
280-                       $output .= '<input type="hidden" name="menu-item-object-id[]" value="'. esc_attr( $menu_item->object_id ) .'" />';
281-                       $output .= '<input type="hidden" name="menu-item-object[]" value="'. esc_attr( $menu_item->object ) .'" />';
282-                       $output .= '<input type="hidden" name="menu-item-parent-id[]" value="'. esc_attr( $menu_item->post_parent ) .'" />';
283-                       $output .= '<input type="hidden" name="menu-item-position[]" value="'. esc_attr( $menu_item->menu_order ) .'" />';
284-                       $output .= '<input type="hidden" name="menu-item-type[]" value="'. esc_attr( $menu_item->type ) .'" />';
285-                       $output .= '<input type="hidden" name="menu-item-title[]" value="'. esc_attr( $menu_item->title ) .'" />';
286-                       $output .= '<input type="hidden" name="menu-item-url[]" value="'. esc_attr( $menu_item->url ) .'" />';
287-                       $output .= '<input type="hidden" name="menu-item-description[]" value="'. esc_attr( $menu_item->description ) .'" />';
288-                       $output .= '<input type="hidden" name="menu-item-classes[]" value="'. esc_attr( $menu_item->classes ) .'" />';
289-                       $output .= '<input type="hidden" name="menu-item-xfn[]" value="'. esc_attr( $menu_item->xfn ) .'" />';
290-                       $output .= '<input type="hidden" name="menu-item-attr-title[]" value="'.esc_attr( $menu_item->post_excerpt )  .'" />';
291-                       $output .= '<input type="hidden" name="menu-item-target[]" value="'. esc_attr( $menu_item->target ) .'" />';
292-                       break;
293-
294-               case 'custom':
295-               case 'taxonomy':
296-               case 'post_type':
297-                       $output .= '<label class="menu-item-title"><input type="checkbox" id="'. esc_attr( 'menu-item-' . $menu_item->object_id ) .'" value="'. esc_attr( $menu_item->url ) .'" />'. $menu_item->title .'</label>';
298-
299-                       // Menu item hidden fields
300-                       $output .= '<input type="hidden" class="menu-item-db-id" value="0" />';
301-                       $output .= '<input type="hidden" class="menu-item-object-id" value="'. esc_attr( $menu_item->object_id ) .'" />';
302-                       $output .= '<input type="hidden" class="menu-item-object" value="'. esc_attr( $menu_item->object ) .'" />';
303-                       $output .= '<input type="hidden" class="menu-item-parent-id" value="'. esc_attr( $menu_item->post_parent ) .'" />';
304-                       $output .= '<input type="hidden" class="menu-item-type" value="'. esc_attr( $menu_item->type ) .'" />';
305-                       $output .= '<input type="hidden" class="menu-item-append" value="'. esc_attr( $menu_item->append ) .'" />';
306-                       $output .= '<input type="hidden" class="menu-item-title" value="'. esc_attr( $menu_item->title ) .'" />';
307-                       $output .= '<input type="hidden" class="menu-item-url" value="'. esc_attr( $menu_item->url ) .'" />';
308-                       $output .= '<input type="hidden" class="menu-item-append" value="'. esc_attr( $menu_item->append ) .'" />';
309-                       $output .= '<input type="hidden" class="menu-item-target" value="'. esc_attr( $menu_item->target ) .'" />';
310-                       $output .= '<input type="hidden" class="menu-item-attr_title" value="'. esc_attr( $menu_item->attr_title ) .'" />';
311-                       $output .= '<input type="hidden" class="menu-item-description" value="'. esc_attr( $menu_item->description ) .'" />';
312-                       $output .= '<input type="hidden" class="menu-item-classes" value="'. esc_attr( $menu_item->classes ) .'" />';
313-                       $output .= '<input type="hidden" class="menu-item-xfn" value="'. esc_attr( $menu_item->xfn ) .'" />';
314-                       break;
315-       }
316-
317-       return apply_filters( 'wp_get_nav_menu_item', $output, $context, $args );
318-}
319-?>
320\ No newline at end of file
321+?>
322Index: wp-includes/post.php
323===================================================================
324--- wp-includes/post.php        (revision 14247)
325+++ wp-includes/post.php        (working copy)
326@@ -2190,7 +2190,7 @@
327        $data = stripslashes_deep( $data );
328        $where = array( 'ID' => $post_ID );
329 
330-       if ($update) {
331+       if ( $update ) {
332                do_action( 'pre_post_update', $post_ID );
333                if ( false === $wpdb->update( $wpdb->posts, $data, $where ) ) {
334                        if ( $wp_error )
335@@ -2265,7 +2265,7 @@
336 
337        wp_transition_post_status($data['post_status'], $previous_status, $post);
338 
339-       if ( $update)
340+       if ( $update )
341                do_action('edit_post', $post_ID, $post);
342 
343        do_action('save_post', $post_ID, $post);
344Index: wp-includes/classes.php
345===================================================================
346--- wp-includes/classes.php     (revision 14247)
347+++ wp-includes/classes.php     (working copy)
348@@ -1124,102 +1124,6 @@
349 }
350 
351 /**
352- * Create HTML list of nav menu items.
353- *
354- * @package WordPress
355- * @since 3.0.0
356- * @uses Walker
357- */
358-class Walker_Nav_Menu extends Walker {
359-       /**
360-        * @see Walker::$tree_type
361-        * @since 3.0.0
362-        * @var string
363-        */
364-       var $tree_type = array( 'post_type', 'taxonomy', 'custom' );
365-
366-       /**
367-        * @see Walker::$db_fields
368-        * @since 3.0.0
369-        * @todo Decouple this.
370-        * @var array
371-        */
372-       var $db_fields = array( 'parent' => 'post_parent', 'id' => 'object_id' );
373-
374-       /**
375-        * @see Walker::start_lvl()
376-        * @since 3.0.0
377-        *
378-        * @param string $output Passed by reference. Used to append additional content.
379-        * @param int $depth Depth of page. Used for padding.
380-        */
381-       function start_lvl(&$output, $depth) {
382-               $indent = str_repeat("\t", $depth);
383-               $output .= "\n$indent<ul class=\"sub-menu\">\n";
384-       }
385-
386-       /**
387-        * @see Walker::end_lvl()
388-        * @since 3.0.0
389-        *
390-        * @param string $output Passed by reference. Used to append additional content.
391-        * @param int $depth Depth of page. Used for padding.
392-        */
393-       function end_lvl(&$output, $depth) {
394-               $indent = str_repeat("\t", $depth);
395-               $output .= "$indent</ul>\n";
396-       }
397-
398-       /**
399-        * @see Walker::start_el()
400-        * @since 3.0.0
401-        *
402-        * @param string $output Passed by reference. Used to append additional content.
403-        * @param object $item Menu item data object.
404-        * @param int $depth Depth of menu item. Used for padding.
405-        * @param int $current_page Menu item ID.
406-        * @param object $args
407-        */
408-       function start_el(&$output, $item, $depth, $args) {
409-               $indent = ( $depth ) ? str_repeat( "\t", $depth ) : '';
410-
411-               $classes = $value = '';
412-               if ( 'frontend' == $args->context ) {
413-                       global $wp_query;
414-
415-                       $classes = array( 'menu-item', 'menu-item-type-'. $item->type, $item->classes );
416-
417-                       if ( 'custom' != $item->object )
418-                               $classes[] = 'menu-item-object-'. $item->object;
419-
420-                       if ( $item->object_id == $wp_query->get_queried_object_id() )
421-                               $classes[] = 'current-menu-item';
422-
423-                       // @todo add classes for parent/child relationships
424-
425-                       $classes = join( ' ', apply_filters( 'nav_menu_css_class', array_filter( $classes ), $item ) );
426-                       $classes = ' class="' . esc_attr( $classes ) . '"';
427-               } else {
428-                       $value = ' value="' . $item->ID . '"';
429-               }
430-
431-               $output .= $indent . '<li id="menu-item-'. $item->ID . '"' . $value . $classes .'>' . wp_get_nav_menu_item( $item, $args->context, $args );
432-       }
433-
434-       /**
435-        * @see Walker::end_el()
436-        * @since 3.0.0
437-        *
438-        * @param string $output Passed by reference. Used to append additional content.
439-        * @param object $item Page data object. Not used.
440-        * @param int $depth Depth of page. Not Used.
441-        */
442-       function end_el(&$output, $item, $depth) {
443-               $output .= "</li>\n";
444-       }
445-}
446-
447-/**
448  * Create HTML list of pages.
449  *
450  * @package WordPress
451Index: wp-includes/script-loader.php
452===================================================================
453--- wp-includes/script-loader.php       (revision 14247)
454+++ wp-includes/script-loader.php       (working copy)
455@@ -393,12 +393,13 @@
456                ) );
457 
458                // Custom Navigation
459-               $scripts->add( 'nav-menu', "/wp-admin/js/nav-menu$suffix.js", false, '20100403' );
460+               $scripts->add( 'nav-menu', "/wp-admin/js/nav-menu$suffix.js", false, '20100426' );
461                $scripts->localize( 'nav-menu', 'navMenuL10n', array(
462                        'custom' => _x('Custom', 'menu nav item type'),
463                        'thickbox' => _x('Edit Menu Item', 'Thickbox Title'),
464                        'edit' => _x('Edit', 'menu item edit text'),
465-                       'warnDelete' => __( "You are about to permanently delete this menu. \n 'Cancel' to stop, 'OK' to delete." ),
466+                       'warnDeleteMenu' => __( "You are about to permanently delete this menu. \n 'Cancel' to stop, 'OK' to delete." ),
467+                       'warnDeleteMenuItem' => __( "You are about to permanently delete this menu item. \n 'Cancel' to stop, 'OK' to delete." ),
468                ) );
469 
470                $scripts->add( 'custom-background', "/wp-admin/js/custom-background$suffix.js", array('farbtastic'), '20100321' );
471@@ -472,7 +473,7 @@
472        $styles->add( 'farbtastic', '/wp-admin/css/farbtastic.css', array(), '1.2' );
473        $styles->add( 'jcrop', '/wp-includes/js/jcrop/jquery.Jcrop.css', array(), '0.9.8' );
474        $styles->add( 'imgareaselect', '/wp-includes/js/imgareaselect/imgareaselect.css', array(), '0.9.1' );
475-       $styles->add( 'nav-menu', "/wp-admin/css/nav-menu$suffix.css", array(), '20100322' );
476+       $styles->add( 'nav-menu', "/wp-admin/css/nav-menu$suffix.css", array(), '20100426' );
477 
478        foreach ( $rtl_styles as $rtl_style ) {
479                $styles->add_data( $rtl_style, 'rtl', true );
480Index: wp-includes/nav-menu.php
481===================================================================
482--- wp-includes/nav-menu.php    (revision 14247)
483+++ wp-includes/nav-menu.php    (working copy)
484@@ -16,7 +16,22 @@
485  * @return mixed $menu|false Or WP_Error
486  */
487 function wp_get_nav_menu_object( $menu ) {
488-       return is_nav_menu( $menu );
489+       if ( ! $menu )
490+               return false;
491+
492+       $menu_obj = get_term( $menu, 'nav_menu' );
493+
494+       if ( ! $menu_obj )
495+               $menu_obj = get_term_by( 'slug', $menu, 'nav_menu' );
496+
497+       if ( ! $menu_obj )
498+               $menu_obj = get_term_by( 'name', $menu, 'nav_menu' );
499+
500+       if ( ! $menu_obj ) {
501+               $menu_obj = false;
502+       }
503+
504+       return $menu_obj;
505 }
506 
507 /**
508@@ -27,25 +42,18 @@
509  * @since 3.0.0
510  *
511  * @param int|string $menu The menu to check
512- * @return mixed Menu Object, if it exists. Else, false or WP_Error
513+ * @return bool Whether the menu exists.
514  */
515 function is_nav_menu( $menu ) {
516-       if ( !$menu )
517+       if ( ! $menu )
518                return false;
519+       
520+       $menu_obj = wp_get_nav_menu_object( $menu );
521 
522-       $menu_obj = get_term( $menu, 'nav_menu' );
523-
524-       if ( !$menu_obj )
525-               $menu_obj = get_term_by( 'slug', $menu, 'nav_menu' );
526-
527-       if ( !$menu_obj )
528-               $menu_obj = get_term_by( 'name', $menu, 'nav_menu' );
529-
530-       if ( !$menu_obj ) {
531-               $menu_obj = false;
532-       }
533-
534-       return $menu_obj;
535+       if ( $menu_obj && ! is_wp_error( $menu_obj ) && ! empty( $menu_obj->term_id ) )
536+               return true;
537+       
538+       return false;
539 }
540 
541 /**
542@@ -96,7 +104,7 @@
543  */
544 function wp_delete_nav_menu( $menu ) {
545        $menu = wp_get_nav_menu_object( $menu );
546-       if ( !$menu  )
547+       if ( ! $menu  )
548                return false;
549 
550        $menu_objects = get_objects_in_term( $menu->term_id, 'nav_menu' );
551@@ -117,6 +125,151 @@
552 }
553 
554 /**
555+ * Save the properties of a menu or create a new menu with those properties.
556+ *
557+ * @since 3.0.0
558+ *
559+ * @param int $menu_id The ID of the menu
560+ * @param array $menu_data The array of menu data.
561+ * @return int The menu's ID.
562+ */
563+function wp_update_nav_menu_object( $menu_id = 0, $menu_data = array() ) {
564+       $menu_id = (int) $menu_id;
565+
566+       $_menu = wp_get_nav_menu_object( $menu_id );
567+
568+       // menu doesn't already exist
569+       if ( ! $_menu || is_wp_error( $_menu ) ) {
570+               $_menu = wp_create_nav_menu( $menu_data['menu-name'] );
571+       }
572+
573+       if ( $_menu && isset( $_menu->term_id ) && ! is_wp_error( $_menu ) ) {
574+               $args = array(
575+                       'description' => ( isset( $menu_data['description'] ) ? $menu_data['description'] : '' ),
576+                       'name' => ( isset( $menu_data['menu-name'] ) ? $menu_data['menu-name'] : '' ),
577+                       'parent' => ( isset( $menu_data['parent'] ) ? (int) $menu_data['parent'] : 0 ),
578+                       'slug' => null,
579+               );
580+       
581+               $menu_id = (int) $_menu->term_id;
582+
583+               $update_response = wp_update_term( $menu_id, 'nav_menu', $args );
584+
585+               if ( ! is_wp_error( $update_response ) ) {
586+                       return $menu_id;
587+               }
588+       } else {
589+               return 0;
590+       }
591+}
592+
593+/**
594+ * Save the properties of a menu item or create a new one.
595+ *
596+ * @since 3.0.0
597+ *
598+ * @param int $menu_id The ID of the menu. Required.
599+ * @param int $menu_item_db_id The ID of the menu item. If "0", creates a new menu item.
600+ * @param array $menu_item_data The menu item's data.
601+ * @return int The menu item's database ID or WP_Error object on failure.
602+ */
603+function wp_update_nav_menu_item( $menu_id = 0, $menu_item_db_id = 0, $menu_item_data = array() ) {
604+
605+       $menu_id = (int) $menu_id;
606+       $menu_item_db_id = (int) $menu_item_db_id;
607+
608+       $menu = wp_get_nav_menu_object( $menu_id );
609+
610+       if ( ! $menu || is_wp_error( $menu ) ) {
611+               return $menu;
612+       }
613+
614+       $menu_items = (array) wp_get_nav_menu_items( $menu_id );
615+
616+       $count = count( $menu_items );
617+
618+       $defaults = array(
619+               'menu-item-db-id' => $menu_item_db_id,
620+               'menu-item-object-id' => 0,
621+               'menu-item-object' => '',
622+               'menu-item-parent-id' => 0,
623+               'menu-item-position' => 0,
624+               'menu-item-type' => 'custom',
625+               'menu-item-append' => 'custom',
626+               'menu-item-title' => '',
627+               'menu-item-url' => '',
628+               'menu-item-description' => '',
629+               'menu-item-attr-title' => '',
630+               'menu-item-target' => '',
631+               'menu-item-classes' => '',
632+               'menu-item-xfn' => '',
633+       );
634+
635+       $args = wp_parse_args( $menu_item_data, $defaults );
636+
637+       if ( 0 == (int) $args['menu-item-position'] ) {
638+               $last_item = array_pop( $menu_items );
639+               if ( $last_item && isset( $last_item->ID ) ) {
640+                       $last_data = get_post( $last_item->ID );
641+                       if ( ! is_wp_error( $last_data ) && isset( $last_data->menu_order ) ) {
642+                               $args['menu-item-position'] = 1 + (int) $last_data->menu_order;
643+                       }
644+
645+               } else {
646+                       $args['menu-item-position'] = $count;
647+               }
648+       }
649+       
650+       // Populate the menu item object
651+       $post = array(
652+               'menu_order' => $args['menu-item-position'],
653+               'ping_status' => 0,
654+               'post_content' => $args['menu-item-description'],
655+               'post_excerpt' => $args['menu-item-attr-title'],
656+               'post_parent' => $args['menu-item-parent-id'],
657+               'post_status' => 'publish',
658+               'post_title' => $args['menu-item-title'],
659+               'post_type' => 'nav_menu_item',
660+               'tax_input' => array( 'nav_menu' => $menu->name ),
661+       );
662+
663+       // New menu item
664+       if ( 0 == $menu_item_db_id ) {
665+               $menu_item_db_id = wp_insert_post( $post );
666+
667+       // Update existing menu item
668+       } else {
669+               $post['ID'] = $menu_item_db_id;
670+               wp_update_post( $post );
671+       }
672+
673+       if ( 'custom' == $args['menu-item-type'] ) {
674+               $args['menu-item-object-id'] = $menu_item_db_id;
675+               $args['menu-item-object'] = 'custom';
676+       }
677+
678+       if ( $menu_item_db_id && ! is_wp_error( $menu_item_db_id ) ) {
679+
680+               $menu_item_db_id = (int) $menu_item_db_id;
681+
682+               update_post_meta( $menu_item_db_id, '_menu_item_type', sanitize_key($args['menu-item-type']) );
683+               update_post_meta( $menu_item_db_id, '_menu_item_object_id', (int) $args['menu-item-object-id'] );
684+               update_post_meta( $menu_item_db_id, '_menu_item_object', sanitize_key($args['menu-item-object']) );
685+               update_post_meta( $menu_item_db_id, '_menu_item_target', sanitize_key($args['menu-item-target']) );
686+               // @todo handle sanitizing multiple classes separated by whitespace.
687+               update_post_meta( $menu_item_db_id, '_menu_item_classes', sanitize_html_class($args['menu-item-classes']) );
688+               update_post_meta( $menu_item_db_id, '_menu_item_xfn', sanitize_html_class($args['menu-item-xfn']) );
689+
690+               // @todo: only save custom link urls.
691+               update_post_meta( $menu_item_db_id, '_menu_item_url', esc_url_raw($args['menu-item-url']) );
692+
693+               do_action('wp_update_nav_menu_item', $menu_id, $menu_item_db_id, $args );
694+       }
695+
696+       return $menu_item_db_id;
697+}
698+
699+/**
700  * Returns all navigation menu objects.
701  *
702  * @since 3.0.0
703@@ -127,7 +280,44 @@
704        return get_terms( 'nav_menu', array( 'hide_empty' => false, 'orderby' => 'id' ) );
705 }
706 
707+
708 /**
709+ * Sort menu items by the desired key.
710+ *
711+ * @since 3.0.0
712+ * @access private
713+ *
714+ * @param object $a The first object to compare
715+ * @param object $b The second object to compare
716+ * @return int -1, 0, or 1 if $a is considered to be respectively less than, equal to, or greater than $b.
717+ */
718+function _sort_nav_menu_items($a, $b) {
719+       global $_menu_item_sort_prop;
720+
721+       if ( empty( $_menu_item_sort_prop ) ) {
722+               return 0;
723+       }
724+
725+       if ( isset( $a->$_menu_item_sort_prop ) && isset( $b->$_menu_item_sort_prop ) ) {
726+               $_a = (int) $a->$_menu_item_sort_prop;
727+               $_b = (int) $b->$_menu_item_sort_prop;
728+
729+               if ( $a->$_menu_item_sort_prop == $b->$_menu_item_sort_prop ) {
730+                       return 0;       
731+               } elseif (
732+                       ( $_a == $a->$_menu_item_sort_prop ) &&
733+                       ( $_b == $b->$_menu_item_sort_prop )
734+               ) {
735+                       return $_a < $_b ? -1 : 1;
736+               } else {
737+                       return strcmp( $a->$_menu_item_sort_prop, $b->$_menu_item_sort_prop );
738+               }
739+       } else {
740+               return 0;
741+       }
742+}
743+
744+/**
745  * Returns all menu items of a navigation menu.
746  *
747  * @since 3.0.0
748@@ -139,13 +329,13 @@
749 function wp_get_nav_menu_items( $menu, $args = array() ) {
750        $menu = wp_get_nav_menu_object( $menu );
751 
752-       if ( !$menu )
753+       if ( ! $menu )
754                return false;
755-
756+       
757        $items = get_objects_in_term( $menu->term_id, 'nav_menu' );
758 
759        if ( ! empty( $items ) ) {
760-               $defaults = array( 'orderby' => 'menu_order', 'post_type' => 'nav_menu_item', 'post_status' => 'publish', 'output' => ARRAY_A, 'output_key' => 'menu_order' );
761+               $defaults = array( 'order' => 'ASC', 'orderby' => 'menu_order', 'post_type' => 'nav_menu_item', 'post_status' => 'publish', 'output' => ARRAY_A, 'output_key' => 'menu_order' );
762                $args = wp_parse_args( $args, $defaults );
763                if ( count( $items ) > 1 )
764                        $args['include'] = implode( ',', $items );
765@@ -155,50 +345,48 @@
766                $items = get_posts( $args );
767 
768                if ( ARRAY_A == $args['output'] ) {
769-                       $output = array();
770-                       foreach ( $items as $item ) {
771-                               $output[$item->$args['output_key']] = $item;
772+                       $GLOBALS['_menu_item_sort_prop'] = $args['output_key'];
773+                       usort($items, '_sort_nav_menu_items');
774+                       $i = 1;
775+                       foreach( $items as $k => $item ) {
776+                               $items[$k]->$args['output_key'] = $i++;
777                        }
778-                       unset( $items );
779-                       ksort( $output );
780-                       return $output;
781                }
782        }
783        return $items;
784 }
785 
786 /**
787- * Retrieve the HTML list content for nav menu items.
788+ * Decorates a menu item object with the shared navigation menu item properties.
789  *
790- * @uses Walker_Nav_Menu to create HTML list content.
791- * @since 2.1.0
792- * @see Walker::walk() for parameters and return description.
793- */
794-function walk_nav_menu_tree( $items, $depth, $r ) {
795-       $walker = ( empty($r->walker) ) ? new Walker_Nav_Menu : $r->walker;
796-       $args = array( $items, $depth, $r );
797-
798-       return call_user_func_array( array(&$walker, 'walk'), $args );
799-}
800-
801-/**
802- * Adds all the navigation menu properties to the menu item.
803+ * Properties:
804+ * - db_id:            The DB ID of the this item as a nav_menu_item object, if it exists (0 if it doesn't exist).
805+ * - object_id:                The DB ID of the original object this menu item represents, e.g. ID for posts and term_id for categories.
806+ * - type:             The family of objects originally represented, such as "post_type" or "taxonomy."
807+ * - object:           The type of object originally represented, such as "category," "post", or "attachment."
808+ * - append:           The singular label used to describe this type of menu item.
809+ * - parent:           The DB ID of the original object's parent object, if any (0 otherwise).
810+ * - url:              The URL to which this menu item points.
811+ * - title:            The title of this menu item.
812+ * - target:           The target attribute of the link element for this menu item.
813+ * - attr_title:       The title attribute of the link element for this menu item.     
814+ * - classes:          The class attribute value for the link element of this menu item.
815+ * - xfn:              The XFN relationship expressed in the link of this menu item.
816+ * - description:      The description of this menu item.
817  *
818  * @since 3.0.0
819  *
820- * @param string $menu_item The menu item to modify
821- * @param string $menu_item_type The menu item type (frontend, custom, post_type, taxonomy).
822- * @param string $menu_item_object Optional. The menu item object type (post type or taxonomy).
823- * @return object $menu_item The modified menu item.
824+ * @param object $menu_item The menu item to modify.
825+ * @return object $menu_item The menu item with standard menu item properties.
826  */
827-function wp_setup_nav_menu_item( $menu_item, $menu_item_type = null, $menu_item_object = '' ) {
828-       switch ( $menu_item_type ) {
829-               case 'frontend':
830+function wp_setup_nav_menu_item( $menu_item ) {
831+       if ( isset( $menu_item->post_type ) ) {
832+               if ( 'nav_menu_item' == $menu_item->post_type ) {
833                        $menu_item->db_id = (int) $menu_item->ID;
834                        $menu_item->object_id = get_post_meta( $menu_item->ID, '_menu_item_object_id', true );
835                        $menu_item->object = get_post_meta( $menu_item->ID, '_menu_item_object', true );
836                        $menu_item->type = get_post_meta( $menu_item->ID, '_menu_item_type', true );
837-
838+                       
839                        if ( 'post_type' == $menu_item->type ) {
840                                $object = get_post_type_object( $menu_item->object );
841                                $menu_item->append = $object->singular_label;
842@@ -213,7 +401,7 @@
843                                $menu_item->append = __('Custom');
844                                $menu_item->url = get_post_meta( $menu_item->ID, '_menu_item_url', true );
845                        }
846-
847+                       
848                        $menu_item->title = $menu_item->post_title;
849                        $menu_item->target = get_post_meta( $menu_item->ID, '_menu_item_target', true );
850 
851@@ -222,31 +410,12 @@
852 
853                        $menu_item->classes = get_post_meta( $menu_item->ID, '_menu_item_classes', true );
854                        $menu_item->xfn = get_post_meta( $menu_item->ID, '_menu_item_xfn', true );
855-                       break;
856-               
857-               case 'custom':
858+               } else {
859                        $menu_item->db_id = 0;
860                        $menu_item->object_id = (int) $menu_item->ID;
861-                       $menu_item->object = 'custom';
862-                       $menu_item->type = 'custom';
863-                       $menu_item->append = __('custom');
864+                       $menu_item->type = 'post_type';
865 
866-                       $menu_item->attr_title = strip_tags( $menu_item->post_excerpt );
867-                       $menu_item->description = strip_tags( $menu_item->post_content );
868-
869-                       $menu_item->title = $menu_item->post_title;
870-                       $menu_item->url = get_post_meta( $menu_item->ID, '_menu_item_url', true );
871-                       $menu_item->target = get_post_meta( $menu_item->ID, '_menu_item_target', true );
872-                       $menu_item->classes = get_post_meta( $menu_item->ID, '_menu_item_target', true );
873-                       $menu_item->xfn = get_post_meta( $menu_item->ID, '_menu_item_xfn', true );
874-                       break;
875-
876-               case 'post_type':
877-                       $menu_item->db_id = 0;
878-                       $menu_item->object_id = (int) $menu_item->ID;
879-                       $menu_item->type = $menu_item_type;
880-
881-                       $object = get_post_type_object( $menu_item_object );
882+                       $object = get_post_type_object( $menu_item->post_type );
883                        $menu_item->object = $object->name;
884                        $menu_item->append = strtolower( $object->singular_label );
885 
886@@ -254,33 +423,32 @@
887                        $menu_item->url = get_permalink( $menu_item->ID );
888                        $menu_item->target = '';
889 
890-                       $menu_item->attr_title = '';
891+                       $menu_item->attr_title = strip_tags( $menu_item->post_excerpt );
892                        $menu_item->description = strip_tags( $menu_item->post_content );
893                        $menu_item->classes = '';
894                        $menu_item->xfn = '';
895-                       break;
896+               }
897+       } elseif ( isset( $menu_item->taxonomy ) ) {
898+               $menu_item->ID = $menu_item->term_id;
899+               $menu_item->db_id = 0;
900+               $menu_item->object_id = (int) $menu_item->term_id;
901+               $menu_item->post_parent = (int) $menu_item->parent;
902+               $menu_item->type = 'taxonomy';
903 
904-               case 'taxonomy':
905-                       $menu_item->ID = $menu_item->term_id;
906-                       $menu_item->db_id = 0;
907-                       $menu_item->object_id = (int) $menu_item->term_id;
908-                       $menu_item->post_parent = (int) $menu_item->parent;
909-                       $menu_item->type = $menu_item_type;
910+               $object = get_taxonomy( $menu_item->taxonomy );
911+               $menu_item->object = $object->name;
912+               $menu_item->append = strtolower( $object->singular_label );
913 
914-                       $object = get_taxonomy( $menu_item_object );
915-                       $menu_item->object = $object->name;
916-                       $menu_item->append = strtolower( $object->singular_label );
917+               $menu_item->title = $menu_item->name;
918+               $menu_item->url = get_term_link( $menu_item, $menu_item->taxonomy );
919+               $menu_item->target = '';
920+               $menu_item->attr_title = '';
921+               $menu_item->description = strip_tags( get_term_field( 'description', $menu_item->term_id, $menu_item->taxonomy ) );
922+               $menu_item->classes = '';
923+               $menu_item->xfn = '';
924 
925-                       $menu_item->title = $menu_item->name;
926-                       $menu_item->url = get_term_link( $menu_item, $menu_item_object );
927-                       $menu_item->target = '';
928-                       $menu_item->attr_title = '';
929-                       $menu_item->description = '';
930-                       $menu_item->classes = '';
931-                       $menu_item->xfn = '';
932-                       break;
933        }
934-       
935-       return apply_filters( 'wp_setup_nav_menu_item', $menu_item, $menu_item_type, $menu_item_object );
936+
937+       return apply_filters( 'wp_setup_nav_menu_item', $menu_item );
938 }
939-?>
940\ No newline at end of file
941+?>
942Index: wp-admin/admin-ajax.php
943===================================================================
944--- wp-admin/admin-ajax.php     (revision 14247)
945+++ wp-admin/admin-ajax.php     (working copy)
946@@ -126,11 +126,21 @@
947        check_ajax_referer( "image_editor-$post_id" );
948 
949        include_once( ABSPATH . 'wp-admin/includes/image-edit.php' );
950-       if ( !stream_preview_image($post_id) )
951+       if ( ! stream_preview_image($post_id) )
952                die('-1');
953 
954        die();
955        break;
956+case 'menu-quick-search':
957+       if ( ! current_user_can( 'switch_themes' ) )
958+               die('-1');
959+       
960+       require_once ABSPATH . 'wp-admin/includes/nav-menu.php';
961+
962+       _wp_ajax_menu_quick_search( $_REQUEST );
963+
964+       exit;
965+       break;
966 case 'oembed-cache' :
967        $return = ( $wp_embed->cache_oembed( $_GET['post'] ) ) ? '1' : '0';
968        die( $return );
969@@ -386,6 +396,17 @@
970        else
971                die('0');
972        break;
973+case 'delete-menu-item' :
974+       $menu_item_id = (int) $_POST['menu-item'];
975+       check_admin_referer( 'delete-menu_item_' . $menu_item_id );
976+       if ( ! current_user_can( 'switch_themes' ) )
977+               die('-1');
978+
979+       if ( 'nav_menu_item' == get_post_type( $menu_item_id ) && wp_delete_post( $menu_item_id, true ) )
980+               die('1');
981+       else
982+               die('0');
983+       break;
984 case 'delete-meta' :
985        check_ajax_referer( "delete-meta_$id" );
986        if ( !$meta = get_post_meta_by_id( $id ) )
987@@ -795,6 +816,40 @@
988 
989        $x->send();
990        break;
991+case 'add-menu-item' :
992+       if ( ! current_user_can( 'switch_themes' ) )
993+               die('-1');
994+
995+       check_admin_referer( 'add-menu_item', 'menu-settings-column-nonce' );
996+
997+       require_once ABSPATH . 'wp-admin/includes/nav-menu.php';
998+
999+       $menu_id = (int) $_POST['menu'];
1000+       if ( isset( $_POST['menu-item'] ) ) {
1001+               $item_ids = wp_save_nav_menu_item( $menu_id, $_POST['menu-item'] );
1002+       } else {
1003+               $item_ids = array();
1004+       }
1005+       
1006+       foreach ( (array) $item_ids as $menu_item_id ) {
1007+               $menu_obj = get_post( $menu_item_id );
1008+               if ( ! empty( $menu_obj->ID ) ) {
1009+                       $menu_items[] = wp_setup_nav_menu_item( $menu_obj );
1010+               }
1011+       }
1012+
1013+       if ( ! empty( $menu_items ) ) {
1014+               $args = array(
1015+                       'after' => '',
1016+                       'before' => '',
1017+                       'context' => 'backend',
1018+                       'link_after' => '',
1019+                       'link_before' => '',
1020+                       'walker' => new Walker_Nav_Menu_Edit,
1021+               );
1022+               echo walk_nav_menu_tree( $menu_items, 0, (object) $args );
1023+       }
1024+       break;
1025 case 'add-meta' :
1026        check_ajax_referer( 'add-meta' );
1027        $c = 0;
1028@@ -1033,6 +1088,16 @@
1029 
1030        die('1');
1031        break;
1032+case 'menu-quick-search':
1033+       if ( ! current_user_can( 'switch_themes' ) )
1034+               die('-1');
1035+       
1036+       require_once ABSPATH . 'wp-admin/includes/nav-menu.php';
1037+
1038+       _wp_ajax_menu_quick_search( $_REQUEST );
1039+
1040+       exit;
1041+       break;
1042 case 'meta-box-order':
1043        check_ajax_referer( 'meta-box-order' );
1044        $order = isset( $_POST['order'] ) ? (array) $_POST['order'] : false;
1045Index: wp-admin/includes/nav-menu.php
1046===================================================================
1047--- wp-admin/includes/nav-menu.php      (revision 14247)
1048+++ wp-admin/includes/nav-menu.php      (working copy)
1049@@ -1,13 +1,268 @@
1050 <?php
1051+
1052 /**
1053+ * Create HTML list of nav menu input items.
1054+ *
1055+ * @package WordPress
1056+ * @since 3.0.0
1057+ * @uses Walker_Nav_Menu
1058+ */
1059+class Walker_Nav_Menu_Edit extends Walker_Nav_Menu  {
1060+
1061+       /**
1062+        * @see Walker::start_el()
1063+        * @since 3.0.0
1064+        *
1065+        * @param string $output Passed by reference. Used to append additional content.
1066+        * @param object $item Menu item data object.
1067+        * @param int $depth Depth of menu item. Used for padding.
1068+        * @param int $current_page Menu item ID.
1069+        * @param object $args
1070+        */
1071+       function start_el(&$output, $item, $depth, $args) {
1072+               $indent = ( $depth ) ? str_repeat( "\t", $depth ) : '';
1073+
1074+               ob_start();
1075+               $item_id = esc_attr( $item->ID );
1076+               $removed_args = array(
1077+                       'action',
1078+                       'customlink-tab',
1079+                       'edit-menu-item',
1080+                       'menu-item',
1081+                       'page-tab',
1082+                       '_wpnonce',
1083+               );
1084+               ?>
1085+               <li id="menu-item-<?php echo $item_id; ?>">
1086+                       <dl>
1087+                               <dt>
1088+                                       <span class="item-title"><?php echo esc_html( $item->title ); ?></span>
1089+                                       <span class="item-controls">
1090+                                               <span class="item-type"><?php echo esc_html( $item->append ); ?></span>
1091+                                               <span class="item-order">
1092+                                                       <a href="<?php
1093+                                                               echo wp_nonce_url(
1094+                                                                       add_query_arg(
1095+                                                                               array(
1096+                                                                                       'action' => 'move-up-menu-item',
1097+                                                                                       'menu-item' => $item_id,
1098+                                                                               ),
1099+                                                                               remove_query_arg($removed_args, admin_url( 'nav-menus.php' ) )
1100+                                                                       ),
1101+                                                                       'move-item'
1102+                                                               );
1103+                                                       ?>" class="item-move-up"><abbr title="<?php esc_attr_e('Move up'); ?>">&#8593;</abbr></a>
1104+                                                       |
1105+                                                       <a href="<?php
1106+                                                               echo wp_nonce_url(
1107+                                                                       add_query_arg(
1108+                                                                               array(
1109+                                                                                       'action' => 'move-down-menu-item',
1110+                                                                                       'menu-item' => $item_id,
1111+                                                                               ),
1112+                                                                               remove_query_arg($removed_args, admin_url( 'nav-menus.php' ) )
1113+                                                                       ),
1114+                                                                       'move-item'
1115+                                                               );
1116+                                                       ?>" class="item-move-down"><abbr title="<?php esc_attr_e('Move down'); ?>">&#8595;</abbr></a>
1117+                                                       |
1118+                                               </span>
1119+                                               <a class="item-edit" id="edit-<?php echo $item_id; ?>" title="<?php _e('Edit Menu Item'); ?>" href="<?php
1120+                                                       echo add_query_arg('edit-menu-item', $item_id, remove_query_arg($removed_args, admin_url( 'nav-menus.php' ) ) );
1121+                                               ?>#menu-item-settings-<?php echo $item_id; ?>"><?php _e('Edit'); ?></a> |
1122+                                               <a class="item-delete submitdelete deletion" id="delete-<?php echo $item_id; ?>" href="<?php
1123+                                               echo wp_nonce_url(
1124+                                                       add_query_arg(
1125+                                                               array(
1126+                                                                       'action' => 'delete-menu-item',
1127+                                                                       'menu-item' => $item_id,
1128+                                                               ),
1129+                                                               remove_query_arg($removed_args, admin_url( 'nav-menus.php' ) )
1130+                                                       ),
1131+                                                       'delete-menu_item_' . $item_id
1132+                                               ); ?>"><?php _e('Delete'); ?></a>
1133+                                       </span>
1134+                               </dt>
1135+                       </dl>
1136+
1137+                       <div class="menu-item-settings <?php
1138+                               if ( isset($_GET['edit-menu-item']) && $item_id == $_GET['edit-menu-item'] ) :
1139+                                       echo ' menu-item-edit-active';
1140+                               else :
1141+                                       echo ' menu-item-edit-inactive';
1142+                               endif;
1143+                       ?>" id="menu-item-settings-<?php echo $item_id; ?>">
1144+                               <p class="description">
1145+                                       <label for="edit-menu-item-title-<?php echo $item_id; ?>">
1146+                                               <?php _e( 'Menu Title' ); ?><br />
1147+                                               <input type="text" id="edit-menu-item-title-<?php echo $item_id; ?>" class="widefat edit-menu-item-title" name="menu-item-title[<?php echo $item_id; ?>]" value="<?php echo esc_attr( $item->title ); ?>" />
1148+                                       </label>
1149+                               </p>
1150+                               <p class="description">
1151+                                       <label for="edit-menu-item-url-<?php echo $item_id; ?>">
1152+                                               <?php _e( 'URL' ); ?><br />
1153+                                               <input type="text" id="edit-menu-item-url-<?php echo $item_id; ?>" class="widefat code edit-menu-item-url" name="menu-item-url[<?php echo $item_id; ?>]" value="<?php echo esc_attr( $item->url ); ?>" />
1154+                                       </label>
1155+                               </p>
1156+                               <p class="description">
1157+                                       <label for="edit-menu-item-attr-title-<?php echo $item_id; ?>">
1158+                                               <?php _e( 'Title Attribute' ); ?><br />
1159+                                               <input type="text" id="edit-menu-item-attr-title-<?php echo $item_id; ?>" class="widefat edit-menu-item-attr-title" name="menu-item-attr-title[<?php echo $item_id; ?>]" value="<?php echo esc_attr( $item->post_excerpt ); ?>" />
1160+                                       </label>
1161+                               </p>
1162+                               <p class="description">
1163+                                       <label for="edit-menu-item-target-<?php echo $item_id; ?>">
1164+                                               <?php _e( 'Link Target' ); ?><br />
1165+                                               <select id="edit-menu-item-target-<?php echo $item_id; ?>" class="widefat edit-menu-item-target" name="menu-item-target[<?php echo $item_id; ?>]">
1166+                                                       <option value="" <?php selected( $item->target, ''); ?>><?php _e('Same window or tab'); ?></option>
1167+                                                       <option value="_blank" <?php selected( $item->target, '_blank'); ?>><?php _e('New window or tab'); ?></option>
1168+                                               </select>
1169+                                       </label>
1170+                               </p>
1171+                               <p class="description">
1172+                                       <label for="edit-menu-item-classes-<?php echo $item_id; ?>">
1173+                                               <?php _e( 'CSS Classes (optional)' ); ?><br />
1174+                                               <input type="text" id="edit-menu-item-classes-<?php echo $item_id; ?>" class="widefat code edit-menu-item-classes" name="menu-item-classes[<?php echo $item_id; ?>]" value="<?php echo esc_attr( $item->classes ); ?>" />
1175+                                       </label>
1176+                               </p>
1177+                               <p class="description">
1178+                                       <label for="edit-menu-item-xfn-<?php echo $item_id; ?>">
1179+                                               <?php _e( 'Link Relationship (XFN) (optional)' ); ?><br />
1180+                                               <input type="text" id="edit-menu-item-xfn-<?php echo $item_id; ?>" class="widefat code edit-menu-item-xfn" name="menu-item-xfn[<?php echo $item_id; ?>]" value="<?php echo esc_attr( $item->xfn ); ?>" />
1181+                                       </label>
1182+                               </p>
1183+                               <p class="description">
1184+                                       <label for="edit-menu-item-description-<?php echo $item_id; ?>">
1185+                                               <?php _e( 'Description (optional)' ); ?><br />
1186+                                               <textarea id="edit-menu-item-description-<?php echo $item_id; ?>" class="widefat edit-menu-item-description" rows="3" name="menu-item-description[<?php echo $item_id; ?>]"><?php echo esc_html( $item->description ); ?></textarea>
1187+                                               <span class="description"><?php _e('The description will be displayed in the menu if the current theme supports it.'); ?></span>
1188+                                       </label>
1189+                               </p>
1190+                               
1191+                               <input type="hidden" name="menu-item-append[<?php echo $item_id; ?>]" value="<?php echo $item->append; ?>" />
1192+                               <input type="hidden" name="menu-item-db-id[<?php echo $item_id; ?>]" value="<?php echo $item_id; ?>" />
1193+                               <input type="hidden" name="menu-item-object-id[<?php echo $item_id; ?>]" value="<?php echo esc_attr( $item->object_id ); ?>" />
1194+                               <input type="hidden" name="menu-item-object[<?php echo $item_id; ?>]" value="<?php echo esc_attr( $item->object ); ?>" />
1195+                               <input type="hidden" name="menu-item-parent-id[<?php echo $item_id; ?>]" value="<?php echo esc_attr( $item->post_parent ); ?>" />
1196+                               <input type="hidden" class="menu-item-position" name="menu-item-position[<?php echo $item_id; ?>]" value="<?php echo esc_attr( $item->menu_order ); ?>" />
1197+                               <input type="hidden" name="menu-item-type[<?php echo $item_id; ?>]" value="<?php echo esc_attr( $item->type ); ?>" />
1198+                       </div><!-- .menu-item-settings-->
1199+               <?php
1200+               $output .= ob_get_clean();
1201+       }
1202+}
1203+
1204+/**
1205+ * Prints the appropriate response to a menu quick search.
1206+ *
1207+ * @since 3.0.0
1208+ *
1209+ * @param array $request The unsanitized request values.
1210+ */
1211+function _wp_ajax_menu_quick_search( $request = array() ) {
1212+       $args = array();
1213+       $type = isset( $request['type'] ) ? $request['type'] : '';
1214+       $object_type = isset( $request['object_type'] ) ? $request['object_type'] : '';
1215+       $query = isset( $request['q'] ) ? $request['q'] : '';
1216+       $response_format = isset( $request['response-format'] ) && in_array( $request['response-format'], array( 'json', 'markup' ) ) ? $request['response-format'] : 'json';
1217+
1218+       if ( 'markup' == $response_format ) {
1219+               $args['walker'] = new Walker_Nav_Menu_Checklist;
1220+       }
1221+
1222+       if ( 'get-post-item' == $type ) {
1223+               if ( get_post_type_object( $object_type ) ) {
1224+                       if ( isset( $request['ID'] ) ) {
1225+                               $object_id = (int) $request['ID'];
1226+                               if ( 'markup' == $response_format ) {
1227+                                       echo walk_nav_menu_tree( array_map('wp_setup_nav_menu_item', array( get_post( $object_id ) ) ), 0, (object) $args );
1228+                               } elseif ( 'json' == $response_format ) {
1229+                                       $post_obj = get_post( $object_id );
1230+                                       echo json_encode(
1231+                                               array(
1232+                                                       'ID' => $object_id,
1233+                                                       'post_title' => get_the_title( $object_id ),
1234+                                                       'post_type' => get_post_type( $object_id ),
1235+                                               )
1236+                                       );
1237+                                       echo "\n";
1238+                               }
1239+                       }
1240+               } elseif ( is_taxonomy( $object_type ) ) {
1241+                       if ( isset( $request['ID'] ) ) {
1242+                               $object_id = (int) $request['ID'];
1243+                               if ( 'markup' == $response_format ) {
1244+                                       echo walk_nav_menu_tree( array_map('wp_setup_nav_menu_item', array( get_term( $object_id, $object_type ) ) ), 0, (object) $args );
1245+                               } elseif ( 'json' == $response_format ) {
1246+                                       $post_obj = get_term( $object_id, $object_type );
1247+                                       echo json_encode(
1248+                                               array(
1249+                                                       'ID' => $object_id,
1250+                                                       'post_title' => $post_obj->name,
1251+                                                       'post_type' => $object_type,
1252+                                               )
1253+                                       );
1254+                                       echo "\n";
1255+                               }
1256+                       }
1257+
1258+               }
1259+
1260+
1261+       } elseif ( preg_match('/quick-search-(posttype|taxonomy)-([a-zA-Z_-]*\b)/', $type, $matches) ) {
1262+               if ( 'posttype' == $matches[1] && get_post_type_object( $matches[2] ) ) {
1263+                       query_posts(array(
1264+                               'posts_per_page' => 10,
1265+                               'post_type' => $matches[2],
1266+                               's' => $query,
1267+                       ));
1268+                       while ( have_posts() ) {
1269+                               the_post();
1270+                               if ( 'markup' == $response_format ) {
1271+                                       echo walk_nav_menu_tree( array_map('wp_setup_nav_menu_item', array( get_post( get_the_ID() ) ) ), 0, (object) $args );
1272+                               } elseif ( 'json' == $response_format ) {
1273+                                       echo json_encode(
1274+                                               array(
1275+                                                       'ID' => get_the_ID(),
1276+                                                       'post_title' => get_the_title(),
1277+                                                       'post_type' => get_post_type(),
1278+                                               )
1279+                                       );
1280+                                       echo "\n";
1281+                               }
1282+                       }
1283+               } elseif ( 'taxonomy' == $matches[1] ) {
1284+                       $terms = get_terms( $matches[2], array(
1285+                               'name__like' => $query,
1286+                               'number' => 10,
1287+                       ));
1288+                       foreach( (array) $terms as $term ) {
1289+                               if ( 'markup' == $response_format ) {
1290+                                       echo walk_nav_menu_tree( array_map('wp_setup_nav_menu_item', array( $term ) ), 0, (object) $args );
1291+                               } elseif ( 'json' == $response_format ) {
1292+                                       echo json_encode(
1293+                                               array(
1294+                                                       'ID' => $term->term_id,
1295+                                                       'post_title' => $term->name,
1296+                                                       'post_type' => $matches[2],
1297+                                               )
1298+                                       );
1299+                                       echo "\n";
1300+                               }
1301+                       }
1302+               }
1303+       }
1304+}
1305+
1306+/**
1307  * Register nav menu metaboxes
1308  *
1309  * @since 3.0.0
1310  **/
1311-function wp_nav_menu_metaboxes_setup() {
1312-       add_meta_box( 'add-custom-links', __('Add Custom Links'), 'wp_nav_menu_item_link_metabox', 'nav-menus', 'side', 'default' );
1313-       wp_nav_menu_post_type_metaboxes();
1314-       wp_nav_menu_taxonomy_metaboxes();
1315+function wp_nav_menu_meta_boxes_setup() {
1316+       add_meta_box( 'add-custom-links', __('Add Custom Links'), 'wp_nav_menu_item_link_meta_box', 'nav-menus', 'side', 'default' );
1317+       wp_nav_menu_post_type_meta_boxes();
1318+       wp_nav_menu_taxonomy_meta_boxes();
1319 }
1320 
1321 /**
1322@@ -18,7 +273,7 @@
1323 function wp_initial_nav_menu_meta_boxes() {
1324        global $wp_meta_boxes;
1325 
1326-       if ( !get_user_option( 'metaboxhidden_nav-menus' ) && is_array($wp_meta_boxes) ) {
1327+       if ( !get_user_option( 'meta-box-hidden_nav-menus' ) && is_array($wp_meta_boxes) ) {
1328 
1329                $initial_meta_boxes = array( 'manage-menu', 'create-menu', 'add-custom-links', 'add-page', 'add-category' );
1330                $hidden_meta_boxes = array();
1331@@ -35,7 +290,7 @@
1332                        }
1333                }
1334                $user = wp_get_current_user();
1335-               update_user_meta( $user->ID, 'metaboxhidden_nav-menus', $hidden_meta_boxes );
1336+               update_user_meta( $user->ID, 'meta-box-hidden_nav-menus', $hidden_meta_boxes );
1337 
1338                // returns all the hidden metaboxes to the js function: wpNavMenu.initial_meta_boxes()
1339                return join( ',', $hidden_meta_boxes );
1340@@ -47,7 +302,7 @@
1341  *
1342  * @since 3.0.0
1343  */
1344-function wp_nav_menu_post_type_metaboxes() {
1345+function wp_nav_menu_post_type_meta_boxes() {
1346        $post_types = get_post_types( array( 'public' => true ), 'object' );
1347 
1348        if ( !$post_types )
1349@@ -55,7 +310,7 @@
1350 
1351        foreach ( $post_types as $post_type ) {
1352                $id = $post_type->name;
1353-               add_meta_box( "add-{$id}", sprintf( __('Add %s'), $post_type->label ), 'wp_nav_menu_item_post_type_metabox', 'nav-menus', 'side', 'default', $post_type );
1354+               add_meta_box( "add-{$id}", sprintf( __('Add %s'), $post_type->label ), 'wp_nav_menu_item_post_type_meta_box', 'nav-menus', 'side', 'default', $post_type );
1355        }
1356 }
1357 
1358@@ -64,7 +319,7 @@
1359  *
1360  * @since 3.0.0
1361  */
1362-function wp_nav_menu_taxonomy_metaboxes() {
1363+function wp_nav_menu_taxonomy_meta_boxes() {
1364        $taxonomies = get_taxonomies( array( 'show_ui' => true ), 'object' );
1365 
1366        if ( !$taxonomies )
1367@@ -72,97 +327,84 @@
1368 
1369        foreach ( $taxonomies as $tax ) {
1370                $id = $tax->name;
1371-               add_meta_box( "add-{$id}", sprintf( __('Add %s'), $tax->label ), 'wp_nav_menu_item_taxonomy_metabox', 'nav-menus', 'side', 'default', $tax );
1372+               add_meta_box( "add-{$id}", sprintf( __('Add %s'), $tax->label ), 'wp_nav_menu_item_taxonomy_meta_box', 'nav-menus', 'side', 'default', $tax );
1373        }
1374 }
1375 
1376 /**
1377- * Displays a metabox for managing the active menu being edited.
1378+ * Displays a metabox for the custom links menu item.
1379  *
1380  * @since 3.0.0
1381  */
1382-function wp_nav_menu_manage_menu_metabox( $object, $menu ) { ?>
1383-       <div id="submitpost" class="submitbox">
1384-               <div id="minor-publishing">
1385-                       <div class="misc-pub-section misc-pub-section-last">
1386-                               <label class="howto" for="menu-name">
1387-                                       <span><?php _e('Name'); ?></span>
1388-                                       <input id="menu-name" name="menu-name" type="text" class="regular-text menu-item-textbox" value="<?php echo esc_attr( $menu['args'][1] ); ?>" />
1389-                                       <br class="clear" />
1390-                               </label>
1391-                       </div><!--END .misc-pub-section misc-pub-section-last-->
1392-                       <br class="clear" />
1393-               </div><!--END #misc-publishing-actions-->
1394-               <div id="major-publishing-actions">
1395-                       <div id="delete-action">
1396-                               <a class="submitdelete deletion" href="<?php echo wp_nonce_url( admin_url('nav-menus.php?action=delete&amp;menu=' . $menu['args'][0]), 'delete-nav_menu-' . $menu['args'][0] ); ?>"><?php _e('Delete Menu'); ?></a>
1397-                       </div><!--END #delete-action-->
1398+function wp_nav_menu_item_link_meta_box() {
1399+       static $_placeholder;
1400+       $_placeholder = 0 > $_placeholder ? $_placeholder - 1 : -1;
1401 
1402-                       <div id="publishing-action">
1403-                               <input class="button-primary" name="save_menu" type="submit" value="<?php esc_attr_e('Save Menu'); ?>" />
1404-                       </div><!--END #publishing-action-->
1405-                       <br class="clear" />
1406-               </div><!--END #major-publishing-actions-->
1407-       </div><!--END #submitpost .submitbox-->
1408-       <?php
1409-}
1410-
1411-/**
1412- * Displays a metabox for creating a new menu.
1413- *
1414- * @since 3.0.0
1415- */
1416-function wp_nav_menu_create_metabox() { ?>
1417-       <p>
1418-               <input type="text" name="create-menu-name" id="create-menu-name" class="regular-text" value="<?php esc_attr_e( 'Menu name' ); ?>"  />
1419-               <input type="submit" name="create-menu-button" id="create-menu-button" class="button" value="<?php esc_attr_e('Create Menu'); ?>" />
1420-       </p>
1421-       <?php
1422-}
1423-
1424-/**
1425- * Displays a metabox for the custom links menu item.
1426- *
1427- * @since 3.0.0
1428- */
1429-function wp_nav_menu_item_link_metabox() {
1430        // @note: hacky query, see #12660
1431        $args = array( 'post_type' => 'nav_menu_item', 'post_status' => 'any', 'meta_key' => '_menu_item_type', 'numberposts' => -1, 'orderby' => 'title', );
1432 
1433        // @todo transient caching of these results with proper invalidation on updating links
1434        $links = get_posts( $args );
1435+
1436+       $current_tab = 'create';
1437+       if ( isset( $_REQUEST['customlink-tab'] ) && in_array( $_REQUEST['customlink-tab'], array('create', 'all') ) ) {
1438+               $current_tab = $_REQUEST['customlink-tab'];
1439+       }
1440+
1441+       $removed_args = array(
1442+               'action',
1443+               'customlink-tab',
1444+               'edit-menu-item',
1445+               'menu-item',
1446+               'page-tab',
1447+               '_wpnonce',
1448+       );
1449+
1450        ?>
1451-       <p id="menu-item-url-wrap">
1452-               <label class="howto" for="menu-item-url">
1453-                       <span><?php _e('URL'); ?></span>
1454-                       <input id="custom-menu-item-url" name="custom-menu-item-url" type="text" class="code menu-item-textbox" value="http://" />
1455-               </label>
1456-       </p>
1457-       <p id="menu-item-name-wrap">
1458-               <label class="howto" for="custom-menu-item-name">
1459-                       <span><?php _e('Text'); ?></span>
1460-                       <input id="custom-menu-item-name" name="custom-menu-item-name" type="text" class="regular-text menu-item-textbox" value="<?php echo esc_attr( __('Menu Item') ); ?>" />
1461-               </label>
1462-       </p>
1463+       <div class="customlinkdiv">
1464+               <ul id="customlink-tabs" class="customlink-tabs add-menu-item-tabs">
1465+                       <li <?php echo ( 'create' == $current_tab ? ' class="tabs"' : '' ); ?>><a class="menu-tab-link" href="<?php echo add_query_arg('customlink-tab', 'create', remove_query_arg($removed_args)); ?>#tabs-panel-create-custom"><?php _e('Create New'); ?></a></li>
1466+                       <li <?php echo ( 'all' == $current_tab ? ' class="tabs"' : '' ); ?>><a class="menu-tab-link" href="<?php echo add_query_arg('customlink-tab', 'all', remove_query_arg($removed_args)); ?>#tabs-panel-all-custom"><?php _e('View All'); ?></a></li>
1467+               </ul>
1468 
1469-       <p class="button-controls">
1470-               <span class="lists-controls">
1471-                       <a class="show-all"><?php _e('View All'); ?></a>
1472-                       <a class="hide-all"><?php _e('Hide All'); ?></a>
1473-               </span>
1474+               <div class="tabs-panel <?php
1475+                       echo ( 'create' == $current_tab ? 'tabs-panel-active' : 'tabs-panel-inactive' );
1476+               ?>" id="tabs-panel-create-custom">
1477+                       <input type="hidden" value="custom" name="menu-item[<?php echo $_placeholder; ?>][menu-item-type]" />
1478+                       <p id="menu-item-url-wrap">
1479+                               <label class="howto" for="custom-menu-item-url">
1480+                                       <span><?php _e('URL'); ?></span>
1481+                                       <input id="custom-menu-item-url" name="menu-item[<?php echo $_placeholder; ?>][menu-item-url]" type="text" class="code menu-item-textbox" value="http://" />
1482+                               </label>
1483+                       </p>
1484 
1485-               <span class="add-to-menu">
1486-                       <a class="button"><?php _e('Add to Menu'); ?></a>
1487-               </span>
1488-       </p>
1489-       <div id="available-links" class="list-wrap">
1490-               <div class="list-container">
1491-                       <ul class="list">
1492-                               <?php echo wp_nav_menu_get_items( $links, 'custom', 'custom' ); ?>
1493+                       <p id="menu-item-name-wrap">
1494+                               <label class="howto" for="custom-menu-item-name">
1495+                                       <span><?php _e('Text'); ?></span>
1496+                                       <input id="custom-menu-item-name" name="menu-item[<?php echo $_placeholder; ?>][menu-item-title]" type="text" class="regular-text menu-item-textbox" value="<?php echo esc_attr( __('Menu Item') ); ?>" />
1497+                               </label>
1498+                       </p>
1499+               </div><!-- /.tabs-panel -->
1500+
1501+               <div class="tabs-panel <?php
1502+                       echo ( 'all' == $current_tab ? 'tabs-panel-active' : 'tabs-panel-inactive' );
1503+               ?>" id="tabs-panel-all-custom">
1504+                       <ul id="customlinkchecklist" class="list:customlink customlinkchecklist form-no-clear">
1505+                               <?php
1506+                               $args['walker'] = new Walker_Nav_Menu_Checklist;
1507+                               echo walk_nav_menu_tree( array_map('wp_setup_nav_menu_item', $links), 0, (object) $args );
1508+                               ?>
1509                        </ul>
1510-               </div><!-- /.list-container-->
1511-       </div><!-- /#available-links-->
1512-       <div class="clear"></div>
1513+               </div><!-- /.tabs-panel -->
1514+
1515+               <p class="button-controls">
1516+                       <span class="add-to-menu">
1517+                               <input type="submit" class="button-secondary" value="<?php esc_attr_e('Add to Menu'); ?>" name="add-custom-menu-item" />
1518+                       </span>
1519+               </p>
1520+
1521+               <div class="clear"></div>
1522+       </div><!-- /.customlinkdiv -->
1523        <?php
1524 }
1525 
1526@@ -174,58 +416,173 @@
1527  * @param string $object Not used.
1528  * @param string $post_type The post type object.
1529  */
1530-function wp_nav_menu_item_post_type_metabox( $object, $post_type ) {
1531-       $args = array( 'post_type' => $post_type['args']->name, 'numberposts' => -1, 'orderby' => 'title', );
1532+function wp_nav_menu_item_post_type_meta_box( $object, $post_type ) {
1533+       $post_type_name = $post_type['args']->name;
1534 
1535+       // paginate browsing for large numbers of post objects
1536+       $per_page = 50;
1537+       $pagenum = isset( $_REQUEST[$post_type_name . '-tab'] ) && isset( $_REQUEST['paged'] ) ? absint( $_REQUEST['paged'] ) : 1;
1538+       $offset = 0 < $pagenum ? $per_page * ( $pagenum - 1 ) : 0;
1539+
1540+       $args = array(
1541+               'offset' => $offset,
1542+               'order' => 'ASC',
1543+               'orderby' => 'title',
1544+               'posts_per_page' => $per_page,
1545+               'post_type' => $post_type_name,
1546+               'suppress_filters' => true,
1547+       );
1548+
1549        // @todo transient caching of these results with proper invalidation on updating of a post of this type
1550-       $posts = get_posts( $args );
1551+       $get_posts = new WP_Query;
1552+       $posts = $get_posts->query( $args );
1553 
1554+       $post_type_object = get_post_type_object($post_type_name);
1555+
1556+       $num_pages = $get_posts->max_num_pages;
1557+
1558+       $count_posts = (int) @count( $posts );
1559+
1560+       if ( isset( $get_posts->found_posts ) && ( $get_posts->found_posts > $count_posts ) ) {
1561+               // somewhat like display_page_row(), let's make sure ancestors show up on paged display
1562+               $parent_ids = array();
1563+               $child_ids = array();
1564+               foreach( (array) $posts as $post ) {
1565+                       $parent_ids[] = (int) $post->post_parent;
1566+                       $child_ids[] = (int) $post->ID;
1567+               }
1568+               $parent_ids = array_unique($parent_ids);
1569+               $child_ids = array_unique($child_ids);
1570+               
1571+               $missing_parents = array();
1572+               do {
1573+                       foreach( (array) $missing_parents as $missing_parent_id ) {
1574+                               $missing_parent = get_post($missing_parent_id);
1575+                               $posts[] = $missing_parent;
1576+                               $child_ids[] = $missing_parent_id;
1577+                               $parent_ids[] = $missing_parent->post_parent;
1578+                       }
1579+                       
1580+                       $missing_parents = array_filter( array_diff( array_unique( $parent_ids ), array_unique( $child_ids ) ) );
1581+
1582+               } while( 0 < count( $missing_parents ) );
1583+               
1584+       }
1585+
1586+       $page_links = paginate_links( array(
1587+               'base' => add_query_arg(
1588+                       array(
1589+                               $post_type_name . '-tab' => 'all',
1590+                               'paged' => '%#%',
1591+                       )
1592+               ),
1593+               'format' => '',
1594+               'prev_text' => __('&laquo;'),
1595+               'next_text' => __('&raquo;'),
1596+               'total' => $num_pages,
1597+               'current' => $pagenum
1598+       ));
1599+       
1600        if ( !$posts )
1601                $error = '<li id="error">'. sprintf( __( 'No %s exists' ), $post_type['args']->label ) .'</li>';
1602 
1603-       $pt_names = '';
1604-       if ( is_array($posts) ) {
1605-               foreach ( $posts as $post ) {
1606-                       if ( $post->post_title ) {
1607-                               $pt_names .= htmlentities( $post->post_title ) .'|';
1608-                       }
1609-               }
1610+       $current_tab = 'search';
1611+       if ( isset( $_REQUEST[$post_type_name . '-tab'] ) && in_array( $_REQUEST[$post_type_name . '-tab'], array('all', 'search') ) ) {
1612+               $current_tab = $_REQUEST[$post_type_name . '-tab'];
1613        }
1614 
1615-       $id = $post_type['args']->name;
1616+       if ( ! empty( $_REQUEST['quick-search-posttype-' . $post_type_name] ) ) {
1617+               $current_tab = 'search';
1618+       }
1619+
1620+       $removed_args = array(
1621+               'action',
1622+               'customlink-tab',
1623+               'edit-menu-item',
1624+               'menu-item',
1625+               'page-tab',
1626+               '_wpnonce',
1627+       );
1628+
1629        ?>
1630-       <p class="quick-search-wrap">
1631-               <input type="text" class="quick-search regular-text" value="" />
1632-               <a class="quick-search-submit button-secondary"><?php _e('Search'); ?></a>
1633-       </p>
1634+       <div id="posttype-<?php echo $post_type_name; ?>" class="posttypediv">
1635+               <ul id="posttype-<?php echo $post_type_name; ?>-tabs" class="posttype-tabs add-menu-item-tabs">
1636+                       <li <?php echo ( 'search' == $current_tab ? ' class="tabs"' : '' ); ?>><a class="menu-tab-link" href="<?php echo add_query_arg($post_type_name . '-tab', 'search', remove_query_arg($removed_args)); ?>#tabs-panel-posttype-<?php echo $post_type_name; ?>-search"><?php _e('Search'); ?></a></li>
1637+                       <li <?php echo ( 'all' == $current_tab ? ' class="tabs"' : '' ); ?>><a class="menu-tab-link" href="<?php echo add_query_arg($post_type_name . '-tab', 'all', remove_query_arg($removed_args)); ?>#<?php echo $post_type_name; ?>-all"><?php _e('View All'); ?></a></li>
1638+               </ul>
1639 
1640-       <p class="button-controls">
1641-               <span class="lists-controls">
1642-                       <a class="show-all"><?php _e('View All'); ?></a>
1643-                       <a class="hide-all"><?php _e('Hide All'); ?></a>
1644-               </span>
1645+               <div class="tabs-panel <?php
1646+                       echo ( 'search' == $current_tab ? 'tabs-panel-active' : 'tabs-panel-inactive' );
1647+               ?>" id="tabs-panel-posttype-<?php echo $post_type_name; ?>-search">
1648+                       <?php
1649+                       if ( isset( $_REQUEST['quick-search-posttype-' . $post_type_name] ) ) {
1650+                               $searched = esc_attr( $_REQUEST['quick-search-posttype-' . $post_type_name] );
1651+                               $search_results = get_posts( array( 's' => $searched, 'post_type' => $post_type_name, 'fields' => 'all', 'order' => 'DESC', ) );
1652+                       } else {
1653+                               $searched = '';
1654+                               $search_results = array();
1655+                       }
1656+                       ?>
1657+                       <p class="quick-search-wrap">
1658+                               <input type="text" class="quick-search regular-text" value="<?php echo $searched; ?>" name="quick-search-posttype-<?php echo $post_type_name; ?>" />
1659+                               <input type="submit" class="quick-search-submit button-secondary" value="<?php esc_attr_e('Search'); ?>" />
1660+                       </p>
1661 
1662-               <span class="add-to-menu">
1663-                       <a class="button"><?php _e('Add to Menu'); ?></a>
1664-               </span>
1665-       </p>
1666+                       <ul id="<?php echo $post_type_name; ?>-search-checklist" class="list:<?php echo $post_type_name?> categorychecklist form-no-clear">
1667+                       <?php if ( ! empty( $search_results ) && ! is_wp_error( $search_results ) ) : ?>
1668+                               <?php
1669+                               $args['walker'] = new Walker_Nav_Menu_Checklist;
1670+                               echo walk_nav_menu_tree( array_map('wp_setup_nav_menu_item', $search_results), 0, (object) $args );
1671+                               ?>
1672+                       <?php endif; ?>
1673+                       </ul>
1674+               </div><!-- /.tabs-panel -->
1675 
1676-       <div id="existing-<?php echo esc_attr( $id ); ?>" class="list-wrap">
1677-               <div class="list-container">
1678-                       <ul class="list">
1679-                               <?php echo isset( $error ) ? $error : wp_nav_menu_get_items( $posts, 'post_type', $id ); ?>
1680+
1681+               <div id="<?php echo $post_type_name; ?>-all" class="tabs-panel <?php
1682+                       echo ( 'all' == $current_tab ? 'tabs-panel-active' : 'tabs-panel-inactive' );
1683+               ?>">
1684+                       <div class="add-menu-item-pagelinks">
1685+                               <?php echo $page_links; ?>
1686+                       </div>
1687+                       <ul id="<?php echo $post_type_name; ?>checklist" class="list:<?php echo $post_type_name?> categorychecklist form-no-clear">
1688+                               <?php
1689+                               $args['walker'] = new Walker_Nav_Menu_Checklist;
1690+                               $checkbox_items = walk_nav_menu_tree( array_map('wp_setup_nav_menu_item', $posts), 0, (object) $args );
1691+
1692+                               if ( 'all' == $current_tab && ! empty( $_REQUEST['selectall'] ) ) {
1693+                                       $checkbox_items = preg_replace('/(type=(.)checkbox(\2))/', '$1 checked=$2checked$2', $checkbox_items);
1694+                                       
1695+                               }
1696+                               echo $checkbox_items;
1697+                               ?>
1698                        </ul>
1699-               </div><!-- /.list-container-->
1700-       </div><!-- /#existing-categories-->
1701-       <input type="hidden" class="autocomplete" name="autocomplete-<?php echo esc_attr( $id ); ?>-names" value="<?php echo esc_js( $pt_names ); ?>" />
1702-       <br class="clear" />
1703-       <script type="text/javascript" charset="utf-8">
1704-               // <![CDATA[
1705-               jQuery(document).ready(function(){
1706-                       wpNavMenu.autocomplete('<?php echo esc_attr($id); ?>');
1707-               });
1708-               // ]]>
1709-       </script>
1710+                       <div class="add-menu-item-pagelinks">
1711+                               <?php echo $page_links; ?>
1712+                       </div>
1713+               </div><!-- /.tabs-panel -->
1714+
1715+
1716+               <p class="button-controls">
1717+                       <span class="lists-controls">
1718+                               <a href="<?php
1719+                                       echo add_query_arg(
1720+                                               array(
1721+                                                       $post_type_name . '-tab' => 'all',
1722+                                                       'selectall' => 1,
1723+                                               ),
1724+                                               remove_query_arg($removed_args)
1725+                                       );
1726+                               ?>#posttype-<?php echo $post_type_name; ?>" class="select-all"><?php _e('Select All'); ?></a>
1727+                       </span>
1728+
1729+                       <span class="add-to-menu">
1730+                               <input type="submit" class="button-secondary" value="<?php esc_attr_e('Add to Menu'); ?>" name="add-post-type-menu-item" />
1731+                       </span>
1732+               </p>
1733+
1734+               <br class="clear" />
1735+       </div><!-- /.posttypediv -->
1736        <?php
1737 }
1738 
1739@@ -237,169 +594,246 @@
1740  * @param string $object Not used.
1741  * @param string $taxonomy The taxonomy object.
1742  */
1743-function wp_nav_menu_item_taxonomy_metabox( $object, $taxonomy ) {
1744+function wp_nav_menu_item_taxonomy_meta_box( $object, $taxonomy ) {
1745+       $taxonomy_name = $taxonomy['args']->name;
1746+       // paginate browsing for large numbers of objects
1747+       $per_page = 50;
1748+       $pagenum = isset( $_REQUEST[$taxonomy_name . '-tab'] ) && isset( $_REQUEST['paged'] ) ? absint( $_REQUEST['paged'] ) : 1;
1749+       $offset = 0 < $pagenum ? $per_page * ( $pagenum - 1 ) : 0;
1750+       
1751        $args = array(
1752-               'child_of' => 0, 'orderby' => 'name', 'order' => 'ASC',
1753-               'hide_empty' => false, 'include_last_update_time' => false, 'hierarchical' => 1, 'exclude' => '',
1754-               'include' => '', 'number' => '', 'pad_counts' => false
1755+               'child_of' => 0,
1756+               'exclude' => '',
1757+               'hide_empty' => false,
1758+               'hierarchical' => 1,
1759+               'include' => '',
1760+               'include_last_update_time' => false,
1761+               'number' => $per_page,
1762+               'offset' => $offset,
1763+               'order' => 'ASC',
1764+               'orderby' => 'name',
1765+               'pad_counts' => false,
1766        );
1767 
1768+       $num_pages = ceil( wp_count_terms($taxonomy_name) / $per_page );
1769+
1770+       $page_links = paginate_links( array(
1771+               'base' => add_query_arg(
1772+                       array(
1773+                               $taxonomy_name . '-tab' => 'all',
1774+                               'paged' => '%#%',
1775+                       )
1776+               ),
1777+               'format' => '',
1778+               'prev_text' => __('&laquo;'),
1779+               'next_text' => __('&raquo;'),
1780+               'total' => $num_pages,
1781+               'current' => $pagenum
1782+       ));
1783+       
1784+       $walker = new Walker_Nav_Menu_Checklist;
1785        // @todo transient caching of these results with proper invalidation on updating of a tax of this type
1786-       $terms = get_terms( $taxonomy['args']->name, $args );
1787+       $terms = get_terms( $taxonomy_name, $args );
1788 
1789-       if ( !$terms || is_wp_error($terms) )
1790+       if ( ! $terms || is_wp_error($terms) )
1791                $error = '<li id="error">'. sprintf( __( 'No %s exists' ), $taxonomy['args']->label ) .'</li>';
1792 
1793-       $term_names = '';
1794-       if ( is_array($terms) ) {
1795-               foreach ( $terms as $term ) {
1796-                       if ( $term->name ) {
1797-                               $term_names .= htmlentities( $term->name ) .'|';
1798-                       }
1799-               }
1800+       $current_tab = 'most-used';
1801+       if ( isset( $_REQUEST[$taxonomy_name . '-tab'] ) && in_array( $_REQUEST[$taxonomy_name . '-tab'], array('all', 'most-used', 'search') ) ) {
1802+               $current_tab = $_REQUEST[$taxonomy_name . '-tab'];
1803        }
1804 
1805-       $id = $taxonomy['args']->name;
1806+       if ( ! empty( $_REQUEST['quick-search-taxonomy-' . $taxonomy_name] ) ) {
1807+               $current_tab = 'search';
1808+       }
1809+
1810+       $removed_args = array(
1811+               'action',
1812+               'customlink-tab',
1813+               'edit-menu-item',
1814+               'menu-item',
1815+               'page-tab',
1816+               '_wpnonce',
1817+       );
1818+
1819        ?>
1820-       <p class="quick-search-wrap">
1821-               <input type="text" class="quick-search regular-text" value="" />
1822-               <a class="quick-search-submit button-secondary"><?php _e('Search'); ?></a>
1823-       </p>
1824+       <div id="taxonomy-<?php echo $taxonomy_name; ?>" class="taxonomydiv">
1825+               <ul id="taxonomy-<?php echo $taxonomy_name; ?>-tabs" class="taxonomy-tabs add-menu-item-tabs">
1826+                       <li <?php echo ( 'most-used' == $current_tab ? ' class="tabs"' : '' ); ?>><a class="menu-tab-link" href="<?php echo add_query_arg($taxonomy_name . '-tab', 'most-used', remove_query_arg($removed_args)); ?>#tabs-panel-<?php echo $taxonomy_name; ?>-pop"><?php _e('Most Used'); ?></a></li>
1827+                       <li <?php echo ( 'search' == $current_tab ? ' class="tabs"' : '' ); ?>><a class="menu-tab-link" href="<?php echo add_query_arg($taxonomy_name . '-tab', 'search', remove_query_arg($removed_args)); ?>#tabs-panel-search-taxonomy-<?php echo $taxonomy_name; ?>"><?php _e('Search'); ?></a></li>
1828+                       <li <?php echo ( 'all' == $current_tab ? ' class="tabs"' : '' ); ?>><a class="menu-tab-link" href="<?php echo add_query_arg($taxonomy_name . '-tab', 'all', remove_query_arg($removed_args)); ?>#tabs-panel-<?php echo $taxonomy_name; ?>-all"><?php _e('View All'); ?></a></li>
1829+               </ul>
1830 
1831-       <p class="button-controls">
1832-               <span class="lists-controls">
1833-                       <a class="show-all"><?php _e('View All'); ?></a>
1834-                       <a class="hide-all"><?php _e('Hide All'); ?></a>
1835-               </span>
1836+               <div id="tabs-panel-<?php echo $taxonomy_name; ?>-pop" class="tabs-panel <?php
1837+                       echo ( 'most-used' == $current_tab ? 'tabs-panel-active' : 'tabs-panel-inactive' );
1838+               ?>">
1839+                       <ul id="<?php echo $taxonomy_name; ?>checklist-pop" class="categorychecklist form-no-clear" >
1840+                               <?php
1841+                               $popular_terms = get_terms( $taxonomy_name, array( 'orderby' => 'count', 'order' => 'DESC', 'number' => 10, 'hierarchical' => false ) );
1842+                               $args['walker'] = $walker;
1843+                               echo walk_nav_menu_tree( array_map('wp_setup_nav_menu_item', $popular_terms), 0, (object) $args );
1844+                               ?>
1845+                               <?php
1846+                               ?>
1847+                       </ul>
1848+               </div><!-- /.tabs-panel -->
1849 
1850-               <span class="add-to-menu">
1851-                       <a class="button"><?php _e('Add to Menu'); ?></a>
1852-               </span>
1853-       </p>
1854+               <div class="tabs-panel <?php
1855+                       echo ( 'search' == $current_tab ? 'tabs-panel-active' : 'tabs-panel-inactive' );
1856+               ?>" id="tabs-panel-search-taxonomy-<?php echo $taxonomy_name; ?>">
1857+                       <?php
1858+                       if ( isset( $_REQUEST['quick-search-taxonomy-' . $taxonomy_name] ) ) {
1859+                               $searched = esc_attr( $_REQUEST['quick-search-taxonomy-' . $taxonomy_name] );
1860+                               $search_results = get_terms( $taxonomy_name, array( 'name__like' => $searched, 'fields' => 'all', 'orderby' => 'count', 'order' => 'DESC', 'hierarchical' => false ) );
1861+                       } else {
1862+                               $searched = '';
1863+                               $search_results = array();
1864+                       }
1865+                       ?>
1866+                       <p class="quick-search-wrap">
1867+                               <input type="text" class="quick-search regular-text" value="<?php echo $searched; ?>" name="quick-search-taxonomy-<?php echo $taxonomy_name; ?>" />
1868+                               <input type="submit" class="quick-search-submit button-secondary" value="<?php esc_attr_e('Search'); ?>" />
1869+                       </p>
1870+               
1871+                       <ul id="<?php echo $taxonomy_name; ?>-search-checklist" class="list:<?php echo $taxonomy_name?> categorychecklist form-no-clear">
1872+                       <?php if ( ! empty( $search_results ) && ! is_wp_error( $search_results ) ) : ?>
1873+                               <?php
1874+                               $args['walker'] = $walker;
1875+                               echo walk_nav_menu_tree( array_map('wp_setup_nav_menu_item', $search_results), 0, (object) $args );
1876+                               ?>
1877+                       <?php endif; ?>
1878+                       </ul>
1879+               </div><!-- /.tabs-panel -->
1880 
1881-       <div id="existing-<?php echo esc_attr( $id ); ?>" class="list-wrap">
1882-               <div class="list-container">
1883-                       <ul class="list">
1884-                               <?php echo isset( $error ) ? $error : wp_nav_menu_get_items( $terms, 'taxonomy', $id ); ?>
1885+               <div id="tabs-panel-<?php echo $taxonomy_name; ?>-all" class="tabs-panel <?php
1886+                       echo ( 'all' == $current_tab ? 'tabs-panel-active' : 'tabs-panel-inactive' );
1887+               ?>">
1888+                       <div class="add-menu-item-pagelinks">
1889+                               <?php echo $page_links; ?>
1890+                       </div>
1891+                       <ul id="<?php echo $taxonomy_name; ?>checklist" class="list:<?php echo $taxonomy_name?> categorychecklist form-no-clear">
1892+                               <?php
1893+                               $args['walker'] = $walker;
1894+                               echo walk_nav_menu_tree( array_map('wp_setup_nav_menu_item', $terms), 0, (object) $args );
1895+                               ?>
1896                        </ul>
1897-               </div><!-- /.list-container-->
1898-       </div><!-- /#existing-categories-->
1899-       <input type="hidden" class="autocomplete" name="autocomplete-<?php echo esc_attr($id); ?>-names" value="<?php echo esc_js( $term_names ); ?>" />
1900-       <br class="clear" />
1901-       <script type="text/javascript" charset="utf-8">
1902-               // <![CDATA[
1903-               jQuery(document).ready(function(){
1904-                       wpNavMenu.autocomplete('<?php echo esc_attr($id); ?>');
1905-               });
1906-               // ]]>
1907-       </script>
1908+                       <div class="add-menu-item-pagelinks">
1909+                               <?php echo $page_links; ?>
1910+                       </div>
1911+               </div><!-- /.tabs-panel -->
1912+
1913+               <p class="button-controls">
1914+                       <span class="lists-controls">
1915+                               <a href="<?php
1916+                                       echo add_query_arg(
1917+                                               array(
1918+                                                       $taxonomy_name . '-tab' => 'all',
1919+                                                       'selectall' => 1,
1920+                                               ),
1921+                                               remove_query_arg($removed_args)
1922+                                       );
1923+                               ?>#taxonomy-<?php echo $taxonomy_name; ?>" class="select-all"><?php _e('Select All'); ?></a>
1924+                       </span>
1925+
1926+                       <span class="add-to-menu">
1927+                               <input type="submit" class="button-secondary" value="<?php esc_attr_e('Add to Menu'); ?>" name="add-taxonomy-menu-item" />
1928+                       </span>
1929+               </p>
1930+
1931+               <br class="clear" />
1932+       </div><!-- /.taxonomydiv -->
1933        <?php
1934 }
1935 
1936 /**
1937- * Abstract function for returning all menu items of a menu item type.
1938+ * Save posted nav menu item data.
1939  *
1940  * @since 3.0.0
1941  *
1942- * @param string $menu_items Array of objects containing all menu items to be displayed.
1943- * @param string $object_type Menu item type.
1944- * @param string $object Optional. Menu item type name.
1945- * @param string $context Optional. The context for how the menu items should be formatted.
1946- * @return string $ouput Menu items.
1947+ * @param int $menu_id The menu ID for which to save this item.
1948+ * @param array $menu_data The unsanitized posted menu item data.
1949+ * @return array The database IDs of the items saved.
1950  */
1951-function wp_nav_menu_get_items( $menu_items, $object_type, $object = null, $context = 'frontend' ) {
1952-       if ( !$menu_items )
1953-               return __( 'Not Found' );
1954+function wp_save_nav_menu_item( $menu_id = 0, $menu_data = array() ) {
1955+       $menu_id = (int) $menu_id;
1956+       $items_saved = array();
1957 
1958-       $output = '';
1959-       $i = 1;
1960-       foreach ( $menu_items as $menu_item ) {
1961-               // convert the 'parent' taxonomy property to 'post_parent'
1962-               // so we don't have to duplicate this entire function.
1963-               if ( !isset($menu_item->post_parent) )
1964-                       $menu_item->post_parent = $menu_item->parent;
1965+       if ( is_nav_menu( $menu_id ) ) {
1966 
1967-               // Get all attachements and links
1968-               if ( in_array($object, array( 'attachment', 'custom' )) )
1969-                       $menu_item->post_parent = 0;
1970+               // Loop through all the menu items' POST values
1971+               foreach( (array) $menu_data as $_possible_db_id => $_item_object_data ) {
1972+                       if (
1973+                               empty( $_item_object_data['menu-item-object-id'] ) && // checkbox is not checked
1974+                               (
1975+                                       ! isset( $_item_object_data['menu-item-type'] ) || // and item type either isn't set
1976+                                       in_array( $_item_object_data['menu-item-url'], array( 'http://', '' ) ) || // or URL is the default
1977+                                       'custom' != $_item_object_data['menu-item-type'] ||  // or it's not a custom menu item 
1978+                                       ! empty( $_item_object_data['menu-item-db-id'] ) // or it *is* a custom menu item that already exists
1979+                               )
1980+                       ) {
1981+                               continue; // then this potential menu item is not getting added to this menu
1982+                       }
1983 
1984-               if ( 0 == $menu_item->post_parent ) {
1985-                       // Set up the menu item
1986-                       $menu_item = wp_setup_nav_menu_item( $menu_item, $object_type, $object );
1987+                       // if this possible menu item doesn't actually have a menu database ID yet
1988+                       if (
1989+                               empty( $_item_object_data['menu-item-db-id'] ) ||
1990+                               ( 0 > $_possible_db_id ) ||
1991+                               $_possible_db_id != $_item_object_data['menu-item-db-id']
1992+                       ) {
1993+                               $_actual_db_id = 0;
1994+                       } else {
1995+                               $_actual_db_id = (int) $_item_object_data['menu-item-db-id'];
1996+                       }
1997+                       
1998+                       $args = array(
1999+                               'menu-item-db-id' => ( isset( $_item_object_data['menu-item-db-id'] ) ? $_item_object_data['menu-item-db-id'] : '' ),
2000+                               'menu-item-object-id' => ( isset( $_item_object_data['menu-item-object-id'] ) ? $_item_object_data['menu-item-object-id'] : '' ),
2001+                               'menu-item-object' => ( isset( $_item_object_data['menu-item-object'] ) ? $_item_object_data['menu-item-object'] : '' ),
2002+                               'menu-item-parent-id' => ( isset( $_item_object_data['menu-item-parent-id'] ) ? $_item_object_data['menu-item-parent-id'] : '' ),
2003+                               'menu-item-position' => ( isset( $_item_object_data['menu-item-position'] ) ? $_item_object_data['menu-item-position'] : '' ),
2004+                               'menu-item-type' => ( isset( $_item_object_data['menu-item-type'] ) ? $_item_object_data['menu-item-type'] : '' ),
2005+                               'menu-item-append' => ( isset( $_item_object_data['menu-item-append'] ) ? $_item_object_data['menu-item-append'] : '' ),
2006+                               'menu-item-title' => ( isset( $_item_object_data['menu-item-title'] ) ? $_item_object_data['menu-item-title'] : '' ),
2007+                               'menu-item-url' => ( isset( $_item_object_data['menu-item-url'] ) ? $_item_object_data['menu-item-url'] : '' ),
2008+                               'menu-item-description' => ( isset( $_item_object_data['menu-item-description'] ) ? $_item_object_data['menu-item-description'] : '' ),
2009+                               'menu-item-attr-title' => ( isset( $_item_object_data['menu-item-attr-title'] ) ? $_item_object_data['menu-item-attr-title'] : '' ),
2010+                               'menu-item-target' => ( isset( $_item_object_data['menu-item-target'] ) ? $_item_object_data['menu-item-target'] : '' ),
2011+                               'menu-item-classes' => ( isset( $_item_object_data['menu-item-classes'] ) ? $_item_object_data['menu-item-classes'] : '' ),
2012+                               'menu-item-xfn' => ( isset( $_item_object_data['menu-item-xfn'] ) ? $_item_object_data['menu-item-xfn'] : '' ),
2013+                       );
2014 
2015-                       // No blank titles
2016-                       if ( empty($menu_item->title) )
2017-                               continue;
2018+                       $items_saved[] = wp_update_nav_menu_item( $menu_id, $_actual_db_id, $args );
2019 
2020-                       $attributes = ( 'backend' == $context ) ? ' id="menu-item-'. $i .'" value="'. $i .'"' : '';
2021-
2022-                       $output .= '<li'. $attributes .'>';
2023-                       $output .= wp_get_nav_menu_item( $menu_item, $object_type, $object );
2024-                       $output .= wp_get_nav_menu_sub_items( $menu_item->ID, $object_type, $object, $context );
2025-                       $output .= '</li>';
2026-
2027-                       ++$i;
2028                }
2029        }
2030-
2031-       return $output;
2032+       return $items_saved;
2033 }
2034 
2035 /**
2036- * Recursive function to retrieve sub menu items.
2037+ * Returns the menu item formatted to edit.
2038  *
2039  * @since 3.0.0
2040  *
2041- * @param string $childof The Parent ID.
2042- * @param string $object_type The object type.
2043- * @param string $object The object name.
2044- * @return string $output sub menu items.
2045+ * @param string $menu_item_id The ID of the menu item to format.
2046+ * @return string|WP_Error $output The menu formatted to edit or error object on failure.
2047  */
2048-function wp_get_nav_menu_sub_items( $childof, $object_type, $object = null, $context = 'frontend' ) {
2049-       $args = array( 'child_of' => $childof, 'parent' => $childof, 'hide_empty' => false, );
2050+function wp_get_nav_menu_to_edit( $menu_item_id = 0 ) {
2051+       static $_placeholder;
2052+       
2053+       $menu = wp_get_nav_menu_object( $menu_item_id );
2054+       
2055+       // If the menu exists, get its items.
2056+       if ( is_nav_menu( $menu ) ) {
2057+               $menu_items = wp_get_nav_menu_items( $menu->term_id );
2058 
2059-       switch ( $object_type ) {
2060-               case 'post_type':
2061-                       $hierarchical_post_types = get_post_types( array( 'hierarchical' => true ) );
2062-                       if ( in_array( $object, $hierarchical_post_types ) ) {
2063-                               $args['post_type'] = $object;
2064-                               $sub_menu_items = get_pages( $args );
2065-                       } else {
2066-                               $sub_menu_items = array();
2067-                       }
2068-                       break;
2069+               $walker = new Walker_Nav_Menu_Edit;
2070 
2071-               case 'taxonomy':
2072-                       if ( is_taxonomy_hierarchical( $object ) ) {
2073-                               $sub_menu_items = get_terms( $object, $args );
2074-                       } else {
2075-                               $sub_menu_items = array();
2076-                       }
2077-                       break;
2078-
2079-               default:
2080-                       $sub_menu_items = array();
2081-                       break;
2082+               return walk_nav_menu_tree( array_map('wp_setup_nav_menu_item', $menu_items), 0, (object) array('walker' => $walker ) );
2083+       } elseif ( is_wp_error( $menu ) ) {
2084+               return $menu;   
2085        }
2086 
2087-       $output = '';
2088-       $i = 1;
2089-       if ( !empty($sub_menu_items) && !is_wp_error($sub_menu_items) ) {
2090-               $output .= '<ul class="sub-menu menu-item-type-'. $object_type .'">';
2091-               foreach ( $sub_menu_items as $menu_item ) {
2092-                       // Set up the menu item
2093-                       $menu_item = wp_setup_nav_menu_item( $menu_item, $object_type, $object );
2094-                       $attributes = ( 'backend' == $context ) ? ' id="menu-item-'. $i .'" value="'. $i .'"' : '';
2095 
2096-                       $output .= '<li'. $attributes .'>';
2097-                       $output .= wp_get_nav_menu_item( $menu_item, $object_type, $object );
2098-                       $output .= wp_get_nav_menu_sub_items( $menu_item->ID, $object_type, $object );
2099-                       $output .= '</li>';
2100+}
2101 
2102-                       ++$i;
2103-               }
2104-               $output .= '</ul>';
2105-       }
2106-       return $output;
2107-}
2108-?>
2109\ No newline at end of file
2110+?>
2111Index: wp-admin/js/nav-menu.dev.js
2112===================================================================
2113--- wp-admin/js/nav-menu.dev.js (revision 14247)
2114+++ wp-admin/js/nav-menu.dev.js (working copy)
2115@@ -8,494 +8,647 @@
2116  * @subpackage Administration
2117  */
2118 
2119-var wpNavMenu;
2120+var WPNavMenuHandler = function () {
2121+       var $ = jQuery,
2122+       activeHovering = false,
2123+       currentDropzone = null,
2124+       
2125+       customLinkNameInput,
2126+       customLinkURLInput,
2127+       customLinkNameDefault,
2128+       customLinkURLDefault,
2129 
2130-(function($) {
2131+       autoCompleteData = {},
2132+
2133+       formatAutocompleteResponse = function( resultRow, pos, total, queryTerm ) {
2134+               if ( resultRow && resultRow[0] ) {
2135+                       var data = $.parseJSON(resultRow[0]);
2136+                       if ( data.post_title ) {
2137+                               if ( data.ID && data.post_type )
2138+                                       autoCompleteData[data.post_title] = {ID: data.ID, object_type: data.post_type};
2139+                               return data.post_title;
2140+                       }
2141+               }
2142+       },
2143+
2144+       formatAutocompleteResult = function( resultRow, pos, total, queryTerm ) {
2145+               if ( resultRow && resultRow[0] ) {
2146+                       var data = $.parseJSON(resultRow[0]);
2147+                       if ( data.post_title )
2148+                               return data.post_title;
2149+               }
2150+       },
2151       
2152-       wpNavMenu = {
2153+       getListDataFromID = function(menuItemID, parentEl) {
2154+               if ( ! menuItemID )
2155+                       return false;
2156+               parentEl = parentEl || document;
2157+               var fields = [
2158+                       'menu-item-db-id',
2159+                       'menu-item-object-id',
2160+                       'menu-item-object',
2161+                       'menu-item-parent-id',
2162+                       'menu-item-position',
2163+                       'menu-item-type',
2164+                       'menu-item-append',
2165+                       'menu-item-title',
2166+                       'menu-item-url',
2167+                       'menu-item-description',
2168+                       'menu-item-attr-title',
2169+                       'menu-item-target',
2170+                       'menu-item-classes',
2171+                       'menu-item-xfn'
2172+               ],
2173+               itemData = {},
2174+               inputs = parentEl.getElementsByTagName('input'),
2175+               i = inputs.length,
2176+               j,
2177+               menuID = document.getElementById('nav-menu-meta-object-id').value;
2178+
2179+               while ( i-- ) {
2180+                       j = fields.length;
2181+                       while ( j-- ) {
2182+                               if (
2183+                                       inputs[i] &&
2184+                                       inputs[i].name &&
2185+                                       'menu-item[' + menuItemID + '][' + fields[j] + ']' == inputs[i].name
2186+                               ) {
2187+                                       itemData[fields[j]] = inputs[i].value;
2188+                               }
2189+                       }
2190+               }
2191+
2192+               return itemData;
2193+       },
2194+
2195+       getParentMenuItemDBId = function() {
2196+               var allInputs = this.getElementsByTagName('input'),
2197+               i = allInputs.length,
2198+               j,
2199+               parentEl,
2200+               parentInputs;
2201+
2202+               while( i-- ) {
2203+                       if ( -1 != allInputs[i].name.indexOf('menu-item-parent-id[' + parseInt(this.id.replace('menu-item-', ''), 10) + ']') ) {
2204+                               /*  This LI element is not in a submenu */
2205+                               if ( ! this.parentNode.className || -1 == this.parentNode.className.indexOf('sub-menu') ) {
2206+                                       allInputs[i].value = 0;
2207+
2208+                               /* This LI is in a submenu, so need to get the parent's object ID (which is different from the parent's DB ID, the ID in its attributes) */
2209+                               } else if ( 'LI' == this.parentNode.parentNode.nodeName && -1 != this.parentNode.parentNode.id.indexOf('menu-item-') )  {
2210+                                        parentEl = this.parentNode.parentNode;
2211+                                        parentInputs = parentEl.getElementsByTagName('input');
2212+                                        j = parentInputs.length;
2213+                                        while ( j-- ) {
2214+                                               if ( parentInputs[j].name && -1 != parentInputs[j].name.indexOf('menu-item-object-id[' + parseInt(parentEl.id.replace('menu-item-', ''), 10) + ']') ) {
2215+                                                       allInputs[i].value = parseInt(parentInputs[j].value, 10);
2216+                                                       break;
2217+                                               }
2218+                                        }
2219+                               }
2220+                               break;
2221+                       }
2222+               }
2223+       },
2224+
2225+       makeDroppable = function(el) {
2226+               var that = this;
2227+
2228+               $(el).droppable({
2229+                       accept: '.menu li',
2230+                       tolerance: 'pointer',
2231+                       drop: function(e, ui) {
2232+                               that.eventOnDrop(ui.draggable[0], this, ui, e);
2233+                       },
2234+
2235+                       over: function(e,ui) {
2236+                               that.eventOnDragOver(ui.draggable[0], this, ui, e);
2237+                       },
2238+
2239+                       out: function(e, ui) {
2240+                               that.eventOnDragOut(ui.draggable[0], this, ui, e);
2241+                       }
2242+               });
2243+       },
2244+
2245+       menuList,
2246+
2247+       setupListItemsDragAndDrop = function(list) {
2248+               if ( ! list )
2249+                       return;
2250+
2251+               var menuListItems = list.getElementsByTagName('li'),
2252+               i = menuListItems.length;
2253               
2254+               while ( i-- )
2255+                       this.setupListItemDragAndDrop(menuListItems[i]);
2256+       };
2257+
2258+       return {
2259+               
2260                // Functions that run on init.
2261                init : function() {
2262+                       menuList = document.getElementById('menu-to-edit');
2263                       
2264-                       wpNavMenu.initial_meta_boxes();
2265+                       this.attachMenuEditListeners();
2266+
2267+                       this.attachMenuMetaListeners(document.getElementById('nav-menu-meta'));
2268                       
2269-                       wpNavMenu.drag_and_drop();
2270+                       this.attachTabsPanelListeners();
2271                       
2272-                       // Delete AYS
2273-                       $('#update-nav-menu .deletion').click(function(){
2274-                               if ( confirm( navMenuL10n.warnDelete ) ) {
2275-                                       return true;
2276-                               } else {
2277-                                       return false;
2278-                               };
2279-                       });
2280+                       // init drag and drop
2281+                       setupListItemsDragAndDrop.call(this, menuList);
2282 
2283-                       // Handle Save Button Clicks
2284-                       $('#update-nav-menu').submit(function(){
2285-                               wpNavMenu.update_post_data();
2286-                       });
2287-
2288-                       // Handle some return keypresses
2289-                       $('#create-menu-name').keypress(function(e){
2290-                               if ( 13 == e.keyCode ) {
2291-                                       $('#create-menu-button').click();
2292-                                       return false;
2293+                       postboxes.add_postbox_toggles('nav-menus');
2294+               },
2295+               
2296+               attachMenuEditListeners : function() {
2297+                       var that = this;
2298+                       $('#update-nav-menu').bind('click', function(e) {
2299+                               if ( e.target && e.target.className ) {
2300+                                       if ( -1 != e.target.className.indexOf('item-edit') ) {
2301+                                               return that.eventOnClickEditLink(e.target);
2302+                                       } else if ( -1 != e.target.className.indexOf('menu-delete') ) {
2303+                                               return that.eventOnClickMenuDelete(e.target);
2304+                                       } else if ( -1 != e.target.className.indexOf('item-delete') ) {
2305+                                               return that.eventOnClickMenuItemDelete(e.target);
2306+                                       }
2307                                }
2308                        });
2309+               },
2310 
2311-                       $('#custom-menu-item-url, #custom-menu-item-name').keypress(function(e){
2312-                               if ( 13 == e.keyCode ) {
2313-                                       $('#add-custom-links a.button').click();
2314-                                       return false;
2315-                               }
2316-                       }).focus(function(){
2317-                               if ( $(this).val() == $(this).attr('defaultValue') && $(this).attr('id') != 'custom-menu-item-url' ) {
2318-                                       $(this).val('');
2319-                               }
2320-                       }).blur(function(){
2321-                               if ( $(this).val() == '' ) {
2322-                                       $(this).val($(this).attr('defaultValue'));
2323-                               }
2324-                       });
2325+               attachMenuMetaListeners : function(formEL) {
2326+                       if ( ! formEL )
2327+                               return;
2328 
2329-                       $('#create-menu-name').focus(function(){
2330-                               if ( $(this).val() == $(this).attr('defaultValue') ) {
2331-                                       $(this).val('');
2332-                               }
2333-                       }).blur(function(){
2334-                               if ( $(this).val() == '' ) {
2335-                                       $(this).val($(this).attr('defaultValue'));
2336-                               }
2337-                       });
2338+                       var that = this;
2339 
2340-                       // close postboxes that should be closed
2341-                       $('.if-js-closed').removeClass('if-js-closed').addClass('closed');
2342+                       // set default value for custom link name
2343+                       customLinkNameInput = document.getElementById('custom-menu-item-name');
2344+                       customLinkURLInput = document.getElementById('custom-menu-item-url');
2345 
2346-                       // postboxes setup
2347-                       postboxes.add_postbox_toggles('nav-menus');
2348+                       if ( customLinkNameInput ) {
2349+                               customLinkNameDefault = 'undefined' != typeof customLinkNameInput.defaultValue ? customLinkNameInput.defaultValue : customLinkNameInput.getAttribute('value');
2350+                               customLinkURLDefault = 'undefined' != typeof customLinkURLInput.defaultValue ? customLinkURLInput.defaultValue : customLinkURLInput.getAttribute('value');
2351+                               $(customLinkNameInput).bind('focus', function(e) {
2352+                                       this.value = customLinkNameDefault == this.value ? '' : this.value;
2353+                               });
2354+                               
2355+                               $(customLinkNameInput).bind('blur', function(e) {
2356+                                       this.value = '' == this.value ? customLinkNameDefault : this.value;
2357+                               });
2358+                       }
2359 
2360-                       // Clear the quick search textbox
2361-                       $('.quick-search').click(function(){
2362-                               $(this).attr( 'value', '' );
2363+                       // auto-suggest for the quick-search boxes
2364+                       $('input.quick-search').each(function(i, el) {
2365+                               that.setupQuickSearchEventListeners(el);
2366                        });
2367-
2368-                       // Quick Search submit
2369-                       $('.quick-search-submit').click(function(){
2370-                               $(this).siblings('.quick-search').search();
2371+                       
2372+                       $(formEL).bind('submit', function(e) {
2373+                               return that.eventSubmitMetaForm.call(that, this, e);
2374                        });
2375+               },
2376 
2377-                       // Edit menu item
2378-                       $('#menu-container .item-edit').click(function(){
2379-                               wpNavMenu.edit_menu_item( $(this).attr('value') );
2380-                       });
2381+               attachTabsPanelListeners : function() {
2382+                       $('#menu-settings-column').bind('click', function(e) {
2383+                               if ( e.target && e.target.className && -1 != e.target.className.indexOf('menu-tab-link') ) {
2384+                                       var i = e.target.parentNode,
2385+                                       activePanel,
2386+                                       panelIdMatch = /#(.*)$/.exec(e.target.href),
2387+                                       tabPanels;
2388+                                       while ( ! i.className || -1 == i.className.indexOf('inside') ) {
2389+                                               i = i.parentNode;
2390+                                       }
2391+                                       $('.tabs-panel', i).each(function() {
2392+                                               if ( this.className )
2393+                                                       this.className = this.className.replace('tabs-panel-active', 'tabs-panel-inactive');
2394+                                       });
2395 
2396-                       // Delete menu item
2397-                       $('#menu-container .item-delete').click(function(){
2398-                               wpNavMenu.remove_menu_item( $(this).attr('value') );
2399-                       });
2400+                                       $('.tabs', i).each(function() {
2401+                                               this.className = this.className.replace('tabs', '');
2402+                                       });
2403 
2404-                       // Update menu item settings (thickbox)
2405-                       $('#update-menu-item').click(function(){
2406-                               wpNavMenu.update_menu_item();
2407-                               tb_remove();
2408-                       });
2409+                                       e.target.parentNode.className += ' tabs';
2410 
2411-                       // Close thickbox
2412-                       $('#cancel-save').click(function(){
2413-                               tb_remove();
2414+                                       if ( panelIdMatch && panelIdMatch[1] ) {
2415+                                               activePanel = document.getElementById(panelIdMatch[1]);
2416+                                               if ( activePanel ) {
2417+                                                       activePanel.className = activePanel.className.replace('tabs-panel-inactive', 'tabs-panel-active');
2418+                                               }
2419+                                       }
2420+                                       
2421+                                       return false;
2422+                               } else if ( e.target && e.target.className && -1 != e.target.className.indexOf('select-all') ) {
2423+                                       var selectAreaMatch = /#(.*)$/.exec(e.target.href);
2424+                                       if ( selectAreaMatch && selectAreaMatch[1] ) {
2425+                                               $('#' + selectAreaMatch[1] + ' .tabs-panel-active input[type=checkbox]').attr('checked', 'checked');
2426+                                               return false;
2427+                                       }
2428+                               }
2429                        });
2430+               },
2431 
2432-                       // Show All Button
2433-                       $('.show-all').click(function(e){
2434-                               $(e.currentTarget).parent().parent().siblings('.list-wrap').css( 'display', 'block' );
2435-                               $(e.currentTarget).parent().parent().siblings('.list-wrap').find('li').css( 'display', 'block' );
2436-                               $(e.currentTarget).hide();
2437-                               $(e.currentTarget).siblings('.hide-all').show();
2438-                       });
2439+               setupListItemDragAndDrop : function(el) {
2440+                       var defLists = el.getElementsByTagName('dl'),
2441+                       dropZone = this.makeListItemDropzone(el),
2442+                       i = defLists.length;
2443 
2444-                       // Hide All Button
2445-                       $('.hide-all').click(function(e){
2446-                               $(e.currentTarget).parent().parent().siblings('.list-wrap').css( 'display', 'none' );
2447-                               $(e.currentTarget).parent().parent().siblings('.list-wrap').find('li').css( 'display', 'none' );
2448-                               $(e.currentTarget).hide();
2449-                               $(e.currentTarget).siblings('.show-all').show();
2450-                       });
2451+                       makeDroppable.call(this, dropZone);
2452+                       this.makeListItemDraggable(el);
2453 
2454-                       // Add menu items into the menu
2455-                       $('.add-to-menu').click(function(e){
2456-                               wpNavMenu.add_checked_items_to_menu(e.currentTarget);
2457-                       });
2458+                       while( i-- ) {
2459+                               makeDroppable.call(this, defLists[i]);
2460+                       }
2461+               },
2462 
2463-                       // Create a new link then add it to the menu
2464-                       $('#add-custom-links .add-to-menu a').click(function(e){
2465-                               // Add link to menu
2466-                               if ( $('#custom-menu-item-url').val() == $('#custom-menu-item-url').attr('defaultValue') )
2467-                                       return; // Do not allow "http://" submissions to go through
2468-
2469-                               wpNavMenu.add_custom_link( $('#custom-menu-item-name').val(), $('#custom-menu-item-url').val() );
2470-                               
2471-                               // Reset the fields back to their defaults
2472-                               $('#custom-menu-item-name').val($('#custom-menu-item-name').attr('defaultValue'));
2473-                               $('#custom-menu-item-url' ).val($('#custom-menu-item-url' ).attr('defaultValue')).focus();
2474+               /**
2475+                * Set up quick-search input fields' events.
2476+                *
2477+                * @param object el The input element.
2478+                */
2479+               setupQuickSearchEventListeners : function(el) {
2480+                       var that = this;
2481+                       $(el).autocomplete( ajaxurl + '?action=menu-quick-search&type=' + el.name,
2482+                               {
2483+                                       delay: 500,
2484+                                       formatItem: formatAutocompleteResponse,
2485+                                       formatResult: formatAutocompleteResult,
2486+                                       minchars: 2,
2487+                                       multiple: false
2488+                               }
2489+                       ).bind('blur', function(e) {
2490+                               var changedData = autoCompleteData[this.value],
2491+                               inputEl = this;
2492+                               if ( changedData ) {
2493+                                       $.post(
2494+                                               ajaxurl + '?action=menu-quick-search&type=get-post-item&response-format=markup',
2495+                                               changedData,
2496+                                               function(r) {
2497+                                                       that.processQuickSearchQueryResponse.call(that, r, changedData);
2498+                                                       autoCompleteData[inputEl.value] = false;
2499+                                               }
2500+                                       );
2501+                               }
2502                        });
2503                },
2504+
2505+               eventOnClickEditLink : function(clickedEl) {
2506+                       var activeEdit,
2507+                       matchedSection = /#(.*)$/.exec(clickedEl.href);
2508+                       if ( matchedSection && matchedSection[1] ) {
2509+                               activeEdit = document.getElementById(matchedSection[1]);
2510+                               if ( activeEdit ) {
2511+                                       if ( -1 != activeEdit.className.indexOf('menu-item-edit-inactive') ) {
2512+                                               activeEdit.className = activeEdit.className.replace('menu-item-edit-inactive', 'menu-item-edit-active');
2513+                                       } else {
2514+                                               activeEdit.className = activeEdit.className.replace('menu-item-edit-active', 'menu-item-edit-inactive');
2515+                                       }
2516+                                       return false;
2517+                               }
2518+                       }
2519+               },
2520               
2521-               add_custom_link : function( link_name, link_url ) {
2522-                       var params = {
2523-                               action: 'save-custom-link',
2524-                               link_name: link_name,
2525-                               link_url: link_url
2526+               eventOnClickMenuDelete : function(clickedEl) {
2527+                       // Delete warning AYS
2528+                       if ( confirm( navMenuL10n.warnDeleteMenu ) ) {
2529+                               return true;
2530+                       } else {
2531+                               return false;
2532                        }
2533-                       
2534-                       $.post( ajaxurl, params, function(link_id) {
2535-                               if ( '-1' == link_id )
2536-                                       return;
2537+               },
2538 
2539-                               wpNavMenu.add_to_menu( link_id, link_id, 'custom', 'custom', navMenuL10n.custom, 0, link_name, link_url, '', '', '', '', '' );
2540-                       }, 'json');
2541+               eventOnClickMenuItemDelete : function(clickedEl) {
2542+                       var itemID,
2543+                       matchedSection,
2544+                       that = this;
2545+
2546+                       // Delete warning AYS
2547+                       if ( confirm( navMenuL10n.warnDeleteMenuItem ) ) {
2548+                               matchedSection = /_wpnonce=([a-zA-Z0-9]*)$/.exec(clickedEl.href);
2549+                               if ( matchedSection && matchedSection[1] ) {
2550+                                       itemID = parseInt(clickedEl.id.replace('delete-', ''), 10);     
2551+                                       $.post(
2552+                                               ajaxurl,
2553+                                               {
2554+                                                       action:'delete-menu-item',
2555+                                                       'menu-item':itemID,
2556+                                                       '_wpnonce':matchedSection[1]
2557+                                               },
2558+                                               function (resp) {
2559+                                                       if ( '1' == resp )
2560+                                                               that.removeMenuItem(document.getElementById('menu-item-' + itemID));
2561+                                               }
2562+                                       );
2563+                                       return false;   
2564+                               }
2565+                               return true;
2566+                       } else {
2567+                               return false;
2568+                       }
2569                },
2570-               
2571+
2572                /**
2573-                * In combination with the php function wp_initial_nav_menu_meta_boxes(),
2574-                * this function limits the metaboxes for first time users to just links, pages and cats.
2575+                * Callback for the drag over action when dragging a list item.
2576+                *
2577+                * @param object draggedEl The DOM element being dragged
2578+                * @param object dropEl The DOM element on top of which we're dropping.
2579                 */
2580-               initial_meta_boxes : function() {
2581-                       var hidden = $('#hidden-metaboxes').val().split( ',' );
2582+               eventOnDragOver : function(draggedEl, dropEl) {
2583+                       activeHovering = true;
2584+                       currentDropzone = dropEl;
2585+                       dropEl.className += ' sortable-placeholder';
2586+               },
2587 
2588-                       if ( '' != hidden ) {
2589-                               for ( var i = 0; i < hidden.length; i++ ) {
2590-                                       $( '#' + hidden[i] ).attr( 'style', 'display: none;' );
2591-                                       $( '#' + hidden[i] + '-hide' ).attr( 'checked', false );
2592-                               };
2593-                       };
2594+               /**
2595+                * Callback for the drag out action when dragging a list item.
2596+                *
2597+                * @param object draggedEl The DOM element being dragged
2598+                * @param object dropEl The DOM element on top of which we're dropping.
2599+                */
2600+               eventOnDragOut : function(draggedEl, dropEl) {
2601+                       activeHovering = false;
2602+
2603+                       /* delay the disappearance of the droppable area so it doesn't flicker in and out */
2604+                       (function(that) {
2605+                               setTimeout(function() {
2606+                                       if ( that != currentDropzone || ( ! activeHovering && that.className && -1 != that.className.indexOf('sortable-placeholder') ) ) {
2607+                                               that.className = that.className.replace(/sortable-placeholder/g, '');
2608+                                       }
2609+                               }, 500);
2610+                       })(dropEl);
2611                },
2612-               
2613-               // Makes the menu items drag and droppable.
2614-               drag_and_drop : function() {
2615-                       // Make sure all li's have dropzones
2616-                       $('.menu li').each(function(){
2617-                               if ( !$(this).children('.dropzone').attr('class') ) {
2618-                                       $(this).prepend('<div class="dropzone"></div>');
2619-                               };
2620-                       });
2621 
2622-                       // make menu item draggable
2623-                       $('.menu li').draggable({
2624-                               handle: ' > dl',
2625-                               opacity: .8,
2626-                               addClasses: false,
2627-                               helper: 'clone',
2628-                               zIndex: 100
2629-                       });
2630+               /**
2631+                * Callback for the drop action when dragging and dropping a list item.
2632+                *
2633+                * @param object draggedEl The DOM element being dragged (and now dropped)
2634+                * @param object dropEl The DOM element on top of which we're dropping.
2635+                */
2636+               eventOnDrop : function(draggedEl, dropEl) {
2637+                       var dropIntoSublist = !! ( -1 == dropEl.className.indexOf('dropzone') ),
2638+                       subLists = dropEl.parentNode.getElementsByTagName('ul'),
2639+                       hasSublist = false,
2640+                       i = subLists.length,
2641+                       subList;
2642 
2643-                       // make menu item droppable
2644-                       $('.menu li dl, .menu li .dropzone').droppable({
2645-                               accept: '.menu li',
2646-                               tolerance: 'pointer',
2647-                               drop: function(e, ui) {
2648-                                       var li = $(this).parent();
2649-                                       var child = !$(this).hasClass('dropzone');
2650+                       activeHovering = false;
2651+                       
2652+                       dropEl.className = dropEl.className.replace(/sortable-placeholder/g, '');
2653 
2654-                                       var parent_id = li.children('input[name=menu-item-object-id[]]').val();
2655-                                       var child_id = ui.draggable.children('input[name=menu-item-object-id[]]').val();
2656-
2657-                                       // An item cannot be a child of itself. Use a custom link for the effect.
2658-                                       if ( parent_id == child_id ) {
2659-                                               ui.draggable.find('dt').animate( { backgroundColor: '#FF3333' }, { duration: 'normal', complete: function() { $(this).css( 'backgroundColor', '' ) } } );
2660-                                               $(this).parent().find('dt').removeAttr('style');
2661-                                               return;
2662-                                       };
2663-
2664-                                       // Append UL to first child
2665-                                       if ( child && li.children('ul').length == 0 ) {
2666-                                               li.append( '<ul class="sub-menu" />' );
2667+                       if ( dropIntoSublist ) {
2668+                               while ( i-- ) {
2669+                                       if ( subLists[i] && 1 != subLists[i].className.indexOf('sub-menu') ) {
2670+                                               hasSublist = true;
2671+                                               subList = subLists[i];
2672                                        }
2673-                                       // Make it draggable
2674-                                       if ( child ) {
2675-                                               li.children('ul').append( ui.draggable );
2676-                                       } else {
2677-                                               li.before( ui.draggable );
2678-                                       }
2679+                               }
2680 
2681-                                       li.find('dl,.dropzone').css({ backgroundColor: '', borderColor: '' });
2682+                               if ( ! hasSublist ) {
2683+                                       subList = document.createElement('ul');
2684+                                       subList.className = 'sub-menu';
2685+                                       dropEl.parentNode.appendChild(subList);
2686+                               }
2687 
2688-                                       var draggablevalue = ui.draggable.attr('value');
2689-                                       var droppablevalue = li.attr('value');
2690+                               subList.appendChild(draggedEl);
2691+                       } else {
2692+                               dropEl.parentNode.parentNode.insertBefore(draggedEl, dropEl.parentNode);
2693+                       }
2694 
2695-                                       li.find('#menu-' + draggablevalue).find('#parent' + draggablevalue).val(droppablevalue);
2696-                                       $(this).parent().find('dt').removeAttr('style');
2697-                                       $(this).parent().find('div:first').removeAttr('style');
2698+                       this.recalculateSortOrder(menuList);
2699 
2700-                               },
2701-                               over: function(e) {
2702-                               // Add child
2703-                                       if ( $(this).attr('class') == 'dropzone ui-droppable' ) {
2704-                                       $(this).parent().find('div:first').css({ background: '#f5f5f5', border: '1px dashed #bbb', margin: '10px 0px', height: '40px' });
2705-                               }
2706-                                       // Add above
2707-                               else if ( $(this).attr('class') == 'ui-droppable' ) {
2708-                                               $(this).parent().find('dt:first').css('background', '#d8d8d8');
2709-                               } else {
2710-                                               // Do nothing
2711-                               }
2712-                       },
2713-                           out: function() {
2714-                               $(this).parent().find('dt').removeAttr('style');
2715-                               $(this).parent().find('div:first').removeAttr('style');
2716-                               $(this).filter('.dropzone').css({ borderColor: '' });
2717-                       }
2718-                       });
2719+                       getParentMenuItemDBId.call(draggedEl);
2720                },
2721-       
2722-               // Prepares menu items for POST.
2723-               update_post_data : function() {
2724-                       var i = 0; // counter
2725 
2726-                       $('.menu li').each(function(){
2727-                               i = i + 1; // the menu order for each item
2728+               /**
2729+                * Callback for the meta form submit action listener.
2730+                *
2731+                * @param object thisForm The submitted form.
2732+                * @param object e The event object.
2733+                */
2734+               eventSubmitMetaForm : function(thisForm, e) {
2735+                       var inputs = thisForm.getElementsByTagName('input'),
2736+                       i = inputs.length,
2737+                       j,
2738+                       listItemData,
2739+                       listItemDBID,
2740+                       listItemDBIDMatch,
2741+                       params = {},
2742+                       processMethod = function(){},
2743+                       re = new RegExp('menu-item\\[(\[^\\]\]*)');
2744 
2745-                               var j = $(this).attr('value'); // reference to the current menu item (e.g. li#menu-item + j)
2746+                       thisForm.className = thisForm.className + ' processing',
2747+                       that = this;
2748 
2749-                               // Grab the menu item id
2750-                               var id = $(this).children('input[name=menu-item-db-id[]]').val();
2751+                       params['action'] = '';
2752 
2753-                               // Update the li value to equal the menu order
2754-                               $(this).attr('value', i);
2755+                       while ( i-- ) {
2756+                               if (    // we're submitting a checked item
2757+                                       inputs[i].name &&
2758+                                       -1 != inputs[i].name.indexOf('menu-item-object-id') &&
2759+                                       inputs[i].checked ||
2760+                                       ( // or we're dealing with a custom link
2761+                                               'undefined' != typeof inputs[i].id &&
2762+                                               'custom-menu-item-url' == inputs[i].id &&
2763+                                               '' != inputs[i].value &&
2764+                                               'http://' != inputs[i].value
2765+                                       )
2766+                               ) {
2767+                                       params['action'] = 'add-menu-item';
2768+                                       processMethod = that.processAddMenuItemResponse;
2769 
2770-                               // Update the position
2771-                               $(this).children('input[name=menu-item-position[]]').attr( 'value', i );
2772+                                       listItemDBIDMatch = re.exec(inputs[i].name);
2773+                                       listItemDBID = 'undefined' == typeof listItemDBIDMatch[1] ? 0 : parseInt(listItemDBIDMatch[1], 10);
2774+                                       listItemData = getListDataFromID(listItemDBID);
2775+                                       
2776+                                       for ( j in listItemData ) {
2777+                                               params['menu-item[' + listItemDBID + '][' + j + ']'] = listItemData[j];
2778+                                       }
2779 
2780-                               // Update the parent id
2781-                               var pid = $(this).parent('.sub-menu').siblings('input[name=menu-item-object-id[]]').val();
2782-                               
2783-                               if ( undefined == pid ) {
2784-                                       pid = 0;
2785-                               };
2786+                                       inputs[i].checked = false;
2787 
2788-                               $(this).children('input[name=menu-item-parent-id[]]').attr( 'value', pid );
2789+                               // we're submitting a search term
2790+                               } else if (
2791+                                       '' == params['action'] && // give precedence to adding items
2792+                                       '' != inputs[i].value &&
2793+                                       inputs[i].className &&
2794+                                       -1 != inputs[i].className.search(/quick-search\b[^-]/)
2795+                               ) {
2796+                                       params['action'] = 'menu-quick-search';
2797+                                       params['q'] = inputs[i].value;
2798+                                       params['response-format'] = 'markup';
2799+                                       params['type'] = inputs[i].name;
2800+                                       processMethod = that.processQuickSearchQueryResponse;
2801+                               }
2802+                       }
2803+                       params['menu'] = thisForm.elements['menu'].value;
2804+                       params['menu-settings-column-nonce'] = thisForm.elements['menu-settings-column-nonce'].value;
2805 
2806-                               // Update the menu item count
2807-                               $('#li-count').attr( 'value', i );
2808+                       $.post( ajaxurl, params, function(menuMarkup) {
2809+                               processMethod.call(that, menuMarkup, params);   
2810+                               thisForm.className = thisForm.className.replace(/processing/g, '');
2811                        });
2812+
2813+                       return false;
2814                },
2815-               
2816-               /**
2817-                * Enables autocomplete for nav menu types.
2818-                *
2819-                * @param int id - the id of the menu item type.
2820-                */
2821-               autocomplete : function( id ) {
2822-                       $('#add-'+ id +' .quick-search').autocomplete( $( '#add-'+ id +' .autocomplete' ).val().split('|') );
2823 
2824-                       $('#add-'+ id +' .quick-search').result(function( event, data, formatted ) {
2825-                               $('#add-'+ id +' .list-wrap').css( 'display', 'block' );
2826-                               $("#add-"+ id +" .list-wrap li:contains('" + data + "')").css( 'display', 'block' );
2827-                               $('#add-'+ id +' .show-all').hide();
2828-                               $('#add-'+ id +' .hide-all').show();
2829+               makeListItemDraggable : function(el) {
2830+                       // make menu item draggable
2831+                       $(el).draggable({
2832+                               handle: ' > dl',
2833+                               opacity: .8,
2834+                               addClasses: false,
2835+                               helper: 'clone',
2836+                               zIndex: 100
2837                        });
2838                },
2839-               
2840+
2841                /**
2842-                * Populate the thickbox window with the selected menu items
2843-                *
2844-                * @param int id - the id of the menu item to edit.
2845+                * Add the child element that acts as the dropzone for drag-n-drop.
2846+                *
2847+                * @param object el The parent object to which we'll prepend the dropzone.
2848+                * @return object The dropzone DOM element.
2849                 */
2850-               edit_menu_item : function( id ) {
2851-                       var item_type = $('#menu-item-' + id).children('input[name=menu-item-type[]]').val();
2852-                       var item_title = $('#menu-item-' + id).children('input[name=menu-item-title[]]').val();
2853-                       var item_link = $('#menu-item-' + id).children('input[name=menu-item-url[]]').val();
2854-                       var item_attr_title = $('#menu-item-' + id).children('input[name=menu-item-attr-title[]]').val();
2855-                       var item_target = $('#menu-item-' + id).children('input[name=menu-item-target[]]').val();
2856-                       var item_description = $('#menu-item-' + id).children('input[name=menu-item-description[]]').val();
2857-                       var item_classes = $('#menu-item-' + id).children('input[name=menu-item-classes[]]').val();
2858-                       var item_xfn = $('#menu-item-' + id).children('input[name=menu-item-xfn[]]').val();
2859+               makeListItemDropzone : function(el) {
2860+                       if ( ! el )
2861+                               return false;
2862+                       var divs = el.getElementsByTagName('div'),
2863+                       i = divs.length,
2864+                       dropZone = document.createElement('div');
2865 
2866-                       // Only allow custom links to be editable.
2867-                       if ( 'custom' != item_type )
2868-                               $( '#edit-menu-item-url' ).attr('disabled', 'disabled' );
2869+                       while( i-- ) {
2870+                               if ( divs[i].className && -1 != divs[i].className.indexOf('dropzone') && ( el == divs[i].parentNode ) )
2871+                                       return divs[i];
2872+                       }
2873 
2874-                       // Populate the fields for thickbox
2875-                       $( '#edit-menu-item-id' ).val(id);
2876-                       $( '#edit-menu-item-title' ).val(item_title);
2877-                       $( '#edit-menu-item-url' ).val(item_link);
2878-                       $( '#edit-menu-item-attr-title' ).val(item_attr_title);
2879-                       $( '#edit-menu-item-target' ).val(item_target);
2880-                       $( "#edit-menu-item-target option[value='" + item_target  + "']" ).attr('selected', 'selected');
2881-                       $( '#edit-menu-item-description' ).val(item_description);
2882-                       $( '#edit-menu-item-classes' ).val(item_classes);
2883-                       $( '#edit-menu-item-xfn' ).val(item_xfn);
2884+                       dropZone.className = 'dropzone';
2885+                       el.insertBefore(dropZone, el.firstChild);
2886+                       return dropZone;
2887+               },
2888 
2889-                       // @todo: focus on #edit-menu-item-title
2890-               },
2891-               
2892                /**
2893-                * Update the values for the menu item being editing
2894+                * Process the add menu item request response into menu list item.
2895+                *
2896+                * @param string menuMarkup The text server response of menu item markup.
2897+                * @param object req The request arguments.
2898                 */
2899-               update_menu_item : function() {
2900-                       var id = $('#edit-menu-item-id').val();
2901-                       var item_title = $('#edit-menu-item-title').val();
2902-                       var item_link = $('#edit-menu-item-url').val();
2903-                       var item_attr_title = $('#edit-menu-item-attr-title').val();
2904-                       var item_target = $('#edit-menu-item-target').val();
2905-                       var item_description = $('#edit-menu-item-description').val();
2906-                       var item_classes = $('#edit-menu-item-classes').val();
2907-                       var item_xfn = $('#edit-menu-item-xfn').val();
2908+               processAddMenuItemResponse : function( menuMarkup, req ) {
2909+                       if ( ! req )
2910+                               req = {};
2911+                       var dropZone,
2912+                       i,
2913+                       listElements,
2914+                       wrap = document.createElement('ul');
2915 
2916-                       // update menu item settings
2917-                       $('.menu #menu-item-' + id).find('span.item-title:first').html(item_title);
2918+                       wrap.innerHTML = menuMarkup;
2919+                       listElements = wrap.getElementsByTagName('li');
2920+                       i = listElements.length;
2921+                       while ( i-- ) {
2922+                               this.setupListItemDragAndDrop(listElements[i]);
2923+                               menuList.appendChild(listElements[i]);
2924+                       }
2925 
2926-                       $('#menu-item-' + id).children('input[name=menu-item-title[]]').val(item_title);
2927-                       $('#menu-item-' + id).children('input[name=menu-item-url[]]').val(item_link);
2928-                       $('#menu-item-' + id).children('input[name=menu-item-attr-title[]]').val(item_attr_title);
2929-                       $('#menu-item-' + id).children('input[name=menu-item-target[]]').val(item_target);
2930-                       $('#menu-item-' + id).children('input[name=menu-item-description[]]').val(item_description);
2931-                       $('#menu-item-' + id).children('input[name=menu-item-classes[]]').val(item_classes);
2932-                       $('#menu-item-' + id).children('input[name=menu-item-xfn[]]').val(item_xfn);
2933+                       /* set custom link form back to defaults */
2934+                       if ( customLinkNameInput && customLinkURLInput ) {
2935+                               customLinkNameInput.value = customLinkNameDefault;
2936+                               customLinkURLInput.value = customLinkURLDefault;
2937+                       }
2938+               },
2939 
2940-                       $('.menu #menu-item-' + id + ' dt:first').animate( { backgroundColor: '#FFFF33' }, { duration: 'normal', complete: function() { $(this).css( 'backgroundColor', '' ); }});
2941-               },
2942-               
2943                /**
2944-                * Removes a menu item from current menu
2945-                *
2946-                * @param int id - the id of the menu item to remove.
2947+                * Process the quick search response into a search result
2948+                *
2949+                * @param string resp The server response to the query.
2950+                * @param object req The request arguments.
2951                 */
2952-               remove_menu_item : function( id ) {
2953-                       var todelete = $('#menu-item-' + id);
2954+               processQuickSearchQueryResponse : function(resp, req) {
2955+                       if ( ! req )
2956+                               req = {};
2957+                       var wrap = document.createElement('ul'),
2958+                       form = document.getElementById('nav-menu-meta'),
2959+                       i,
2960+                       items,
2961+                       matched,
2962+                       newID,
2963+                       pattern = new RegExp('menu-item\\[(\[^\\]\]*)'),
2964+                       resultList;
2965 
2966-                       if ( todelete ) {
2967-                               // Give some feedback to the user
2968-                               $( todelete ).find('dt').each(function(){
2969-                                       $(this).animate( { backgroundColor: '#FF3333' }, { duration: 'normal', complete: function() { $(this).parent().parent().remove() } } );
2970-                               });
2971+                       // make a unique DB ID number
2972+                       matched = pattern.exec(resp);
2973+                       if ( matched && matched[1] ) {
2974+                               newID = matched[1];
2975+                               while( form.elements['menu-item[' + newID + '][menu-item-type]'] ) {
2976+                                       newID--;
2977+                               }
2978+
2979+                               if ( newID != matched[1] ) {
2980+                                       resp = resp.replace(new RegExp('menu-item\\[' + matched[1] + '\\]', 'g'), 'menu-item[' + newID + ']');
2981+                               }
2982                        }
2983-               },
2984-               
2985-               /**
2986-                * Adds the item to the menu
2987-                *
2988-                * @param string item_db_id - The menu item's db id.
2989-                * @param string item_object_id - The menu item's object id.
2990-                * @param string item_object - The menu item's object name.
2991-                * @param string item_type - The menu item's object type.
2992-                * @param string item_append - The menu item's nice name.
2993-                * @param string item_parent_id - The menu item's parent id.
2994-                * @param string item_title - The menu item title.
2995-                * @param string item_url - The menu item url
2996-                * @param string item_description - The menu item description.
2997-                * @param string item_attr_title - The title attribute.
2998-                * @param string item_target - The target attribute.
2999-                * @param string item_classes - Optional. Additional CSS classes for the menu item
3000-                * @param string item_xfn - Optional. The rel attribute.
3001-                */
3002-               add_to_menu : function( item_db_id, item_object_id, item_object, item_type, item_append, item_parent_id, item_title, item_url, item_description, item_attr_title, item_target, item_classes, item_xfn ) {
3003-                       var randomnumber = $('.menu li').length + 1;
3004-                       var hidden = wpNavMenu.get_hidden_inputs( randomnumber, item_db_id, item_object_id, item_object, item_type, item_parent_id, item_title, item_url, item_description, item_attr_title, item_target, item_classes, item_xfn );
3005+
3006+                       wrap.innerHTML = resp;
3007                       
3008-                       // Adds the item to the menu
3009-                       $('.menu').append('<li id="menu-item-' + randomnumber + '" value="' + randomnumber + '"><div class="dropzone ui-droppable"></div><dl class="ui-droppable"><dt><span class="item-title">' + item_title + '</span><span class="item-controls"><span class="item-type">' + item_append + '</span><a class="item-edit thickbox" id="edit' + randomnumber + '" value="' + randomnumber +'" onclick="wpNavMenu.edit_menu_item('+ randomnumber +');" title="' + navMenuL10n.thickbox + '" href="#TB_inline?height=540&width=300&inlineId=menu-item-settings">' + navMenuL10n.edit + '</a> | <a class="item-delete" id="delete' + randomnumber + '" value="' + randomnumber +'" onclick="wpNavMenu.remove_menu_item('+ randomnumber +');">Delete</a></span></dt></dl>' + hidden + '</li>');
3010+                       items = wrap.getElementsByTagName('li');
3011 
3012-                       // Give some feedback to the user
3013-                       $( '.menu #menu-item-' + randomnumber + ' dt:first' ).animate( { backgroundColor: '#FFFF33' }, { duration: 'normal', complete: function() { $(this).css( 'backgroundColor', '' ); }});
3014+                       if ( items[0] && req.object_type ) {
3015+                               resultList = document.getElementById(req.object_type + '-search-checklist');
3016+                               if ( resultList ) {
3017+                                       resultList.appendChild(items[0]);
3018+                               }
3019+                       } else if ( req.type ) {
3020+                               matched = /quick-search-posttype-([a-zA-Z_-]*)/.exec(req.type);
3021+                               if ( matched && matched[1] ) {
3022+                                       resultList = document.getElementById(matched[1] + '-search-checklist');
3023+                                       if ( resultList ) {
3024+                                               i = items.length;
3025+                                               while( i-- ) {
3026+                                                       resultList.appendChild(items[i]);
3027+                                               }
3028+                                       }
3029+                               }
3030+                       }
3031+               },
3032 
3033-                       // Enable drag-n-drop
3034-                       wpNavMenu.drag_and_drop();
3035+               recalculateSortOrder : function(parentEl) {
3036+                       var allInputs = parentEl.getElementsByTagName('input'),
3037+                       i,
3038+                       j = 0;
3039 
3040-                       // Reload thickbox
3041-                       tb_init('a.thickbox, area.thickbox, input.thickbox');
3042+                       for( i = 0; i < allInputs.length; i++ ) {
3043+                               if ( allInputs[i].name && -1 != allInputs[i].name.indexOf('menu-item-position') ) {
3044+                                       allInputs[i].value = ++j;
3045+                               }
3046+                       }
3047                },
3048-               
3049-               /**
3050-                * Grabs items from the queue and adds them to the menu.
3051-                *
3052-                * @param string button - a reference to the button that was clicked
3053-                */
3054-               add_checked_items_to_menu : function( button ) {
3055-                       // Grab checked items
3056-                       var items = $(button).parent().siblings('.list-wrap').find(':checked');
3057 
3058-                       // If nothing was checked, cancel
3059-                       if ( 0 == items.length )
3060+               removeMenuItem : function(el) {
3061+                       if ( ! el )
3062                                return false;
3063 
3064-                       // Loop through each item, grab it's hidden data and add it to the menu.
3065-                       $(items).each(function(){
3066-                               var item_type = $(this).parent().siblings('.menu-item-type').val();
3067+                       var subMenus = el.getElementsByTagName('ul'),
3068+                       subs,
3069+                       i;
3070 
3071-                               if ( 'custom' == item_type ) {
3072-                                       var item_attr_title = $(this).parent().siblings('.menu-item-attr-title').val();
3073-                                       var item_target = $(this).parent().siblings('.menu-item-target').val();
3074-                                       var item_classes = $(this).parent().siblings('.menu-item-classes').val();
3075-                                       var item_xfn = $(this).parent().siblings('.menu-item-xfn').val();
3076-                               } else {
3077-                                       var item_attr_title = '';
3078-                                       var item_target = '';
3079-                                       var item_classes = '';
3080-                                       var item_xfn = '';
3081-                               };
3082+                       if ( subMenus[0] ) {
3083+                               subs = subMenus[0].getElementsByTagName('li');
3084+                               for ( i = 0; i < subs.length; i++ ) {
3085+                                       if ( subs[i].id && -1 != subs[i].id.indexOf('menu-item-') && subs[i].parentNode == subMenus[0] ) {
3086+                                               el.parentNode.insertBefore(subs[i], el);
3087+                                       }
3088+                               }
3089+                       }
3090 
3091-                               var item_db_id = $(this).parent().siblings('.menu-item-db-id').val();
3092-                               var item_object_id = $(this).parent().siblings('.menu-item-object-id').val();
3093-                               var item_object = $(this).parent().siblings('.menu-item-object').val();
3094-                               var item_append = $(this).parent().siblings('.menu-item-append').val();
3095-                               var item_parent_id = $(this).parent().siblings('.menu-item-parent-id').val();
3096-                               var item_title = $(this).parent().siblings('.menu-item-title').val();
3097-                               var item_url = $(this).parent().siblings('.menu-item-url').val();
3098-                               var item_description = $(this).parent().siblings('.menu-item-description').val();
3099-
3100-                               if ( undefined == item_description ) {
3101-                                       item_description = '';
3102-                               };
3103-
3104-                               if ( undefined == item_attr_title ) {
3105-                                       item_attr_title = '';
3106-                               };
3107-
3108-                               // Add the menu item to the menu
3109-                               wpNavMenu.add_to_menu( item_db_id, item_object_id, item_object, item_type, item_append, item_parent_id, item_title, item_url, item_description, item_attr_title, item_target, item_classes, item_xfn );
3110-
3111-                               // uncheck the menu item in the list
3112-                               $(this).attr( 'checked', false );
3113+                       el.className += ' deleting';
3114+                       $(el).fadeOut( 350 , function() {
3115+                               this.parentNode.removeChild(this);     
3116                        });
3117-               },
3118-               
3119-               /**
3120-                * Returns all the nessecary hidden inputs for each menu item.
3121-                *
3122-                * @param string item_db_id - The menu item's db id.
3123-                * @param string item_object_id - The menu item's object id.
3124-                * @param string item_object - The menu item's object name.
3125-                * @param string item_type - The menu item's object type.
3126-                * @param string item_append - The menu item's nice name.
3127-                * @param string item_parent_id - The menu item's parent id.
3128-                * @param string item_title - The menu item title.
3129-                * @param string item_url - The menu item url
3130-                * @param string item_description - The menu item description.
3131-                * @param string item_attr_title - The title attribute.
3132-                * @param string item_target - The target attribute.
3133-                * @param string item_classes - Optional. Additional CSS classes for the menu item
3134-                * @param string item_xfn - Optional. The rel attribute.
3135-                */
3136-               get_hidden_inputs : function( randomnumber, item_db_id, item_object_id, item_object, item_type, item_parent_id, item_title, item_url, item_description, item_attr_title, item_target, item_classes, item_xfn ) {
3137-                       var hidden = '';
3138+                       
3139+                       this.recalculateSortOrder(menuList);
3140+               }
3141+       }
3142+}
3143 
3144-                       hidden += '<input type="hidden" name="menu-item-db-id[]" value="' + item_db_id + '" />';
3145-                       hidden += '<input type="hidden" name="menu-item-object-id[]" value="' + item_object_id + '" />';
3146-                       hidden += '<input type="hidden" name="menu-item-object[]" value="' + item_object + '" />';
3147-                       hidden += '<input type="hidden" name="menu-item-type[]" value="' + item_type + '" />';
3148-                       hidden += '<input type="hidden" name="menu-item-parent-id[]" value="' + item_parent_id + '" />';
3149-                       hidden += '<input type="hidden" name="menu-item-position[]" value="' + randomnumber + '" />';
3150-                       hidden += '<input type="hidden" name="menu-item-title[]" value="' + item_title + '" />';
3151-                       hidden += '<input type="hidden" name="menu-item-attr-title[]" value="' + item_attr_title + '" />';
3152-                       hidden += '<input type="hidden" name="menu-item-url[]" value="' + item_url + '" />';
3153-                       hidden += '<input type="hidden" name="menu-item-target[]" value="' + item_target + '" />';
3154-                       hidden += '<input type="hidden" name="menu-item-description[]" value="' + item_description + '" />';
3155-                       hidden += '<input type="hidden" name="menu-item-classes[]" value="' + item_classes + '" />';
3156-                       hidden += '<input type="hidden" name="menu-item-xfn[]" value="' + item_xfn + '" />';
3157+var wpNavMenu = new WPNavMenuHandler();
3158 
3159-                       return hidden;
3160-               }
3161-       }
3162-       
3163-       $(document).ready(function($){ wpNavMenu.init(); });
3164-})(jQuery);
3165\ No newline at end of file
3166+jQuery(function() {
3167+       wpNavMenu.init();
3168+});
3169Index: wp-admin/nav-menus.php
3170===================================================================
3171--- wp-admin/nav-menus.php      (revision 14247)
3172+++ wp-admin/nav-menus.php      (working copy)
3173@@ -10,7 +10,7 @@
3174  */
3175 
3176 /** Load WordPress Administration Bootstrap */
3177-require_once( './admin.php' );
3178+require_once( 'admin.php' );
3179 
3180 // Load all the nav menu interface functions
3181 require_once( ABSPATH . 'wp-admin/includes/nav-menu.php' );
3182@@ -37,9 +37,6 @@
3183 wp_enqueue_script( 'wp-lists' );
3184 wp_enqueue_script( 'postbox' );
3185 
3186-// Thickbox
3187-add_thickbox();
3188-
3189 // Container for any messages displayed to the user
3190 $messages_div = '';
3191 
3192@@ -53,10 +50,133 @@
3193 $action = isset( $_REQUEST['action'] ) ? $_REQUEST['action'] : 'edit';
3194 
3195 switch ( $action ) {
3196+       case 'add-menu-item':
3197+               if ( current_user_can( 'switch_themes' ) ) {
3198+                       check_admin_referer( 'add-menu_item', 'menu-settings-column-nonce' );
3199+                       if ( isset( $_REQUEST['menu-item'] ) ) {
3200+                               wp_save_nav_menu_item( $nav_menu_selected_id, $_REQUEST['menu-item'] );
3201+                       }
3202+               }
3203+               break;
3204+       case 'move-down-menu-item' :
3205+               // moving down a menu item is the same as moving up the next in order
3206+               check_admin_referer( 'move-menu_item' );
3207+               $menu_item_id = (int) $_REQUEST['menu-item'];
3208+               $next_item_id = 0;
3209+               if ( 'nav_menu_item' == get_post_type( $menu_item_id ) ) {
3210+                       $menus = isset( $_REQUEST['menu'] ) ? array( (int) $_REQUEST['menu'] ) : wp_get_object_terms( $menu_item_id, 'nav_menu', array( 'fields' => 'ids' ) );
3211+                       if ( ! is_wp_error( $menus ) ) {
3212+                               foreach( (array) $menus as $menu_id ) {
3213+                                       $move_down_ordered_menu_items = (array) wp_get_nav_menu_items( $menu_id );
3214+                                       while ( $next = array_shift( $move_down_ordered_menu_items ) ) {
3215+                                               if ( isset( $next->ID ) && $next->ID == $menu_item_id ) {
3216+                                                       break;
3217+                                               }
3218+                                       }
3219+
3220+                                       if ( $following = array_shift( $move_down_ordered_menu_items ) ) {
3221+                                               $next_item_id = (int) $following->ID;
3222+                                       }
3223+                               }
3224+                       }
3225+               }
3226+               // fall through to next case
3227+       case 'move-up-menu-item' :
3228+               check_admin_referer( 'move-menu_item' );
3229+               $menu_item_id = empty( $next_item_id ) ? (int) $_REQUEST['menu-item'] : $next_item_id;
3230+               if ( 'nav_menu_item' == get_post_type( $menu_item_id ) ) {
3231+                       $menus = isset( $_REQUEST['menu'] ) ? array( (int) $_REQUEST['menu'] ) : wp_get_object_terms( $menu_item_id, 'nav_menu', array( 'fields' => 'ids' ) );
3232+                       if ( ! is_wp_error( $menus ) ) {
3233+                               foreach( (array) $menus as $menu_id ) {
3234+                                       $ordered_menu_items = wp_get_nav_menu_items( $menu_id );
3235+                                       $menu_item_data = get_post( $menu_item_id , ARRAY_A );
3236+
3237+                                       // setup the data we need in one pass through the array of menu items
3238+                                       $dbids_to_orders = array();
3239+                                       $orders_to_dbids = array();
3240+                                       $objectids_to_dbids = array();
3241+                                       $dbids_to_objectids = array();
3242+                                       foreach( (array) $ordered_menu_items as $ordered_menu_item_object ) {
3243+                                               if ( isset( $ordered_menu_item_object->ID ) ) {
3244+                                                       if ( isset( $ordered_menu_item_object->menu_order ) ) {
3245+                                                               $dbids_to_orders[$ordered_menu_item_object->ID] = $ordered_menu_item_object->menu_order;
3246+                                                               $orders_to_dbids[$ordered_menu_item_object->menu_order] = $ordered_menu_item_object->ID;
3247+                                                       }
3248+
3249+                                                       $possible_object_id = (int) get_post_meta( $ordered_menu_item_object->ID, '_menu_item_object_id', true );
3250+                                                       if ( ! empty( $possible_object_id ) ) {
3251+                                                               $dbids_to_objectids[$ordered_menu_item_object->ID] = $possible_object_id;
3252+                                                               $objectids_to_dbids[$possible_object_id] = $ordered_menu_item_object->ID;
3253+                                                       }
3254+                                               }
3255+                                       }
3256+
3257+
3258+                                       // if this menu item is not first
3259+                                       if ( ! empty( $dbids_to_orders[$menu_item_id] ) && ! empty( $orders_to_dbids[$dbids_to_orders[$menu_item_id] - 1] ) ) {
3260+                                               
3261+                                               // if this menu item is a child of the previous
3262+                                               if (
3263+                                                       ! empty( $menu_item_data['post_parent'] ) &&
3264+                                                       isset( $objectids_to_dbids[$menu_item_data['post_parent']] ) &&
3265+                                                       isset( $orders_to_dbids[$dbids_to_orders[$menu_item_id] - 1] ) &&
3266+                                                       ( $objectids_to_dbids[$menu_item_data['post_parent']] == $orders_to_dbids[$dbids_to_orders[$menu_item_id] - 1] )
3267+                                               ) {
3268+
3269+                                                       $parent_db_id = $objectids_to_dbids[$menu_item_data['post_parent']];
3270+                                                       $parent_data = get_post( $parent_db_id, ARRAY_A );
3271+
3272+                                                       if ( ! is_wp_error( $parent_data ) ) {
3273+                                                               
3274+                                                               // if there is something before the parent, make menu item a child of the parent's parent
3275+                                                               if ( ! empty( $dbids_to_orders[$parent_db_id] ) && ! empty( $orders_to_dbids[$dbids_to_orders[$parent_db_id] - 1] ) ) {
3276+                                                                       $menu_item_data['post_parent'] = $parent_data['post_parent'];
3277+
3278+                                                               // else there isn't something before the parent
3279+                                                               } else {
3280+                                                                       $menu_item_data['post_parent'] = 0;
3281+                                                               }
3282+                                                               
3283+                                                               // set former parent's [menu_order] to that of menu-item's
3284+                                                               $parent_data['menu_order'] = $parent_data['menu_order'] + 1;
3285+
3286+                                                               // set menu-item's [menu_order] to that of former parent
3287+                                                               $menu_item_data['menu_order'] = $menu_item_data['menu_order'] - 1;
3288+                                                               
3289+                                                               // save changes
3290+                                                               wp_update_post($menu_item_data);
3291+                                                               wp_update_post($parent_data);
3292+                                                       }
3293+
3294+                                               // else this menu item is not a child of the previous
3295+                                               } elseif ( isset($dbids_to_objectids[$orders_to_dbids[$dbids_to_orders[$menu_item_id] - 1]] ) ) {
3296+                                                       // just make it a child of the previous; keep the order
3297+                                                       $menu_item_data['post_parent'] = (int) $dbids_to_objectids[$orders_to_dbids[$dbids_to_orders[$menu_item_id] - 1]];
3298+                                                       wp_update_post($menu_item_data);
3299+                                               }
3300+                                       }
3301+                               }
3302+                       }
3303+               }
3304+               break;
3305+
3306+       case 'delete-menu-item':
3307+               $menu_item_id = (int) $_REQUEST['menu-item'];
3308+
3309+               check_admin_referer( 'delete-menu_item_' . $menu_item_id );
3310+
3311+
3312+               if ( 'nav_menu_item' == get_post_type( $menu_item_id ) ) {
3313+                       if ( wp_delete_post( $menu_item_id, true ) ) {
3314+                               
3315+                               $messages_div = '<div id="message" class="updated"><p>' . __('The menu item has been successfully deleted.') . '</p></div>';
3316+                       }
3317+               }
3318+               break;
3319        case 'delete':
3320                check_admin_referer( 'delete-nav_menu-' . $nav_menu_selected_id );
3321 
3322-               if ( is_nav_menu($nav_menu_selected_id) ) {
3323+               if ( is_nav_menu( $nav_menu_selected_id ) ) {
3324                        $delete_nav_menu = wp_delete_nav_menu( $nav_menu_selected_id );
3325 
3326                        if ( is_wp_error($delete_nav_menu) ) {
3327@@ -70,98 +190,73 @@
3328                break;
3329 
3330        case 'update':
3331-               check_admin_referer( 'update-nav_menu' );
3332+               check_admin_referer( 'update-nav_menu', 'update-nav-menu-nonce' );
3333 
3334                // Add Menu
3335-               if ( isset($_POST['create-menu-button']) ) {
3336+               if ( 0 == $nav_menu_selected_id ) {
3337                        if ( current_theme_supports('nav-menus') || current_theme_supports('widgets') ) {
3338-                               $add_nav_menu = esc_html( $_POST['create-menu-name'] );
3339+                               $new_menu_title = esc_html( $_POST['menu-name'] );
3340 
3341-                               if ( $add_nav_menu ) {
3342-                                       $add_nav_menu = wp_create_nav_menu( $add_nav_menu );
3343+                               if ( $new_menu_title ) {
3344+                                       $_nav_menu_selected_id = wp_update_nav_menu_object( 0, array('menu-name' => $new_menu_title) );
3345 
3346-                                       if ( is_wp_error( $add_nav_menu ) ) {
3347-                                               $messages_div = '<div id="message" class="error"><p>' . $add_nav_menu->get_error_message() . '</p></div>';
3348+                                       if ( is_wp_error( $_nav_menu_selected_id ) ) {
3349+                                               $messages_div = '<div id="message" class="error"><p>' . $_nav_menu_selected_id->get_error_message() . '</p></div>';
3350                                        } else {
3351-                                               $nav_menu_selected_id = $add_nav_menu->term_id;
3352-                                               $nav_menu_selected_title = $add_nav_menu->name;
3353-                                               $messages_div = '<div id="message" class="updated"><p>' . sprintf( __('The <strong>%s</strong> menu has been successfully created.'), $add_nav_menu->name ) . '</p></div>';
3354+                                               $_menu_object = wp_get_nav_menu_object( $_nav_menu_selected_id );
3355+                                               $nav_menu_selected_id = $_nav_menu_selected_id;
3356+                                               $nav_menu_selected_title = $_menu_object->name;
3357+                                               $messages_div = '<div id="message" class="updated"><p>' . sprintf( __('The <strong>%s</strong> menu has been successfully created.'), $nav_menu_selected_title ) . '</p></div>';
3358                                        }
3359                                } else {
3360                                        $messages_div = '<div id="message" class="error"><p>' . __('Please enter a valid menu name.') . '</p></div>';
3361                                }
3362-                               unset( $add_nav_menu );
3363                        }
3364+
3365+               // update existing menu
3366                } else {
3367 
3368-                       // @todo wrap this into wp_update_nav_menu_object();
3369-                       if ( isset($_POST['menu-name']) ) {
3370-                               $old_nav_menu = get_term( $nav_menu_selected_id, 'nav_menu', ARRAY_A );
3371-                               $args = array( 'name' => $_POST['menu-name'], 'slug' => null, 'description' => $old_nav_menu['description'], 'parent' => $old_nav_menu['parent'], );
3372-                               $new_nav_menu = wp_update_term( $nav_menu_selected_id, 'nav_menu', $args );
3373+                       $_menu_object = wp_get_nav_menu_object( $nav_menu_selected_id );
3374+
3375+                       if ( ! is_wp_error( $_menu_object ) ) {
3376+                               wp_update_nav_menu_object( $nav_menu_selected_id, array( 'menu-name' => $_POST['menu-name'] ) );
3377+                               $nav_menu_selected_title = $_menu_object->name;
3378                        }
3379 
3380                        // Update menu items
3381 
3382-                       // @todo: wrap update logic into wp_update_nav_menu();
3383-                       $update_count = isset( $_POST['li-count'] ) ? (int) $_POST['li-count'] : 0;
3384-                       $update_nav_menu = is_nav_menu( $nav_menu_selected_id );
3385-
3386-                       if ( !is_wp_error($update_nav_menu) ) {
3387+                       if ( ! is_wp_error( $_menu_object ) ) {
3388                                $menu_items = wp_get_nav_menu_items( $nav_menu_selected_id, array('orderby' => 'ID', 'output' => ARRAY_A, 'output_key' => 'ID') );
3389 
3390-                               // Loop through all POST variables
3391-                               for ( $k = 0; $k < $update_count; $k++ ) {
3392+                               // Loop through all the menu items' POST variables
3393+                               foreach( (array) $_POST['menu-item-db-id'] as $_key => $k ) {
3394 
3395                                        // Menu item title can't be blank
3396-                                       if ( '' == $_POST['menu-item-title'][$k] )
3397+                                       if ( '' == $_POST['menu-item-title'][$_key] )
3398                                                continue;
3399-
3400-                                       $menu_item_db_id       = isset( $_POST['menu-item-db-id'][$k] )       ? $_POST['menu-item-db-id'][$k]       : 0;
3401-                                       $menu_item_object_id   = isset( $_POST['menu-item-object-id'][$k] )   ? $_POST['menu-item-object-id'][$k]   : 0;
3402-                                       $menu_item_object      = isset( $_POST['menu-item-object'][$k] )      ? $_POST['menu-item-object'][$k]      : '';
3403-                                       $menu_item_parent_id   = isset( $_POST['menu-item-parent-id'][$k] )   ? $_POST['menu-item-parent-id'][$k]   : 0;
3404-                                       $menu_item_position    = isset( $_POST['menu-item-position'][$k] )    ? $_POST['menu-item-position'][$k]    : 0;
3405-                                       $menu_item_type        = isset( $_POST['menu-item-type'][$k] )        ? $_POST['menu-item-type'][$k]        : 'custom';
3406-                                       $menu_item_append      = isset( $_POST['menu-item-append'][$k] )      ? $_POST['menu-item-append'][$k]      : 'custom';
3407-                                       $menu_item_title       = isset( $_POST['menu-item-title'][$k] )       ? $_POST['menu-item-title'][$k]       : '';
3408-                                       $menu_item_url         = isset( $_POST['menu-item-url'][$k] )         ? $_POST['menu-item-url'][$k]         : '';
3409-                                       $menu_item_description = isset( $_POST['menu-item-description'][$k] ) ? $_POST['menu-item-description'][$k] : '';
3410-                                       $menu_item_attr_title  = isset( $_POST['menu-item-attr-title'][$k] )  ? $_POST['menu-item-attr-title'][$k]  : '';
3411-                                       $menu_item_target      = isset( $_POST['menu-item-target'][$k] )      ? $_POST['menu-item-target'][$k]      : '';
3412-                                       $menu_item_classes     = isset( $_POST['menu-item-classes'][$k] )     ? $_POST['menu-item-classes'][$k]     : '';
3413-                                       $menu_item_xfn         = isset( $_POST['menu-item-xfn'][$k] )         ? $_POST['menu-item-xfn'][$k]         : '';
3414-
3415-                                       // Populate the menu item object
3416-                                       $post = array(
3417-                                               'post_status' => 'publish', 'post_type' => 'nav_menu_item', 'ping_status' => 0,
3418-                                               'post_author' => $user_ID, 'tax_input' => array( 'nav_menu' => $update_nav_menu->name ),
3419-                                               'post_title' => $menu_item_title, 'post_excerpt' => $menu_item_attr_title,
3420-                                               'post_parent' => $menu_item_parent_id, 'menu_order' => $menu_item_position,
3421-                                               'post_content' => $menu_item_description,
3422+       
3423+                                       $args = array(
3424+                                               'menu-item-db-id' => $_POST['menu-item-db-id'][$_key],
3425+                                               'menu-item-object-id' => $_POST['menu-item-object-id'][$_key],
3426+                                               'menu-item-object' => $_POST['menu-item-object'][$_key],
3427+                                               'menu-item-parent-id' => $_POST['menu-item-parent-id'][$_key],
3428+                                               'menu-item-position' => $_POST['menu-item-position'][$_key],
3429+                                               'menu-item-type' => $_POST['menu-item-type'][$_key],
3430+                                               'menu-item-append' => $_POST['menu-item-append'][$_key],
3431+                                               'menu-item-title' => $_POST['menu-item-title'][$_key],
3432+                                               'menu-item-url' => $_POST['menu-item-url'][$_key],
3433+                                               'menu-item-description' => $_POST['menu-item-description'][$_key],
3434+                                               'menu-item-attr-title' => $_POST['menu-item-attr-title'][$_key],
3435+                                               'menu-item-target' => $_POST['menu-item-target'][$_key],
3436+                                               'menu-item-classes' => $_POST['menu-item-classes'][$_key],
3437+                                               'menu-item-xfn' => $_POST['menu-item-xfn'][$_key],
3438                                        );
3439 
3440-                                       // New menu item
3441-                                       if ( $menu_item_db_id == 0 ) {
3442-                                               $menu_item_db_id = wp_insert_post( $post );
3443+                                       $menu_item_db_id = wp_update_nav_menu_item( $nav_menu_selected_id, ( $_POST['menu-item-db-id'][$_key] != $_key ? 0 : $_key ), $args );
3444 
3445-                                       // Update existing menu item
3446-                                       } elseif ( isset($menu_items[$menu_item_db_id]) || ( 'custom' == $menu_item_type && 0 != $menu_item_db_id ) ) {
3447-                                               $post['ID'] = $menu_item_db_id;
3448-                                               wp_update_post( $post );
3449+                                       if ( ! is_wp_error( $menu_item_db_id ) && isset( $menu_items[$menu_item_db_id] ) ) {
3450                                                unset( $menu_items[$menu_item_db_id] );
3451                                        }
3452-
3453-                                       update_post_meta( $menu_item_db_id, '_menu_item_type', sanitize_key($menu_item_type) );
3454-                                       update_post_meta( $menu_item_db_id, '_menu_item_object_id', (int) $menu_item_object_id );
3455-                                       update_post_meta( $menu_item_db_id, '_menu_item_object', sanitize_key($menu_item_object) );
3456-                                       update_post_meta( $menu_item_db_id, '_menu_item_target', sanitize_key($menu_item_target) );
3457-                                       // @todo handle sanitizing multiple classes separated by whitespace.
3458-                                       update_post_meta( $menu_item_db_id, '_menu_item_classes', sanitize_html_class($menu_item_classes) );
3459-                                       update_post_meta( $menu_item_db_id, '_menu_item_xfn', sanitize_html_class($menu_item_xfn) );
3460-
3461-                                       // @todo: only save custom link urls.
3462-                                       update_post_meta( $menu_item_db_id, '_menu_item_url', esc_url_raw($menu_item_url) );
3463                                }
3464 
3465                                // Remove menu items from the menu that weren't in $_POST
3466@@ -173,8 +268,8 @@
3467 
3468                                do_action( 'wp_update_nav_menu', $nav_menu_selected_id );
3469 
3470-                               $messages_div = '<div id="message" class="updated"><p>' . sprintf( __('The <strong>%s</strong> menu has been updated.'), $update_nav_menu->name ) . '</p></div>';
3471-                               unset( $update_nav_menu, $update_count, $menu_items );
3472+                               $messages_div = '<div id="message" class="updated"><p>' . sprintf( __('The <strong>%s</strong> menu has been updated.'), $nav_menu_selected_title ) . '</p></div>';
3473+                               unset( $menu_items );
3474                        }
3475                }
3476                break;
3477@@ -184,48 +279,40 @@
3478 $nav_menus = wp_get_nav_menus();
3479 
3480 // Get recently edited nav menu
3481-$recently_edited = get_user_option( 'nav_menu_recently_edited' );
3482+$recently_edited = (int) get_user_option( 'nav_menu_recently_edited' );
3483 
3484 // If there was no recently edited menu, and $nav_menu_selected_id is a nav menu, update recently edited menu.
3485-if ( !$recently_edited && is_nav_menu($nav_menu_selected_id) ) {
3486+if ( !$recently_edited && is_nav_menu( $nav_menu_selected_id ) ) {
3487        $recently_edited = $nav_menu_selected_id;
3488 
3489-// Else if $nav_menu_selected_id is not a menu, but $recently_edited is, grab that one.
3490-} elseif ( 0 == $nav_menu_selected_id && is_nav_menu($recently_edited) ) {
3491+// Else if $nav_menu_selected_id is not a menu and not requesting that we create a new menu, but $recently_edited is a menu, grab that one.
3492+} elseif ( 0 == $nav_menu_selected_id && ! isset( $_REQUEST['menu'] ) && is_nav_menu( $recently_edited ) ) {
3493        $nav_menu_selected_id = $recently_edited;
3494 
3495 // Else try to grab the first menu from the menus list
3496-} elseif ( 0 == $nav_menu_selected_id && ! empty($nav_menus) ) {
3497+} elseif ( 0 == $nav_menu_selected_id && ! isset( $_REQUEST['menu'] ) && ! empty($nav_menus) ) {
3498        $nav_menu_selected_id = $nav_menus[0]->term_id;
3499 }
3500 
3501 // Update the user's setting
3502-if ( $nav_menu_selected_id != $recently_edited && is_nav_menu($nav_menu_selected_id) )
3503+if ( $nav_menu_selected_id != $recently_edited && is_nav_menu( $nav_menu_selected_id ) )
3504        update_user_meta( $current_user->ID, 'nav_menu_recently_edited', $nav_menu_selected_id );
3505 
3506-// If there's a menu, get it's name.
3507-if ( !$nav_menu_selected_title && $nav_menu_selected_title = is_nav_menu( $nav_menu_selected_id ) ) {
3508-       $nav_menu_selected_title = $nav_menu_selected_title->name;
3509+// If there's a menu, get its name.
3510+if ( ! $nav_menu_selected_title && is_nav_menu( $nav_menu_selected_id ) ) {
3511+       $_menu_object = wp_get_nav_menu_object( $nav_menu_selected_id );
3512+       $nav_menu_selected_title = ! is_wp_error( $_menu_object ) ? $_menu_object->name : '';
3513 }
3514 
3515-// Create Menu Metabox
3516-add_meta_box( 'create-menu', __('Create Menu'), 'wp_nav_menu_create_metabox', 'nav-menus', 'side', 'core' );
3517-
3518-// The user has no menus.
3519-if ( !is_nav_menu( $nav_menu_selected_id ) ) {
3520-       $messages_div = '<div id="message" class="updated"><p>' . __('You do not have any menus. Create a new menu.') . '</p></div>';
3521-
3522 // The theme supports menus
3523-} elseif ( current_theme_supports('nav-menus') ) {
3524+if ( current_theme_supports('nav-menus') ) {
3525        // Register nav menu metaboxes
3526-       add_meta_box( 'manage-menu', __( 'Menu Settings' ), 'wp_nav_menu_manage_menu_metabox', 'nav-menus', 'side', 'high', array( $nav_menu_selected_id, $nav_menu_selected_title ) );
3527-       wp_nav_menu_metaboxes_setup();
3528+       wp_nav_menu_meta_boxes_setup();
3529 
3530 // The theme does not support menus but supports widgets
3531 } elseif ( current_theme_supports('widgets') ) {
3532        // Register nav menu metaboxes
3533-       add_meta_box( 'manage-menu', __( 'Menu Settings' ), 'wp_nav_menu_manage_menu_metabox', 'nav-menus', 'side', 'high', array( $nav_menu_selected_id, $nav_menu_selected_title ) );
3534-       wp_nav_menu_metaboxes_setup();
3535+       wp_nav_menu_meta_boxes_setup();
3536        $messages_div = '<div id="message" class="error"><p>' . __('The current theme does not natively support menus, but you can use the &#8220;Navigation Menu&#8221; widget to add any menus you create here to the theme&#8217;s sidebar.') . '</p></div>';
3537 
3538 // The theme supports neither menus nor widgets.
3539@@ -235,114 +322,113 @@
3540 }
3541 
3542 // Get the admin header
3543-require_once( './admin-header.php' );
3544+require_once( 'admin-header.php' );
3545 ?>
3546-<div class="wrap">
3547+<div class="wrap nav-edit-wrap">
3548        <?php screen_icon(); ?>
3549        <h2><?php esc_html_e('Menus'); ?></h2>
3550-       <?php /* OMGWTFBBQ */ ?><div class="error"><p><strong><?php _e('Beta Testers:') ?></strong> <?php _e('This feature is still under construction. You can try it out, but expect it to change in layout and functionality in the second beta release.'); ?></p></div>
3551        <?php echo $messages_div; ?>
3552-       <div class="hide-if-js error"><p><?php _e('You do not have JavaScript enabled in your browser. Please enable it to access the Menus functionality.'); ?></p></div>
3553+       
3554+       <?php if ( current_theme_supports('nav-menus') || current_theme_supports('widgets') ) : ?>
3555+       <div id="menu-settings-column" class="metabox-holder">
3556 
3557-       <?php if ( !empty($nav_menus) && count($nav_menus) > 1 && ( current_theme_supports('nav-menus') || current_theme_supports('widgets') ) ) : ?>
3558-       <ul class="subsubsub">
3559-               <?php
3560-                       foreach ( $nav_menus as $_nav_menu ) {
3561-                               $sep = end( $nav_menus ) == $_nav_menu ? '' : ' | ';
3562+               <form id="nav-menu-meta" action="<?php echo admin_url( 'nav-menus.php' ); ?>" class="nav-menu-meta" method="post" enctype="multipart/form-data">
3563+                       <input type="hidden" name="menu" id="nav-menu-meta-object-id" value="<?php echo esc_attr( $nav_menu_selected_id ); ?>" />
3564+                       <input type="hidden" name="action" value="add-menu-item" />
3565+                       <?php wp_nonce_field( 'add-menu_item', 'menu-settings-column-nonce' ); ?>
3566+                       <?php do_meta_boxes( 'nav-menus', 'side', null ); ?>
3567+               </form>
3568 
3569-                               if ( $nav_menu_selected_id == $_nav_menu->term_id )
3570-                                       echo '<li><a href="'. admin_url( 'nav-menus.php?action=edit&amp;menu=' . esc_attr($_nav_menu->term_id) ) .'" class="current">'. esc_html( $_nav_menu->name ) .'</a>'. $sep .'</li>';
3571-                               else
3572-                                       echo '<li><a href="'. admin_url( 'nav-menus.php?action=edit&amp;menu=' . esc_attr($_nav_menu->term_id) ) .'">'. esc_html( $_nav_menu->name ) .'</a>'. $sep .'</li>';
3573-                       }
3574-               ?>
3575-       </ul>
3576-       <?php endif; ?>
3577+       </div><!-- /#menu-settings-column -->
3578+       
3579+       <div id="menu-management" class="">
3580+               <h2>
3581+                       <?php
3582+                       foreach( (array) $nav_menus as $_nav_menu ) :
3583+                               
3584+                               ?>
3585+                               <a href="<?php
3586+                                       echo add_query_arg(
3587+                                               array(
3588+                                                       'action' => 'edit',
3589+                                                       'menu' => $_nav_menu->term_id,
3590+                                               ),
3591+                                               admin_url( 'nav-menus.php' )
3592+                                       );
3593+                               ?>" class="menu-tabs<?php
3594+                                       if ( $nav_menu_selected_id != $_nav_menu->term_id )
3595+                                               echo ' menu-tab-inactive';
3596+                               ?>"><?php echo esc_html( $_nav_menu->name ); ?></a>
3597 
3598-       <div id="menu-management" class="metabox-holder has-right-sidebar">
3599-               <form id="update-nav-menu" action="<?php echo admin_url( 'nav-menus.php' ); ?>" method="post" enctype="multipart/form-data">
3600-                       <?php wp_nonce_field( 'closedpostboxes', 'closedpostboxesnonce', false ); ?>
3601-                       <?php wp_nonce_field( 'meta-box-order', 'meta-box-order-nonce', false ); ?>
3602-                       <?php wp_nonce_field( 'update-nav_menu' ); ?>
3603-                       <input type="hidden" name="action" value="update" />
3604-                       <input type="hidden" name="li-count" id="li-count" value="-1" />
3605-                       <input type="hidden" name="menu" id="menu" value="<?php echo esc_attr( $nav_menu_selected_id ); ?>" />
3606-                       <input type="hidden" id="hidden-metaboxes" value="<?php echo wp_initial_nav_menu_meta_boxes(); ?>" />
3607-                       <div id="post-body">
3608-                               <div id="post-body-content">
3609-                                       <?php if ( is_nav_menu($nav_menu_selected_id) && ( current_theme_supports('nav-menus') || current_theme_supports('widgets') ) ) : ?>
3610-                                               <div id="menu-container" class="postbox">
3611-                                                       <h3 class="hndle"><?php echo esc_html( $nav_menu_selected_title ); ?></h3>
3612-                                                       <div class="inside">
3613-                                                               <?php wp_nav_menu( array( 'menu' => $nav_menu_selected_id, 'context' => 'backend' ) ); ?>
3614-                                                       </div><!-- /.inside -->
3615-                                               <!-- /#nav-menu-canvas .postbox-->
3616-                                               </div>
3617-                                       <?php endif; ?>
3618-                               </div><!-- /#post-body-content-->
3619-                       </div><!--- /#post-body -->
3620-                       <div id="menu-settings-column" class="inner-sidebar">
3621+                               <?php
3622+                       endforeach;
3623+                       ?>
3624+                       <a href="<?php
3625+                               echo add_query_arg(
3626+                                       array(
3627+                                               'action' => 'edit',
3628+                                               'menu' => 0,
3629+                                       ),
3630+                                       admin_url( 'nav-menus.php' )
3631+                               );
3632+                       ?>" class="menu-tabs menu-add-new<?php
3633+                               if ( 0 != $nav_menu_selected_id )
3634+                                       echo ' menu-tab-inactive';
3635+                       ?>"><?php printf( '<abbr title="%s">+</abbr>', esc_html__( 'Add menu' ) ); ?></a>
3636+               </h2>
3637+               <div class="menu-edit">
3638+                       <form id="update-nav-menu" action="<?php echo admin_url( 'nav-menus.php' ); ?>" method="post" enctype="multipart/form-data">
3639+                               <div id="submitpost" class="submitbox">
3640+                                       <div id="minor-publishing">
3641+                                               <div class="misc-pub-section misc-pub-section-last">
3642+                                                       <label class="howto" for="menu-name">
3643+                                                               <span><?php _e('Name'); ?></span>
3644+                                                               <input id="menu-name" name="menu-name" type="text" class="regular-text menu-item-textbox" value="<?php echo esc_attr( $nav_menu_selected_title  ); ?>" />
3645+                                                               <br class="clear" />
3646+                                                       </label>
3647+                                               </div><!--END .misc-pub-section misc-pub-section-last-->
3648+                                               <br class="clear" />
3649+                                       </div><!--END #misc-publishing-actions-->
3650+                                       <div id="major-publishing-actions">
3651 
3652-                               <?php do_meta_boxes( 'nav-menus', 'side', null ); ?>
3653+                                               <?php if ( ! empty( $nav_menu_selected_id ) ) : ?>
3654+                                               <div id="delete-action">
3655+                                                       <a class="submitdelete deletion menu-delete" href="<?php echo wp_nonce_url( admin_url('nav-menus.php?action=delete&amp;menu=' . $nav_menu_selected_id), 'delete-nav_menu-' . $nav_menu_selected_id ); ?>"><?php _e('Delete Menu'); ?></a>
3656+                                               </div><!--END #delete-action-->
3657+                                               <?php endif; ?>
3658 
3659-                       </div><!-- /#menu-settings-column -->
3660-               </form><!--/#update-nav-menu-->
3661-               <br class="clear" />
3662-       </div><!-- /.metabox-holder has-right-sidebar-->
3663+                                               <div id="publishing-action">
3664+                                                       <input class="button-primary" name="save_menu" type="submit" value="<?php esc_attr_e('Save Menu'); ?>" />
3665+                                               </div><!--END #publishing-action-->
3666+                                               <br class="clear" />
3667+                                       </div><!--END #major-publishing-actions-->
3668+                               </div><!--END #submitpost .submitbox-->
3669+                               <?php wp_nonce_field( 'closedpostboxes', 'closedpostboxesnonce', false ); ?>
3670+                               <?php wp_nonce_field( 'meta-box-order', 'meta-box-order-nonce', false ); ?>
3671+                               <?php wp_nonce_field( 'update-nav_menu', 'update-nav-menu-nonce' ); ?>
3672+                               <input type="hidden" name="action" value="update" />
3673+                               <input type="hidden" name="menu" id="menu" value="<?php echo esc_attr( $nav_menu_selected_id ); ?>" />
3674+                               <input type="hidden" id="hidden-metaboxes" value="<?php echo wp_initial_nav_menu_meta_boxes(); ?>" />
3675+                               <div id="post-body">
3676+                                       <div id="post-body-content">
3677+                                               <?php if ( is_nav_menu( $nav_menu_selected_id ) && ( current_theme_supports('nav-menus') || current_theme_supports('widgets') ) ) : ?>
3678+                                                       <ul class="menu" id="menu-to-edit">
3679+                                                       <?php
3680+                                                       $edit_markup = wp_get_nav_menu_to_edit( $nav_menu_selected_id  );
3681+                                                       if ( ! is_wp_error( $edit_markup ) ) {
3682+                                                               echo $edit_markup;
3683+                                                       }
3684+                                                       ?>
3685+                                                       </ul>
3686+                                               <?php endif; ?>
3687+                                               <br class="clear" />
3688+                                       </div><!-- /#post-body-content-->
3689+                               </div><!--- /#post-body -->
3690+                       </form><!--/#update-nav-menu-->
3691+               </div><!-- /.menu-edit -->
3692+       </div><!-- /#menu-management -->
3693+       <?php endif; // if menus supported in current theme ?>
3694 </div><!-- /.wrap-->
3695 
3696-<div id="menu-item-settings">
3697-       <p class="description">
3698-               <label for="edit-menu-item-title">
3699-                       <?php _e( 'Menu Title' ); ?><br />
3700-                       <input type="text" id="edit-menu-item-title" class="widefat" name="edit-menu-item-title" value="" tabindex="1" />
3701-               </label>
3702-       </p>
3703-       <p class="description">
3704-               <label for="edit-menu-item-url">
3705-                       <?php _e( 'URL' ); ?><br />
3706-                       <input type="text" id="edit-menu-item-url" class="widefat code" name="edit-menu-item-url" value="" tabindex="2" />
3707-               </label>
3708-       </p>
3709-       <p class="description">
3710-               <label for="edit-menu-item-attr-title">
3711-                       <?php _e( 'Title Attribute' ); ?><br />
3712-                       <input type="text" id="edit-menu-item-attr-title" class="widefat" name="edit-menu-item-attr-title" value="" tabindex="3" />
3713-               </label>
3714-       </p>
3715-       <p class="description">
3716-               <label for="edit-menu-item-target">
3717-                       <?php _e( 'Link Target' ); ?><br />
3718-                       <select id="edit-menu-item-target" class="widefat" name="edit-menu-item-target" tabindex="4">
3719-                               <option value=""><?php _e('Same window or tab'); ?></option>
3720-                               <option value="_blank"><?php _e('New window or tab'); ?></option>
3721-                       </select>
3722-               </label>
3723-       </p>
3724-       <p class="description">
3725-               <label for="edit-menu-item-classes">
3726-                       <?php _e( 'CSS Classes (optional)' ); ?><br />
3727-                       <input type="text" id="edit-menu-item-classes" class="widefat code" name="edit-menu-item-classes" value="" tabindex="5" />
3728-               </label>
3729-       </p>
3730-       <p class="description">
3731-               <label for="edit-menu-item-xfn">
3732-                       <?php _e( 'Link Relationship (XFN) (optional)' ); ?><br />
3733-                       <input type="text" id="edit-menu-item-xfn" class="widefat code" name="edit-menu-item-xfn" value="" tabindex="6" />
3734-               </label>
3735-       </p>
3736-       <p class="description">
3737-               <label for="edit-menu-item-description">
3738-                       <?php _e( 'Description (optional)' ); ?><br />
3739-                       <textarea id="edit-menu-item-description" class="widefat" rows="3" name="edit-menu-item-description" tabindex="7" /></textarea>
3740-                       <span class="description"><?php _e('The description will be displayed in the menu if the current theme supports it.'); ?></span>
3741-               </label>
3742-       </p>
3743-       <p>
3744-               <a id="update-menu-item" class="save button-primary" tabindex="8"><?php _e('Save Changes'); ?></a>
3745-               <a id="cancel-save" class="submitdelete deletion" tabindex="9"><?php _e('Cancel'); ?></a>
3746-       </p>
3747-       <input type="hidden" id="edit-menu-item-id" name="edit-item-id" value="" />
3748-</div><!-- /#menu-item-settings-->
3749 
3750-<?php include( './admin-footer.php' ); ?>
3751\ No newline at end of file
3752+<?php include( 'admin-footer.php' ); ?>
3753Index: wp-admin/css/wp-admin-rtl.dev.css
3754===================================================================
3755--- wp-admin/css/wp-admin-rtl.dev.css   (revision 14247)
3756+++ wp-admin/css/wp-admin-rtl.dev.css   (working copy)
3757@@ -298,7 +298,8 @@
3758        margin-left: 0;
3759        margin-right: 120px;
3760 }
3761-#post-body ul.category-tabs li.tabs {
3762+#post-body ul.category-tabs li.tabs,
3763+#post-body ul.add-menu-item-tabs li.tabs {
3764        -moz-border-radius: 0 3px 3px 0;
3765        -webkit-border-top-left-radius: 0;
3766        -webkit-border-top-right-radius: 3px;
3767@@ -309,21 +310,25 @@
3768        border-bottom-left-radius: 0;
3769        border-bottom-right-radius: 3px;
3770 }
3771-#post-body ul.category-tabs {
3772+#post-body ul.category-tabs,
3773+#post-body ul.add-menu-item-tabs {
3774        float: right;
3775        text-align: left;
3776        margin: 0 0 0 -120px;
3777 }
3778 #post-body .categorydiv div.tabs-panel,
3779+#post-body .taxonomy div.tabs-panel,
3780 #post-body #linkcategorydiv div.tabs-panel {
3781        margin: 0 120px 0 5px;
3782 }
3783 /* 1800 - 2000
3784 =================================== */
3785-#side-sortables .category-tabs li {
3786+#side-sortables .category-tabs li,
3787+#side-sortables .add-menu-item-tabs li {
3788        padding-left: 8px;
3789 }
3790 .categorydiv ul.categorychecklist ul,
3791+.taxonomydiv ul.categorychecklist ul,
3792 #linkcategorydiv ul.categorychecklist ul {
3793        margin-left: 0;
3794        margin-right: 18px;
3795Index: wp-admin/css/colors-classic.dev.css
3796===================================================================
3797--- wp-admin/css/colors-classic.dev.css (revision 14247)
3798+++ wp-admin/css/colors-classic.dev.css (working copy)
3799@@ -110,11 +110,13 @@
3800 }
3801 
3802 div.tabs-panel,
3803-ul.category-tabs li.tabs {
3804+ul.category-tabs li.tabs,
3805+ul.add-menu-item-tabs li.tabs {
3806        border-color: #dfdfdf;
3807 }
3808 
3809-ul.category-tabs li.tabs {
3810+ul.category-tabs li.tabs,
3811+ul.add-menu-item-tabs li.tabs {
3812        background-color: #f1f1f1;
3813 }
3814 
3815@@ -380,7 +382,8 @@
3816        border-color: #dfdfdf;
3817 }
3818 
3819-#side-sortables .category-tabs .tabs a {
3820+#side-sortables .category-tabs .tabs a,
3821+#side-sortables .add-menu-item-tabs .tabs a {
3822        color: #333;
3823 }
3824 
3825@@ -1467,7 +1470,8 @@
3826        background-color: #f5f5f5;
3827 }
3828 
3829-#post-body ul.category-tabs li.tabs a {
3830+#post-body ul.category-tabs li.tabs a,
3831+#post-body ul.add-menu-item-tabs li.tabs a {
3832        color: #333;
3833 }
3834 
3835Index: wp-admin/css/colors-fresh.dev.css
3836===================================================================
3837--- wp-admin/css/colors-fresh.dev.css   (revision 14247)
3838+++ wp-admin/css/colors-fresh.dev.css   (working copy)
3839@@ -110,11 +110,13 @@
3840 }
3841 
3842 div.tabs-panel,
3843-ul.category-tabs li.tabs {
3844+ul.category-tabs li.tabs,
3845+ul.add-menu-item-tabs li.tabs {
3846        border-color: #dfdfdf;
3847 }
3848 
3849-ul.category-tabs li.tabs {
3850+ul.category-tabs li.tabs,
3851+ul.add-menu-item-tabs li.tabs {
3852        background-color: #f1f1f1;
3853 }
3854 
3855@@ -379,7 +381,8 @@
3856        border-color: #dfdfdf;
3857 }
3858 
3859-#side-sortables .category-tabs .tabs a {
3860+#side-sortables .category-tabs .tabs a,
3861+#side-sortables .add-menu-item-tabs .tabs a {
3862        color: #333;
3863 }
3864 
3865@@ -490,7 +493,9 @@
3866 }
3867 
3868 /* Because we don't want visited on these links */
3869+body.press-this .tabs a,
3870 body.press-this .tabs a:hover {
3871+       background-color: #fff;
3872        border-color: #c6d9e9;
3873        border-bottom-color: #fff;
3874        color: #d54e21;
3875@@ -1460,7 +1465,8 @@
3876        background-color: #f5f5f5;
3877 }
3878 
3879-#post-body ul.category-tabs li.tabs a {
3880+#post-body ul.category-tabs li.tabs a,
3881+#post-body ul.add-menu-item-tabs li.tabs a {
3882        color: #333;
3883 }
3884 
3885Index: wp-admin/css/wp-admin.dev.css
3886===================================================================
3887--- wp-admin/css/wp-admin.dev.css       (revision 14247)
3888+++ wp-admin/css/wp-admin.dev.css       (working copy)
3889@@ -1959,7 +1959,8 @@
3890        width: auto;
3891 }
3892 
3893-#post-body ul.category-tabs {
3894+#post-body ul.category-tabs,
3895+#post-body ul.add-menu-item-tabs {
3896        float: left;
3897        width: 120px;
3898        text-align: right;
3899@@ -1968,11 +1969,13 @@
3900        padding: 0;
3901 }
3902 
3903-#post-body ul.category-tabs li {
3904+#post-body ul.category-tabs li,
3905+#post-body ul.add-menu-item-tabs li {
3906        padding: 8px;
3907 }
3908 
3909-#post-body ul.category-tabs li.tabs {
3910+#post-body ul.category-tabs li.tabs,
3911+#post-body ul.add-menu-item-tabs li.tabs {
3912        -moz-border-radius: 3px 0 0 3px;
3913        -webkit-border-top-left-radius: 3px;
3914        -webkit-border-bottom-left-radius: 3px;
3915@@ -1982,12 +1985,16 @@
3916        border-bottom-left-radius: 3px;
3917 }
3918 
3919-#post-body ul.category-tabs li.tabs a {
3920+#post-body ul.category-tabs li.tabs a,
3921+#post-body ul.add-menu-item-tabs li.tabs a {
3922        font-weight: bold;
3923        text-decoration: none;
3924 }
3925 
3926 .categorydiv div.tabs-panel,
3927+.customlinkdiv div.tabs-panel,
3928+.posttypediv div.tabs-panel,
3929+.taxonomydiv div.tabs-panel,
3930 #linkcategorydiv div.tabs-panel {
3931        height: 200px;
3932        overflow: auto;
3933@@ -1996,25 +2003,40 @@
3934        border-width: 1px;
3935 }
3936 
3937+div.tabs-panel-active {
3938+       display:block; 
3939+}
3940+
3941+div.tabs-panel-inactive {
3942+       display:none;   
3943+}
3944+
3945 #post-body .categorydiv div.tabs-panel,
3946+.taxonomy div.tabs-panel,
3947 #post-body #linkcategorydiv div.tabs-panel {
3948        margin: 0 5px 0 125px;
3949 }
3950 
3951-#side-sortables .category-tabs li {
3952+#side-sortables .category-tabs li,
3953+#side-sortables .add-menu-item-tabs li {
3954        display: inline;
3955        padding-right: 8px;
3956 }
3957 
3958-#side-sortables .category-tabs a {
3959+#side-sortables .category-tabs a,
3960+#side-sortables .add-menu-item-tabs a {
3961        text-decoration: none;
3962 }
3963 
3964-#side-sortables .category-tabs {
3965+#side-sortables .category-tabs,
3966+#side-sortables .add-menu-item-tabs {
3967        margin-bottom: 3px;
3968 }
3969 
3970 .categorydiv ul,
3971+.customlinkdiv ul,
3972+.posttypediv ul,
3973+.taxonomydiv ul,
3974 #linkcategorydiv ul {
3975        list-style: none;
3976        padding: 0;
3977@@ -2025,6 +2047,9 @@
3978 #front-static-pages ul,
3979 .inline-editor ul.cat-checklist ul,
3980 .categorydiv ul.categorychecklist ul,
3981+.customlinkdiv ul.categorychecklist ul,
3982+.posttypediv ul.categorychecklist ul,
3983+.taxonomydiv ul.categorychecklist ul,
3984 #linkcategorydiv ul.categorychecklist ul {
3985        margin-left: 18px;
3986 }
3987@@ -2040,27 +2065,34 @@
3988        margin-bottom: 0px;
3989 }
3990 
3991-.categorydiv .tabs-panel {
3992+.categorydiv .tabs-panel,
3993+.customlinkdiv .tabs-panel,
3994+.posttypediv .tabs-panel,
3995+.taxonomydiv .tabs-panel {
3996        border-width: 3px;
3997        border-style: solid;
3998 }
3999 
4000-ul.category-tabs {
4001+ul.category-tabs,
4002+ul.add-menu-item-tabs {
4003        margin-top: 12px;
4004 }
4005 
4006-ul.category-tabs li.tabs {
4007+ul.category-tabs li.tabs,
4008+ul.add-menu-item-tabs li.tabs {
4009        border-style: solid solid none;
4010        border-width: 1px 1px 0;
4011 }
4012 
4013-#post-body .category-tabs li.tabs {
4014+#post-body .category-tabs li.tabs,
4015+#post-body .add-menu-item-tabs li.tabs {
4016        border-style: solid none solid solid;
4017        border-width: 1px 0 1px 1px;
4018        margin-right: -1px;
4019 }
4020 
4021-ul.category-tabs li {
4022+ul.category-tabs li,
4023+ul.add-menu-item-tabs li {
4024        padding: 5px 8px;
4025        -moz-border-radius: 3px 3px 0 0;
4026        -webkit-border-top-left-radius: 3px;
4027@@ -3705,4 +3737,4 @@
4028        border-width: 1px 1px 0;
4029        background-color: #fafafa;
4030        color: #c1c1c1;
4031-}
4032\ No newline at end of file
4033+}
4034Index: wp-admin/css/nav-menu.dev.css
4035===================================================================
4036--- wp-admin/css/nav-menu.dev.css       (revision 14247)
4037+++ wp-admin/css/nav-menu.dev.css       (working copy)
4038@@ -8,8 +8,61 @@
4039  * @subpackage Administration
4040  */
4041 
4042+.nav-edit-wrap {
4043+       clear:both;
4044+}
4045+
4046+#menu-settings-column {
4047+       display:block;
4048+       float:left;
4049+       width:281px;
4050+}
4051+
4052+#menu-settings-column .inside {
4053+       padding:0 10px;
4054+}
4055+
4056 /* Menu Container */
4057-#menu-management { clear: both; }
4058+#menu-management {
4059+       float:left;
4060+       margin-left:15px;
4061+}
4062+       #menu-management .menu-edit {
4063+               background-color:#fff;
4064+               border-color: #dfdfdf;
4065+               border-width: 1px;
4066+               border-style: solid;
4067+               margin-bottom: 20px;
4068+               padding:0 10px 10px;
4069+               -moz-border-radius-bottomleft: 6px;
4070+               -webkit-border-bottom-left-radius: 6px;
4071+               -khtml-border-bottom-left-radius: 6px;
4072+               border-bottom-left-radius: 6px;
4073+               -moz-border-radius-bottomright: 6px;
4074+               -webkit-border-bottom-right-radius: 6px;
4075+               -khtml-border-bottom-right-radius: 6px;
4076+               border-bottom-right-radius: 6px;
4077+               -moz-border-radius-topright: 6px;
4078+               -webkit-border-top-right-radius: 6px;
4079+               -khtml-border-top-right-radius: 6px;
4080+               border-top-right-radius: 6px;
4081+       }
4082+
4083+       #menu-management .menu-add-new abbr {
4084+               font-weight:bold;
4085+       }
4086+
4087+       #menu-management .menu-tabs {
4088+               background-color:#fff;
4089+               border-color:#dfdfdf;
4090+               border-bottom-color:#fff;
4091+       }
4092+       
4093+       #menu-management .menu-tab-inactive {
4094+               background-color:#fafafa;
4095+               border-bottom-color:#fafafa;
4096+       }
4097+
4098 #menu-management .inside { padding: 0 10px; }
4099 
4100 /* Button Primary Actions */
4101@@ -21,7 +74,20 @@
4102 
4103 /* Button Secondary Actions */
4104 .list-controls { float: left; }
4105-.add-to-menu { float: right; }
4106+.add-to-menu {
4107+       float: right;
4108+}
4109+
4110+form.processing .add-to-menu {
4111+       background: url("../images/wpspin_light.gif") no-repeat top center;
4112+       display:block;
4113+       height:20px;
4114+       overflow:hidden;
4115+       text-align:left;
4116+       text-indent:-999em;
4117+       width:20px;
4118+}
4119+
4120 .button-controls { margin: 10px 0; }
4121 .show-all, .hide-all { cursor: pointer; }
4122 .hide-all { display: none; }
4123@@ -61,12 +127,58 @@
4124 /* Nav Menu */
4125 #menu-container .inside { padding-bottom: 10px; }
4126 
4127+.menu {
4128+       padding-top:1em;
4129+}
4130+
4131 .menu ul { width: 100%; }
4132-.menu li { margin: 0; }
4133-.menu li dl dt { -webkit-border-radius: 6px; border-radius: 6px; -moz-border-radius: 6px; border: 1px solid #E6E6E6; position: relative; padding-left: 10px; background-color: #f1f1f1; height: 35px; line-height: 35px; }
4134-.menu li dl dt:hover { cursor: move; }
4135+.menu ul.sub-menu {
4136+}
4137+.menu li {
4138+       margin: 0;
4139+}
4140+.menu li dl {
4141+       clear:both;
4142+       line-height:1.5em;
4143+       position:relative;
4144+}
4145+.menu li dl dt {
4146+       -webkit-border-radius: 6px;
4147+       border-radius: 6px;
4148+       -moz-border-radius: 6px;
4149+       border: 1px solid #E6E6E6;
4150+       clear:both;
4151+       cursor: move;
4152+       position: relative;
4153+       padding-left: 10px;
4154+       background-color: #f1f1f1;
4155+       height: 35px;
4156+       line-height: 35px;
4157+}
4158+.menu li dl dt:hover {
4159+}
4160+.menu li.deleting dl dt {
4161+       background-color:#faa;
4162+}
4163 
4164-.menu li .item-title { }
4165+.menu li .item-title {
4166+       display:block;
4167+       height:1em;
4168+       margin-right:18em;
4169+}
4170+
4171+.menu li div.sortable-placeholder {
4172+       background: #f5f5f5;
4173+       border: 1px dashed #bbb;
4174+       margin: 10px 0px;
4175+       padding-top:40px;
4176+}
4177+
4178+.menu li dl.sortable-placeholder {
4179+       background: #f5f5f5;
4180+       padding-bottom:40px;
4181+}
4182+
4183 .menu li ul li { margin-left: 20px; opacity: .7; }
4184 .menu li ul li ul li { opacity: .9; }
4185 .menu li ul li ul li ul li { opacity: .9; }
4186@@ -81,10 +193,30 @@
4187 .item-controls { font-size: 11px; position: absolute; right: 15px; top: -1px; }
4188 .item-controls a { text-decoration: none; }
4189 .item-controls a:hover { cursor: pointer; }
4190+.item-controls .item-order a {
4191+       font-weight:bold;
4192+}
4193+
4194+body.js .item-order {
4195+       display:none;
4196+}
4197+
4198 .item-controls .menu-item-delete:hover { color: #ff0000; }
4199 
4200-/* Thickbox */
4201-#menu-item-settings { display: none; }
4202+/* Menu editing */
4203+.menu-item-edit-active {
4204+       display:block;
4205+}
4206+
4207+.menu-item-edit-inactive {
4208+       display:none;
4209+}
4210+
4211+.add-menu-item-pagelinks {
4212+       margin:.5em auto;
4213+       text-align:center;
4214+}
4215+
4216 #cancel-save { cursor: pointer; }
4217 #cancel-save:hover { color: #fff !important; }
4218 #update-menu-item { color: #fff !important; }
4219@@ -94,4 +226,4 @@
4220 
4221 /* Clearfix */
4222 .button-controls:after, #menu-item-url-wrap:after, #menu-item-name-wrap:after { content: "."; display: block; height: 0; clear: both; visibility: hidden; }
4223-.button-controls, #menu-item-url-wrap, #menu-item-name-wrap { display: block; }
4224\ No newline at end of file
4225+.button-controls, #menu-item-url-wrap, #menu-item-name-wrap { display: block; }