Skip to content

Instantly share code, notes, and snippets.

@chasereeves
Created March 4, 2015 19:59
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 chasereeves/2a36fd3cf02844eef47f to your computer and use it in GitHub Desktop.
Save chasereeves/2a36fd3cf02844eef47f to your computer and use it in GitHub Desktop.
Fizzle Soundcloud Shortcode
// [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&rsquo;s better to listen on the go!</em> &nbsp;
<a target="_blank" href="https://itunes.apple.com/us/podcast/fizzle-show-honest-online/id656726654" class="btn_green">&nbsp;Subscribe&nbsp;on&nbsp;iTunes&nbsp;</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.'&amp;color=f3954b&amp;auto_play=false&amp;hide_related=true&amp;show_comments=true&amp;show_user=true&amp;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