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