get_oembed_endpoint_url

Retrieves the oEmbed endpoint URL for a given permalink.

Description

(string) get_oembed_endpoint_url( (string) $permalink = '', (string) $format = 'json' ); 

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

  1. if ( !function_exists( 'get_oembed_endpoint_url' ) ) { 
  2. require_once ABSPATH . WPINC . '/embed.php'; 
  3.  
  4. // Optional. The permalink used for the `url` query arg. Default empty. 
  5. $permalink = ''; 
  6.  
  7. // Optional. The requested response format. Default 'json'. 
  8. $format = 'json'; 
  9.  
  10. // NOTICE! Understand what this does before running. 
  11. $result = get_oembed_endpoint_url($permalink, $format); 
  12.  

Defined (1)

The function is defined in the following location(s).

/wp-includes/embed.php  
  1. function get_oembed_endpoint_url( $permalink = '', $format = 'json' ) { 
  2. $url = rest_url( 'oembed/1.0/embed' ); 
  3.  
  4. if ( '' !== $permalink ) { 
  5. $url = add_query_arg( array( 
  6. 'url' => urlencode( $permalink ),  
  7. 'format' => ( 'json' !== $format ) ? $format : false,  
  8. ), $url ); 
  9.  
  10. /** 
  11. * Filters the oEmbed endpoint URL. 
  12. * @since 4.4.0 
  13. * @param string $url The URL to the oEmbed endpoint. 
  14. * @param string $permalink The permalink used for the `url` query arg. 
  15. * @param string $format The requested response format. 
  16. */ 
  17. return apply_filters( 'oembed_endpoint_url', $url, $permalink, $format );