Make WordPress Core

Ticket #38486: 38486.diff

File 38486.diff, 1.2 KB (added by henry.wright, 8 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..559939a 100644
    function _wp_menu_item_classes_by_context( &$menu_items ) { 
    431431                                $classes[] = 'menu-item-home';
    432432                }
    433433
    434                 // back-compat with wp_page_menu: add "current_page_parent" to static home page link for any non-page query
    435                 if ( ! empty( $home_page_id ) && 'post_type' == $menu_item->type && empty( $wp_query->is_page ) && $home_page_id == $menu_item->object_id )
     434                // Get an array of all public post types.
     435                $post_types = get_post_types( array(
     436                        'public' => true
     437                ) );
     438
     439                // Remove 'post' from the array of public post types.
     440                $post_types = array_diff( $post_types, array( 'post' ) );
     441
     442                // back-compat with wp_page_menu: add "current_page_parent" to static home page link for any non-page, non-cpt query.
     443                if ( ! empty( $home_page_id ) && 'post_type' == $menu_item->type && empty( $wp_query->is_page ) && $home_page_id == $menu_item->object_id && ! is_post_type_archive() && ! is_singular( $post_types ) )
    436444                        $classes[] = 'current_page_parent';
    437445
    438446                $menu_items[$key]->classes = array_unique( $classes );