Avoid PHP notices in redirect_canonical() and _wp_menu_item_classes_by_context() if $_SERVER['HTTP_HOST'] is not set.

fixes #32229.

git-svn-id: https://develop.svn.wordpress.org/trunk@33775 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Sergey Biryukov 2015-08-28 03:30:55 +00:00
parent 0c19c94561
commit 923498aaa4
2 changed files with 2 additions and 2 deletions

View File

@ -59,7 +59,7 @@ function redirect_canonical( $requested_url = null, $do_redirect = true ) {
return;
}
if ( !$requested_url ) {
if ( ! $requested_url && isset( $_SERVER['HTTP_HOST'] ) ) {
// build the URL in the address bar
$requested_url = is_ssl() ? 'https://' : 'http://';
$requested_url .= $_SERVER['HTTP_HOST'];

View File

@ -553,7 +553,7 @@ function _wp_menu_item_classes_by_context( &$menu_items ) {
$active_object = $menu_item->object;
// if the menu item corresponds to the currently-requested URL
} elseif ( 'custom' == $menu_item->object ) {
} elseif ( 'custom' == $menu_item->object && isset( $_SERVER['HTTP_HOST'] ) ) {
$_root_relative_current = untrailingslashit( $_SERVER['REQUEST_URI'] );
$current_url = set_url_scheme( 'http://' . $_SERVER['HTTP_HOST'] . $_root_relative_current );
$raw_item_url = strpos( $menu_item->url, '#' ) ? substr( $menu_item->url, 0, strpos( $menu_item->url, '#' ) ) : $menu_item->url;