Attachment URLs should only be forced to SSL on the front end.

Detecting SSL status on the Dashboard introduces problems when writing content
that is saved to the database and then displayed on the front end, where SSL
may be optional (or impossible, due to self-signed certificates). The new
approach parallels the logic in `get_home_url()` for forcing HTTPS.

See [31614] #15928 for background.

Fixes #32112 for 4.2 branch.

Built from https://develop.svn.wordpress.org/branches/4.2@32384


git-svn-id: http://core.svn.wordpress.org/branches/4.2@32354 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Boone Gorges 2015-05-06 16:21:29 +00:00
parent 80d7ad721a
commit 0baf141106

View File

@ -4992,12 +4992,9 @@ function wp_get_attachment_url( $post_id = 0 ) {
$url = get_the_guid( $post->ID );
}
/*
* If currently on SSL, prefer HTTPS URLs when we know they're supported by the domain
* (which is to say, when they share the domain name of the current SSL page).
*/
if ( is_ssl() && 'https' !== substr( $url, 0, 5 ) && parse_url( $url, PHP_URL_HOST ) === $_SERVER['HTTP_HOST'] ) {
$url = set_url_scheme( $url, 'https' );
// On SSL front-end, URLs should be HTTPS.
if ( is_ssl() && ! is_admin() && 'wp-login.php' !== $GLOBALS['pagenow'] ) {
$url = set_url_scheme( $url );
}
/**