Make WordPress Core

Ticket #16724: current-menu-item-custom-link-path.diff

File current-menu-item-custom-link-path.diff, 1.1 KB (added by chrisbliss18, 14 years ago)
  • wp-includes/nav-menu-template.php

    diff --git wp-includes/nav-menu-template.php wp-includes/nav-menu-template.php
    index 21898ab..ea795eb 100644
    function _wp_menu_item_classes_by_context( &$menu_items ) { 
    360360
    361361                // if the menu item corresponds to the currently-requested URL
    362362                } elseif ( 'custom' == $menu_item->object ) {
    363                         $current_url = untrailingslashit( ( is_ssl() ? 'https://' : 'http://' ) . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'] );
    364363                        $item_url = untrailingslashit( strpos( $menu_item->url, '#' ) ? substr( $menu_item->url, 0, strpos( $menu_item->url, '#' ) ) : $menu_item->url );
     364                        if ( 0 === strpos( $item_url, '/' ) )
     365                                $item_url = untrailingslashit( ( is_ssl() ? 'https://' : 'http://' ) . $_SERVER['HTTP_HOST'] ) . $item_url;
     366
     367                        $current_url = untrailingslashit( ( is_ssl() ? 'https://' : 'http://' ) . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'] );
    365368                        $_indexless_current = untrailingslashit( preg_replace( '/index.php$/', '', $current_url ) );
    366369
    367370                        if ( in_array( $item_url, array( $current_url, $_indexless_current ) ) ) {