Created
March 4, 2015 19:59
-
-
Save chasereeves/2a36fd3cf02844eef47f to your computer and use it in GitHub Desktop.
Fizzle Soundcloud Shortcode
This file contains 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
// [podsc url="069-work-for-yourself-or-for" hrtop="" hrbottom="" btn_top=""] | |
function podsc($atts) { | |
extract(shortcode_atts(array( | |
"url" => '', | |
"hrtop" => 'true', | |
"hrbottom" => 'true', | |
"btn_top" => '' | |
), $atts)); | |
// remove intro bits of URL if it's in the shortcode | |
$track_url = str_replace("https://soundcloud.com/fizzleco/","",$url); | |
// create a client object with your app credentials | |
$client = new Services_Soundcloud('BITS_GO_HERE', 'BITS_GO_HERE'); | |
$client->setCurlOptions(array(CURLOPT_FOLLOWLOCATION => 1)); | |
// resolve track URL into track resource | |
$track = json_decode($client->get('resolve', array('url' => 'https://soundcloud.com/fizzleco/'.$track_url))); | |
$track_id = $track->id; | |
if( $hrtop != 'none') { $return_string = '<hr/>'; } | |
if (empty($btn_top)) {$return_string = ' | |
<div class="center" style="margin:2em 0 3em;"> | |
<p style="line-height:3em;"> | |
<em>It’s better to listen on the go!</em> | |
<a target="_blank" href="https://itunes.apple.com/us/podcast/fizzle-show-honest-online/id656726654" class="btn_green"> Subscribe on iTunes </a> | |
</p> | |
</div> | |
'; } | |
$return_string .= ' | |
<div class="fz_soundcloud_player"> | |
<iframe width="100%" height="166" scrolling="no" frameborder="no" src="https://w.soundcloud.com/player/?url=https%3A//api.soundcloud.com/tracks/'.$track_id.'&color=f3954b&auto_play=false&hide_related=true&show_comments=true&show_user=true&show_reposts=false"></iframe> | |
<div class="after_soundcloud"> | |
<strong>Subscribe:</strong> (<a href="http://fizzle.co/show/subscribe" target="_blank">how to</a>) | |
<a target="_blank" href="https://itunes.apple.com/us/podcast/fizzle-show-honest-online/id656726654">iTunes</a>, | |
<a target="_blank" href="https://soundcloud.com/fizzleco/sets/the-fizzle-show">Soundcloud</a>, | |
<a target="_blank" href="http://www.stitcher.com/podcast/fizzlepodcast/the-fizzle-show">Stitcher</a>, | |
<a target="_blank" href="http://feeds.soundcloud.com/users/soundcloud:users:71269227/sounds.rss">RSS</a>, | |
<a target="_blank" href="https://soundcloud.com/fizzleco/'.$track_url.'/download">Download</a> | |
</div> | |
</div> | |
'; | |
if($hrbottom != 'none') { $return_string .= '<hr/>'; } | |
return $return_string; | |
} | |
add_shortcode('podsc', 'podsc'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment