diff options
| author | danixland <danix@danixland.net> | 2018-07-04 15:21:19 +0200 |
|---|---|---|
| committer | danixland <danix@danixland.net> | 2018-07-04 15:21:19 +0200 |
| commit | 131808ed204725baf7456808538e85be7e8fd1fc (patch) | |
| tree | b4a3a0f71c8d5c8a01467538acb06faeb6f6b115 /danixland-asciinema.php | |
| download | danixland-asciinema-131808ed204725baf7456808538e85be7e8fd1fc.tar.gz danixland-asciinema-131808ed204725baf7456808538e85be7e8fd1fc.zip | |
initial import
Diffstat (limited to 'danixland-asciinema.php')
| -rw-r--r-- | danixland-asciinema.php | 42 |
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ì +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' ); |
