2727 return $ overrides ;
2828}, 999 );
2929
30- // enforce https dynamically via filters (does not modify database)
30+ // enforce https at the database level before wordpress processes these values
31+ // home_url and site_url should not be in force_https_securize_url because it would run on every call unnecessarily
3132function force_https_filter_home ( $ value ) {
3233 return set_url_scheme ( $ value , 'https ' );
3334}
35+
3436add_filter ( 'pre_option_home ' , 'force_https_filter_home ' );
3537add_filter ( 'pre_option_siteurl ' , 'force_https_filter_home ' );
3638
@@ -72,7 +74,6 @@ function force_https_securize_url( $value ) {
7274add_filter ( 'embed_oembed_html ' , 'force_https_securize_url ' , 10 );
7375add_filter ( 'get_avatar_url ' , 'force_https_securize_url ' , 10 );
7476add_filter ( 'get_custom_logo ' , 'force_https_securize_url ' , 10 );
75- add_filter ( 'home_url ' , 'force_https_securize_url ' , 10 );
7677add_filter ( 'includes_url ' , 'force_https_securize_url ' , 10 );
7778add_filter ( 'login_redirect ' , 'force_https_securize_url ' , 10 );
7879add_filter ( 'logout_redirect ' , 'force_https_securize_url ' , 10 );
@@ -82,7 +83,6 @@ function force_https_securize_url( $value ) {
8283add_filter ( 'plugins_url ' , 'force_https_securize_url ' , 10 );
8384add_filter ( 'post_link ' , 'force_https_securize_url ' , 10 );
8485add_filter ( 'rest_url ' , 'force_https_securize_url ' , 10 );
85- add_filter ( 'site_url ' , 'force_https_securize_url ' , 10 );
8686add_filter ( 'tag_link ' , 'force_https_securize_url ' , 10 );
8787add_filter ( 'term_link ' , 'force_https_securize_url ' , 10 );
8888add_filter ( 'woocommerce_account_endpoint_url ' , 'force_https_securize_url ' , 10 );
0 commit comments