LLMS_HTTPS::get_force_redirect_url( bool $https = true )
Retrieve the http/s version of the current url.
Parameters Parameters
- $https
-
(bool) (Optional) If true, gets the HTTPS url, otherwise gets url without HTTPS
Default value: true
Return Return
(string)
Source Source
File: includes/class.llms.https.php
protected function get_force_redirect_url( $https = true ) {
$uri = ! empty( $_SERVER['REQUEST_URI'] ) ? filter_var( wp_unslash( $_SERVER['REQUEST_URI'] ), FILTER_SANITIZE_URL ) : '';
// URI is http, switch it to https.
if ( $uri && 0 === strpos( $uri, 'http' ) ) {
return $https ? preg_replace( '|^http://|', 'https://', $uri ) : preg_replace( '|^https://|', 'http://', $uri );
}
// URI doesn't have a protocol, build a new uri.
$redirect = $https ? 'https://' : 'http://';
if ( ! empty( $_SERVER['HTTP_X_FORWARDED_HOST'] ) ) {
$redirect .= sanitize_text_field( wp_unslash( $_SERVER['HTTP_X_FORWARDED_HOST'] ) );
} elseif ( ! empty( $_SERVER['HTTP_HOST'] ) ) {
$redirect .= sanitize_text_field( wp_unslash( $_SERVER['HTTP_HOST'] ) );
}
$redirect .= $uri;
return $redirect;
}
Expand full source code Collapse full source code View on GitHub
Changelog Changelog
| Version | Description |
|---|---|
| 3.35.1 | Introduced. |