Make WordPress Core


Ignore:
Timestamp:
05/25/2010 02:25:06 PM (15 years ago)
Author:
ryan
Message:

Add ancestor classes. Props filosofo. see #12812

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-includes/nav-menu-template.php

    r14876 r14881  
    293293            }
    294294        }
     295    } elseif ( ! empty( $queried_object->post_type ) && is_post_type_hierarchical( $queried_object->post_type ) ) {
     296        _get_post_ancestors( $queried_object );
    295297    }
    296298
     
    334336
    335337    // set parent's class
    336     if ( ! empty( $active_parent_item_ids ) || ! empty( $active_parent_object_ids ) ) {
    337         foreach( (array) $menu_items as $key => $parent_item ) {
    338             if ( in_array( $parent_item->db_id, $active_parent_item_ids ) )
    339                 $menu_items[$key]->classes = trim( $parent_item->classes . ' ' . 'current-menu-parent' );
    340             if ( in_array( $parent_item->object_id, $active_parent_object_ids ) )
    341                 $menu_items[$key]->classes = trim( $parent_item->classes . ' ' . 'current-' . $active_object . '-parent' );
    342         }
     338    foreach( (array) $menu_items as $key => $parent_item ) {
     339        if ( 'post_type' == $parent_item->type && is_post_type_hierarchical( $queried_object->post_type ) && in_array( $parent_item->object_id, $queried_object->ancestors ) )
     340            $menu_items[$key]->classes = trim( $parent_item->classes . ' ' . 'current-' . $queried_object->post_type . '-ancestor' );
     341        if ( in_array( $parent_item->db_id, $active_parent_item_ids ) )
     342            $menu_items[$key]->classes = trim( $parent_item->classes . ' ' . 'current-menu-parent' );
     343        if ( in_array( $parent_item->object_id, $active_parent_object_ids ) )
     344            $menu_items[$key]->classes = trim( $parent_item->classes . ' ' . 'current-' . $active_object . '-parent' );
    343345    }
    344346}
Note: See TracChangeset for help on using the changeset viewer.