wp-includes/class-oembed.php
API for fetching the HTML to embed remote content based on a provided URL.
Used internally by the {@link WP_Embed} class, but is designed to be generic.
- link
- oEmbed Codex Article
- link
- oEmbed Homepage
- package
- WordPress
- subpackage
- oEmbed
Functions
_wp_oembed_get_object(
)
:
\WP_oEmbedReturns the initialized {@link WP_oEmbed} object
| Type | Description |
|---|---|
| \WP_oEmbed |
- access
- private
- see
- \WP_oEmbed
- since
- 2.9.0
- uses
- \WP_oEmbed
\WP_oEmbed
oEmbed class.
- package
- WordPress
- since
- 2.9.0
- subpackage
- oEmbed
- used_by
- _wp_oembed_get_object()
Properties
Methods

_fetch_with_format(
string $provider_url_with_args, string $format
)
:
bool|objectFetches result from an oEmbed provider for a specific format and complete provider URL
| Name | Type | Description |
|---|---|---|
| $provider_url_with_args | string | URL to the provider with full arguments list (url, maxheight, etc.) |
| $format | string | Format to use |
| Type | Description |
|---|---|
| boolobject |
- access
- private
- since
- 3.0.0

_parse_json(
$response_body
)
:
Parses a json response body.
| Name | Type | Description |
|---|---|---|
| $response_body |
- access
- private
- since
- 3.0.0

_parse_xml(
$response_body
)
:
Parses an XML response body.
| Name | Type | Description |
|---|---|---|
| $response_body |
- access
- private
- since
- 3.0.0

_strip_newlines(
string $html, object $data, string $url
)
:
stringStrip any new lines from the HTML.
| Name | Type | Description |
|---|---|---|
| $html | string | Existing HTML. |
| $data | object | Data object from WP_oEmbed::data2html() |
| $url | string | The original URL passed to oEmbed. |
| Type | Description |
|---|---|
| string |
- access
- private

data2html(
object $data, string $url
)
:
bool|stringConverts a data object from {@link WP_oEmbed::fetch()} and returns the HTML.
| Name | Type | Description |
|---|---|---|
| $data | object | A data object result from an oEmbed provider. |
| $url | string | The URL to the content that is desired to be embedded. |
| Type | Description |
|---|---|
| boolstring |

discover(
string $url
)
:
bool|stringAttempts to find oEmbed provider discovery tags at the given URL.
| Name | Type | Description |
|---|---|---|
| $url | string | The URL that should be inspected for discovery tags. |
| Type | Description |
|---|---|
| boolstring |

fetch(
string $provider, string $url, array $args
)
:
bool|objectConnects to a oEmbed provider and returns the result.
| Name | Type | Description |
|---|---|---|
| $provider | string | The URL to the oEmbed provider. |
| $url | string | The URL to the content that is desired to be embedded. |
| $args | array | Optional arguments. Usually passed from a shortcode. |
| Type | Description |
|---|---|
| boolobject |

get_html(
string $url, array $args
)
:
bool|stringThe do-it-all function that takes a URL and attempts to return the HTML.
| Name | Type | Description |
|---|---|---|
| $url | string | The URL to the content that should be attempted to be embedded. |
| $args | array | Optional arguments. Usually passed from a shortcode. |
| Type | Description |
|---|---|
| boolstring |
- see
- \WP_oEmbed::discover()
- see
- \WP_oEmbed::fetch()
- see
- \WP_oEmbed::data2html()
- used_by
- wp_oembed_get()