<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" /><style type="text/css"><!--
#msg dl { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; }
#msg dl a { font-weight: bold}
#msg dl a:link { color:#fc3; }
#msg dl a:active { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fc0 solid; padding: 6px; }
#msg ul, pre { overflow: auto; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<title>[14031] trunk: Nav menu fixes.</title>
</head>
<body>
<div id="msg">
<dl>
<dt>Revision</dt> <dd><a href="http://trac.wordpress.org/changeset/14031">14031</a></dd>
<dt>Author</dt> <dd>ryan</dd>
<dt>Date</dt> <dd>2010-04-07 15:25:48 +0000 (Wed, 07 Apr 2010)</dd>
</dl>
<h3>Log Message</h3>
<pre>Nav menu fixes. Props ptahdunbar. see <a href="http://trac.wordpress.org/ticket/12896">#12896</a> fixes <a href="http://trac.wordpress.org/ticket/12844">#12844</a></pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkwpadminincludesnavmenuphp">trunk/wp-admin/includes/nav-menu.php</a></li>
<li><a href="#trunkwpadminnavmenusphp">trunk/wp-admin/nav-menus.php</a></li>
<li><a href="#trunkwpcontentthemestwentytenstylecss">trunk/wp-content/themes/twentyten/style.css</a></li>
<li><a href="#trunkwpincludesclassesphp">trunk/wp-includes/classes.php</a></li>
<li><a href="#trunkwpincludesnavmenutemplatephp">trunk/wp-includes/nav-menu-template.php</a></li>
<li><a href="#trunkwpincludesnavmenuphp">trunk/wp-includes/nav-menu.php</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkwpadminincludesnavmenuphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-admin/includes/nav-menu.php (14030 => 14031)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-admin/includes/nav-menu.php        2010-04-07 13:52:12 UTC (rev 14030)
+++ trunk/wp-admin/includes/nav-menu.php        2010-04-07 15:25:48 UTC (rev 14031)
</span><span class="lines">@@ -55,7 +55,7 @@
</span><span class="cx">
</span><span class="cx">         foreach ( $post_types as $post_type ) {
</span><span class="cx">                 $id = $post_type->name;
</span><del>-                add_meta_box( "add-{$id}", sprintf( __('Add an Existing %s'), $post_type->singular_label ), 'wp_nav_menu_item_post_type_metabox', 'nav-menus', 'side', 'default', $post_type );
</del><ins>+                add_meta_box( "add-{$id}", sprintf( __('Add %s'), $post_type->label ), 'wp_nav_menu_item_post_type_metabox', 'nav-menus', 'side', 'default', $post_type );
</ins><span class="cx">         }
</span><span class="cx"> }
</span><span class="cx">
</span><span class="lines">@@ -72,8 +72,7 @@
</span><span class="cx">
</span><span class="cx">         foreach ( $taxonomies as $tax ) {
</span><span class="cx">                 $id = $tax->name;
</span><del>-
-                add_meta_box( "add-{$id}", sprintf( __('Add an Existing %s'), $tax->singular_label ), 'wp_nav_menu_item_taxonomy_metabox', 'nav-menus', 'side', 'default', $tax );
</del><ins>+                add_meta_box( "add-{$id}", sprintf( __('Add %s'), $tax->label ), 'wp_nav_menu_item_taxonomy_metabox', 'nav-menus', 'side', 'default', $tax );
</ins><span class="cx">         }
</span><span class="cx"> }
</span><span class="cx">
</span></span></pre></div>
<a id="trunkwpadminnavmenusphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-admin/nav-menus.php (14030 => 14031)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-admin/nav-menus.php        2010-04-07 13:52:12 UTC (rev 14030)
+++ trunk/wp-admin/nav-menus.php        2010-04-07 15:25:48 UTC (rev 14031)
</span><span class="lines">@@ -274,7 +274,7 @@
</span><span class="cx">                                                 <div id="menu-container" class="postbox">
</span><span class="cx">                                                         <h3 class="hndle"><?php echo esc_html( $nav_menu_selected_title ); ?></h3>
</span><span class="cx">                                                         <div class="inside">
</span><del>-                                                                <?php echo wp_get_nav_menu( array( 'context' => 'backend', 'menu' => $nav_menu_selected_id ) ); ?>
</del><ins>+                                                                <?php wp_nav_menu( array( 'menu' => $nav_menu_selected_id, 'context' => 'backend' ) ); ?>
</ins><span class="cx">                                                         </div><!-- /.inside -->
</span><span class="cx">                                                 <!-- /#nav-menu-canvas .postbox-->
</span><span class="cx">                                                 </div>
</span></span></pre></div>
<a id="trunkwpcontentthemestwentytenstylecss"></a>
<div class="modfile"><h4>Modified: trunk/wp-content/themes/twentyten/style.css (14030 => 14031)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-content/themes/twentyten/style.css        2010-04-07 13:52:12 UTC (rev 14030)
+++ trunk/wp-content/themes/twentyten/style.css        2010-04-07 15:25:48 UTC (rev 14031)
</span><span class="lines">@@ -113,6 +113,7 @@
</span><span class="cx"> h3#comments-title,
</span><span class="cx"> h3#reply-title,
</span><span class="cx"> #access .menu,
</span><ins>+#access div.menu ul,
</ins><span class="cx"> #cancel-comment-reply-link,
</span><span class="cx"> .form-allowed-tags,
</span><span class="cx"> #site-info,
</span><span class="lines">@@ -153,6 +154,7 @@
</span><span class="cx">
</span><span class="cx"> /* The main theme structure */
</span><span class="cx"> #access .menu-header,
</span><ins>+div.menu,
</ins><span class="cx"> #colophon,
</span><span class="cx"> #branding,
</span><span class="cx"> #main,
</span><span class="lines">@@ -360,15 +362,15 @@
</span><span class="cx">         display:block;
</span><span class="cx">         float:left;
</span><span class="cx"> }
</span><del>-#access .menu-header {
</del><ins>+#access .menu-header, div.menu {
</ins><span class="cx">         font-size: 13px;
</span><span class="cx">         margin-left: 12px;
</span><span class="cx"> }
</span><del>-#access .menu-header ul {
</del><ins>+#access .menu-header ul, div.menu ul {
</ins><span class="cx">         list-style: none;
</span><span class="cx">         margin: 0;
</span><span class="cx"> }
</span><del>-#access .menu-header li {
</del><ins>+#access .menu-header li, div.menu li {
</ins><span class="cx">         float:left;
</span><span class="cx">         position: relative;
</span><span class="cx"> }
</span></span></pre></div>
<a id="trunkwpincludesclassesphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-includes/classes.php (14030 => 14031)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-includes/classes.php        2010-04-07 13:52:12 UTC (rev 14030)
+++ trunk/wp-includes/classes.php        2010-04-07 15:25:48 UTC (rev 14031)
</span><span class="lines">@@ -1178,7 +1178,7 @@
</span><span class="cx">          * @param object $item Menu item data object.
</span><span class="cx">          * @param int $depth Depth of menu item. Used for padding.
</span><span class="cx">          * @param int $current_page Menu item ID.
</span><del>-         * @param array $args
</del><ins>+         * @param object $args
</ins><span class="cx">          */
</span><span class="cx">         function start_el(&$output, $item, $depth, $args) {
</span><span class="cx">                 $indent = ( $depth ) ? str_repeat( "\t", $depth ) : '';
</span><span class="lines">@@ -1217,7 +1217,6 @@
</span><span class="cx">         function end_el(&$output, $item, $depth) {
</span><span class="cx">                 $output .= "</li>\n";
</span><span class="cx">         }
</span><del>-
</del><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> /**
</span></span></pre></div>
<a id="trunkwpincludesnavmenutemplatephp"></a>
<div class="modfile"><h4>Modified: trunk/wp-includes/nav-menu-template.php (14030 => 14031)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-includes/nav-menu-template.php        2010-04-07 13:52:12 UTC (rev 14030)
+++ trunk/wp-includes/nav-menu-template.php        2010-04-07 15:25:48 UTC (rev 14031)
</span><span class="lines">@@ -22,8 +22,9 @@
</span><span class="cx"> * link_before - Text before the link.
</span><span class="cx"> * link_after - Text after the link.
</span><span class="cx"> * echo - Whether to echo the menu or return it. Defaults to echo.
</span><del>- * show_home - If you set this argument, then it will display the link to the home page. The show_home argument really just needs to be set to the value of the text of the link.
</del><span class="cx"> *
</span><ins>+ * @todo show_home - If you set this argument, then it will display the link to the home page. The show_home argument really just needs to be set to the value of the text of the link.
+ *
</ins><span class="cx"> * @since 3.0.0
</span><span class="cx"> *
</span><span class="cx"> * @param array $args Arguments
</span><span class="lines">@@ -31,7 +32,7 @@
</span><span class="cx"> function wp_nav_menu( $args = array() ) {
</span><span class="cx">         $defaults = array( 'menu' => '', 'container' => 'div', 'container_class' => '', 'menu_class' => 'menu', 'echo' => true,
</span><span class="cx">         'fallback_cb' => 'wp_page_menu', 'before' => '', 'after' => '', 'link_before' => '', 'link_after' => '',
</span><del>-        'depth' => 0, 'walker' => '' );
</del><ins>+        'depth' => 0, 'walker' => '', 'context' => 'frontend' );
</ins><span class="cx">
</span><span class="cx">         $args = wp_parse_args( $args, $defaults );
</span><span class="cx">         $args = apply_filters( 'wp_nav_menu_args', $args );
</span><span class="lines">@@ -51,80 +52,38 @@
</span><span class="cx">                         }
</span><span class="cx">                 }
</span><span class="cx">         }
</span><del>-
-        if ( $menu && ! is_wp_error( $menu ) )
-                $args->menu = $menu->term_id;
-        $nav_menu = '';
-
-        if ( 'div' == $args->container ) {
-                $class = $args->container_class ? ' class="' . esc_attr($args->container_class) . '"' : '';
-
-                if ( is_nav_menu($menu) ) {
-                        $nav_menu .= '<div id="menu-' . $menu->slug . '"'. $class .'>';
-                } else {
-                        $nav_menu .= '<div'. $class .'>';
-                }
-        }
-
-        $nav_menu .= wp_get_nav_menu( $args );
-
-        if ( 'div' == $args->container )
-                $nav_menu .= '</div>';
-
-        $nav_menu = apply_filters( 'wp_nav_menu', $nav_menu, $args );
-
-        if ( $args->echo )
-                echo $nav_menu;
-        else
-                return $nav_menu;
-}
-
-/**
- * Returns a Navigation Menu.
- *
- * See wp_nav_menu() for args.
- *
- * @since 3.0.0
- *
- * @param array $args Arguments
- * @return mixed $output False if menu doesn't exists, else, returns the menu.
- **/
-function wp_get_nav_menu( $args = array() ) {
-        $defaults = array( 'menu' => '', 'menu_class' => 'menu', 'context' => 'frontend', 'depth' => 0,
-        'fallback_cb' => '', 'walker' => '', 'before' => '', 'after' => '', 'link_before' => '', 'link_after' => '', );
-
-        $args = wp_parse_args( $args, $defaults );
-        $args = apply_filters( 'wp_get_nav_menu_args', $args );
-        $args = (object) $args;
-
-        // Variable setup
-        $nav_menu = '';
-        $items = '';
-
-        // Get the menu object
-        $menu = wp_get_nav_menu_object( $args->menu );
-
</del><ins>+        
</ins><span class="cx">         // If the menu exists, get it's items.
</span><span class="cx">         if ( $menu && !is_wp_error($menu) )
</span><span class="cx">                 $menu_items = wp_get_nav_menu_items( $menu->term_id, $args->context );
</span><span class="cx">
</span><span class="cx">         // If no menu was found or if the menu has no items, call the fallback_cb
</span><span class="cx">         if ( !$menu || is_wp_error($menu) || ( isset($menu_items) && empty($menu_items) ) ) {
</span><del>-                if ( function_exists($args->fallback_cb) || is_callable( $args->fallback_cb ) ) {
-                        $_args = array_merge( (array) $args, array('echo' => false) );
-                        return call_user_func( $args->fallback_cb, $_args );
</del><ins>+                if ( 'frontend' == $args->context && ( function_exists($args->fallback_cb) || is_callable( $args->fallback_cb ) ) ) {
+                        return call_user_func( $args->fallback_cb, (array) $args );
</ins><span class="cx">                 }
</span><span class="cx">         }
</span><ins>+        
+        $nav_menu = '';
+        $items = '';
+        $container_allowedtags = apply_filters( 'wp_nav_menu_container_allowedtags', array( 'div', 'p', 'nav' ) );
</ins><span class="cx">
</span><ins>+        if ( in_array( $args->container, $container_allowedtags ) ) {
+                $class = $args->container_class ? ' class="' . esc_attr($args->container_class) . '"' : ' class="menu-'. $menu->slug .'-container"';
+                $nav_menu .= '<'. $args->container . $class .'>';
+        }
+
</ins><span class="cx">         // Set up the $menu_item variables
</span><span class="cx">         foreach ( (array) $menu_items as $key => $menu_item )
</span><span class="cx">                 $menu_items[$menu_item->menu_order] = wp_setup_nav_menu_item( $menu_item, 'frontend' );
</span><span class="cx">
</span><span class="cx">         $items .= walk_nav_menu_tree( $menu_items, $args->depth, $args );
</span><span class="cx">
</span><del>-        // CSS class
-        $ul_class = $args->menu_class ? ' class="'. $args->menu_class .'"' : '';
-        $nav_menu .= '<ul'. $ul_class .'>';
</del><ins>+        // Attributes        
+        $attributes = ' id="menu-' . $menu->slug . '"';
+        $attributes .= $args->menu_class ? ' class="'. $args->menu_class .'"' : '';
+        
+        $nav_menu .= '<ul'. $attributes .'>';
</ins><span class="cx">
</span><span class="cx">         // Allow plugins to hook into the menu to add their own <li>'s
</span><span class="cx">         if ( 'frontend' == $args->context ) {
</span><span class="lines">@@ -137,7 +96,15 @@
</span><span class="cx">
</span><span class="cx">         $nav_menu .= '</ul>';
</span><span class="cx">
</span><del>-        return apply_filters( 'wp_get_nav_menu', $nav_menu );
</del><ins>+        if ( in_array( $args->container, $container_allowedtags ) )
+                $nav_menu .= '</'. $args->container .'>';
+
+        $nav_menu = apply_filters( 'wp_nav_menu', $nav_menu, $args );
+
+        if ( $args->echo )
+                echo $nav_menu;
+        else
+                return $nav_menu;
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> /**
</span><span class="lines">@@ -161,7 +128,7 @@
</span><span class="cx">
</span><span class="cx">                         $output .= $args->before;
</span><span class="cx">                         $output .= '<a'. $attributes .'>';
</span><del>-                        $output .= $args->link_before . apply_filters('the_title', $menu_item->title) . $args->link_after;
</del><ins>+                        $output .= $args->link_before . apply_filters( 'the_title', $menu_item->title ) . $args->link_after;
</ins><span class="cx">                         $output .= '</a>';
</span><span class="cx">                         $output .= $args->after;
</span><span class="cx">
</span><span class="lines">@@ -218,6 +185,6 @@
</span><span class="cx">                         break;
</span><span class="cx">         }
</span><span class="cx">
</span><del>-        return $output;
</del><ins>+        return apply_filters( 'wp_get_nav_menu_item', $output, $context, $args );
</ins><span class="cx"> }
</span><span class="cx"> ?>
</span><span class="cx">\ No newline at end of file
</span></span></pre></div>
<a id="trunkwpincludesnavmenuphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-includes/nav-menu.php (14030 => 14031)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-includes/nav-menu.php        2010-04-07 13:52:12 UTC (rev 14030)
+++ trunk/wp-includes/nav-menu.php        2010-04-07 15:25:48 UTC (rev 14031)
</span><span class="lines">@@ -178,7 +178,7 @@
</span><span class="cx">         $walker = ( empty($r->walker) ) ? new Walker_Nav_Menu : $r->walker;
</span><span class="cx">         $args = array( $items, $depth, $r );
</span><span class="cx">
</span><del>-        return call_user_func_array(array(&$walker, 'walk'), $args);
</del><ins>+        return call_user_func_array( array(&$walker, 'walk'), $args );
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> /**
</span><span class="lines">@@ -202,17 +202,19 @@
</span><span class="cx">                         if ( 'post_type' == $menu_item->type ) {
</span><span class="cx">                                 $object = get_post_type_object( $menu_item->object );
</span><span class="cx">                                 $menu_item->append = $object->singular_label;
</span><ins>+                                $menu_item->url = get_permalink( $menu_item->object_id );
</ins><span class="cx">
</span><span class="cx">                         } elseif ( 'taxonomy' == $menu_item->type ) {
</span><span class="cx">                                 $object = get_taxonomy( $menu_item->object );
</span><span class="cx">                                 $menu_item->append = $object->singular_label;
</span><ins>+                                $menu_item->url = get_term_link( (int) $menu_item->object_id, $menu_item->object );
</ins><span class="cx">
</span><span class="cx">                         } else {
</span><span class="cx">                                 $menu_item->append = __('Custom');
</span><ins>+                                $menu_item->url = get_post_meta( $menu_item->ID, '_menu_item_url', true );
</ins><span class="cx">                         }
</span><span class="cx">
</span><span class="cx">                         $menu_item->title = $menu_item->post_title;
</span><del>-                        $menu_item->url = get_post_meta( $menu_item->ID, '_menu_item_url', true );
</del><span class="cx">                         $menu_item->target = get_post_meta( $menu_item->ID, '_menu_item_target', true );
</span><span class="cx">
</span><span class="cx">                         $menu_item->attr_title = strip_tags( $menu_item->post_excerpt );
</span><span class="lines">@@ -221,7 +223,7 @@
</span><span class="cx">                         $menu_item->classes = get_post_meta( $menu_item->ID, '_menu_item_classes', true );
</span><span class="cx">                         $menu_item->xfn = get_post_meta( $menu_item->ID, '_menu_item_xfn', true );
</span><span class="cx">                         break;
</span><del>-
</del><ins>+                
</ins><span class="cx">                 case 'custom':
</span><span class="cx">                         $menu_item->db_id = 0;
</span><span class="cx">                         $menu_item->object_id = (int) $menu_item->ID;
</span><span class="lines">@@ -235,8 +237,8 @@
</span><span class="cx">                         $menu_item->title = $menu_item->post_title;
</span><span class="cx">                         $menu_item->url = get_post_meta( $menu_item->ID, '_menu_item_url', true );
</span><span class="cx">                         $menu_item->target = get_post_meta( $menu_item->ID, '_menu_item_target', true );
</span><del>-                        $menu_item->classes = '';
-                        $menu_item->xfn = '';
</del><ins>+                        $menu_item->classes = get_post_meta( $menu_item->ID, '_menu_item_target', true );
+                        $menu_item->xfn = get_post_meta( $menu_item->ID, '_menu_item_xfn', true );
</ins><span class="cx">                         break;
</span><span class="cx">
</span><span class="cx">                 case 'post_type':
</span><span class="lines">@@ -273,11 +275,12 @@
</span><span class="cx">                         $menu_item->url = get_term_link( $menu_item, $menu_item_object );
</span><span class="cx">                         $menu_item->target = '';
</span><span class="cx">                         $menu_item->attr_title = '';
</span><del>-                        $menu_item->description = strip_tags( $menu_item->description );
</del><ins>+                        $menu_item->description = '';
</ins><span class="cx">                         $menu_item->classes = '';
</span><span class="cx">                         $menu_item->xfn = '';
</span><span class="cx">                         break;
</span><span class="cx">         }
</span><del>-        return $menu_item;
</del><ins>+        
+        return apply_filters( 'wp_setup_nav_menu_item', $menu_item, $menu_item_type, $menu_item_object );
</ins><span class="cx"> }
</span><del>-?>
</del><ins>+?>
</ins><span class="cx">\ No newline at end of file
</span></span></pre>
</div>
</div>
</body>
</html>