@@ -63,33 +63,24 @@ function force_https_securize_url( $value ) {
6363 return set_url_scheme ( $ value , 'https ' );
6464}
6565
66- // apply https to all relevant wordpress filters
66+ // apply https to urls used across wordpress and woocommerce
6767add_filter ( 'admin_url ' , 'force_https_securize_url ' , 10 );
68- add_filter ( 'ajax_url ' , 'force_https_securize_url ' , 10 );
69- add_filter ( 'attachment_link ' , 'force_https_securize_url ' , 10 );
7068add_filter ( 'author_feed_link ' , 'force_https_securize_url ' , 10 );
71- add_filter ( 'author_link ' , 'force_https_securize_url ' , 10 );
7269add_filter ( 'category_feed_link ' , 'force_https_securize_url ' , 10 );
7370add_filter ( 'category_link ' , 'force_https_securize_url ' , 10 );
74- add_filter ( 'comment_link ' , 'force_https_securize_url ' , 10 );
7571add_filter ( 'content_url ' , 'force_https_securize_url ' , 10 );
76- add_filter ( 'day_link ' , 'force_https_securize_url ' , 10 );
77- add_filter ( 'do_shortcode_tag ' , 'force_https_securize_url ' , 10 );
7872add_filter ( 'embed_oembed_html ' , 'force_https_securize_url ' , 10 );
79- add_filter ( 'feed_link ' , 'force_https_securize_url ' , 10 );
8073add_filter ( 'get_avatar_url ' , 'force_https_securize_url ' , 10 );
8174add_filter ( 'get_custom_logo ' , 'force_https_securize_url ' , 10 );
8275add_filter ( 'home_url ' , 'force_https_securize_url ' , 10 );
8376add_filter ( 'includes_url ' , 'force_https_securize_url ' , 10 );
8477add_filter ( 'login_redirect ' , 'force_https_securize_url ' , 10 );
8578add_filter ( 'logout_redirect ' , 'force_https_securize_url ' , 10 );
86- add_filter ( 'month_link ' , 'force_https_securize_url ' , 10 );
8779add_filter ( 'network_home_url ' , 'force_https_securize_url ' , 10 );
8880add_filter ( 'network_site_url ' , 'force_https_securize_url ' , 10 );
8981add_filter ( 'page_link ' , 'force_https_securize_url ' , 10 );
9082add_filter ( 'plugins_url ' , 'force_https_securize_url ' , 10 );
9183add_filter ( 'post_link ' , 'force_https_securize_url ' , 10 );
92- add_filter ( 'pre_option_permalink_structure ' , 'force_https_securize_url ' , 10 );
9384add_filter ( 'rest_url ' , 'force_https_securize_url ' , 10 );
9485add_filter ( 'script_loader_src ' , 'force_https_securize_url ' , 10 );
9586add_filter ( 'site_url ' , 'force_https_securize_url ' , 10 );
@@ -100,26 +91,21 @@ function force_https_securize_url( $value ) {
10091add_filter ( 'term_link ' , 'force_https_securize_url ' , 10 );
10192add_filter ( 'theme_file_uri ' , 'force_https_securize_url ' , 10 );
10293add_filter ( 'woocommerce_account_endpoint_url ' , 'force_https_securize_url ' , 10 );
103- add_filter ( 'woocommerce_get_cart_url ' , 'force_https_securize_url ' , 10 );
104- add_filter ( 'woocommerce_get_checkout_url ' , 'force_https_securize_url ' , 10 );
105- add_filter ( 'woocommerce_get_terms_and_conditions_page ' , 'force_https_securize_url ' , 10 );
106- add_filter ( 'wp_get_attachment_metadata ' , 'force_https_securize_url ' , 10 );
10794add_filter ( 'wp_get_attachment_url ' , 'force_https_securize_url ' , 10 );
10895add_filter ( 'wp_upload_dir ' , 'force_https_securize_url ' , 10 );
109- add_filter ( 'year_link ' , 'force_https_securize_url ' , 10 );
11096
111- // replace http with https in text or html content
97+ // enforce https on html content that may contain urls
11298function force_https_filter_output ( $ content ) {
113- // return unchanged if not a string or http not found
99+ // return unchanged if not a string or does not contain http
114100 if ( ! is_string ( $ content ) || strpos ( $ content , 'http:// ' ) === false ) {
115101 return $ content ;
116102 }
117103
118- // replace all instances of http with https
104+ // replace http with https in text or html output
119105 return str_replace ( 'http:// ' , 'https:// ' , $ content );
120106}
121107
122- // apply to simple html filters that need url enforcement
108+ // apply https enforcement to html content in various wordpress areas
123109add_filter ( 'comment_text ' , 'force_https_filter_output ' , 20 );
124110add_filter ( 'post_thumbnail_html ' , 'force_https_filter_output ' , 10 );
125111add_filter ( 'render_block ' , 'force_https_filter_output ' , 20 );
0 commit comments