WordPress.org

Make WordPress Core

Opened 7 weeks ago

Last modified 5 days ago

#51269 new defect (bug)

Document the $args parameter of wp_oembed_get()

Reported by: SergeyBiryukov Owned by:
Milestone: 5.6 Priority: normal
Severity: normal Version:
Component: Embeds Keywords: has-patch
Focuses: docs Cc:

Description

Reported by @vakho114 on support forums.

wp_oembed_get() has an $args parameter, but it's not clarified which arguments exactly can be accepted.

Looking at the code, the array is passed to a few WP_oEmbed methods:

  • WP_oEmbed::get_html()
  • WP_oEmbed::get_data()
  • WP_oEmbed::get_provider()
  • WP_oEmbed::fetch()

In WP_oEmbed::get_provider(), the value of $args['discover'] determines whether to call the ::discover() method if the oEmbed provider URL is not found in the built-in providers list.

In WP_oEmbed::fetch(), $args is merged with wp_embed_defaults(), then $args['width'] and $args['height'] are passed to the provider URL.

So it looks like while any custom parameters can be passed, only width, height, and discover are supported by default and should be documented as such.

Attachments (1)

51269.2.diff (9.6 KB) - added by hellofromTonya 5 days ago.
Documents the optional $args array elements to include width, height, and discovery.

Download all attachments as: .zip

Change History (2)

@hellofromTonya
5 days ago

Documents the optional $args array elements to include width, height, and discovery.

#1 @hellofromTonya
5 days ago

  • Keywords has-patch added

Documented the args per @SergeyBiryukov's notes for each method and filter.

Note: See TracTickets for help on using tickets.