WordPress.org

Make WordPress Core

Ticket #36012: 36012.patch

File 36012.patch, 697 bytes (added by Mista-Flo, 16 months ago)

Add classes for all custom post types and custom taxonomies - current ancestors

  • wp-includes/nav-menu-template.php

    diff --git a/wp-includes/nav-menu-template.php b/wp-includes/nav-menu-template.php
    index 45d9e47de4..dc684c327e 100644
    a b function _wp_menu_item_classes_by_context( &$menu_items ) { 
    553553                        if ( in_array( 'current-menu-parent', $classes ) ) {
    554554                                $classes[] = 'current_page_parent';
    555555                        }
    556                         if ( in_array( 'current-menu-ancestor', $classes ) ) {
    557                                 $classes[] = 'current_page_ancestor';
    558                         }
     556                }
     557
     558                if ( in_array( 'current-menu-ancestor', $classes ) ) {
     559                        $classes[] = sprintf( 'current_%s_ancestor', $parent_item->object );
    559560                }
    560561
    561562                $menu_items[ $key ]->classes = array_unique( $classes );