

<?php
/*
Plugin Name: IPM Video Tuts
Plugin URI: http://ipmulricehamn.se
Description: Show youtube tutorial videos on dashboard.
Version: 1.0
Author: Michael & Erik
Author URI: http://ipmulricehamn.se
*/
/* Enqueue js file */
function enqueue_vt_js($hook) {
if( 'index.php' != $hook )
return;
wp_enqueue_script( 'video_script', plugins_url('/ipm-video-tuts.js', __FILE__) );
wp_register_style( 'video_wp_admin_css', plugins_url('/ipm-video-tuts.css', __FILE__), false, '1.0.0' );
wp_enqueue_style( 'video_wp_admin_css' );
}
add_action( 'admin_enqueue_scripts', 'enqueue_vt_js' );
// Create the function to output the contents of our Dashboard Widget
function videos_dashboard_widget_function() {
// Display our videos
/*
Example embed code from youtube
rel=0 == inga föreslagna videoklipp visas när klippet är slut
<iframe width="640" height="360" src="http://www.youtube.com/embed/069Xr8IuGxY?rel=0" frameborder="0" allowfullscreen></iframe>
*/
?>
<p>Här kan du se några filmer.</p>
<ol class="video-tuts">
<li><a href="https://www.youtube.com/watch?v=e1Ukb4LStUU" data-embed="e1Ukb4LStUU">Västgötanytt</a></li>
<ol>
<li><a href="https://www.youtube.com/watch?v=aqpnGBO19FY" data-embed="aqpnGBO19FY">Soneby City Sport</a></li>
</ol>
<li><a href="https://www.youtube.com/watch?v=_XZorHsav1E" data-embed="_XZorHsav1E">Puma Swede</a></li>
<li><a href="https://www.youtube.com/watch?v=ifhy57GpNLc" data-embed="ifhy57GpNLc">DJ ASHBA</a></li>
<li><a href="https://www.youtube.com/watch?v=wlYvspZ3ZhE" data-embed="wlYvspZ3ZhE">Roxie 77 - The Solution</a></li>
<li><a href="https://www.youtube.com/watch?v=FO5jo0imeSQ" data-embed="FO5jo0imeSQ">Christian Hedgren</a></li>
<li><a href="https://www.youtube.com/watch?v=_jud_SnKTlY" data-embed="_jud_SnKTlY">The Agonist</a></li>
</ol>
<?php
}
// Create the function use in the action hook
function videos_add_dashboard_widgets() {
wp_add_dashboard_widget('videos_dashboard_widget', __('Utbildningsfilmer', 'video-tuts'), 'videos_dashboard_widget_function');
}
// Hook into the 'wp_dashboard_setup' action to register our other functions
add_action('wp_dashboard_setup', 'videos_add_dashboard_widgets' );
jQuery(document).ready(function($) {
$("ol.video-tuts li a").click(function(e){
e.preventDefault();
var obj = $(this);
var parent = obj.parent();
var list = parent.parents('ol');
var vidID = obj.data('embed');
list.find('.embed-container').remove();
parent.append($('<div class="embed-container"><iframe class="ipm-video-frame" width="680" height="480" src="https://www.youtube.com/embed/'+ vidID +'?rel=0" frameborder="0" allowfullscreen></iframe></div>'));
});
});
ol.video-tuts {
}
.ipm-video-frame {
clear: both;
display: block;
}
.embed-container { position: relative; padding-bottom: 56.25%; height: 0; overflow: hidden; max-width: 100%; height: auto; }
.embed-container iframe, .embed-container object, .embed-container embed { position: absolute; top: 0; left: 0; width: 100%; height: 100%; }