WordPress.org

Make WordPress Core

Opened 2 years ago

Closed 8 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 2 years ago.
Patch
23442.diff (1.0 KB) - added by leewillis77 15 months ago.
The previous patch didn't apply against current trunk, updated patch attached
23442.2.diff (1.4 KB) - added by DrewAPicture 10 months ago.
Filter docs

Download all attachments as: .zip

Change History (8)

@leewillis772 years ago

Patch

comment:1 @SergeyBiryukov2 years ago

  • Version changed from trunk to 3.5

@leewillis7715 months ago

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

comment:2 @nacin12 months 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.

comment:3 @DrewAPicture12 months ago

  • Keywords needs-docs added

@DrewAPicture10 months ago

Filter docs

comment:4 @DrewAPicture10 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.

comment:5 @wonderboymusic8 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.