@@ -63,33 +63,24 @@ function force_https_securize_url( $value ) {
63
63
return set_url_scheme ( $ value , 'https ' );
64
64
}
65
65
66
- // apply https to all relevant wordpress filters
66
+ // apply https to urls used across wordpress and woocommerce
67
67
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 );
70
68
add_filter ( 'author_feed_link ' , 'force_https_securize_url ' , 10 );
71
- add_filter ( 'author_link ' , 'force_https_securize_url ' , 10 );
72
69
add_filter ( 'category_feed_link ' , 'force_https_securize_url ' , 10 );
73
70
add_filter ( 'category_link ' , 'force_https_securize_url ' , 10 );
74
- add_filter ( 'comment_link ' , 'force_https_securize_url ' , 10 );
75
71
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 );
78
72
add_filter ( 'embed_oembed_html ' , 'force_https_securize_url ' , 10 );
79
- add_filter ( 'feed_link ' , 'force_https_securize_url ' , 10 );
80
73
add_filter ( 'get_avatar_url ' , 'force_https_securize_url ' , 10 );
81
74
add_filter ( 'get_custom_logo ' , 'force_https_securize_url ' , 10 );
82
75
add_filter ( 'home_url ' , 'force_https_securize_url ' , 10 );
83
76
add_filter ( 'includes_url ' , 'force_https_securize_url ' , 10 );
84
77
add_filter ( 'login_redirect ' , 'force_https_securize_url ' , 10 );
85
78
add_filter ( 'logout_redirect ' , 'force_https_securize_url ' , 10 );
86
- add_filter ( 'month_link ' , 'force_https_securize_url ' , 10 );
87
79
add_filter ( 'network_home_url ' , 'force_https_securize_url ' , 10 );
88
80
add_filter ( 'network_site_url ' , 'force_https_securize_url ' , 10 );
89
81
add_filter ( 'page_link ' , 'force_https_securize_url ' , 10 );
90
82
add_filter ( 'plugins_url ' , 'force_https_securize_url ' , 10 );
91
83
add_filter ( 'post_link ' , 'force_https_securize_url ' , 10 );
92
- add_filter ( 'pre_option_permalink_structure ' , 'force_https_securize_url ' , 10 );
93
84
add_filter ( 'rest_url ' , 'force_https_securize_url ' , 10 );
94
85
add_filter ( 'script_loader_src ' , 'force_https_securize_url ' , 10 );
95
86
add_filter ( 'site_url ' , 'force_https_securize_url ' , 10 );
@@ -100,26 +91,21 @@ function force_https_securize_url( $value ) {
100
91
add_filter ( 'term_link ' , 'force_https_securize_url ' , 10 );
101
92
add_filter ( 'theme_file_uri ' , 'force_https_securize_url ' , 10 );
102
93
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 );
107
94
add_filter ( 'wp_get_attachment_url ' , 'force_https_securize_url ' , 10 );
108
95
add_filter ( 'wp_upload_dir ' , 'force_https_securize_url ' , 10 );
109
- add_filter ( 'year_link ' , 'force_https_securize_url ' , 10 );
110
96
111
- // replace http with https in text or html content
97
+ // enforce https on html content that may contain urls
112
98
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
114
100
if ( ! is_string ( $ content ) || strpos ( $ content , 'http:// ' ) === false ) {
115
101
return $ content ;
116
102
}
117
103
118
- // replace all instances of http with https
104
+ // replace http with https in text or html output
119
105
return str_replace ( 'http:// ' , 'https:// ' , $ content );
120
106
}
121
107
122
- // apply to simple html filters that need url enforcement
108
+ // apply https enforcement to html content in various wordpress areas
123
109
add_filter ( 'comment_text ' , 'force_https_filter_output ' , 20 );
124
110
add_filter ( 'post_thumbnail_html ' , 'force_https_filter_output ' , 10 );
125
111
add_filter ( 'render_block ' , 'force_https_filter_output ' , 20 );
0 commit comments