W3cubDocs

/WordPress

WP_oEmbed::get_data( string $url, string|array $args = ): object|false

Takes a URL and attempts to return the oEmbed data.

Description

See also

Parameters

$urlstringrequired
The URL to the content that should be attempted to be embedded.
$argsstring|arrayoptional
Additional arguments for retrieving embed HTML.
See wp_oembed_get() for accepted arguments.
More Arguments from wp_oembed_get( … $args )Additional arguments for retrieving embed HTML.
  • width int|string
    Optional. The maxwidth value passed to the provider URL.
  • height int|string
    Optional. The maxheight value passed to the provider URL.
  • discover bool
    Optional. Determines whether to attempt to discover link tags at the given URL for an oEmbed provider when the provider URL is not found in the built-in providers list. Default true.

Default:''

Return

object|false The result in the form of an object on success, false on failure.

Source

public function get_data( $url, $args = '' ) {
	$args = wp_parse_args( $args );

	$provider = $this->get_provider( $url, $args );

	if ( ! $provider ) {
		return false;
	}

	$data = $this->fetch( $provider, $url, $args );

	if ( false === $data ) {
		return false;
	}

	return $data;
}

Changelog

Version Description
4.8.0 Introduced.

© 2003–2024 WordPress Foundation
Licensed under the GNU GPLv2+ License.
https://developer.wordpress.org/reference/classes/wp_oembed/get_data