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

function _wp_oembed_get_object( ) : \WP_oEmbed
Returns the initialized {@link WP_oEmbed} object
Returns
Type Description
\WP_oEmbed
Details
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

Propertypublic $providers= 'array'
Default valuearrayDetails
Type

Methods

methodpublic __construct( ) :
Constructor
Details
uses
\apply_filters()
methodpublic _fetch_with_format( string $provider_url_with_args, string $format ) : bool|object
Fetches result from an oEmbed provider for a specific format and complete provider URL
Parameters
Name Type Description
$provider_url_with_args string

URL to the provider with full arguments list (url, maxheight, etc.)

$format string Format to use
Returns
Type Description
boolobject
Details
access
private
since
3.0.0
methodpublic _parse_json( $response_body ) :
Parses a json response body.
Parameters
Name Type Description
$response_body
Details
access
private
since
3.0.0
methodpublic _parse_xml( $response_body ) :
Parses an XML response body.
Parameters
Name Type Description
$response_body
Details
access
private
since
3.0.0
methodpublic _strip_newlines( string $html, object $data, string $url ) : string
Strip any new lines from the HTML.
Parameters
Name Type Description
$html string Existing HTML.
$data object

Data object from WP_oEmbed::data2html()

$url string The original URL passed to oEmbed.
Returns
Type Description
string
Details
access
private
methodpublic data2html( object $data, string $url ) : bool|string
Converts a data object from {@link WP_oEmbed::fetch()} and returns the HTML.
Parameters
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.
Returns
Type Description
boolstring
methodpublic discover( string $url ) : bool|string
Attempts to find oEmbed provider discovery tags at the given URL.
Parameters
Name Type Description
$url string

The URL that should be inspected for discovery tags.

Returns
Type Description
boolstring
methodpublic fetch( string $provider, string $url, array $args ) : bool|object
Connects to a oEmbed provider and returns the result.
Parameters
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.
Returns
Type Description
boolobject
methodpublic get_html( string $url, array $args ) : bool|string
The do-it-all function that takes a URL and attempts to return the HTML.
Parameters
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.
Returns
Type Description
boolstring
Details
see
\WP_oEmbed::discover()
see
\WP_oEmbed::fetch()
see
\WP_oEmbed::data2html()
used_by
wp_oembed_get()
Documentation was generated by DocBlox 0.13.0.