wp_embed_register_handler

Registers an embed handler.

Description

wp_embed_register_handler( (string) $id, (string) $regex, (callable) $callback, (int) $priority = 10 ); 

Should probably only be used for sites that do not support oEmbed.

Parameters (4)

0. $id (string)
An internal ID/name for the handler. Needs to be unique.
1. $regex (string)
The regex that will be used to see if this handler should be used for a URL.
2. $callback (callable)
The callback function that will be called if the regex is matched.
3. $priority — Optional. (int) => 10
Used to specify the order in which the registered handlers will be tested. Default 10.

Usage

  1. if ( !function_exists( 'wp_embed_register_handler' ) ) { 
  2. require_once ABSPATH . WPINC . '/embed.php'; 
  3.  
  4. // An internal ID/name for the handler. Needs to be unique. 
  5. $id = ''; 
  6.  
  7. // The regex that will be used to see if this handler should be used for a URL. 
  8. $regex = ''; 
  9.  
  10. // The callback function that will be called if the regex is matched. 
  11. $callback = null; 
  12.  
  13. // Optional. Used to specify the order in which the registered handlers will 
  14. // be tested. Default 10. 
  15. $priority = 10; 
  16.  
  17. // NOTICE! Understand what this does before running. 
  18. $result = wp_embed_register_handler($id, $regex, $callback, $priority); 
  19.  

Defined (1)

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

/wp-includes/embed.php  
  1. function wp_embed_register_handler( $id, $regex, $callback, $priority = 10 ) { 
  2. global $wp_embed; 
  3. $wp_embed->register_handler( $id, $regex, $callback, $priority );