Guest User

CBS Embed code for WordPress

a guest
May 23rd, 2012
172
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.27 KB | None | 0 0
  1. add_action('plugins_loaded','add_cbs_embed');
  2. function add_cbs_embed() {
  3.     wp_embed_register_handler( 'cbsvideo', '#https?://(www\.)?cbs.com/.*?/video/\?pid=([^&]*).*#i', 'wp_embed_handler_cbsvideo' );
  4. }
  5.  
  6. function wp_embed_handler_cbsvideo( $matches, $attr, $url, $rawattr ) {
  7.     $pid = $matches[2];
  8.     if ( !empty($rawattr['width']) && !empty($rawattr['height']) ) {
  9.         $width  = (int) $rawattr['width'];
  10.         $height = (int) $rawattr['height'];
  11.     } else {
  12.         list( $width, $height ) = wp_expand_dimensions( 400, 300, $attr['width'], $attr['height'] );
  13.     }
  14.  
  15.     return apply_filters( 'embed_cbsvideo', "<object width='400' height='300'><param name='movie' value='http://www.cbs.com/e/".esc_attr($pid)."/cbs/1/'></param><param name='allowFullScreen' value='true'></param><param name='allowScriptAccess' value='always'></param><param name='FlashVars' value='config=http://www.cbs.com/thunder/player/1_0/partner/cbs/skin_cbs_norelated'></param><embed width='".esc_attr($width)."' height='".esc_attr($height)."' src='http://www.cbs.com/e/".esc_attr($pid)."/cbs/1/'  allowfullscreen='true' allowScriptAccess='always' type='application/x-shockwave-flash' FlashVars='config=http://www.cbs.com/thunder/player/1_0/partner/cbs/skin_cbs_norelated'></embed></object>", $matches, $attr, $url, $rawattr );
  16. }
Advertisement
Add Comment
Please, Sign In to add comment