Sitelet https://web.archive.org/web/20201119122638/https://github.com/wp-cli/server-command/issues/51
Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Server on `http://` returns `https://` links #51

Open
evilebottnawi opened this issue Feb 1, 2019 · 5 comments
Open

Server on `http://` returns `https://` links #51

evilebottnawi opened this issue Feb 1, 2019 · 5 comments

Comments

@evilebottnawi
Copy link

@evilebottnawi evilebottnawi commented Feb 1, 2019

If you have site on https and run php server on http the function get_site_icon_url return a link with https.

I think the problem here https://github.com/WordPress/WordPress/blob/master/wp-includes/general-template.php#L810, because WordPress should use here get_site_url() instead get_option( 'site_icon' ).

Maybe we can add filter on get_site_icon_url to fix it problem or we should fix it in WordPress?

@evilebottnawi
Copy link
Author

@evilebottnawi evilebottnawi commented Feb 1, 2019 •

Same problem for wp_upload_dir so all images have https, maybe we can add more filters here https://github.com/wp-cli/server-command/blob/master/router.php?

@swissspidy
Copy link
Member

@swissspidy swissspidy commented Feb 1, 2019

Worth noting that get_option( 'site_icon' ) just holds the ID of the site icon, not its URL. The actual URL is generated by wp_get_attachment_image_url() and then wp_get_attachment_url(), which uses the image URL stored in the attachment metadata in the database.

So the right filter in that case would probably be wp_get_attachment_url.

@evilebottnawi
Copy link
Author

@evilebottnawi evilebottnawi commented Feb 1, 2019

@swissspidy yep, i find what wp_get_attachment_url use wp_upload_dir for getting host, so i think filter should in wp_upload_dir, it is fix all images urls

@schlessera
Copy link
Member

@schlessera schlessera commented Feb 4, 2019

I'm not sure this can be easily solved. You still have all the links that are stored throughout post content fields that point to https://.

Maybe a better approach would be to add a flag --adapt-scheme that filters the actual output to replace all https:// links pointing to the local server with http:// links?

@schlessera schlessera changed the title `get_site_icon_url` return link with `https` Server on `http://` return `https://` links Feb 4, 2019
@schlessera schlessera changed the title Server on `http://` return `https://` links Server on `http://` returns `https://` links Feb 4, 2019
@evilebottnawi
Copy link
Author

@evilebottnawi evilebottnawi commented Feb 4, 2019

@schlessera we rewrite url in production, but for development mode will be great have valid url

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
3 participants
You can’t perform that action at this time.