wpcom_twitchtv_shortcode

(Live URL) http://www.twitch.tv/paperbat.

Description

wpcom_twitchtv_shortcode( $attr, (null) $content = null ); 

Video:

(Archive URL) http://www.twitch.tv/paperbat/v/323486192

Parameters (2)

0. $attr
The attr.
1. $content — Optional. (null) => null
The content.

Usage

  1. if ( !function_exists( 'wpcom_twitchtv_shortcode' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'jetpack-by-wordpress-com/modules/shortcodes/twitchtv.php'; 
  3.  
  4. // The attr. 
  5. $attr = null; 
  6.  
  7. // The content. 
  8. $content = null; 
  9.  
  10. // NOTICE! Understand what this does before running. 
  11. $result = wpcom_twitchtv_shortcode($attr, $content); 
  12.  

Defined (1)

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

/modules/shortcodes/twitchtv.php  
  1. function wpcom_twitchtv_shortcode( $attr, $content = NULL ) { 
  2. $attr = extract( shortcode_atts( array( 
  3. 'height' => 378,  
  4. 'width' => 620,  
  5. 'url' => '',  
  6. 'autoplay' => false 
  7. ), $attr ) ); 
  8.  
  9. if ( empty( $url ) ) 
  10. return; 
  11.  
  12. preg_match( '|^http://www.twitch.tv/([^/?]+)(/v/(\d+))?|i', $url, $match ); 
  13.  
  14. $width = (int) $width; 
  15. $height = (int) $height; 
  16. $autoplay = var_export( filter_var( $autoplay, FILTER_VALIDATE_BOOLEAN ), true ); 
  17.  
  18. $user_id = esc_attr( $match[1] ); 
  19. $video_id = 0; 
  20. if ( !empty( $match[3] ) ) 
  21. $video_id = (int) $match[3]; 
  22.  
  23. /** This action is documented in modules/widgets/social-media-icons.php */ 
  24. do_action( 'jetpack_bump_stats_extras', 'twitchtv', 'shortcode' ); 
  25.  
  26. if ( $video_id > 0 ) { 
  27. // Archive video 
  28. return "<object bgcolor='#000000' data='//www-cdn.jtvnw.net/swflibs/TwitchPlayer.swf' height='$height' width='$width' id='clip_embed_player_flash' type='application/x-shockwave-flash'> 
  29. <param name='movie' value='//www-cdn.jtvnw.net/swflibs/TwitchPlayer.swf'> 
  30. <param name='allowScriptAccess' value='always'> 
  31. <param name='allowNetworking' value='all'> 
  32. <param name='allowFullScreen' value='true'> 
  33. <param name='flashvars' value='videoId=v$video_id&hostname=www.twitch.tv&channel=$user_id&auto_play=$autoplay'> 
  34. </object>"; 
  35.  
  36. $html = "<object type='application/x-shockwave-flash' height='$height' width='$width' id='live_embed_player_flash' data='//www-cdn.jtvnw.net/swflibs/TwitchPlayer.swf?channel=$user_id' bgcolor='#000000'> 
  37. <param name='allowFullScreen' value='true' /> 
  38. <param name='allowScriptAccess' value='always' /> 
  39. <param name='allowNetworking' value='all' /> 
  40. <param name='movie' value='//www-cdn.jtvnw.net/swflibs/TwitchPlayer.swf' /> 
  41. <param name='flashvars' value='hostname=www.twitch.tv&channel=$user_id&auto_play=$autoplay&start_volume=25' /> 
  42. </object>"; 
  43.  
  44. return $html;