Skip to content

Instantly share code, notes, and snippets.

@jlao
Created July 8, 2010 04:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jlao/467644 to your computer and use it in GitHub Desktop.
Save jlao/467644 to your computer and use it in GitHub Desktop.
function p75_jw_player_handler( $matches, $attr, $url, $rawattr )
{
static $counter = 1;
if ( !empty($rawattr['width']) && !empty($rawattr['height']) ) {
$width = (int) $rawattr['width'];
$height = (int) $rawattr['height'];
} else {
list( $width, $height ) = wp_expand_dimensions(
get_option('p75_default_player_width'),
get_option('p75_default_player_height'),
$attr['width'], $attr['height'] );
}
$flashvars = get_option('p75_jw_flashvars');
if ( !empty($flashvars) && substr($flashvars, 0, 1)!='&' )
parse_str( $flashvars, $vars );
$file_loc = get_option('p75_jw_files');
if ( substr($file_loc, -1)!='/' )
$file_loc = $file_loc . '/';
$res = "
<script type='text/javascript' src='{$file_loc}swfobject.js'></script>
<div id='videoContainer-" . $counter . "'>This text will be replaced</div>
<script type='text/javascript'>
var so = new SWFObject('{$file_loc}player.swf','ply','" . esc_attr($width) . "','" . esc_attr($height) . "','9','#000000');
so.addParam('allowfullscreen','true');
so.addParam('allowscriptaccess','always');
so.addParam('wmode','opaque');
so.addVariable('file','" . esc_attr($url) . "');\n";
foreach ( $vars as $key => $val )
$res .= "so.addVariable('$key','" . rawurlencode($val) . "');\n";
$res .= "so.write('videoContainer-" . $counter++ . "');
</script>\n";
return $res;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment