Use 'localhost' if $_SERVER['HTTP_HOST'] is empty

This commit is contained in:
denisbaranov
2019-04-10 18:19:56 +03:00
parent a3fb633b5c
commit dc213aab31
+3 -2
View File
@@ -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, '?' );