woocommerce-dev-helper icon indicating copy to clipboard operation
woocommerce-dev-helper copied to clipboard

SSL ignored when calling get_home_url() in admin

Open ragulka opened this issue 7 years ago • 0 comments

Perhaps an edge case, but if I have a local site that normally runs on HTTP (no SSL), for example http://mysite.test, and use Forward on it, it becomes something like https://mysite.fwd.wf, because Forward uses SSL by default.

However, when I call get_home_url() in WP admin (whenever is_admin() is true), WP bypasses the $_SERVER['https'] flag and simply uses the schema from the home option: https://github.com/WordPress/WordPress/blob/7c77266b9bb2f1882dd345a460f56f62a14bf0ed/wp-includes/link-template.php#L3088-L3094

I don't know the reasoning why WP is doing this (it seems very odd to me), but the only way to circumvent this is to force any http:// urls to https:// here.

I stumbled upon this when working on Jilt for WC, where we construct the OAauth redirect_uri using get_home_url() in admin, and WP was stubbornly returning a http:// url for me.

ragulka avatar Feb 02 '18 10:02 ragulka