WordPress.org

Make WordPress Core


Ignore:
Timestamp:
09/24/2013 04:00:14 PM (7 years ago)
Author:
helen
Message:

Add classes to menus to indicate that an item has sub-items: .menu-item-has-children for wp_nav_menu() and .page_item_has_children for wp_page_menu(). props hotchkissconsulting. fixes #23834.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/post-template.php

    r25582 r25602  
    956956        $walker = $r['walker'];
    957957
     958    foreach ( (array) $pages as $page ) {
     959        if ( $page->post_parent )
     960            $r['pages_with_children'][ $page->post_parent ] = true;
     961    }
     962
    958963    $args = array($pages, $depth, $r, $current_page);
    959964    return call_user_func_array(array($walker, 'walk'), $args);
     
    10441049        extract($args, EXTR_SKIP);
    10451050        $css_class = array('page_item', 'page-item-'.$page->ID);
     1051
     1052        if( isset( $args['pages_with_children'][ $page->ID ] ) )
     1053            $css_class[] = 'page_item_has_children';
     1054
    10461055        if ( !empty($current_page) ) {
    10471056            $_current_page = get_post( $current_page );
Note: See TracChangeset for help on using the changeset viewer.