- function_exists: documentation ( source)
- str_replace: documentation ( source)
- stripos: documentation ( source)
<?php
//Get the Audiomack URL
if (!function_exists('samk_audio_audiomack')) {
function samk_audio_audiomack($url, $width = '100%', $height = 250) {
if($url!='') {
$buff = '';
$buff .= "\n<!-- audiomack | {$plugin_data['name']} | {$plugin_data['url']} -->\n";
$embed_src = $url;
$embed_ver_prefix = 'embed4';
// Check if the embedded source is song or album
if(stripos($embed_src, '/song/') !== false) { //it is a song
$embed_src = str_replace('/song/', "/$embed_ver_prefix-large/", $embed_src);
}else{ //it is an album
$height = 352;
$embed_src = str_replace('/album/', "/$embed_ver_prefix-album/", $embed_src);
}
$height_str = "height='$height'";
$embed_code = "<iframe src='$embed_src' scrolling='no' width='$width' $height_str scrollbars='no' frameborder='0'></iframe>\n";
$buff .= "<div class='audiomack_player_container'>\n";
$buff .= $embed_code;
$buff .= "</div> <!-- /audiomack_player_container -->\n";
$buff .= "\n<!-- /audiomack | {$plugin_data['name']} | {$plugin_data['url']} -->\n";
return $buff;
}
}
}
$audio_caller = samk_audio_audiomack('http://www.example.com');
echo $audio_caller;