Skip to content

Instantly share code, notes, and snippets.

@rinatkhaziev
Last active August 29, 2015 14:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rinatkhaziev/bf278f49e701681c921e to your computer and use it in GitHub Desktop.
Save rinatkhaziev/bf278f49e701681c921e to your computer and use it in GitHub Desktop.
Simple shortcode callback for v2 NDN player
<?php
/*
Plugin Name: Doejo NDN Shortcode
Description: Simple NDN Shortcode
Author: Rinat Khaziev, doejo
Version: 0.7.5
Author URI: http://digitallyconscious.com
GNU General Public License, Free Software Foundation <http://creativecommons.org/licenses/GPL/2.0/>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
/**
* Shortcode callback [ndn id="123456789"]
*
* V2 responsive player
*
*/
function doejo_ndn_embed( $atts ) {
global $content_width;
extract( shortcode_atts( array(
'id' => '',
'width' => $content_width,
'height' => ( $content_width / 16 ) * 9,
), $atts ) );
$id = (int) $id;
$width = (int) $width;
$height = (int) $height;
if ( $id == 0 )
return; // we don't have a valid video id, return
ob_start();
?>
<div id="my-ndn-player-<?php echo $id ?>"
class="ndn_embed"
data-config-widget-id="2"
data-config-type="VideoPlayer/Single"
style="<?php echo $width ?>px; height: <?php echo $height ?>px;"
data-config-tracking-group="91046"
data-config-video-id="<?php echo $id ?>"
></div>
<?php
return ob_get_clean();
}
add_shortcode( 'ndn', 'doejo_ndn_embed' );
add_action( 'wp_enqueue_scripts', 'doejo_ndn_script' );
function doejo_ndn_script() {
wp_enqueue_script( 'doejo-ndn-player', 'http://launch.newsinc.com/js/embed.js', array(), false, true );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment