jetpack_shortcode_get_hulu_id

Return a Hulu video ID from a given set to attributes.

Description

(string) jetpack_shortcode_get_hulu_id( (array) $atts ); 

Returns (string)

$id Hulu video ID.

Parameters (1)

0. $atts (array)
Shortcode parameters.

Usage

  1. if ( !function_exists( 'jetpack_shortcode_get_hulu_id' ) ) { 
  2. require_once '/modules/shortcodes/hulu.php'; 
  3.  
  4. // Shortcode parameters. 
  5. $atts = array(); 
  6.  
  7. // NOTICE! Understand what this does before running. 
  8. $result = jetpack_shortcode_get_hulu_id($atts); 
  9.  

Defined (1)

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

/modules/shortcodes/hulu.php  
  1. function jetpack_shortcode_get_hulu_id( $atts ) { 
  2. // This will catch an id explicitly defined as such, or assume any param without a label is the id. First found is used. 
  3. if ( isset( $atts['id'] ) ) { 
  4. // First we check to see if [hulu id=369061] or [hulu id=gQ6Z0I990IWv_VFQI2J7Eg] was used 
  5. $id = esc_attr( $atts['id'] ); 
  6. } else if ( isset( $atts[0] ) && preg_match( '|www\.hulu\.com/watch/(\d+)|i', $atts[0], $match ) ) { 
  7. // this checks for [hulu http://www.hulu.com/watch/369061] 
  8. $id = (int) $match[1]; 
  9. } else if ( isset( $atts[0] ) ) { 
  10. // This checks for [hulu 369061] or [hulu 65yppv6xqa45s5n7_m1wng] 
  11. $id = esc_attr( $atts[0] ); 
  12. } else { 
  13. $id = 0; 
  14.  
  15. return $id;