WordPress.org

Make WordPress Core

Ticket #13543: current_page_parent-back-compat.13543.diff

File current_page_parent-back-compat.13543.diff, 1.6 KB (added by filosofo, 8 years ago)
  • wp-includes/nav-menu-template.php

     
    333333                } elseif (
    334334                        $menu_item->object_id == $queried_object_id &&
    335335                        (
    336                                 ( ! empty( $home_page_id ) && 'post_type' == $menu_item->type && $wp_query->is_home && $home_page_id = $menu_item->object_id ) ||
     336                                ( ! empty( $home_page_id ) && 'post_type' == $menu_item->type && $wp_query->is_home && $home_page_id == $menu_item->object_id ) ||
    337337                                ( 'post_type' == $menu_item->type && $wp_query->is_singular ) ||
    338338                                ( 'taxonomy' == $menu_item->type && ( $wp_query->is_category || $wp_query->is_tag || $wp_query->is_tax ) )
    339339                        )
    340340                ) {
    341                         $menu_items[$key]->classes = trim( $menu_item->classes . ' ' . 'current-menu-item' );
     341                        $menu_items[$key]->classes = trim( $menu_items[$key]->classes . ' ' . 'current-menu-item' );
    342342                        $active_parent_item_ids[] = (int) $menu_item->menu_item_parent;
    343343                        $active_parent_object_ids[] = (int) $menu_item->post_parent;
    344344                        $active_object = $menu_item->object;
     
    356356                                $active_object = $menu_item->object;
    357357                        }
    358358                }
     359               
     360                // back-compat with wp_page_menu: add "current_page_parent" to static home page link for any non-page query
     361                if ( ! empty( $home_page_id ) && 'post_type' == $menu_item->type && empty( $wp_query->is_page ) && $home_page_id == $menu_item->object_id )
     362                        $menu_items[$key]->classes = trim( $menu_items[$key]->classes . ' ' . 'current_page_parent' );
    359363        }
    360364
    361365        $active_parent_item_ids = array_filter( array_unique( $active_parent_item_ids ) );