WordPress.org

Make WordPress Core

Changeset 14457


Ignore:
Timestamp:
05/04/2010 10:01:56 PM (8 years ago)
Author:
nacin
Message:

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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-includes/nav-menu-template.php

    r14450 r14457  
    7373        $classes = array( 'menu-item', 'menu-item-type-'. $item->type, $item->classes );
    7474
    75         if ( 'custom' != $item->object )
     75        if ( 'custom' == $item->object ) {
     76            $current_url = ( is_ssl() ? 'https://' : 'http://' ) . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
     77            $item_url = strpos( $item->url, '#' ) ? substr( $item->url, 0, strpos( $item->url, '#' ) ) : $item->url;
     78            if ( $item_url == $current_url )
     79                $classes[] = 'current-menu-item';
     80        } else {
    7681            $classes[] = 'menu-item-object-'. $item->object;
    77 
    78         if ( $item->object_id == $wp_query->get_queried_object_id() )
    79             $classes[] = 'current-menu-item';
     82            if ( $item->object_id == $wp_query->get_queried_object_id() )
     83                $classes[] = 'current-menu-item';
     84        }
    8085
    8186        // @todo add classes for parent/child relationships
Note: See TracChangeset for help on using the changeset viewer.