mirror of
git://develop.git.wordpress.org/
synced 2025-02-27 10:02:43 +01:00
Check custom links, including a home link, against the current URL to see if we should add current-menu-item. props ptahdunbar, fixes #13213, see #13220.
git-svn-id: https://develop.svn.wordpress.org/trunk@14457 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
53e65714a1
commit
1ec3a58cd1
@ -72,11 +72,16 @@ class Walker_Nav_Menu extends Walker {
|
||||
|
||||
$classes = array( 'menu-item', 'menu-item-type-'. $item->type, $item->classes );
|
||||
|
||||
if ( 'custom' != $item->object )
|
||||
if ( 'custom' == $item->object ) {
|
||||
$current_url = ( is_ssl() ? 'https://' : 'http://' ) . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
|
||||
$item_url = strpos( $item->url, '#' ) ? substr( $item->url, 0, strpos( $item->url, '#' ) ) : $item->url;
|
||||
if ( $item_url == $current_url )
|
||||
$classes[] = 'current-menu-item';
|
||||
} else {
|
||||
$classes[] = 'menu-item-object-'. $item->object;
|
||||
|
||||
if ( $item->object_id == $wp_query->get_queried_object_id() )
|
||||
$classes[] = 'current-menu-item';
|
||||
if ( $item->object_id == $wp_query->get_queried_object_id() )
|
||||
$classes[] = 'current-menu-item';
|
||||
}
|
||||
|
||||
// @todo add classes for parent/child relationships
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user