<!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>[15544] trunk/wp-includes/nav-menu-template.php:
  Make menus manipulation easier for plugin developers</title>
</head>
<body>

<div id="msg">
<dl>
<dt>Revision</dt> <dd><a href="http://trac.wordpress.org/changeset/15544">15544</a></dd>
<dt>Author</dt> <dd>nbachiyski</dd>
<dt>Date</dt> <dd>2010-08-27 16:13:39 +0000 (Fri, 27 Aug 2010)</dd>
</dl>

<h3>Log Message</h3>
<pre>Make menus manipulation easier for plugin developers

 * Add a wp_nav_menu_objects filter, which gets a sorted list of all menu node objects in the currently rendered menu
 * Add current, current_item_ancestor and current_item_parent boolean member variables to each menu node object, which are true when the item has the current-menu-item, current-menu-ancestor or current-menu-parent CSS class respectively</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 (15543 => 15544)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-includes/nav-menu-template.php        2010-08-27 15:41:32 UTC (rev 15543)
+++ trunk/wp-includes/nav-menu-template.php        2010-08-27 16:13:39 UTC (rev 15544)
</span><span class="lines">@@ -196,6 +196,8 @@
</span><span class="cx">                 $sorted_menu_items[$menu_item-&gt;menu_order] = $menu_item;
</span><span class="cx"> 
</span><span class="cx">         unset($menu_items);
</span><ins>+        
+        $sorted_menu_items = apply_filters( 'wp_nav_menu_objects', $sorted_menu_items, $args );
</ins><span class="cx"> 
</span><span class="cx">         $items .= walk_nav_menu_tree( $sorted_menu_items, $args-&gt;depth, $args );
</span><span class="cx">         unset($sorted_menu_items);
</span><span class="lines">@@ -312,6 +314,9 @@
</span><span class="cx">         $possible_object_parents = array_filter( $possible_object_parents );
</span><span class="cx"> 
</span><span class="cx">         foreach ( (array) $menu_items as $key =&gt; $menu_item ) {
</span><ins>+                
+                $menu_items[$key]-&gt;current = false;
+                
</ins><span class="cx">                 $classes = (array) $menu_item-&gt;classes;
</span><span class="cx">                 $classes[] = 'menu-item';
</span><span class="cx">                 $classes[] = 'menu-item-type-' . $menu_item-&gt;type;
</span><span class="lines">@@ -332,6 +337,7 @@
</span><span class="cx">                         )
</span><span class="cx">                 ) {
</span><span class="cx">                         $classes[] = 'current-menu-item';
</span><ins>+                        $menu_items[$key]-&gt;current = true;
</ins><span class="cx">                         $_anc_id = (int) $menu_item-&gt;db_id;
</span><span class="cx"> 
</span><span class="cx">                         while(
</span><span class="lines">@@ -359,6 +365,7 @@
</span><span class="cx">                         
</span><span class="cx">                         if ( in_array( $item_url, array( $current_url, $_indexless_current ) ) ) {
</span><span class="cx">                                 $classes[] = 'current-menu-item';
</span><ins>+                                $menu_items[$key]-&gt;current = true;
</ins><span class="cx">                                 $_anc_id = (int) $menu_item-&gt;db_id;
</span><span class="cx"> 
</span><span class="cx">                                 while(
</span><span class="lines">@@ -394,7 +401,9 @@
</span><span class="cx">         // set parent's class
</span><span class="cx">         foreach ( (array) $menu_items as $key =&gt; $parent_item ) {
</span><span class="cx">                 $classes = (array) $parent_item-&gt;classes;
</span><del>-
</del><ins>+                $menu_items[$key]-&gt;current_item_ancestor = false;
+                $menu_items[$key]-&gt;current_item_parrent = false;
+                
</ins><span class="cx">                 if (
</span><span class="cx">                         isset( $parent_item-&gt;type ) &amp;&amp;
</span><span class="cx">                         (
</span><span class="lines">@@ -419,9 +428,12 @@
</span><span class="cx"> 
</span><span class="cx">                 if ( in_array(  intval( $parent_item-&gt;db_id ), $active_ancestor_item_ids ) ) {
</span><span class="cx">                         $classes[] = 'current-menu-ancestor';
</span><ins>+                        $menu_items[$key]-&gt;current_item_ancestor = true;
</ins><span class="cx">                 }
</span><del>-                if ( in_array( $parent_item-&gt;db_id, $active_parent_item_ids ) )
</del><ins>+                if ( in_array( $parent_item-&gt;db_id, $active_parent_item_ids ) ) {
</ins><span class="cx">                         $classes[] = 'current-menu-parent';
</span><ins>+                        $menu_items[$key]-&gt;current_item_parent = true;
+                }
</ins><span class="cx">                 if ( in_array( $parent_item-&gt;object_id, $active_parent_object_ids ) )
</span><span class="cx">                         $classes[] = 'current-' . $active_object . '-parent';
</span><span class="cx"> 
</span><span class="lines">@@ -464,6 +476,4 @@
</span><span class="cx">         $_used_ids[] = $item-&gt;ID;
</span><span class="cx">         return $id;
</span><span class="cx"> }
</span><del>-add_filter( 'nav_menu_item_id', '_nav_menu_item_id_use_once', 10, 2 );
-
-?&gt;
</del><ins>+add_filter( 'nav_menu_item_id', '_nav_menu_item_id_use_once', 10, 2 );
</ins><span class="cx">\ No newline at end of file
</span></span></pre>
</div>
</div>

</body>
</html>