Make WordPress Core

Ticket #13220: highlight_home_link.4.2.2.diff

File highlight_home_link.4.2.2.diff, 1.2 KB (added by ptahdunbar, 14 years ago)
  • wp-includes/nav-menu-template.php

     
    6969                $indent = ( $depth ) ? str_repeat( "\t", $depth ) : '';
    7070
    7171                $classes = $value = '';
    72 
    7372                $classes = array( 'menu-item', 'menu-item-type-'. $item->type, $item->classes );
    7473
    7574                if ( 'custom' != $item->object )
    7675                        $classes[] = 'menu-item-object-'. $item->object;
    7776
    78                 if ( $item->object_id == $wp_query->get_queried_object_id() )
     77                // Get the requested url
     78                $current_url = ( is_ssl() ? 'https://' : 'http://' ) . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
     79
     80                // remove any anchor links
     81                $item_url = strpos( $item->url, '#' ) ? substr( $item->url, 0, strpos( $item->url, '#' ) ) : $item->url;
     82
     83                if ( $item->object_id == $wp_query->get_queried_object_id() || ( 'custom' == $item->object && $item_url == $current_url ) )
    7984                        $classes[] = 'current-menu-item';
    8085
    8186                // @todo add classes for parent/child relationships
     
    289294        return call_user_func_array( array(&$walker, 'walk'), $args );
    290295}
    291296
    292 ?>
     297?>
     298 No newline at end of file