/** * Returns full URL from relative one */ public static function url_relative_to_full($relative_url) { $relative_url = Util_Environment::path_remove_dots($relative_url); $rel = parse_url($relative_url); // it's full url already if (isset($rel['scheme']) || isset($rel['host'])) { return $relative_url; } if (!isset($rel['host'])) { $rel['host'] = parse_url(get_home_url(), PHP_URL_HOST); } $scheme = isset($rel['scheme']) ? $rel['scheme'] . '://' : '//'; $host = isset($rel['host']) ? $rel['host'] : ''; $port = isset($rel['port']) ? ':' . $rel['port'] : ''; $path = isset($rel['path']) ? $rel['path'] : ''; $query = isset($rel['query']) ? '?' . $rel['query'] : ''; return "{$scheme}{$host}{$port}{$path}{$query}"; }