Plugin Directory

Changeset 1244206


Ignore:
Timestamp:
09/12/2015 09:25:12 PM (11 years ago)
Author:
Caspie
Message:

Add version 1.4 to trunk.

Location:
easy-vbox7/trunk
Files:
3 added
2 deleted
3 edited

Legend:

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

    r211037 r1244206  
    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.3
    7 Author: Casper
     6Version: 1.4
     7Author: Caspie
    88Author URI: http://blog.caspie.net/
     9License: GPLv2 or later
     10Text Domain: easy-vbox7
    911*/
    1012
    1113/*
    12 ** Easy VBOX7 Core
     14This program is free software; you can redistribute it and/or
     15modify it under the terms of the GNU General Public License
     16as published by the Free Software Foundation; either version 2
     17of the License, or (at your option) any later version.
     18
     19This program is distributed in the hope that it will be useful,
     20but WITHOUT ANY WARRANTY; without even the implied warranty of
     21MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     22GNU General Public License for more details.
     23
     24You should have received a copy of the GNU General Public License
     25along with this program; if not, write to the Free Software
     26Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
    1327*/
     28defined( 'WPINC' ) or die;
    1429
     30if ( version_compare( $GLOBALS['wp_version'], '2.9', '>=' ) ) {
     31    add_action( 'widgets_init', 'easy_vbox7_widgets' );
     32} else {
     33    add_action( 'admin_notices', 'easy_vbox7_notice' );
     34}
     35
     36/**
     37 * Include widgets
     38 */
     39include 'includes/widgets/class-easy-vbox7-video.php';
     40
     41/**
     42 * Register widgets
     43 */
     44function easy_vbox7_widgets() {
     45    register_widget( 'Easy_Vbox7_Video_Widget' );
     46}
     47
     48/**
     49 * Admin notice
     50 */
     51function easy_vbox7_notice() {
     52    echo '<div id="message" class="error notice is-dismissible"><p>' . __( 'WordPress 2.9 or newer is required for this plugin to work properly! Easy VBOX7 widgets were not initialized.', 'easy-vbox7' ) . '</p></div>';
     53}
     54
     55/**
     56 * Output
     57 *
     58 * @param array $atts
     59 *
     60 * @return string
     61 */
     62function easy_vbox7_output( $atts ) {
     63    // Bail early if no video
     64    if ( ! $atts['video'] ) {
     65        return '';
     66    }
     67
     68    // Sanitize input
     69    $atts['video']    = array_map( 'trim', explode( ',', ( isset( $atts['id'] ) ? $atts['id'] : $atts['video'] ) ) );
     70    $atts['width']    = (int) $atts['width'];
     71    $atts['height']   = (int) $atts['height'];
     72    $atts['autoplay'] = $atts['autoplay'] ? 1 : 0;
     73
     74    // Additional class
     75    $class = ( ! $atts['width'] || ! $atts['height'] ) ? ' easy-vbox7-container' : '';
     76
     77    // Return
     78    return '<p class="easy_vbox7' . $class . '"><iframe width="' . $atts['width'] . '" height="' . $atts['height'] . '" src="http://vbox7.com/emb/external.php?vid=' . $atts['video'][mt_rand( 0, count( $atts['video'] ) - 1 )] . '&amp;autoplay=' . $atts['autoplay'] . '" frameborder="0" allowfullscreen></iframe></p>';
     79}
     80
     81/**
     82 * Filter content
     83 *
     84 * @param string $content
     85 *
     86 * @return mixed
     87 */
     88function easy_vbox7_content( $content ) {
     89    $pattern = '/\[play:([a-zA-Z0-9]{8,},?)+(:[1-9][0-9]{1,3})?(:[1-9][0-9]{1,3})?(:[0|1])?\]/';
     90
     91    if ( preg_match_all( $pattern, $content, $matches, PREG_SET_ORDER ) ) {
     92        foreach ( $matches as $value ) {
     93            $atts['video']    = ( isset( $value[1][7] ) ) ? $value[1] : '';
     94            $atts['width']    = ( isset( $value[2][1] ) ) ? (int) str_replace( ':', '', $value[2] ) : '';
     95            $atts['height']   = ( isset( $value[3][1] ) ) ? (int) str_replace( ':', '', $value[3] ) : '';
     96            $atts['autoplay'] = ( isset( $value[4][1] ) ) ? 1 : 0;
     97
     98            $content = str_replace( $value[0], easy_vbox7_output( $atts ), $content );
     99        }
     100    }
     101    return $content;
     102}
    15103add_filter( 'the_content', 'easy_vbox7_content', 100 );
    16104
    17 if ( version_compare( $wp_version, '2.9', '>=' ) )
    18     add_action( 'widgets_init', 'widget_easy_vbox7_init' );
    19 else
    20     add_action( 'after_plugin_row', 'easy_vbox7_plugin_notice' );
     105/**
     106 * Shortcode
     107 *
     108 * @param array $atts
     109 * @param null $content
     110 *
     111 * @return string
     112 */
     113function easy_vbox7_shortcode( $atts, $content = null ) {
     114    $atts = shortcode_atts( array( 'id' => $content, 'video' => $content, 'width' => '', 'height' => '', 'autoplay' => 0 ), $atts );
    21115
    22 function easy_vbox7_plugin_notice( $plugin ) {
    23     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.9+ is required for this plugin to work properly! The Easy VBOX7 Widget was not initialized.</div></td></tr>';
     116    return easy_vbox7_output( $atts );
    25117}
     118add_shortcode( 'vbox7', 'easy_vbox7_shortcode' );
    26119
    27 function 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>';
    29     return $vbox7;
     120/**
     121 * Additional styling
     122 */
     123function easy_vbox7_style() {
     124?>
     125<style>
     126    .easy_vbox7 {
     127        display: block;
     128    }
     129    .easy-vbox7-container {
     130        position: relative;
     131        padding-bottom: 56.25%;
     132        padding-top: 35px;
     133        height: 0;
     134        overflow: hidden;
     135    }
     136    .easy-vbox7-container iframe {
     137        position: absolute;
     138        top:0;
     139        left: 0;
     140        width: 100%;
     141        height: 100%;
     142    }
     143</style>
     144<?php
    30145}
    31 
    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)?\]/';
    34     if ( preg_match_all( $pattern, $the_content, $matches, PREG_SET_ORDER ) ) {
    35         foreach ( $matches as $value ) {
    36             $video = $value[1];
    37             $width = $value[2] ? str_replace( ':', '', $value[2] ) : '450';
    38             $height = $value[3] ? str_replace( ':', '', $value[3] ) : '403';
    39             $autoplay = $value[4] ? 1 : 0;
    40             $the_content = str_replace( $value[0], easy_vbox7_output( $video, $width, $height, $autoplay ), $the_content );
    41         }
    42     }
    43     return $the_content;
    44 }
    45 
    46 /*
    47 ** Easy VBOX7 Widget
    48 */
    49 
    50 function widget_easy_vbox7_init() {
    51     register_widget( 'Easy_Vbox7_Widget' );
    52 }
    53 
    54 if ( class_exists( 'WP_Widget' ) ) {
    55 
    56     class Easy_Vbox7_Widget extends WP_Widget {
    57 
    58         function Easy_Vbox7_Widget() {
    59             $widget_ops = array( 'classname' => 'widget_easy_vbox7', 'description' => 'Add VBOX7 Videos to your sidebar' );
    60             $control_ops = array( 'id_base' => 'easy-vbox7', 'video' => '89af3669', 'width' => 190, 'height' => 180, 'autoplay' => false );
    61             $this->WP_Widget( 'easy-vbox7', 'Easy VBOX7', $widget_ops, $control_ops );
    62         }
    63 
    64         function widget( $args, $instance ) {
    65             extract( $args );
    66             echo $before_widget;
    67             $title = apply_filters( 'widget_title', $instance['title'] );
    68             if ( !empty( $title ) ) { echo $before_title . $title . $after_title; }
    69             $videos = explode( ',', $instance['video'] );
    70             $vid = array_rand( $videos );
    71             $video = trim( $videos[$vid] );
    72             $width = $instance['width'];
    73             $height = $instance['height'];
    74             $autoplay = $instance['autoplay'] ? 1 : 0;
    75             echo '<span class="easy_vbox7" style="display:block;">' . easy_vbox7_output( $video, $width, $height, $autoplay ) . '</span>';
    76             echo $after_widget;
    77         }
    78 
    79         function update( $new_instance, $old_instance ) {
    80             $instance = $old_instance;
    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'] );
    85             $instance['autoplay'] = (bool) $new_instance['autoplay'];
    86             return $instance;
    87         }
    88 
    89         function form( $instance ) {
    90             $autoplay = $instance['autoplay'];
    91            
    92             if ( !$title = $instance['title'] )
    93                 $title = 'Video';
    94             else
    95                 $title = esc_attr( $instance['title'] );
    96 
    97             if ( !$video = $instance['video'] )
    98                 $video = '89af3669';
    99             else
    100                 $video = esc_attr( $instance['video'] );
    101 
    102             if ( !$width = (int) $instance['width'] )
    103                 $width = 190;
    104             else
    105                 $width = esc_attr( $instance['width'] );
    106 
    107             if ( !$height = (int) $instance['height'] )
    108                 $height = 180;
    109             else
    110                 $height = esc_attr( $instance['height'] );
    111         ?>
    112             <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>
    113             <p><label for="<?php echo $this->get_field_id( 'video' ); ?>">Video: <input class="widefat" id="<?php echo $this->get_field_id( 'video' ); ?>" name="<?php echo $this->get_field_name( 'video' ); ?>" type="text" value="<?php echo $video; ?>" /></label></p>
    114             <p><label for="<?php echo $this->get_field_id( 'width' ); ?>">Width: <input class="widefat" id="<?php echo $this->get_field_id( 'width' ); ?>" name="<?php echo $this->get_field_name( 'width' ); ?>" type="text" value="<?php echo $width; ?>" /></label></p>
    115             <p><label for="<?php echo $this->get_field_id( 'height' ); ?>">Height: <input class="widefat" id="<?php echo $this->get_field_id( 'height' ); ?>" name="<?php echo $this->get_field_name( 'height' ); ?>" type="text" value="<?php echo $height; ?>" /></label></p>
    116             <p><label for="<?php echo $this->get_field_id( 'autoplay' ); ?>">Autoplay: <input class="checkbox" id="<?php echo $this->get_field_id( 'autoplay' ); ?>" name="<?php echo $this->get_field_name( 'autoplay' ); ?>" type="checkbox" value="1"<?php checked( true, $autoplay ); ?> /></label></p>
    117    <?php
    118        }
    119     }
    120 }
    121 
    122 /*
    123 ** Easy VBOX7 Shortcode
    124 */
    125 
    126 add_shortcode( 'vbox7', 'vbox7_shortcode' );
    127 
    128 function vbox7_shortcode( $atts, $video ) {
    129     $video = $video ? $video : '89af3669';
    130     $atts = shortcode_atts( array( 'id' => $video, 'width' => 450, 'height' => 403, 'autoplay' => 0 ), $atts );
    131     return easy_vbox7_output( $atts['id'], $atts['width'], $atts['height'], $atts['autoplay'] );
    132 }
    133 
    134 ?>
     146add_action( 'wp_head', 'easy_vbox7_style', 100 );
  • easy-vbox7/trunk/readme.txt

    r211037 r1244206  
    22Contributors: Caspie
    33Donate link: http://donate.caspie.net/
    4 Tags: vbox, vbox7, video, videos, clip, clips, insert, posts, pages, sidebar
     4Tags: vbox, vbox7, vbox7.com, video, videos, clip, clips, embed, media insert, posts, pages, sidebar
    55Requires at least: 2.9
    6 Tested up to: 2.9.2
    7 Stable tag: 1.3
     6Tested up to: 4.3
     7Stable tag: 1.4
     8License: GPLv2 or later
     9License URI: http://www.gnu.org/licenses/gpl-2.0.html
    810
    911Quick and easy way to insert videos from VBOX7.com right into your WordPress blog posts, pages and sidebar.
     
    1113== Description ==
    1214
    13 Quick and easy way to insert videos from VBOX7.com right into your WordPress blog posts, pages and sidebar. VBOX7 is the biggest Bulgarian video portal so far. It already has a few million videos and lot of them have titles or tags in english. So even if you can't read Bulgarian, you can easily use the big search box at the top-right corner of the website (vbox7.com) to find your favorite videos and to embed them right into your posts.
     15Quick and easy way to embed videos from VBOX7.com right into your WordPress blog posts, pages and sidebar. VBOX7 is one of the biggest Bulgarian video portals. Many videos have titles or tags in English, so even if you can't read Bulgarian, you can easily use the big search box on top of the website (vbox7.com) to find your favorite videos and to embed them right into your posts.
    1416
    1517Go to Other Notes for: Default, Recommended and Advanced Usage.
     
    1820== Installation ==
    1921
    20 1. Unzip the file easy-vbox7.zip wherever you want.
    21 2. Upload the extracted folder easy-vbox7 in /wp-content/plugins/ of your Wordpress installation.
    22 3. Activate the Plugin via the Plugins section at your WordPress admin panel.
     221. Search and install the plugin via WordPress &gt; Plugins &gt; Add New
     232. Or download the plugin from WordPress.org plugin directory.
     243. Unzip the file easy-vbox7.zip wherever you want.
     254. Upload the extracted easy-vbox7 folder in /wp-content/plugins/ of your WordPress installation.
     265. Activate the Plugin via the Plugins section at your WordPress admin panel.
    2327
    2428== Frequently Asked Questions ==
    2529
     30= iframe or object? =
     31
     32Since version 1.4, iframe is used.
     33
    2634= Casper? =
    2735
    28 Yes, but keep in mind that my wordpress.org username is Caspie.
     36Yes, but keep in mind that my WordPress.org username is Caspie.
    2937
    3038= I want to thank you or send you some feedback? =
     
    4250
    4351== Changelog ==
     52
     53= 1.4 =
     54* Plugin refresh after... 5 years. Doh! :)
     55* Updated code to use iframe embeds.
     56* Widget moved to a separate file.
     57* Widget constructor updated to avoid deprecation notices.
     58* Shortcode supports multiple video IDs, separated with comma.
     59* Code enhancements and optimizations.
    4460
    4561= 1.3 =
  • easy-vbox7/trunk/uninstall.php

    r211037 r1244206  
    11<?php
     2/**
     3 * Uninstall
     4 */
     5if ( ! defined( 'WP_UNINSTALL_PLUGIN' ) || ! WP_UNINSTALL_PLUGIN ||
     6    dirname( WP_UNINSTALL_PLUGIN ) != dirname( plugin_basename( __FILE__ ) ) ) {
     7    status_header( 404 );
     8    exit;
     9}
    210
    3 if ( !defined('WP_UNINSTALL_PLUGIN') || !current_user_can( 'delete_plugins' ) ) {
    4     exit();
    5 }
    6 delete_option('widget-easy_vbox7');
    7 
    8 ?>
     11// Delete options
     12delete_option( 'widget_easy-vbox7' );
Note: See TracChangeset for help on using the changeset viewer.