godaddy-wordpress / godaddy-wordpress/woocommerce-dev-helper

SSL ignored when calling get_home_url() in admin

Open
#4 0 comments 0 reactions 0 assignees View on GitHub
enhancement
Dominant language
PHP
Stars
37
Forks
4
PR merge metrics
No merged PRs in 30d

Description

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](https://github.com/skyverge/woocommerce-dev-helper/blob/master/includes/class-wc-dev-helper-use-forwarded-urls.php#L152-L156).

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.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.