REST API: In get_rest_url(), check if $_SERVER['SERVER_NAME'] is set to avoid a PHP warning in CLI context.
Props paulschreiber. Fixes #47854. Built from https://develop.svn.wordpress.org/trunk@45771 git-svn-id: http://core.svn.wordpress.org/trunk@45582 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
@@ -373,7 +373,7 @@ function get_rest_url( $blog_id = null, $path = '/', $scheme = 'rest' ) {
|
||||
$url = add_query_arg( 'rest_route', $path, $url );
|
||||
}
|
||||
|
||||
if ( is_ssl() ) {
|
||||
if ( is_ssl() && isset( $_SERVER['SERVER_NAME'] ) ) {
|
||||
// If the current host is the same as the REST URL host, force the REST URL scheme to HTTPS.
|
||||
if ( $_SERVER['SERVER_NAME'] === parse_url( get_home_url( $blog_id ), PHP_URL_HOST ) ) {
|
||||
$url = set_url_scheme( $url, 'https' );
|
||||
|
||||
Reference in New Issue
Block a user