On this page
get_oembed_endpoint_url( string $permalink = '', string $format = 'json' ): string
Retrieves the oEmbed endpoint URL for a given permalink.
Description
Pass an empty string as the first argument to get the endpoint base URL.
Parameters
$permalinkstring Optional-
The permalink used for the
urlquery arg.Default:
'' $formatstring Optional-
The requested response format. Default
'json'.Default:
'json'
Return
string The oEmbed endpoint URL.
Source
File: wp-includes/embed.php. View all references
function get_oembed_endpoint_url( $permalink = '', $format = 'json' ) {
$url = rest_url( 'oembed/1.0/embed' );
if ( '' !== $permalink ) {
$url = add_query_arg(
array(
'url' => urlencode( $permalink ),
'format' => ( 'json' !== $format ) ? $format : false,
),
$url
);
}
/**
* Filters the oEmbed endpoint URL.
*
* @since 4.4.0
*
* @param string $url The URL to the oEmbed endpoint.
* @param string $permalink The permalink used for the `url` query arg.
* @param string $format The requested response format.
*/
return apply_filters( 'oembed_endpoint_url', $url, $permalink, $format );
}
Hooks
- apply_filters( 'oembed_endpoint_url',
string $url ,string $permalink ,string $format ) -
Filters the oEmbed endpoint URL.
Related
Uses
| Uses | Description |
|---|---|
| rest_url() wp-includes/rest-api.php | Retrieves the URL to a REST endpoint. |
| add_query_arg() wp-includes/functions.php | Retrieves a modified URL query string. |
| apply_filters() wp-includes/plugin.php | Calls the callback functions that have been added to a filter hook. |
Used By
| Used By | Description |
|---|---|
| wp_oembed_add_discovery_links() wp-includes/embed.php | Adds oEmbed discovery links in the head element of the website. |
Changelog
| Version | Description |
|---|---|
| 4.4.0 | Introduced. |
© 2003–2022 WordPress Foundation
Licensed under the GNU GPLv2+ License.
https://developer.wordpress.org/reference/functions/get_oembed_endpoint_url