Skip to content

Commit 8eaa459

Browse files
authored
Update force-https.php
1 parent 0a8a69b commit 8eaa459

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

force-https.php

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,14 +52,21 @@ function force_https_redirect() {
5252
add_action( $hook, 'force_https_redirect', 10 );
5353
}
5454

55-
// enforce https on all urls by replacing http with https
55+
// enforce https on valid urls and replace http in text content
5656
function force_https_securize_url( $value ) {
57-
// return original if not string
57+
58+
// return original if not a string
5859
if ( ! is_string( $value ) ) {
5960
return $value;
6061
}
61-
// force https on valid urls, replace in text/html
62-
return ( strpos( $value, 'http://' ) === 0 ) ? set_url_scheme( $value, 'https' ) : str_replace( 'http://', 'https://', $value );
62+
63+
// enforce https for valid urls
64+
if ( strpos( $value, 'http://' ) === 0 ) {
65+
return set_url_scheme( $value, 'https' );
66+
}
67+
68+
// replace http with https in text or html content
69+
return str_replace( 'http://', 'https://', $value );
6370
}
6471

6572
// apply https to all relevant wordpress filters

0 commit comments

Comments
 (0)