Make WordPress Core

Opened 4 years ago

Closed 4 years ago

Last modified 4 years ago

#51269 closed defect (bug) (fixed)

Document the $args parameter of wp_oembed_get()

Reported by: sergeybiryukov's profile SergeyBiryukov Owned by: helen's profile helen
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 (2)

51269.2.diff (9.6 KB) - added by hellofromTonya 4 years ago.
Documents the optional $args array elements to include width, height, and discovery.
51269.3.diff (7.8 KB) - added by audrasjb 4 years ago.
patch refreshed against trunk

Download all attachments as: .zip

Change History (7)

@hellofromTonya
4 years ago

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

#1 @hellofromTonya
4 years ago

  • Keywords has-patch added

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

@audrasjb
4 years ago

patch refreshed against trunk

#2 @audrasjb
4 years ago

Hey there, 51269.3.diff refreshes the previous patch against trunk and adds few docblock fixes concerning whitespaces et al :)

Otherwise, the changes make sense to me and look good to go.

#3 @hellofromTonya
4 years ago

@SergeyBiryukov Can you do a code review of 51269.3.diff? Let us know if there are any other changes needed.

#4 @helen
4 years ago

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

In 49620:

Embeds: Document $args in wp_oembed_get().

Props hellofromTonya, audrasjb, SergeyBiryukov.
Fixes #51269.

#5 @SergeyBiryukov
4 years ago

In 49626:

Docs: Document the $args parameter of wp_oembed_get().

Link to wp_oembed_get() as the canonical source when documenting additional arguments in various WP_oEmbed methods.

Follow-up to [49620].

See #51269.

Note: See TracTickets for help on using tickets.