wpcom_shortcodereverse_huluhelper

Makes a Hulu shortcode from $attrs and $pattern.

Description

(string) wpcom_shortcodereverse_huluhelper( (array) $attrs ); 

Returns (string)

Parameters (1)

0. $attrs (array)
The attrs.

Usage

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

Defined (1)

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

/modules/shortcodes/hulu.php  
  1. function wpcom_shortcodereverse_huluhelper( $attrs ) { 
  2. $attrs = wpcom_shortcodereverse_parseattr( $attrs ); 
  3.  
  4. $src_attributes = array(); 
  5. parse_str( parse_url( $attrs['src'], PHP_URL_QUERY ), $src_attributes ); 
  6.  
  7. $attrs = array_merge( $attrs, $src_attributes ); 
  8.  
  9. // If we don't have an eid, we can't do anything. Just send back the src string. 
  10. if ( ! isset( $attrs['eid'] ) ) { 
  11. return $attrs['src']; 
  12.  
  13. $shortcode = '[hulu id=' . esc_attr( $attrs['eid'] ); 
  14.  
  15. if ( $attrs['width'] ) { 
  16. $shortcode .= ' width=' . intval( $attrs['width'] ); 
  17.  
  18. if ( $attrs['height'] ) { 
  19. $shortcode .= ' height=' . intval( $attrs['height'] ); 
  20.  
  21. if ( $attrs['st'] ) { 
  22. $shortcode .= ' start_time=' . intval( $attrs['st'] ); 
  23.  
  24. if ( $attrs['et'] ) { 
  25. $shortcode .= ' end_time=' . intval( $attrs['et'] ); 
  26.  
  27. if ( $attrs['it'] ) { 
  28. // the thumbnail frame attribute comes with an i in front of the value, so we've got to remove that 
  29. $shortcode .= ' thumbnail_frame=' . intval( ltrim( $attrs['it'], 'i' ) ); 
  30. $shortcode .= ']'; 
  31.  
  32. return $shortcode;