@@ -98,6 +98,25 @@ function force_https_securize_url( $value ) {
9898add_filter ( 'wp_get_attachment_url ' , 'force_https_securize_url ' , 999 );
9999add_filter ( 'wp_redirect ' , 'force_https_securize_url ' , 999 );
100100
101+ // enforce https on filtered HTML output
102+ function force_https_filter_output ( $ content ) {
103+
104+ // return original if not a string
105+ if ( ! is_string ( $ content ) || strpos ( $ content , 'http:// ' ) === false ) {
106+ return $ content ;
107+ }
108+
109+ // replace http with https
110+ return str_replace ( 'http:// ' , 'https:// ' , $ content );
111+ }
112+
113+ // apply to simple HTML filters that need URL enforcement
114+ add_filter ( 'post_thumbnail_html ' , 'force_https_filter_output ' , 999 );
115+ add_filter ( 'render_block ' , 'force_https_filter_output ' , 999 );
116+ add_filter ( 'rest_pre_echo_response ' , 'force_https_filter_output ' , 999 );
117+ add_filter ( 'walker_nav_menu_start_el ' , 'force_https_filter_output ' , 999 );
118+ add_filter ( 'woocommerce_email_footer_text ' , 'force_https_filter_output ' , 999 );
119+
101120// force https on all elements and attributes with urls
102121add_filter ( 'the_content ' , 'force_https_process_content ' , 20 );
103122function force_https_process_content ( $ content ) {
0 commit comments