WordPress.org

Make WordPress Core

Opened 3 years ago

Closed 20 months ago

#23442 closed enhancement (fixed)

Allow wp_remote_get args to be filtered for oEmbed calls

Reported by: leewillis77 Owned by: wonderboymusic
Milestone: 4.0 Priority: normal
Severity: normal Version: 3.5
Component: Embeds Keywords: has-patch
Focuses: Cc:

Description

Currently, the oEmbed code use wp_remote_get() to communicate with the oEmbedded service. However, there's no way to filter the arguments that get used - it simply uses the system wide defaults.

Filtering the defaults (E.g. http_request_timeout) seems overkill when you know that you only want to change things for something specific like an oEmbed call that you know may take longer than 5 seconds (E.g.
https://github.com/leewillis77/wp-github-oembed/blob/1.2/github-api.php#L35)

The attached patch adds a new filter oembed_remote_get_args which allows plugins to override the wp_remote_get args for oembed calls (Including discovery)

Attachments (3)

23442-1.diff (1.1 KB) - added by leewillis77 3 years ago.
Patch
23442.diff (1.0 KB) - added by leewillis77 2 years ago.
The previous patch didn't apply against current trunk, updated patch attached
23442.2.diff (1.4 KB) - added by DrewAPicture 21 months ago.
Filter docs

Download all attachments as: .zip

Change History (8)

@leewillis77
3 years ago

Patch

#1 @SergeyBiryukov
3 years ago

  • Version changed from trunk to 3.5

@leewillis77
2 years ago

The previous patch didn't apply against current trunk, updated patch attached

#2 @nacin
2 years ago

  • Keywords needs-patch added; has-patch removed
  • Milestone changed from Awaiting Review to Future Release

These filters will need documentation. They could probably benefit from additional context, such as the URL being passed and anything else available to it. Looks good, otherwise.

#3 @DrewAPicture
2 years ago

  • Keywords needs-docs added

@DrewAPicture
21 months ago

Filter docs

#4 @DrewAPicture
21 months ago

  • Keywords has-patch added; needs-patch needs-docs removed
  • Milestone changed from Future Release to 4.0

23442.2.diff adds filter docs, passing $url per comment:2.

My only real concern there is that $provider_url_with_args passed to the duplicate filter evaluation would differ in form from $url. I suppose we could pass a context string.

#5 @wonderboymusic
20 months ago

  • Owner set to wonderboymusic
  • Resolution set to fixed
  • Status changed from new to closed

In 28815:

Add a filter/docs: 'oembed_remote_get_args' to WP_oEmbed->discover() and ->_fetch_with_format().

Props leewillis77, DrewAPicture.
Fixes #23442.

Note: See TracTickets for help on using tickets.