Last active
August 29, 2015 14:01
-
-
Save rinatkhaziev/bf278f49e701681c921e to your computer and use it in GitHub Desktop.
Simple shortcode callback for v2 NDN player
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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