wp_oembed_ensure_format

Ensures that the specified format is either 'json' or 'xml'.

Description

(string) wp_oembed_ensure_format( (string) $format ); 

Returns (string)

The format, either 'xml' or 'json'. Default 'json'.

Parameters (1)

0. $format (string)
The oEmbed response format. Accepts json or xml..

Usage

  1. if ( !function_exists( 'wp_oembed_ensure_format' ) ) { 
  2. require_once ABSPATH . WPINC . '/embed.php'; 
  3.  
  4. // The oEmbed response format. Accepts 'json' or 'xml'. 
  5. $format = ''; 
  6.  
  7. // NOTICE! Understand what this does before running. 
  8. $result = wp_oembed_ensure_format($format); 
  9.  

Defined (1)

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

/wp-includes/embed.php  
  1. function wp_oembed_ensure_format( $format ) { 
  2. if ( ! in_array( $format, array( 'json', 'xml' ), true ) ) { 
  3. return 'json'; 
  4.  
  5. return $format;