Changeset 13293
- Timestamp:
- 02/22/2010 05:27:34 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-includes/custom-navigation.php
r13287 r13293 117 117 118 118 $parent_stack = array(); 119 $current_parent = 0; 119 120 $parent_menu_order = array(); 120 121 // Display Loop 121 foreach ( $menu_items as $ menu_item ) {122 foreach ( $menu_items as $key => $menu_item ) { 122 123 $menu_type = get_post_meta($menu_item->ID, 'menu_type', true); 123 124 $object_id = get_post_meta($menu_item->ID, 'object_id', true); … … 200 201 } 201 202 */ 202 // Indent children203 if ( empty( $parent_stack ) ) {204 array_unshift( $parent_stack, $menu_item->ID );205 } elseif ( $menu_item->post_parent > 0 ) {206 if ( $menu_item->post_parent == $parent_stack[0] ) { ?>207 <ul>208 <?php array_unshift( $parent_stack, $menu_item->ID );209 } elseif ( count( $parent_stack ) > 1 && $menu_item->post_parent == $parent_stack[1] ) { ?>210 </li>211 <?php $parent_stack[0] = $menu_item->ID;212 } elseif ( in_array( $menu_item->post_parent, $parent_stack ) ) {213 while ( !empty( $parent_stack ) && $menu_item->post_parent != $parent_stack[0] ) { ?>214 </li></ul>215 <? array_shift( $parent_stack );216 }217 }218 } else {219 while ( count( $parent_stack ) > 1 ) { ?>220 </li></ul>221 <? array_shift( $parent_stack );222 } ?>223 </li>224 <?php $parent_stack[0] = $menu_item->ID;225 }226 227 203 // List Items 228 204 ?><li id="menu-<?php echo $menu_item->ID; ?>" value="<?php echo $menu_item->ID; ?>" <?php echo $li_class; ?>><?php … … 290 266 <?php 291 267 } 292 } 293 while ( !empty( $parent_stack ) ) { ?> 294 </li></ul> 295 <? array_shift( $parent_stack ); 296 } 297 if ( !empty( $menu_items ) ) { ?> 268 // Indent children 269 $last_item = ( count( $menu_items ) == $menu_item->menu_order ); 270 if ( $last_item || $current_parent != $menu_items[ $key + 1 ]->post_parent ) { 271 if ( $last_item || in_array( $menu_items[ $key + 1 ]->post_parent, $parent_stack ) ) { ?> 298 272 </li> 299 <?php } 273 <?php while ( !empty( $parent_stack ) && ($last_item || $menu_items[ $key + 1 ]->post_parent != $current_parent ) ) { ?> 274 </ul> 275 </li> 276 <? $current_parent = array_pop( $parent_stack ); 277 } ?> 278 <?php } else { 279 array_push( $parent_stack, $current_parent ); 280 $current_parent = $menu_item->ID; ?> 281 <ul> 282 <?php } 283 } else { ?> 284 </li> 285 <?php } 286 } 300 287 } 301 288 //@todo: implement menu heirarchy
Note: See TracChangeset
for help on using the changeset viewer.