-
Notifications
You must be signed in to change notification settings - Fork 20
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
Local Environment: Fix resolve for external hosts #73
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Confirming from testing that the mu-plugin
filter works as intended to embed media URIs for domains that are included in the $external_hosts
array.
I left a comment regarding some other use cases for alternate YouTube URIs that can be shared that we may want to add to the $external_hosts
array.
Also noting for comparison that when creating a new WordPress.com hosted site on the web (i.e., not a localhost
site using Studio), there are other additional external hosts that are embeddable out-of-the-box (like Vimeo.com URIs, for example).
Approving as I don't consider either a blocker for this PR, but we could consider expanding the domains included in $external_hosts
, too.
vendor/wp-now/src/download.ts
Outdated
} ); | ||
add_filter( 'http_request_host_is_external', function( $allow, $host, $url ) { | ||
$external_hosts = array( | ||
'www.youtube.com', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Noting that this URI will not embed YouTube URLs that do not include the www
, and also the shortened domain youtu.be
, which is the default URI given when sharing a YouTube video.
E.g., the following URIs would not be embeddable:
https://youtu.be/OmgooFTQhYQ?feature=shared
https://youtube.com/watch?v=FcTLMTyD2DU
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I refactored the function to handle those cases ( Actually in all of the examples you provided the host would end up being www.youtube.com
, so it wouldn't be a problem, but we need that change the function after all, as it will easily resolve https://github.com/Automattic/dotcom-forge/issues/6738 )
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
but we need that change the function after all, as it will easily resolve https://github.com/Automattic/dotcom-forge/issues/6738
Makes sense - I re-tested, and the refactored changes look good to me. Thanks for updating. 👍
Can we find a solution that doesn't involve adding hosts to the allowed list? Related Playground issue: WordPress/wordpress-playground#400 |
I'm trying to find one, and this is why I didn't merge it so far. Wasn't familiar with that ticket, so thanks. As this seems bigger than expected, I propose to merge it ( as it seems something that users will want to do sooner or later ), and tackle this more appropriately in the issue mentioned above ( which should do either way ). Then, we can remove this in that ticket, or create another one to remove this file all the way ( As I think it will resolve redirected hosts as well ). |
Sorry for mentioning you @wojtekn , I didn't notice you were afk. I added a "Reviewer can merge" so you can do whatever you want ( I'm afk the next days ). |
@wojtekn , after the discussions we had, I updated this PR, to always return true for |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Works as expected, thanks for the fix.
Fixes https://github.com/Automattic/dotcom-forge/issues/6808
Fixes https://github.com/Automattic/dotcom-forge/issues/6738
Proposed Changes
This PR adds an extra
mu-plugin
to properly resolve domains for embedded urls.Testing Instructions
Test 1
wp-admin
Test 2
wp-admin
Tools -> Import
.Pre-merge Checklist