=' ) )
add_action( 'widgets_init', 'widget_easy_vbox7_init' );
else
add_action( 'after_plugin_row', 'easy_vbox7_plugin_notice' );
function easy_vbox7_plugin_notice( $plugin ) {
if( $plugin == 'easy-vbox7/easy-vbox7.php' )
echo '
WordPress 2.9+ is required for this plugin to work properly! The Easy VBOX7 Widget was not initialized. |
';
}
function easy_vbox7_output( $v = '89af3669', $w = 450, $h = 403, $a = 0 ) {
$vbox7 = '';
return $vbox7;
}
function easy_vbox7_content( $the_content ) {
$pattern = '/\[play:([a-z0-9]{8})(:[1-9][0-9]{1,2})?(:[1-9][0-9]{1,2})?(:1)?\]/';
if ( preg_match_all( $pattern, $the_content, $matches, PREG_SET_ORDER ) ) {
foreach ( $matches as $value ) {
$video = $value[1];
$width = $value[2] ? str_replace( ':', '', $value[2] ) : '450';
$height = $value[3] ? str_replace( ':', '', $value[3] ) : '403';
$autoplay = $value[4] ? 1 : 0;
$the_content = str_replace( $value[0], easy_vbox7_output( $video, $width, $height, $autoplay ), $the_content );
}
}
return $the_content;
}
/*
** Easy VBOX7 Widget
*/
function widget_easy_vbox7_init() {
register_widget( 'Easy_Vbox7_Widget' );
}
if ( class_exists( 'WP_Widget' ) ) {
class Easy_Vbox7_Widget extends WP_Widget {
function Easy_Vbox7_Widget() {
$widget_ops = array( 'classname' => 'widget_easy_vbox7', 'description' => 'Add VBOX7 Videos to your sidebar' );
$control_ops = array( 'id_base' => 'easy-vbox7', 'video' => '89af3669', 'width' => 190, 'height' => 180, 'autoplay' => false );
$this->WP_Widget( 'easy-vbox7', 'Easy VBOX7', $widget_ops, $control_ops );
}
function widget( $args, $instance ) {
extract( $args );
echo $before_widget;
$title = apply_filters( 'widget_title', $instance['title'] );
if ( !empty( $title ) ) { echo $before_title . $title . $after_title; }
$videos = explode( ',', $instance['video'] );
$vid = array_rand( $videos );
$video = trim( $videos[$vid] );
$width = $instance['width'];
$height = $instance['height'];
$autoplay = $instance['autoplay'] ? 1 : 0;
echo '' . easy_vbox7_output( $video, $width, $height, $autoplay ) . '';
echo $after_widget;
}
function update( $new_instance, $old_instance ) {
$instance = $old_instance;
$instance['title'] = wp_strip_all_tags( $new_instance['title'] );
$instance['video'] = wp_strip_all_tags( $new_instance['video'] );
$instance['width'] = (int) wp_strip_all_tags( $new_instance['width'] );
$instance['height'] = (int) wp_strip_all_tags( $new_instance['height'] );
$instance['autoplay'] = (bool) $new_instance['autoplay'];
return $instance;
}
function form( $instance ) {
$autoplay = $instance['autoplay'];
if ( !$title = $instance['title'] )
$title = 'Video';
else
$title = esc_attr( $instance['title'] );
if ( !$video = $instance['video'] )
$video = '89af3669';
else
$video = esc_attr( $instance['video'] );
if ( !$width = (int) $instance['width'] )
$width = 190;
else
$width = esc_attr( $instance['width'] );
if ( !$height = (int) $instance['height'] )
$height = 180;
else
$height = esc_attr( $instance['height'] );
?>
$video, 'width' => 450, 'height' => 403, 'autoplay' => 0 ), $atts );
return easy_vbox7_output( $atts['id'], $atts['width'], $atts['height'], $atts['autoplay'] );
}
?>