wp_maybe_load_embeds

Determines if default embed handlers should be loaded.

Description

wp_maybe_load_embeds(); 

Checks to make sure that the embeds library hasn't already been loaded. If it hasn't, then it will load the embeds library.


Usage

  1. if ( !function_exists( 'wp_maybe_load_embeds' ) ) { 
  2. require_once ABSPATH . WPINC . '/embed.php'; 
  3.  
  4.  
  5. // NOTICE! Understand what this does before running. 
  6. $result = wp_maybe_load_embeds(); 
  7.  

Defined (1)

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

/wp-includes/embed.php  
  1. function wp_maybe_load_embeds() { 
  2. /** 
  3. * Filters whether to load the default embed handlers. 
  4. * Returning a falsey value will prevent loading the default embed handlers. 
  5. * @since 2.9.0 
  6. * @param bool $maybe_load_embeds Whether to load the embeds library. Default true. 
  7. */ 
  8. if ( ! apply_filters( 'load_default_embeds', true ) ) { 
  9. return; 
  10.  
  11. wp_embed_register_handler( 'youtube_embed_url', '#https?://(www.)?youtube\.com/(?:v|embed)/([^/]+)#i', 'wp_embed_handler_youtube' ); 
  12.  
  13. /** 
  14. * Filters the audio embed handler callback. 
  15. * @since 3.6.0 
  16. * @param callable $handler Audio embed handler callback function. 
  17. */ 
  18. wp_embed_register_handler( 'audio', '#^https?://.+?\.(' . join( '|', wp_get_audio_extensions() ) . ')$#i', apply_filters( 'wp_audio_embed_handler', 'wp_embed_handler_audio' ), 9999 ); 
  19.  
  20. /** 
  21. * Filters the video embed handler callback. 
  22. * @since 3.6.0 
  23. * @param callable $handler Video embed handler callback function. 
  24. */ 
  25. wp_embed_register_handler( 'video', '#^https?://.+?\.(' . join( '|', wp_get_video_extensions() ) . ')$#i', apply_filters( 'wp_video_embed_handler', 'wp_embed_handler_video' ), 9999 );