@@ -39,8 +39,8 @@ function force_https_filter_home( $value ) {
3939// enforce https by redirecting non-ssl requests on frontend, admin, and login pages
4040function force_https_redirect () {
4141
42- // exit if already using https, headers are sent, or running via cli
43- if ( is_ssl () || headers_sent () || defined ( 'WP_CLI ' ) ) {
42+ // exit if already using https, headers are sent, or running via cli or ajax, or no request uri exists
43+ if ( is_ssl () || headers_sent () || defined ( 'WP_CLI ' ) || ( defined ( ' DOING_AJAX ' ) && DOING_AJAX ) || ! isset ( $ _SERVER [ ' REQUEST_URI ' ] ) ) {
4444 return ;
4545 }
4646
@@ -50,9 +50,9 @@ function force_https_redirect() {
5050}
5151
5252// apply https redirect during initialization, admin, and login
53- foreach ( [ 'init ' , 'admin_init ' , ' login_init ' ] as $ hook ) {
54- add_action ( $ hook , 'force_https_redirect ' , 10 );
55- }
53+ add_action ( 'init ' , 'force_https_redirect ' , 10 );
54+ add_action ( ' admin_init ' , 'force_https_redirect ' , 10 );
55+ add_action ( ' login_init ' , ' force_https_redirect ' , 10 );
5656
5757// enforce https for valid urls only
5858function force_https_securize_url ( $ value ) {
@@ -125,7 +125,7 @@ function force_https_filter_output( $content ) {
125125add_filter ( 'the_content ' , 'force_https_process_content ' , 20 );
126126function force_https_process_content ( $ content ) {
127127 return preg_replace_callback (
128- '#(<(?:a|img|script|iframe|link|source|form)[^>]+\s(?:href|src)=[" \'])(http://|// )([^" \']+)#i ' ,
128+ '#(<(?:a|img|script|iframe|link|source|form)[^>]+\s(?:href|src)=[" \'])(http://)([^" \']+)#i ' ,
129129 function ( $ matches ) {
130130 return $ matches [1 ] . 'https:// ' . $ matches [3 ];
131131 },
0 commit comments