Skip to content

Commit a369ddf

Browse files
authored
Update force-https.php
1 parent 694a6d7 commit a369ddf

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

force-https.php

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -61,12 +61,15 @@ function force_https_securize_url( $value ) {
6161
}
6262

6363
// enforce https for valid urls
64-
if ( strpos( $value, 'http://' ) === 0 ) {
65-
return set_url_scheme( $value, 'https' );
64+
$secure_value = set_url_scheme( $value, 'https' );
65+
66+
// return if url scheme was changed (valid URL handled)
67+
if ( $secure_value !== $value ) {
68+
return $secure_value;
6669
}
6770

68-
// replace http with https in text or html content
69-
return str_replace( 'http://', 'https://', $value );
71+
// replace http with https in text or html content only if needed
72+
return ( strpos( $value, 'http://' ) !== false ) ? str_replace( 'http://', 'https://', $value ) : $value;
7073
}
7174

7275
// apply https to all relevant wordpress filters

0 commit comments

Comments
 (0)