diff options
-rw-r--r-- | css/mce-button.css | 2 | ||||
-rw-r--r-- | functions.php | 2 | ||||
-rw-r--r-- | js/mce-button.js | 16 | ||||
-rw-r--r-- | librevideojs/librevideojs.php | 252 | ||||
-rw-r--r-- | vinotjs/libre-panel.php (renamed from librevideojs/libre-panel.php) | 6 | ||||
-rw-r--r-- | vinotjs/processor.php (renamed from librevideojs/processor.php) | 0 | ||||
-rw-r--r-- | vinotjs/vinotjs.php | 165 |
7 files changed, 178 insertions, 265 deletions
diff --git a/css/mce-button.css b/css/mce-button.css index 311ee9e..f039409 100644 --- a/css/mce-button.css +++ b/css/mce-button.css @@ -1,4 +1,4 @@ -i.mce-i-librevideojs:before { +i.mce-i-vinotjs:before { font-family: "dashicons"; content: "\f236"; } diff --git a/functions.php b/functions.php index b5fa805..a8f7011 100644 --- a/functions.php +++ b/functions.php @@ -157,4 +157,4 @@ function disable_embeds_rewrites($rules) { /* LibreVideoJS ------------------------------------------------------------------------------*/ -include_once 'librevideojs/librevideojs.php'; +include_once 'vinotjs/vinotjs.php'; diff --git a/js/mce-button.js b/js/mce-button.js index ea424e1..be2d6cd 100644 --- a/js/mce-button.js +++ b/js/mce-button.js @@ -28,11 +28,11 @@ * */ (function() { - tinymce.PluginManager.add('librevideojs', function(editor, url) { - var sh_tag = 'librevideojs_video'; + tinymce.PluginManager.add('vinotjs', function(editor, url) { + var sh_tag = 'vinotjs'; //add popup - editor.addCommand('librevideojs_popup', function(ui, v) { + editor.addCommand('vinotjs_popup', function(ui, v) { //setup defaults var url = ''; if (v.url) @@ -48,7 +48,7 @@ content = v.content; editor.windowManager.open( { - title: 'LibreVideoJS - Inserción de vídeo', + title: 'ViNotJS - Inserción de vídeo', body: [ { type: 'textbox', @@ -105,11 +105,11 @@ }); }); - editor.addButton('librevideojs', { - icon: 'librevideojs', - tooltip: 'LibreVideoJS', + editor.addButton('vinotjs', { + icon: 'vinotjs', + tooltip: 'ViNotJS', onclick: function() { - editor.execCommand('librevideojs_popup', '', { + editor.execCommand('vinotjs_popup', '', { url : '', poster: '', code: 'webm', diff --git a/librevideojs/librevideojs.php b/librevideojs/librevideojs.php deleted file mode 100644 index cbeb03c..0000000 --- a/librevideojs/librevideojs.php +++ /dev/null @@ -1,252 +0,0 @@ -<?php - -/* Implementación de LibreVideoJS -==============================================================================================*/ -include_once 'libre-panel.php'; - -if (!class_exists('LIBREVIDEOJS')){ - - class LIBREVIDEOJS{ - - var $L_version = '2.0'; - - function __construct(){ - define('L_VERSION', $this->L_version); - $this->theme_includes(); - } - - function theme_includes(){ - if (!is_admin()) { - add_action('wp_enqueue_scripts', 'librevideojs_base'); - add_shortcode('librevideojs_video', 'LibreVideoJS_embed'); - //allows shortcode execution in the widget, excerpt and content - add_filter('widget_text', 'do_shortcode'); - add_filter('the_excerpt', 'do_shortcode', 11); - add_filter('the_content', 'do_shortcode', 11); - } - } - } - - $GLOBALS['easy_video_player'] = new LIBREVIDEOJS(); - new librevideojs_panel_shortcode(); -} - -function librevideojs_base(){ - global $post, $theme_url; - $theme_url = get_bloginfo('template_url', __FILE__); - if ( ( is_author() || is_page() || is_single() ) && strpos($post->post_content, '[librevideojs_video') !== false ){ - wp_enqueue_style('LibreVideoJS', $theme_url . '/css/librevideojs/teal.min.css', array(), '1.4'); - wp_enqueue_script('LibreVideoJS', $theme_url . '/js/cliplibrejs.developer.min.js', array(), L_VERSION); - wp_enqueue_script('jQuery-Libre', $theme_url . '/js/jquery-3.1.1.min.js', array(), '3.1.1', true); - } - else { - return false; - } -} - -function LibreVideoJS_embed($atts, $content=null){ - extract(shortcode_atts(array( - 'url' => '', - 'url_calidad' => '', - 'code' => '', - 'selector' => '', - 'width' => '', - 'controls' => '', - 'preload' => 'auto', - 'autoplay' => 'false', - 'loop' => '', - 'muted' => '', - 'poster' => '', - 'class' => '', - ), $atts)); - - if(empty($url)){ - return __('you need to specify the src of the video file', 'Lidra'); - } - - // support youtube without DRM - require 'processor.php'; - - //src - if(!empty($url) && strlen($id) === 11 ){ - $src = '<source src="'. $videoyt .'" type="'. $format .'" />'; - } else { - $src = '<source data-res="'.$url_calidad.'" src="'.$url.'" type="video/'.$code.'"/>'; - } - - //resolution selector - if(!empty($selector)){ - $resolution = "$selector"; - } - else { - $resolution = "$url_calidad"; - } - - //controls - if($controls == "false"){ - $controls = ""; - } - else{ - $controls = " controls"; - } - - //preload - if($preload == "metadata"){ - $preload = ' preload="metadata"'; - } - else if($preload == "none"){ - $preload = ' preload="none"'; - } - else{ - $preload = ' preload="auto"'; - } - - //autoplay - if($autoplay == "true"){ - $autoplay = " autoplay"; - } - else{ - $autoplay = ""; - } - - //loop - if($loop == "true"){ - $loop = " loop"; - } - else{ - $loop = ""; - } - - //muted - if($muted == "true"){ - $muted = " muted"; - } - else{ - $muted = ""; - } - - //Tracks - if(!is_null( $content )){ - $track = do_shortcode($content); - } - else{ - $track = ""; - } - - //Qualities - if(!is_null( $content = '' )){ - $calidades = do_shortcode($content); - } - else{ - $calidades = ""; - } - - //poster - if(!empty($poster)){ - $poster = " poster='$poster'"; - } - $player = "librevideojs" . uniqid(); - - //languages - $_no_html5 = __('Sorry, this video will not work because your web browser does not support HTML5 video. Please, change or update your browser', 'Lidra'); - - $_no_browser = '<p class="librevjs-no-js">' . $_no_html5 . '</p>'; - - //force_types - $_force_types = 'video/' . $code; - - if ($_force_types === "video/webm") { - $_force_types .= "'," . "'video/ogg"; - } - else { - $_force_types .= "'," . "'video/webm"; - } - - //custom style - $style = ''; - if(!empty($width)){ - $style = <<<EOT - <style> - $player { - max-width:{$width}px; - } - </style> -EOT; - - } - $output = <<<EOT - <div class="LibreVideoJS"> - <video id="$player" {$controls}{$preload}{$autoplay}{$loop}{$muted}{$poster} data-setup='{}'> - {$src}\n\t\t{$calidades}{$track}{$_no_browser} - </video> - </div> - <script> - var librestyle = document.getElementById("$player"); - librestyle.className += " cliplibre-js-responsive-container librevjs-hd cliplibre-js librevjs-libre-mix-skin"; - cliplibrejs('$player',{plugins:{resolutionSelector:{force_types:['$_force_types'],default_res:"$resolution",}},nativeControlsForTouch:false}).ready(function(){this.hotkeys({volumeStep:0.1,seekStep:5,enableMute:true,enableFullscreen: true,enableNumbers:true}),this.progressTips();}); - </script> - $style -EOT; - return $output; -} - -/*Adding subtitles using... [track]*/ -function track_shortcode($atts, $content=null){ - extract(shortcode_atts(array( - 'kind' => '', - 'subt' => '', - 'srclang' => '', - 'label' => '', - 'default' => '', - ), $atts)); - - if($kind){ - $kind = " kind='$kind'"; - } - - if($subt){ - $subt = " src='$subt'"; - } - - if($srclang){ - $srclang = " srclang='$srclang'"; - } - - if($label){ - $label = " label='$label'"; - } - - if($default == "true" || $default == "default"){ - $default = " default"; - } - else{ - $default = ""; - } - - $track = "<track" . $kind . $subt . $srclang . $label . $default . "/>\n\t\t"; - - return $track; -} -add_shortcode('track', 'track_shortcode'); - -/*Adding qualities*/ -function calidades_shortcode($atts, $content=null){ - extract(shortcode_atts(array( - 'lvjs_calidad' => '', - 'src_video' => '', - 'lvjs_code' => '', - ), $atts)); - - if($lvjs_calidad){ - $lvjs_calidad = " data-res='$lvjs_calidad'"; - } - - if($src_video){ - $src_video = " src='$src_video'"; - } - - $calidades = "<source" . $lvjs_calidad . $src_video . " type='video/".$lvjs_code."'/>\n\t\t"; - - return $calidades; -} -add_shortcode('calidades', 'calidades_shortcode'); diff --git a/librevideojs/libre-panel.php b/vinotjs/libre-panel.php index 329d22e..9897185 100644 --- a/librevideojs/libre-panel.php +++ b/vinotjs/libre-panel.php @@ -1,11 +1,11 @@ <?php -class librevideojs_panel_shortcode{ +class vinotjs_panel_shortcode{ /** * $shortcode_tag * holds the name of the shortcode tag * @var string */ - public $shortcode_tag = 'librevideojs'; + public $shortcode_tag = 'vinotjs'; /** * __construct @@ -66,6 +66,6 @@ class librevideojs_panel_shortcode{ * @return void */ function admin_enqueue_scripts(){ - wp_enqueue_style('librevideojs_shortcode', get_bloginfo('template_url') . '/css/mce-button.css'); + wp_enqueue_style('vinotjs_shortcode', get_bloginfo('template_url') . '/css/mce-button.css'); } } diff --git a/librevideojs/processor.php b/vinotjs/processor.php index 555a081..555a081 100644 --- a/librevideojs/processor.php +++ b/vinotjs/processor.php diff --git a/vinotjs/vinotjs.php b/vinotjs/vinotjs.php new file mode 100644 index 0000000..1ab4be2 --- /dev/null +++ b/vinotjs/vinotjs.php @@ -0,0 +1,165 @@ +<?php + +/* Implementación de LibreVideoJS +==============================================================================================*/ +include_once 'libre-panel.php'; + +if (!class_exists('VINOTJS')){ + + class VINOTJS{ + + function __construct(){ + $this->theme_includes(); + } + + function theme_includes(){ + if (!is_admin()) { + add_shortcode('vinotjs', 'ViNotJS_embed'); + //allows shortcode execution in the widget, excerpt and content + add_filter('widget_text', 'do_shortcode'); + add_filter('the_excerpt', 'do_shortcode', 11); + add_filter('the_content', 'do_shortcode', 11); + } + } + } + + $GLOBALS['easy_video_player'] = new VINOTJS(); + new vinotjs_panel_shortcode(); +} + +function ViNotJS_embed($atts, $content=null){ + extract(shortcode_atts(array( + 'url' => '', + 'code' => '', + 'width' => '', + 'controls' => '', + 'preload' => 'auto', + 'autoplay' => 'false', + 'loop' => '', + 'muted' => '', + 'poster' => '', + ), $atts)); + + if(empty($url)){ + return __('you need to specify the src of the video file', 'Lidra'); + } + + // support youtube without DRM + require 'processor.php'; + + //src + if(!empty($url) && strlen($id) === 11 ){ + $src = '<source src="'. $videoyt .'" type="'. $format .'"/>'; + } else { + $src = '<source src="'.$url.'" type="video/'.$code.'"/>'; + } + + //controls + if($controls == "false"){ + $controls = ""; + } + else{ + $controls = "controls"; + } + + //preload + if($preload == "metadata"){ + $preload = ' preload="metadata"'; + } + else if($preload == "none"){ + $preload = ' preload="none"'; + } + else{ + $preload = ' preload="auto"'; + } + + //autoplay + if($autoplay == "true"){ + $autoplay = " autoplay"; + } + else{ + $autoplay = ""; + } + + //loop + if($loop == "true"){ + $loop = " loop"; + } + else{ + $loop = ""; + } + + //muted + if($muted == "true"){ + $muted = " muted"; + } + else{ + $muted = ""; + } + + //Tracks + if(!is_null( $content )){ + $track = do_shortcode($content); + } + else{ + $track = ""; + } + + //poster + if(!empty($poster)){ + $poster = " poster='$poster'"; + } + + //languages + $_no_html5 = __('Sorry, this video will not work because your web browser does not support HTML5 video. Please, change or update your browser', 'Lidra'); + + $_no_browser = '<p>' . $_no_html5 . '</p>'; + + $output = <<<EOT + <div class="vinotjs"> + <video {$controls}{$preload}{$autoplay}{$loop}{$muted}{$poster}> + {$src}\n\t\t{$track}{$_no_browser} + </video> + </div> +EOT; + return $output; +} + +/*Adding subtitles using... [track]*/ +function track_vinotjs($atts, $content=null){ + extract(shortcode_atts(array( + 'kind' => '', + 'subt' => '', + 'srclang' => '', + 'label' => '', + 'default' => '', + ), $atts)); + + if($kind){ + $kind = " kind='$kind'"; + } + + if($subt){ + $subt = " src='$subt'"; + } + + if($srclang){ + $srclang = " srclang='$srclang'"; + } + + if($label){ + $label = " label='$label'"; + } + + if($default == "true" || $default == "default"){ + $default = " default"; + } + else{ + $default = ""; + } + + $track = "<track" . $kind . $subt . $srclang . $label . $default . "/>\n\t\t"; + + return $track; +} +add_shortcode('track', 'track_vinotjs');
\ No newline at end of file |