Advertisement
Guest User

VideoJS Wordpress Plugin ID Fix

a guest
Feb 6th, 2012
382
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.10 KB | None | 0 0
  1. <?php
  2. /**
  3.  * @package Video.js
  4.  * @version 3.0
  5.  */
  6. /*
  7. Plugin Name: Video.js - HTML5 Video Player for WordPress
  8. Plugin URI: http://videojs.com/
  9. Description: A video plugin for WordPress built on the widely used Video.js HTML5 video player library. Allows you to embed video in your post or page using HTML5 with Flash fallback support for non-HTML5 browsers.
  10. Author: <a href="http://steveheffernan.com">Steve Heffernan</a>, <a href="http://www.nosecreekweb.ca">Dustin Lammiman</a>
  11. Version: 3.0
  12. */
  13.  
  14. function add_videojs_header(){
  15.   echo "";
  16.   echo <<<_end_
  17.   <link href="http://vjs.zencdn.net/c/video-js.css" rel="stylesheet">
  18.   <script src="http://vjs.zencdn.net/c/video.js"></script>
  19. _end_;
  20. }
  21. add_action('wp_head','add_videojs_header');
  22.  
  23. function video_shortcode($atts){
  24.   extract(shortcode_atts(array(
  25.     'mp4' => '',
  26.     'webm' => '',
  27.     'ogg' => '',
  28.     'poster' => '',
  29.     'id' => '',
  30.     'width' => '',
  31.     'height' => '',
  32.     'preload' => false,
  33.     'autoplay' => false,
  34.   ), $atts));
  35.  
  36.   // MP4 Source Supplied
  37.   if ($mp4)
  38.     $mp4_source = '<source src="'.$mp4.'" type=\'video/mp4\' />';
  39.  
  40.   // WebM Source Supplied
  41.   if ($webm)
  42.     $webm_source = '<source src="'.$webm.'" type=\'video/webm; codecs="vp8, vorbis"\' />';
  43.  
  44.   // Ogg source supplied
  45.   if ($ogg)
  46.     $ogg_source = '<source src="'.$ogg.'" type=\'video/ogg; codecs="theora, vorbis"\' />';
  47.  
  48.   // Poster image supplied
  49.   if ($poster)
  50.     $poster_attribute = ' poster="'.$poster.'"';
  51.    
  52.  
  53.   // Preload the video?
  54.   if ($preload)
  55.     $preload_attribute = 'preload="'+$preload+'"';
  56.  
  57.   // Autoplay the video?
  58.   if ($autoplay)
  59.     $autoplay_attribute = " autoplay";
  60.   else
  61.     $autoplay_attribute = "";
  62.    
  63.  
  64.   $videojs .= <<<_end_
  65.  
  66.   <!-- Begin Video.js -->
  67.   <video class="video-js vjs-default-skin" id="{$id}" width="{$width}" height="{$height}"{$poster_attribute} controls {$preload_attribute}{$autoplay_attribute} data-setup="{}">
  68.     {$mp4_source}
  69.     {$webm_source}
  70.     {$ogg_source}
  71.   </video>
  72.   <!-- End Video.js -->
  73.  
  74. _end_;
  75.  
  76.   return $videojs;
  77.  
  78. }
  79. add_shortcode('video', 'video_shortcode');
  80.  
  81. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement