blob: a59ad69ddc3d8ac56dddc8f3d16745ca7c2f6149 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
|
<?php
defined( 'ABSPATH' ) or die( 'No script kiddies please!' );
/*
Plugin Name: danixland asciinema shortcode
Description: A simple shortcode plugin to embed videos from <a href="https://asciinema.org">asciinema.org</a>
Plugin URI: http://danixland.net/?p=3525
Version: 0.1
Author: Danilo 'danix' Macrì
Author URI: http://danixland.net
License: GPL2
License URI: https://www.gnu.org/licenses/gpl-2.0.html
*/
/*
* The actual video displayed using a shortcode
* @since 0.1
*/
function dnxasc_display_video( $atts ) {
// Attributes
extract( shortcode_atts(
array(
'video' => '22124',
'time' => '0',
'autoplay' => false,
'loop' => false,
'speed' => 1,
'theme' => 'monokai'
), $atts )
);
$autoplay = ( 0 != $time ) ? true : false;
$videoscript = '<script type="text/javascript" src="https://asciinema.org/a/';
$videoscript .= $video . '.js" id="asciicast-' . $video . '" async ';
$videoscript .= 'data-t="' . $time . '" data-autoplay="' . $autoplay . '" ';
$videoscript .= 'data-loop="' . $loop . '" data-speed="' . $speed . '" data-theme="' . $theme . '">';
$videoscript .= '</script>';
return $videoscript;
}
add_shortcode( 'asciinema', 'dnxasc_display_video' );
|