get_oembed_endpoint_url
Retrieves the oEmbed endpoint URL for a given permalink.
Description
Pass an empty string as the first argument to get the endpoint base URL.
Returns (string)
The oEmbed endpoint URL.
Parameters (2)
- 0. $permalink — Optional. (string) =>
''
- The permalink used for the url query arg. Default empty.
- 1. $format — Optional. (string) =>
'json'
- The requested response format. Default json..
Usage
if ( !function_exists( 'get_oembed_endpoint_url' ) ) { require_once ABSPATH . WPINC . '/embed.php'; } // Optional. The permalink used for the `url` query arg. Default empty. $permalink = ''; // Optional. The requested response format. Default 'json'. $format = 'json'; // NOTICE! Understand what this does before running. $result = get_oembed_endpoint_url($permalink, $format);
Defined (1)
The function is defined in the following location(s).
- /wp-includes/embed.php
- 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 );
- }