WordPress.org

Plugin Directory

Changeset 211037


Ignore:
Timestamp:
02/27/10 16:46:44 (4 years ago)
Author:
Caspie
Message:

More than 1 video into the widget

Location:
easy-vbox7/trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • easy-vbox7/trunk/easy-vbox7.php

    r174802 r211037  
    44Plugin URI: http://blog.caspie.net/2009/02/14/easy-vbox7-wordpress-plugin/ 
    55Description: Quick and easy way to insert videos from VBOX7.com right into your WordPress blog posts, pages and sidebar. 
    6 Version: 1.2 
     6Version: 1.3 
    77Author: Casper 
    88Author URI: http://blog.caspie.net/ 
     
    1515add_filter( 'the_content', 'easy_vbox7_content', 100 ); 
    1616 
    17 if ( version_compare( $wp_version, '2.8', '>=' ) ) 
     17if ( version_compare( $wp_version, '2.9', '>=' ) ) 
    1818    add_action( 'widgets_init', 'widget_easy_vbox7_init' ); 
    1919else 
     
    2222function easy_vbox7_plugin_notice( $plugin ) { 
    2323    if( $plugin == 'easy-vbox7/easy-vbox7.php' ) 
    24         echo '<tr class="plugin-update-tr"><td class="plugin-update" colspan="3"><div class="update-message" style="background-color:#ffebe8;border-color:#cc0000;color:#cc0000;">WordPress 2.8+ is required for this plugin to work properly! The new Easy VBOX7 Widget was not initialized.</div></td></tr>'; 
     24        echo '<tr class="plugin-update-tr"><td class="plugin-update" colspan="3"><div class="update-message" style="background-color:#ffebe8;border-color:#cc0000;color:#cc0000;">WordPress 2.9+ is required for this plugin to work properly! The Easy VBOX7 Widget was not initialized.</div></td></tr>'; 
    2525} 
    2626 
    27 function easy_vbox7_output($v = '89af3669', $w = 450, $h = 403, $a = 0) { 
    28     $vbox7 = '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="' . $w . '" height="' . $h . '"><param name="movie" value="http://i.vbox7.com/player/ext.swf?vid=' . $v . '&amp;autoplay=' . $a . '"><param name="quality" value="high"><embed src="http://i.vbox7.com/player/ext.swf?vid=' . $v . '&amp;autoplay=' . $a . '" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="' . $w . '" height="' . $h . '"></embed></object>'; 
     27function easy_vbox7_output( $v = '89af3669', $w = 450, $h = 403, $a = 0 ) { 
     28    $vbox7 = '<object style="outline:none;" type="application/x-shockwave-flash" data="http://i.vbox7.com/player/ext.swf?vid=' . $v . '&amp;autoplay=' . $a . '" width="' . $w . '" height="' . $h . '"><param name="movie" value="http://i.vbox7.com/player/ext.swf?vid=' . $v . '&amp;autoplay=' . $a . '" /></object>'; 
    2929    return $vbox7; 
    3030} 
    3131 
    32 function easy_vbox7_content($the_content) { 
    33     $pattern = "/\[play:([a-z0-9]{8})(:[1-9][0-9]{1,2})?(:[1-9][0-9]{1,2})?(:1)?\]/"; 
     32function easy_vbox7_content( $the_content ) { 
     33    $pattern = '/\[play:([a-z0-9]{8})(:[1-9][0-9]{1,2})?(:[1-9][0-9]{1,2})?(:1)?\]/'; 
    3434    if ( preg_match_all( $pattern, $the_content, $matches, PREG_SET_ORDER ) ) { 
    3535        foreach ( $matches as $value ) { 
    3636            $video = $value[1]; 
    37             $width = $value[2] ? str_replace(":", "", $value[2]) : "450"; 
    38             $height = $value[3] ? str_replace(":", "", $value[3]) : "403"; 
     37            $width = $value[2] ? str_replace( ':', '', $value[2] ) : '450'; 
     38            $height = $value[3] ? str_replace( ':', '', $value[3] ) : '403'; 
    3939            $autoplay = $value[4] ? 1 : 0; 
    4040            $the_content = str_replace( $value[0], easy_vbox7_output( $video, $width, $height, $autoplay ), $the_content ); 
     
    6262        } 
    6363 
    64         function widget($args, $instance) { 
    65             extract($args); 
     64        function widget( $args, $instance ) { 
     65            extract( $args ); 
    6666            echo $before_widget; 
    6767            $title = apply_filters( 'widget_title', $instance['title'] ); 
    6868            if ( !empty( $title ) ) { echo $before_title . $title . $after_title; } 
    69             $video = $instance['video']; 
     69            $videos = explode( ',', $instance['video'] ); 
     70            $vid = array_rand( $videos ); 
     71            $video = trim( $videos[$vid] ); 
    7072            $width = $instance['width']; 
    7173            $height = $instance['height']; 
     
    7577        } 
    7678 
    77         function update($new_instance, $old_instance) { 
     79        function update( $new_instance, $old_instance ) { 
    7880            $instance = $old_instance; 
    79             $instance['title'] = trim( strip_tags( $new_instance['title'] ) ); 
    80             $instance['video'] = trim( strip_tags( $new_instance['video'] ) ); 
    81             $instance['width'] = (int) trim( strip_tags( $new_instance['width'] ) ); 
    82             $instance['height'] = (int) trim( strip_tags( $new_instance['height'] ) ); 
     81            $instance['title'] = wp_strip_all_tags( $new_instance['title'] ); 
     82            $instance['video'] = wp_strip_all_tags( $new_instance['video'] ); 
     83            $instance['width'] = (int) wp_strip_all_tags( $new_instance['width'] ); 
     84            $instance['height'] = (int) wp_strip_all_tags( $new_instance['height'] ); 
    8385            $instance['autoplay'] = (bool) $new_instance['autoplay']; 
    8486            return $instance; 
    8587        } 
    8688 
    87         function form($instance) { 
     89        function form( $instance ) { 
    8890            $autoplay = $instance['autoplay']; 
    8991             
     
    9193                $title = 'Video'; 
    9294            else 
    93                 $title = esc_attr($instance['title']); 
     95                $title = esc_attr( $instance['title'] ); 
    9496 
    9597            if ( !$video = $instance['video'] ) 
    9698                $video = '89af3669'; 
    9799            else 
    98                 $video = esc_attr($instance['video']); 
     100                $video = esc_attr( $instance['video'] ); 
    99101 
    100102            if ( !$width = (int) $instance['width'] ) 
    101103                $width = 190; 
    102104            else 
    103                 $width = esc_attr($instance['width']); 
     105                $width = esc_attr( $instance['width'] ); 
    104106 
    105107            if ( !$height = (int) $instance['height'] ) 
    106108                $height = 180; 
    107109            else 
    108                 $height = esc_attr($instance['height']); 
     110                $height = esc_attr( $instance['height'] ); 
    109111        ?> 
    110112            <p><label for="<?php echo $this->get_field_id( 'title' ); ?>">Title: <input class="widefat" id="<?php echo $this->get_field_id( 'title' ); ?>" name="<?php echo $this->get_field_name( 'title' ); ?>" type="text" value="<?php echo $title; ?>" /></label></p> 
     
    122124*/ 
    123125 
    124 add_shortcode('vbox7', 'vbox7_shortcode'); 
     126add_shortcode( 'vbox7', 'vbox7_shortcode' ); 
    125127 
    126 function vbox7_shortcode($atts, $video ) { 
     128function vbox7_shortcode( $atts, $video ) { 
    127129    $video = $video ? $video : '89af3669'; 
    128130    $atts = shortcode_atts( array( 'id' => $video, 'width' => 450, 'height' => 403, 'autoplay' => 0 ), $atts ); 
  • easy-vbox7/trunk/readme.txt

    r174775 r211037  
    11=== Easy VBOX7 === 
    22Contributors: Caspie 
    3 Donate link: http://blog.caspie.net/downloads 
     3Donate link: http://donate.caspie.net/ 
    44Tags: vbox, vbox7, video, videos, clip, clips, insert, posts, pages, sidebar 
    5 Requires at least: 2.8 
    6 Tested up to: 2.8.6 
    7 Stable tag: 1.2 
     5Requires at least: 2.9 
     6Tested up to: 2.9.2 
     7Stable tag: 1.3 
    88 
    99Quick and easy way to insert videos from VBOX7.com right into your WordPress blog posts, pages and sidebar. 
     
    3838== Screenshots == 
    3939 
    40 1. Easy VBOX7 - Usage 
    41 2. Easy VBOX7 - Widget 
     401. Easy VBOX7 Usage 
     412. Easy VBOX7 Widget 
    4242 
    4343== Changelog == 
     44 
     45= 1.3 = 
     46* Added ability to add more than one video ID into the widget video field. Separate with comma: ID1, ID2, ID3 etc. 
     47* Code validation. 
     48* Minor code enhancements. 
    4449 
    4550= 1.2 = 
Note: See TracChangeset for help on using the changeset viewer.