summaryrefslogtreecommitdiffstats
path: root/danixland-asciinema.php
diff options
context:
space:
mode:
Diffstat (limited to 'danixland-asciinema.php')
-rw-r--r--danixland-asciinema.php42
1 files changed, 42 insertions, 0 deletions
diff --git a/danixland-asciinema.php b/danixland-asciinema.php
new file mode 100644
index 0000000..a59ad69
--- /dev/null
+++ b/danixland-asciinema.php
@@ -0,0 +1,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&igrave;
+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' );