Make WordPress Core

Ticket #38836: 38836.diff

File 38836.diff, 1.0 KB (added by henry.wright, 7 years ago)
  • src/wp-includes/nav-menu-template.php

    diff --git src/wp-includes/nav-menu-template.php src/wp-includes/nav-menu-template.php
    index 8895476..36cc8f4 100644
    function _wp_menu_item_classes_by_context( &$menu_items ) { 
    431431                                $classes[] = 'menu-item-home';
    432432                }
    433433
     434                // Get an array of all public custom post types.
     435                $post_types = get_post_types( array(
     436                        'public'   => true,
     437                        '_builtin' => false
     438                ) );
     439
     440                // Check if a custom post type single item is being viewed.
     441                if ( is_singular( $post_types ) ) {
     442
     443                        // Get the post type being viewed.
     444                        $post_type = get_post_type();
     445
     446                        if ( $post_type === $menu_item->object ) {
     447                                $classes[] = 'current_page_parent';
     448                        }
     449                }
     450
    434451                // back-compat with wp_page_menu: add "current_page_parent" to static home page link for any non-page query
    435452                if ( ! empty( $home_page_id ) && 'post_type' == $menu_item->type && empty( $wp_query->is_page ) && $home_page_id == $menu_item->object_id )
    436453                        $classes[] = 'current_page_parent';