Opened 6 years ago
Closed 6 years ago
#45142 closed defect (bug) (fixed)
Filter HTML response in oEmbed proxy controller
Reported by: | swissspidy | Owned by: | danielbachhuber |
---|---|---|---|
Milestone: | 5.0 | Priority: | normal |
Severity: | normal | Version: | |
Component: | Embeds | Keywords: | has-patch has-unit-tests fixed-5.0 |
Focuses: | rest-api | Cc: |
Description
Related: #43136, https://github.com/WordPress/gutenberg/pull/4226 (especially https://github.com/WordPress/gutenberg/pull/4226#pullrequestreview-91060412)
The Gutenberg plugin currently contains a custom gutenberg_filter_oembed_result()
function that alters the response from WP_oEmbed_Controller::get_proxy_item()
so that the response is correctly filtered and embeds work properly in the block editor.
For WordPress 5.0, the code from that function needs to be moved directly to WP_oEmbed_Controller::get_proxy_item()
in order to fix that behavior.
Attachments (3)
Change History (16)
This ticket was mentioned in Slack in #core-restapi by swissspidy. View the logs.
6 years ago
#3
@
6 years ago
- Focuses rest-api added
- Keywords has-patch dev-feedback added; needs-patch removed
In 45142.diff:
- Extract most logic from
wp_filter_pre_oembed_result()
into newget_oembed_response_data_for_url()
function so it can be more easily reused. - Short-circuit proxy response for internal URLs using
get_oembed_response_data_for_url()
- Add same
oembed_result
filter as for other embeds
@pento @imath would love to get your thoughts on this.
This ticket was mentioned in Slack in #core-restapi by danielbachhuber. View the logs.
6 years ago
#6
@
6 years ago
Hi @swissspidy
Thanks a lot for the ping. I've just tested the patch using branch 5.0 & Gutenberg master.
- I've first tested without it: a self embed post is working as expected
- then I've tested with it, running
grunt build
asgrunt watch
wasn't applying the part of the patch involvingsrc/wp-includes/class-wp-oembed-controller.php
: it worked as expected too.
The only weird thing for both tests were the huge place taken by the block's placeholder > https://cloudup.com/iAIcSlHQMfj But I guess it's not related to this ticket.
About my thoughts: I think it's a good idea, correct me if I'm wrong but this means having the new get_oembed_response_data_for_url()
would make it directly usable with a WordPress URL, right ? It seems very interesting :)
Thanks a lot for your work on this.
This ticket was mentioned in Slack in #core-restapi by desrosj. View the logs.
6 years ago
#8
follow-up:
↓ 9
@
6 years ago
About my thoughts: I think it's a good idea, correct me if I'm wrong but this means having the new
get_oembed_response_data_for_url()
would make it directly usable with a WordPress URL, right ? It seems very interesting :)
Yep, that is an intended nice effect of that patch :-)
As for the patch, I tried to add some tests in 45142.2.diff, but since it's already late here I couldn't make the last test work that should verify the newly added oembed_result
filter in the proxy endpoint.
#9
in reply to:
↑ 8
@
6 years ago
- Keywords has-unit-tests added; needs-testing needs-unit-tests removed
Replying to swissspidy:
As for the patch, I tried to add some tests in 45142.2.diff, but since it's already late here I couldn't make the last test work that should verify the newly added
oembed_result
filter in the proxy endpoint.
@swissspidy I'm not quite sure what you mean by this because 45142.2.diff included:
$this->markTestIncomplete( 'Need to test that the resulting HTML is passed through the oembed_dataparse filter' );
Note: oembed_dataparse
instead of oembed_result
.
In 45142.3.diff, I've added some assertions around the expected calls to oembed_result
. I also fixed the PHPDoc for oembed_result
, because $data
can be false.
Tests running in https://github.com/WordPress/wordpress-develop/pull/26
#10
@
6 years ago
- Owner set to danielbachhuber
- Resolution set to fixed
- Status changed from new to closed
In 43810:
#11
@
6 years ago
- Keywords fixed-5.0 added; dev-feedback removed
- Resolution fixed deleted
- Status changed from closed to reopened
Reopening for merge to trunk.
#12
@
6 years ago
@imath
The only weird thing for both tests were the huge place taken by the block's placeholder > https://cloudup.com/iAIcSlHQMfj But I guess it's not related to this ticket.
And it's fixed by https://github.com/WordPress/gutenberg/pull/10985 :)
Also related: https://github.com/WordPress/gutenberg/issues/5530