ustream_shortcode

Parse shortcode arguments and render output for ustream single video.

Description

(string) ustream_shortcode( $atts ); 

Returns (string)

HTML output.

Parameters (1)

0. $atts
Array of user-supplied arguments.

Usage

  1. if ( !function_exists( 'ustream_shortcode' ) ) { 
  2. require_once '/modules/shortcodes/ustream.php'; 
  3.  
  4. // array of user-supplied arguments. 
  5. $atts = null; 
  6.  
  7. // NOTICE! Understand what this does before running. 
  8. $result = ustream_shortcode($atts); 
  9.  

Defined (1)

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

/modules/shortcodes/ustream.php  
  1. function ustream_shortcode( $atts ) { 
  2. if ( isset( $atts[0] ) ) { 
  3. return '<!-- ustream error: bad parameters -->'; 
  4.  
  5. $defaults = array( 
  6. 'width' => 480,  
  7. 'height' => 296,  
  8. 'id' => 0,  
  9. 'live' => 0,  
  10. 'highlight' => 0,  
  11. 'version' => 3,  
  12. 'hwaccel' => 1,  
  13. ); 
  14.  
  15. $atts = array_map( 'intval', shortcode_atts( $defaults, $atts ) ); 
  16.  
  17. $ustream_id = $atts['id']; 
  18. $width = $atts['width']; 
  19. $height = $atts['height']; 
  20. $live = $atts['live']; 
  21. $highlight = $atts['highlight']; 
  22. $version = $atts['version']; 
  23. $hwaccel = $atts['hwaccel']; 
  24.  
  25. $version = 'v=' . esc_attr( $version ); 
  26.  
  27. if ( 0 >= $ustream_id ) { 
  28. return '<!-- ustream error: bad video ID -->'; 
  29.  
  30. if ( 0 >= $height ) { 
  31. return '<!-- ustream error: height invalid -->'; 
  32.  
  33. if ( 0 >= $width ) { 
  34. return '<!-- ustream error: width invalid -->'; 
  35.  
  36. if ( $live ) { 
  37. $recorded = ''; 
  38. } else { 
  39. $recorded = 'recorded/'; 
  40.  
  41. if ( ! $live && ( 0 < $highlight ) ) { 
  42. $highlight = "/highlight/$highlight"; 
  43. } else { 
  44. $highlight = ''; 
  45.  
  46. if ( 0 < $hwaccel ) { 
  47. $wmode = '&wmode=direct'; 
  48. } else { 
  49. $wmode = ''; 
  50.  
  51. $url = 'http://www.ustream.tv/embed/' . $recorded . esc_attr( $ustream_id ) . $highlight . '?' . $version . $wmode; 
  52. $url = set_url_scheme( $url ); 
  53. $output = '<iframe src="' . esc_url( $url ) . '" width="' . esc_attr( $width ) . '" height="' . esc_attr( $height ) . '" scrolling="no" style="border: 0 none transparent;"></iframe>'; 
  54.  
  55. return $output;