[wp-trac] [WordPress Trac] #51269: Document the $args parameter of wp_oembed_get()

WordPress Trac noreply at wordpress.org
Tue Sep 8 19:51:08 UTC 2020


#51269: Document the $args parameter of wp_oembed_get()
----------------------------+--------------------
 Reporter:  SergeyBiryukov  |      Owner:  (none)
     Type:  defect (bug)    |     Status:  new
 Priority:  normal          |  Milestone:  5.6
Component:  Embeds          |    Version:
 Severity:  normal          |   Keywords:
  Focuses:  docs            |
----------------------------+--------------------
 Reported by @vakho114 on [https://ru.wordpress.org/support/topic
 /wp_oembed_get-дополнительные-аргументы/ 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.

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/51269>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list