From dc213aab319fee875da68358355ca82940b14ae2 Mon Sep 17 00:00:00 2001 From: denisbaranov Date: Wed, 10 Apr 2019 18:19:56 +0300 Subject: [PATCH] Use 'localhost' if $_SERVER['HTTP_HOST'] is empty --- includes/core/class-permalinks.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/includes/core/class-permalinks.php b/includes/core/class-permalinks.php index 7f2408cf..010862a8 100644 --- a/includes/core/class-permalinks.php +++ b/includes/core/class-permalinks.php @@ -132,8 +132,9 @@ if ( ! class_exists( 'um\core\Permalinks' ) ) { function get_current_url( $no_query_params = false ) { //use WP native function for fill $_SERVER variables by correct values wp_fix_server_vars(); - - $page_url = ( is_ssl() ? 'https://' : 'http://' ) . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']; + + $host = isset( $_SERVER['HTTP_HOST'] ) ? $_SERVER['HTTP_HOST'] : 'localhost'; + $page_url = ( is_ssl() ? 'https://' : 'http://' ) . $host . $_SERVER['REQUEST_URI']; if ( $no_query_params == true ) { $page_url = strtok( $page_url, '?' );