REST API: In the admin area, ensure the REST API endpoint URL is forced to `https` when necessary.

In this situation, a site which uses `http` on the front end but `https` in the admin area is more likely to have a working REST API endpoint URL when used in the admin area.

Props mohanjith, westonruter, jnylen0

Fixes #36451


git-svn-id: https://develop.svn.wordpress.org/trunk@40843 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
John Blackbourn 2017-05-25 18:01:16 +00:00
parent cbc3829b62
commit 05434d0c07
1 changed files with 8 additions and 0 deletions

View File

@ -337,6 +337,14 @@ function get_rest_url( $blog_id = null, $path = '/', $scheme = 'rest' ) {
}
}
if ( is_admin() && force_ssl_admin() ) {
// In this situation the home URL may be http:, and `is_ssl()` may be
// false, but the admin is served over https: (one way or another), so
// REST API usage will be blocked by browsers unless it is also served
// over HTTPS.
$url = set_url_scheme( $url, 'https' );
}
/**
* Filters the REST URL.
*