<!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>[13743] trunk/wp-includes/nav-menu-template.php:
Fix notice for when no menus are located.</title>
</head>
<body>
<div id="msg">
<dl>
<dt>Revision</dt> <dd><a href="http://trac.wordpress.org/changeset/13743">13743</a></dd>
<dt>Author</dt> <dd>nacin</dd>
<dt>Date</dt> <dd>2010-03-17 21:34:24 +0000 (Wed, 17 Mar 2010)</dd>
</dl>
<h3>Log Message</h3>
<pre>Fix notice for when no menus are located. see <a href="http://trac.wordpress.org/ticket/11817">#11817</a></pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkwpincludesnavmenutemplatephp">trunk/wp-includes/nav-menu-template.php</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkwpincludesnavmenutemplatephp"></a>
<div class="modfile"><h4>Modified: trunk/wp-includes/nav-menu-template.php (13742 => 13743)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-includes/nav-menu-template.php        2010-03-17 20:44:59 UTC (rev 13742)
+++ trunk/wp-includes/nav-menu-template.php        2010-03-17 21:34:24 UTC (rev 13743)
</span><span class="lines">@@ -45,13 +45,13 @@
</span><span class="cx">                 }
</span><span class="cx">         }
</span><span class="cx">
</span><del>-        if ( !is_wp_error($menu) && $menu)
</del><ins>+        if ( $menu && ! is_wp_error( $menu ) )
</ins><span class="cx">                 $args->menu = $menu->term_id;
</span><span class="cx">         $nav_menu = '';
</span><span class="cx">
</span><span class="cx">         if ( 'div' == $args->container ) {
</span><span class="cx">                 $class = $args->container_class ? ' class="' . esc_attr($args->container_class) . '"' : '';
</span><del>-
</del><ins>+                
</ins><span class="cx">                 if ( is_nav_menu($menu) ) {
</span><span class="cx">                         $nav_menu .= '<div id="menu-' . $menu->slug . '"'. $class .'>';
</span><span class="cx">                 } else {
</span><span class="lines">@@ -63,7 +63,7 @@
</span><span class="cx">
</span><span class="cx">         if ( 'div' == $args->container )
</span><span class="cx">                 $nav_menu .= '</div>';
</span><del>-
</del><ins>+        
</ins><span class="cx">         $nav_menu = apply_filters( 'wp_nav_menu', $nav_menu, $args );
</span><span class="cx">
</span><span class="cx">         if ( $args->echo )
</span><span class="lines">@@ -85,25 +85,25 @@
</span><span class="cx"> function wp_get_nav_menu( $args = array() ) {
</span><span class="cx">         $defaults = array( 'menu' => '', 'menu_class' => 'menu', 'context' => 'frontend',
</span><span class="cx">         'fallback_cb' => '', 'before_link' => '', 'after_link' => '', 'before_title' => '', 'after_title' => '', );
</span><del>-
</del><ins>+        
</ins><span class="cx">         $args = wp_parse_args( $args, $defaults );
</span><span class="cx">         $args = apply_filters( 'wp_get_nav_menu_args', $args );
</span><span class="cx">         $args = (object) $args;
</span><del>-
</del><ins>+        
</ins><span class="cx">         // Variable setup
</span><span class="cx">         $nav_menu = '';
</span><span class="cx">         $items = '';
</span><span class="cx">         $current_parent = 0;
</span><span class="cx">         $parent_stack = array();
</span><span class="cx">         $parent_menu_order = array();
</span><del>-
</del><ins>+        
</ins><span class="cx">         // Get the menu object
</span><span class="cx">         $menu = wp_get_nav_menu_object( $args->menu );
</span><del>-
</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, 'backend' );
</span><del>-
</del><ins>+        
</ins><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><span class="cx">                 if ( function_exists($args->fallback_cb) ) {
</span><span class="lines">@@ -111,7 +111,7 @@
</span><span class="cx">                         return call_user_func( $args->fallback_cb, $_args );
</span><span class="cx">                 }
</span><span class="cx">         }
</span><del>-
</del><ins>+        
</ins><span class="cx">         foreach ( $menu_items as $key => $menu_item ) {
</span><span class="cx">                 // Set up the $menu_item variables
</span><span class="cx">                 $menu_item = wp_setup_nav_menu_item( $menu_item, 'frontend' );
</span><span class="lines">@@ -119,10 +119,10 @@
</span><span class="cx">                 $type = $menu_item->append;
</span><span class="cx">                 $maybe_value = 'frontend' == $args->context ? '' : ' value="'. $menu_item->ID .'"';
</span><span class="cx">                 $classes = 'frontend' == $args->context ? ' class="menu-item-type-'. $type . $menu_item->li_class .'"' : '';
</span><del>-
</del><ins>+                
</ins><span class="cx">                 $items .= '<li id="menu-item-'. $menu_item->ID .'"'. $maybe_value . $classes .'>';
</span><span class="cx">                 $items .= wp_get_nav_menu_item( $menu_item, $args->context, $args );
</span><del>-
</del><ins>+                
</ins><span class="cx">                 // Indent children
</span><span class="cx">                 $last_item = ( count( $menu_items ) == $menu_item->menu_order );
</span><span class="cx">                 if ( $last_item || $current_parent != $menu_items[$key + 1]->post_parent ) {
</span><span class="lines">@@ -141,11 +141,11 @@
</span><span class="cx">                         $items .= '</li>';
</span><span class="cx">                 }
</span><span class="cx">         }
</span><del>-
</del><ins>+        
</ins><span class="cx">         // CSS class
</span><span class="cx">         $ul_class = $args->menu_class ? ' class="'. $args->menu_class .'"' : '';
</span><span class="cx">         $nav_menu .= '<ul'. $ul_class .'>';
</span><del>-
</del><ins>+        
</ins><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="cx">                 $items = apply_filters( 'wp_nav_menu_items', $items, $args );
</span><span class="lines">@@ -154,9 +154,9 @@
</span><span class="cx">         } else {
</span><span class="cx">                 $nav_menu .= $items;
</span><span class="cx">         }
</span><del>-
</del><ins>+        
</ins><span class="cx">         $nav_menu .= '</ul>';
</span><del>-
</del><ins>+        
</ins><span class="cx">         return apply_filters( 'wp_get_nav_menu', $nav_menu );
</span><span class="cx"> }
</span><span class="cx">
</span><span class="lines">@@ -179,15 +179,15 @@
</span><span class="cx">                         $attributes .= ( isset($menu_item->classes) && '' != $menu_item->classes ) ? ' class="'. esc_attr($menu_item->classes) .'"' : '';
</span><span class="cx">                         $attributes .= ( isset($menu_item->xfn) && '' != $menu_item->xfn ) ? ' rel="'. esc_attr($menu_item->xfn) .'"' : '';
</span><span class="cx">                         $attributes .= ( isset($menu_item->url) && '' != $menu_item->url ) ? ' href="'. esc_attr($menu_item->url) .'"' : '';
</span><del>-
</del><ins>+                        
</ins><span class="cx">                         $output .= esc_html( $args->before_link );
</span><span class="cx">                         $output .= '<a'. $attributes .'>';
</span><span class="cx">                         $output .= esc_html( $args->before_title . $menu_item->title . $args->after_title );
</span><span class="cx">                         $output .= '</a>';
</span><span class="cx">                         $output .= esc_html( $args->after_link );
</span><del>-
</del><ins>+                        
</ins><span class="cx">                         break;
</span><del>-
</del><ins>+                
</ins><span class="cx">                 case 'backend':
</span><span class="cx">                         $output .= '<dl><dt>';
</span><span class="cx">                         $output .= '<span class="item-title">'. esc_html($menu_item->title) .'</span>';
</span><span class="lines">@@ -204,13 +204,13 @@
</span><span class="cx">                                 $label = $menu_item->append;
</span><span class="cx">                         }
</span><span class="cx">                         $output .= '<span class="item-type">'. esc_html($label) .'</span>';
</span><del>-
</del><ins>+                        
</ins><span class="cx">                         // Actions
</span><span class="cx">                         $output .= '<a class="item-edit thickbox" id="edit'. esc_attr( $menu_item->menu_order ) .'" value="'. esc_attr( $menu_item->menu_order ) .'" title="'. __('Edit Menu Item') .'" href="#TB_inline?height=540&width=300&inlineId=menu-item-settings">'. __('Edit') .'</a> | ';
</span><span class="cx">                         $output .= '<a class="item-delete" id="delete'. esc_attr( $menu_item->menu_order ) .'" value="'. esc_attr( $menu_item->menu_order ) .'">'. __('Delete') .'</a>';
</span><del>-
</del><ins>+                        
</ins><span class="cx">                         $output .= '</dt></dl>';
</span><del>-
</del><ins>+                        
</ins><span class="cx">                         // Menu Item Settings
</span><span class="cx">                         $output .= '<input type="hidden" name="menu-item-db-id[]" id="menu-item-db-id'. esc_attr( $menu_item->menu_order ) .'" value="'. esc_attr( $menu_item->ID ) .'" />';
</span><span class="cx">                         $output .= '<input type="hidden" name="menu-item-object-id[]" id="menu-item-object-id'. esc_attr( $menu_item->menu_order ) .'" value="'. esc_attr( $menu_item->object_id ) .'" />';
</span><span class="lines">@@ -226,11 +226,11 @@
</span><span class="cx">                         $output .= '<input type="hidden" name="menu-item-attr-title[]" id="menu-item-attr-title'. esc_attr( $menu_item->menu_order ) .'" value="'.esc_attr( $menu_item->post_excerpt ) .'" />';
</span><span class="cx">                         $output .= '<input type="hidden" name="menu-item-target[]" id="menu-item-target'. esc_attr( $menu_item->menu_order ) .'" value="'. esc_attr( $menu_item->target ) .'" />';
</span><span class="cx">                         break;
</span><del>-
</del><ins>+                
</ins><span class="cx">                 case 'custom':
</span><span class="cx">                         $menu_id = 'menu-item-' . $menu_item->db_id;
</span><span class="cx">                         $output .= '<label class="menu-item-title"><input type="checkbox" id="'. esc_attr( $menu_id ) .'" name="'. esc_attr( $menu_item->title ) .'" value="'. esc_attr( $menu_item->url ) .'" />'. $menu_item->title .'</label>';
</span><del>-
</del><ins>+                        
</ins><span class="cx">                         // Menu item hidden fields
</span><span class="cx">                         $output .= '<input type="hidden" class="menu-item-db-id" value="'. esc_attr( $menu_item->db_id ) .'" />';
</span><span class="cx">                         $output .= '<input type="hidden" class="menu-item-object-id" value="'. esc_attr( $menu_item->object_id ) .'" />';
</span><span class="lines">@@ -245,12 +245,12 @@
</span><span class="cx">                         $output .= '<input type="hidden" class="menu-item-classes" value="'. esc_attr( $menu_item->classes ) .'" />';
</span><span class="cx">                         $output .= '<input type="hidden" class="menu-item-xfn" value="'. esc_attr( $menu_item->xfn ) .'" />';
</span><span class="cx">                         break;
</span><del>-
</del><ins>+                
</ins><span class="cx">                 case 'taxonomy':
</span><span class="cx">                 case 'post_type':
</span><span class="cx">                         $menu_id = 'menu-item-' . $menu_item->db_id;
</span><span class="cx">                         $output .= '<label class="menu-item-title"><input type="checkbox" id="'. esc_attr( $menu_id ) .'" name="'. esc_attr( $menu_item->title ) .'" value="'. esc_attr( $menu_item->url ) .'" />'. $menu_item->title .'</label>';
</span><del>-
</del><ins>+                        
</ins><span class="cx">                         // Menu item hidden fields
</span><span class="cx">                         $output .= '<input type="hidden" class="menu-item-db-id" value="0" />';
</span><span class="cx">                         $output .= '<input type="hidden" class="menu-item-object-id" value="'. esc_attr( $menu_item->object_id ) .'" />';
</span><span class="lines">@@ -262,7 +262,7 @@
</span><span class="cx">                         $output .= '<input type="hidden" class="menu-item-append" value="'. esc_attr( $menu_item->append ) .'" />';
</span><span class="cx">                         break;
</span><span class="cx">         }
</span><del>-
</del><ins>+        
</ins><span class="cx">         return $output;
</span><span class="cx"> }
</span><span class="cx"> ?>
</span><span class="cx">\ No newline at end of file
</span></span></pre>
</div>
</div>
</body>
</html>