Changeset 1244206
- Timestamp:
- 09/12/2015 09:25:12 PM (11 years ago)
- Location:
- easy-vbox7/trunk
- Files:
-
- 3 added
- 2 deleted
- 3 edited
-
easy-vbox7.php (modified) (1 diff)
-
includes (added)
-
includes/widgets (added)
-
includes/widgets/class-easy-vbox7-video.php (added)
-
readme.txt (modified) (4 diffs)
-
screenshot-1.png (deleted)
-
screenshot-2.png (deleted)
-
uninstall.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
easy-vbox7/trunk/easy-vbox7.php
r211037 r1244206 4 4 Plugin URI: http://blog.caspie.net/2009/02/14/easy-vbox7-wordpress-plugin/ 5 5 Description: Quick and easy way to insert videos from VBOX7.com right into your WordPress blog posts, pages and sidebar. 6 Version: 1. 37 Author: Casp er6 Version: 1.4 7 Author: Caspie 8 8 Author URI: http://blog.caspie.net/ 9 License: GPLv2 or later 10 Text Domain: easy-vbox7 9 11 */ 10 12 11 13 /* 12 ** Easy VBOX7 Core 14 This program is free software; you can redistribute it and/or 15 modify it under the terms of the GNU General Public License 16 as published by the Free Software Foundation; either version 2 17 of the License, or (at your option) any later version. 18 19 This program is distributed in the hope that it will be useful, 20 but WITHOUT ANY WARRANTY; without even the implied warranty of 21 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 22 GNU General Public License for more details. 23 24 You should have received a copy of the GNU General Public License 25 along with this program; if not, write to the Free Software 26 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 13 27 */ 28 defined( 'WPINC' ) or die; 14 29 30 if ( 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 */ 39 include 'includes/widgets/class-easy-vbox7-video.php'; 40 41 /** 42 * Register widgets 43 */ 44 function easy_vbox7_widgets() { 45 register_widget( 'Easy_Vbox7_Video_Widget' ); 46 } 47 48 /** 49 * Admin notice 50 */ 51 function 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 */ 62 function 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 )] . '&autoplay=' . $atts['autoplay'] . '" frameborder="0" allowfullscreen></iframe></p>'; 79 } 80 81 /** 82 * Filter content 83 * 84 * @param string $content 85 * 86 * @return mixed 87 */ 88 function 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 } 15 103 add_filter( 'the_content', 'easy_vbox7_content', 100 ); 16 104 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 */ 113 function easy_vbox7_shortcode( $atts, $content = null ) { 114 $atts = shortcode_atts( array( 'id' => $content, 'video' => $content, 'width' => '', 'height' => '', 'autoplay' => 0 ), $atts ); 21 115 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 ); 25 117 } 118 add_shortcode( 'vbox7', 'easy_vbox7_shortcode' ); 26 119 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 . '&autoplay=' . $a . '" width="' . $w . '" height="' . $h . '"><param name="movie" value="http://i.vbox7.com/player/ext.swf?vid=' . $v . '&autoplay=' . $a . '" /></object>'; 29 return $vbox7; 120 /** 121 * Additional styling 122 */ 123 function 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 30 145 } 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 ?> 146 add_action( 'wp_head', 'easy_vbox7_style', 100 ); -
easy-vbox7/trunk/readme.txt
r211037 r1244206 2 2 Contributors: Caspie 3 3 Donate link: http://donate.caspie.net/ 4 Tags: vbox, vbox7, v ideo, videos, clip, clips,insert, posts, pages, sidebar4 Tags: vbox, vbox7, vbox7.com, video, videos, clip, clips, embed, media insert, posts, pages, sidebar 5 5 Requires at least: 2.9 6 Tested up to: 2.9.2 7 Stable tag: 1.3 6 Tested up to: 4.3 7 Stable tag: 1.4 8 License: GPLv2 or later 9 License URI: http://www.gnu.org/licenses/gpl-2.0.html 8 10 9 11 Quick and easy way to insert videos from VBOX7.com right into your WordPress blog posts, pages and sidebar. … … 11 13 == Description == 12 14 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 cornerof the website (vbox7.com) to find your favorite videos and to embed them right into your posts.15 Quick 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. 14 16 15 17 Go to Other Notes for: Default, Recommended and Advanced Usage. … … 18 20 == Installation == 19 21 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. 22 1. Search and install the plugin via WordPress > Plugins > Add New 23 2. Or download the plugin from WordPress.org plugin directory. 24 3. Unzip the file easy-vbox7.zip wherever you want. 25 4. Upload the extracted easy-vbox7 folder in /wp-content/plugins/ of your WordPress installation. 26 5. Activate the Plugin via the Plugins section at your WordPress admin panel. 23 27 24 28 == Frequently Asked Questions == 25 29 30 = iframe or object? = 31 32 Since version 1.4, iframe is used. 33 26 34 = Casper? = 27 35 28 Yes, but keep in mind that my wordpress.org username is Caspie.36 Yes, but keep in mind that my WordPress.org username is Caspie. 29 37 30 38 = I want to thank you or send you some feedback? = … … 42 50 43 51 == 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. 44 60 45 61 = 1.3 = -
easy-vbox7/trunk/uninstall.php
r211037 r1244206 1 1 <?php 2 /** 3 * Uninstall 4 */ 5 if ( ! defined( 'WP_UNINSTALL_PLUGIN' ) || ! WP_UNINSTALL_PLUGIN || 6 dirname( WP_UNINSTALL_PLUGIN ) != dirname( plugin_basename( __FILE__ ) ) ) { 7 status_header( 404 ); 8 exit; 9 } 2 10 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 12 delete_option( 'widget_easy-vbox7' );
Note: See TracChangeset
for help on using the changeset viewer.