A recent upgrade to wordpress 3.1 broke a custom plugin written to make use of shortcode in order to generate easy embed html for brightcove videos.
Can anyone see what is happening in the following code that is incompatible with 3.1, and what needs to happen for it to be fixed? It was working fine in 3.0 prior to upgrade.
<?php
/*
Plugin Name: Brightcove Video Player
Version: 1.0
Plugin URI: http://www.brightcove.com
Description: Simplifies the process of adding a Brightcove video to a WordPress blog.
Author: Bob de Wit
Author URI: http://brightcove.active6.com
*/
//Set the publisher ID - YOU MUST SET THIS TO YOUR OWN PUBLISHER ID
$publisher = 1705665024;
//Set a default player to use - YOU MUST SET THIS TO YOUR OWN DEFAULT PLAYER
$player = 1911416499;
//Set width and height for the default video player
$width = 486;
$height = 412;
//Define default video variable
$videoid = 0;
//The actual parse content function called by the filter
//This will use the callback function BCVideo_Render to do the
//actual text replacement for the widget
function Brightcove_Parse($content)
{
$content = preg_replace_callback("/\[brightcove ([^]]*)\/\]/i", "Brightcove_Render", $content);
return $content;
}
function Brightcove_Render($matches)
{
global $video, $player, $publisher, $width, $height, $arguments;
$output = '';
$matches[1] = str_replace(array('”','″'), '', $matches[1]);
preg_match_all('/(\w*)=(.*?) /i', $matches[1], $attributes);
$arguments = array();
foreach ( (array) $attributes[1] as $key => $value )
{
// Strip out legacy quotes
$arguments[$value] = str_replace('"', '', $attributes[2][$key]);
}
//print_r( $arguments );
if (( !array_key_exists('video', $arguments) ) && ( !array_key_exists('player', $arguments) ))
{
return '<div style="background-color:#f99; padding:10px;">Brightcove Player Widget Error: Required parameter "video" or "player" is missing!</div>';
exit;
}
else
{
$video = $arguments['video'];
}
if( array_key_exists('width', $arguments) )
{
$height = $arguments['width'];
}
if( array_key_exists('height', $arguments) )
{
$height = $arguments['height'];
}
if( array_key_exists('player', $arguments) )
{
$player = $arguments['player'];
}
//$flashVars = "isVid=1&playerID=$player&publisherID=$publisher&@videoPlayer=$video";
$output .= "<embed src='http://c.brightcove.com/services/viewer/federated_f9/$player?isVid=1&publisherID=$publisher'
bgcolor='#FFFFFF'
flashVars='@videoPlayer=$video&playerID=$player&domain=embed&'
base='http://admin.brightcove.com'
name='flashObj'
width='$width'
height='$height'
seamlesstabbing='false'
type='application/x-shockwave-flash'
allowFullScreen='true'
swLiveConnect='true'
pluginspage='http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash'>
</embed>";
return $output;
}
//Add a filter hook - this registers the function for all content
//text (Pages and Posts) to search for the [CONTRIBUTOR_WIDGET] tag.
add_filter('the_content', 'Brightcove_Parse');
?>
Thanks!