WordPress.org

Make WordPress Core

Ticket #13220: highlight_home_link.4.diff

File highlight_home_link.4.diff, 872 bytes (added by ptahdunbar, 8 years ago)
  • wp-includes/nav-menu-template.php

     
    7575                if ( 'custom' != $item->object )
    7676                        $classes[] = 'menu-item-object-'. $item->object;
    7777
    78                 if ( $item->object_id == $wp_query->get_queried_object_id() )
     78                // Get the requested uri
     79                $protocol = parse_url($item->url);
     80                $current_url = "{$protocol['scheme']}://{$_SERVER['HTTP_HOST']}{$_SERVER['REQUEST_URI']}";
     81
     82                // remove any anchors to compare
     83                $item_url = preg_replace( '/#(.*)/', '', $item->url );
     84
     85                if ( $item->object_id == $wp_query->get_queried_object_id() || ( 'custom' == $item->object && $item_url == $current_url ) )
    7986                        $classes[] = 'current-menu-item';
    8087
    8188                // @todo add classes for parent/child relationships