Skip to content

Commit 29a7b2c

Browse files
authored
Update force-https.php
1 parent 35967ee commit 29a7b2c

File tree

1 file changed

+5
-19
lines changed

1 file changed

+5
-19
lines changed

force-https.php

Lines changed: 5 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -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
6767
add_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 );
7068
add_filter( 'author_feed_link', 'force_https_securize_url', 10 );
71-
add_filter( 'author_link', 'force_https_securize_url', 10 );
7269
add_filter( 'category_feed_link', 'force_https_securize_url', 10 );
7370
add_filter( 'category_link', 'force_https_securize_url', 10 );
74-
add_filter( 'comment_link', 'force_https_securize_url', 10 );
7571
add_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 );
7872
add_filter( 'embed_oembed_html', 'force_https_securize_url', 10 );
79-
add_filter( 'feed_link', 'force_https_securize_url', 10 );
8073
add_filter( 'get_avatar_url', 'force_https_securize_url', 10 );
8174
add_filter( 'get_custom_logo', 'force_https_securize_url', 10 );
8275
add_filter( 'home_url', 'force_https_securize_url', 10 );
8376
add_filter( 'includes_url', 'force_https_securize_url', 10 );
8477
add_filter( 'login_redirect', 'force_https_securize_url', 10 );
8578
add_filter( 'logout_redirect', 'force_https_securize_url', 10 );
86-
add_filter( 'month_link', 'force_https_securize_url', 10 );
8779
add_filter( 'network_home_url', 'force_https_securize_url', 10 );
8880
add_filter( 'network_site_url', 'force_https_securize_url', 10 );
8981
add_filter( 'page_link', 'force_https_securize_url', 10 );
9082
add_filter( 'plugins_url', 'force_https_securize_url', 10 );
9183
add_filter( 'post_link', 'force_https_securize_url', 10 );
92-
add_filter( 'pre_option_permalink_structure', 'force_https_securize_url', 10 );
9384
add_filter( 'rest_url', 'force_https_securize_url', 10 );
9485
add_filter( 'script_loader_src', 'force_https_securize_url', 10 );
9586
add_filter( 'site_url', 'force_https_securize_url', 10 );
@@ -100,26 +91,21 @@ function force_https_securize_url( $value ) {
10091
add_filter( 'term_link', 'force_https_securize_url', 10 );
10192
add_filter( 'theme_file_uri', 'force_https_securize_url', 10 );
10293
add_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 );
10794
add_filter( 'wp_get_attachment_url', 'force_https_securize_url', 10 );
10895
add_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
11298
function 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
123109
add_filter( 'comment_text', 'force_https_filter_output', 20 );
124110
add_filter( 'post_thumbnail_html', 'force_https_filter_output', 10 );
125111
add_filter( 'render_block', 'force_https_filter_output', 20 );

0 commit comments

Comments
 (0)