Last active
December 18, 2015 00:39
-
-
Save Rayken/5698275 to your computer and use it in GitHub Desktop.
Quick attempt at a zippyshare shortcode thingy for traplin @ #wordpress
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 | |
// Example: [zippy url="http://www5.zippyshare.com/v/13844744/file.html/"] | |
function zippyshare_shortcode( $atts ) { | |
extract( shortcode_atts( array( | |
'url' => null, | |
'textColor' => '#ffffff', | |
'bgColor' => '#000000', | |
'playColor' => '#f58300', | |
'waveColor' => '#ffffff', | |
'borderColor' => '#000000', | |
'volume' => 80, | |
'width' => 450, | |
'auto' => false, | |
'fullscreen' => false | |
), $atts ) ); | |
preg_match( '/\bwww(\d+).zippyshare.com\/v\/(\d+)\//i', $url, $matches ); | |
$www = ( $matches[1] ) ? $matches[1] : false; | |
$file = ( $matches[2] ) ? $matches[2] : false; | |
if( !$url || !$file || !$www ) | |
return; | |
$output = '<object width="' . $width . '" height="80" name="zs_player' . $file . '" id="zs_player' . $file . '" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" style="width: ' . $width . '; height: 80px;">'; | |
$output .= '<param value="http://api.zippyshare.com/api/player.swf" name="movie">'; | |
$output .= '<param value="false" name="allowfullscreen">'; | |
$output .= '<param value="always" name="allowscriptaccess">'; | |
$output .= '<param name="wmode" value="transparent">'; | |
$output .= '<param value="baseurl=http://api.zippyshare.com/api/&file=' . $file . '&server=' . $www . '&autostart=false&flashid=zs_player' . $file . '&availablequality=both&bordercolor=' . $borderColor . '&forecolor=' . $textColor . '&backcolor=' . $bgColor .'&darkcolor=' . $waveColor . '&lightcolor=' . $playColor . '" name="flashvars">'; | |
$output .= '<embed width="450" height="80" flashvars="baseurl=http://api.zippyshare.com/api/&file=' . $file . '&server=' . $www . '&autostart=false&flashid=zs_player' . $file . '&availablequality=both&bordercolor=' . $borderColor . '&forecolor=' . $textColor . '&backcolor=' . $bgColor .'&darkcolor=' . $waveColor . '&lightcolor=' . $playColor . '" allowfullscreen="' . $fullscreen . '" allowscriptaccess="always" type="application/x-shockwave-flash" src="http://api.zippyshare.com/api/player.swf" name="zs_player' . $file . '" wmode="transparent" id="zs_player' . $file . '">'; | |
$output .= '</object>'; | |
return $output; | |
} | |
add_shortcode( 'zippy', 'zippyshare_shortcode' ); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment