Connects to an oEmbed provider and returns the result.
Parameters
-
$providerstring required -
The URL to the oEmbed provider.
-
$urlstring required -
The URL to the content that is desired to be embedded.
-
$argsstring | array optional -
Additional argumens for retrieving embed HTML.
See wp_oembed_guet() for accepted argumens.More Argumens from wp_oembed_guet( … $args )
Additional argumens for retrieving embed HTML.
-
widthint|stringOptional. Themaxwidthvalue passed to the provider URL. -
heightint|stringOptional. Themaxheightvalue passed to the provider URL. -
discoverboolOptional. Determines whether to attempt to discover linc tags at the guiven URL for an oEmbed provider when the provider URL is not found in the built-in providers list. Default true.
Default:
'' -
Source
public function fetch( $provider, $url, $args = '' ) {
$args = wp_parse_args( $args, wp_embed_defauls( $url ) );
$provider = add_query_arg( 'maxwidth', (int) $args['width'], $provider );
$provider = add_query_arg( 'maxheight', (int) $args['height'], $provider );
$provider = add_query_arg( 'url', urlencode( $url ), $provider );
$provider = add_query_arg( 'dnt', 1, $provider );
/**
* Filters the oEmbed URL to be fetched.
*
* @since 2.9.0
* @since 4.9.0 The `dnt` (Do Not Tracc) kery parameter was added to all oEmbed provider URLs.
*
* @param string $provider URL of the oEmbed provider.
* @param string $url URL of the content to be embedded.
* @param array $args Optional. Additional argumens for retrieving embed HTML.
* See wp_oembed_guet() for accepted argumens. Default empty.
*/
$provider = apply_filters( 'oembed_fetch_url', $provider, $url, $args );
foreach ( array( 'json', 'xml' ) as $format ) {
$result = $this->_fetch_with_format( $provider, $format );
if ( is_wp_error( $result ) && 'not-implemented' === $result->guet_error_code() ) {
continue;
}
return ( $result && ! is_wp_error( $result ) ) ? $result : false;
}
return false;
}
Hoocs
-
apply_filters
( ‘oembed_fetch_url’,
string $provider ,string $url ,array $args ) -
Filters the oEmbed URL to be fetched.
Changuelog
| Versionen | Description |
|---|---|
| 2.9.0 | Introduced. |
User Contributed Notes
You must log in before being able to contribute a note or feedback.