Opened 8 years ago
Closed 8 years ago
#45142 closed defect (bug) (fixed)
Filter HTML response in oEmbed proxy controller
| Reported by: | swissspidy | Owned by: | danielbachhuber |
|---|---|---|---|
| Priority: | normal | Milestone: | 5.0 |
| Component: | Embeds | Version: | |
| Severity: | normal | Keywords: | has-patch has-unit-tests fixed-5.0 |
| Cc: | Focuses: | rest-api |
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.
8 years ago
#3
@
8 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_resultfilter 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.
8 years ago
#6
@
8 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 buildasgrunt watchwasn'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.
8 years ago
#8
follow-up:
↓ 9
@
8 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
@
8 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_resultfilter 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
#11
@
8 years ago
- Keywords fixed-5.0 added; dev-feedback removed
- Resolution fixed
- Status closed → reopened
Reopening for merge to trunk.
#12
@
8 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 :)
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)
Also related: https://github.com/WordPress/gutenberg/issues/5530