[ Index ]

PHP Cross Reference of WordPress Trunk (Updated Daily)

Search

title

Body

[close]

/wp-includes/ -> class-wp-oembed.php (summary)

API for fetching the HTML to embed remote content based on a provided URL Used internally by the WP_Embed class, but is designed to be generic.

File Size: 785 lines (31 kb)
Included or required: 1 time
Referenced: 0 times
Includes or requires: 0 files

Defines 1 class

WP_oEmbed:: (15 methods):
  __construct()
  __call()
  get_provider()
  _add_provider_early()
  _remove_provider_early()
  get_data()
  get_html()
  discover()
  fetch()
  _fetch_with_format()
  _parse_json()
  _parse_xml()
  _parse_xml_body()
  data2html()
  _strip_newlines()


Class: WP_oEmbed  - X-Ref

Core class used to implement oEmbed functionality.

__construct()   X-Ref
Constructor.


__call( $name, $arguments )   X-Ref
Exposes private/protected methods for backward compatibility.

param: string $name      Method to call.
param: array  $arguments Arguments to pass when calling.
return: mixed|false Return value of the callback, false otherwise.

get_provider( $url, $args = '' )   X-Ref
Takes a URL and returns the corresponding oEmbed provider's URL, if there is one.

param: string       $url  The URL to the content.
param: string|array $args {
return: string|false The oEmbed provider URL on success, false on failure.

_add_provider_early( $format, $provider, $regex = false )   X-Ref
Adds an oEmbed provider.

The provider is added just-in-time when wp_oembed_add_provider() is called before
the {@see 'plugins_loaded'} hook.

The just-in-time addition is for the benefit of the {@see 'oembed_providers'} filter.

param: string $format   Format of URL that this provider can handle. You can use
param: string $provider The URL to the oEmbed provider..
param: bool   $regex    Optional. Whether the $format parameter is in a regex format.

_remove_provider_early( $format )   X-Ref
Removes an oEmbed provider.

The provider is removed just-in-time when wp_oembed_remove_provider() is called before
the {@see 'plugins_loaded'} hook.

The just-in-time removal is for the benefit of the {@see 'oembed_providers'} filter.

param: string $format The format of URL that this provider can handle. You can use

get_data( $url, $args = '' )   X-Ref
Takes a URL and attempts to return the oEmbed data.

param: string       $url  The URL to the content that should be attempted to be embedded.
param: string|array $args Optional. Additional arguments for retrieving embed HTML.
return: object|false The result in the form of an object on success, false on failure.

get_html( $url, $args = '' )   X-Ref
The do-it-all function that takes a URL and attempts to return the HTML.

param: string       $url  The URL to the content that should be attempted to be embedded.
param: string|array $args Optional. Additional arguments for retrieving embed HTML.
return: string|false The UNSANITIZED (and potentially unsafe) HTML that should be used to embed

discover( $url )   X-Ref
Attempts to discover link tags at the given URL for an oEmbed provider.

param: string $url The URL that should be inspected for discovery `<link>` tags.
return: string|false The oEmbed provider URL on success, false on failure.

fetch( $provider, $url, $args = '' )   X-Ref
Connects to an oEmbed provider and returns the result.

param: string       $provider The URL to the oEmbed provider.
param: string       $url      The URL to the content that is desired to be embedded.
param: string|array $args     Optional. Additional arguments for retrieving embed HTML.
return: object|false The result in the form of an object on success, false on failure.

_fetch_with_format( $provider_url_with_args, $format )   X-Ref
Fetches result from an oEmbed provider for a specific format and complete provider URL

param: string $provider_url_with_args URL to the provider with full arguments list (url, maxheight, etc.)
param: string $format                 Format to use.
return: object|false|WP_Error The result in the form of an object on success, false on failure.

_parse_json( $response_body )   X-Ref
Parses a json response body.

param: string $response_body
return: object|false

_parse_xml( $response_body )   X-Ref
Parses an XML response body.

param: string $response_body
return: object|false

_parse_xml_body( $response_body )   X-Ref
Serves as a helper function for parsing an XML response body.

param: string $response_body
return: stdClass|false

data2html( $data, $url )   X-Ref
Converts a data object from WP_oEmbed::fetch() and returns the HTML.

param: object $data A data object result from an oEmbed provider.
param: string $url  The URL to the content that is desired to be embedded.
return: string|false The HTML needed to embed on success, false on failure.

_strip_newlines( $html, $data, $url )   X-Ref
Strips any new lines from the HTML.

param: string $html Existing HTML.
param: object $data Data object from WP_oEmbed::data2html()
param: string $url The original URL passed to oEmbed.
return: string Possibly modified $html



Generated : Tue Mar 19 08:20:01 2024 Cross-referenced by PHPXref