$value){
$instance[$index] = strip_tags($value);
}
//Set defaults if they are left blank
$default_settings = array(
'height' => '212',
'margin' => '0',
'color' => '6B9B2B',
'collectionid' => '380517',
'itemid' => '119960',
'volume' => '0.7',
'itemlimit' => '20'
);
foreach($default_settings as $index => $value){
if(!isset($instance[$index]) || preg_replace('/\ /','',$instance[$index]) == ''){
$instance[$index] = $value;
}
}
//Validate numerical values
$numerical_settings = array(
'height' => array(
'min' => 0
),
'margin' => array(),
'volume' => array(
'min' => 0,
'max' => 1
),
'itemlimit' => array(
'min' => 1
)
);
foreach($numerical_settings as $index => $value){
$valid = false;
if(is_numeric($instance[$index])){
if(!isset($value['min']) || (isset($value['min']) && $instance[$index] >= $value['min']) ){
if(!isset($value['max']) || (isset($value['max']) && $instance[$index] <= $value['max']) ){
$valid = true;
}
}
}
if(!$valid){
$instance[$index] = $default_settings[$index];
}
}
//Check boolean properties
if($new_instance['display-title']){
$instance['display-title'] = 'true';
} else {
$instance['display-title'] = 'false';
}
if($new_instance['autoplay']){
$instance['autoplay'] = 'true';
} else {
$instance['autoplay'] = 'false';
}
//Capitalise Color
$instance['color'] = strtoupper($instance['color']);
//Compute the flash vars for the set settings
$instance['flashvars'] = 'api=http://marketplace.envato.com/api/edge/' . (
$instance['listtype']=='collection'?'collection:' . $instance['collectionid']:
($instance['listtype']=='search'?'search:audiojungle,,' . $instance['searchquery']:
($instance['listtype']=='new'?'new-files:audiojungle,' . $instance['newcategory']:
($instance['listtype']=='randomnew'?'random-new-files:audiojungle':
($instance['listtype']=='popular'?'popular:audiojungle':
($instance['listtype']=='author'?'new-files-from-user:' . $instance['author']:
($instance['listtype']=='singleitem'?'item:'.$instance['itemid']:
''))))))
) . '.xml&autoplay='.($instance['autoplay']=='true'?'1':'0').'&refid=' . $instance['refid'] . '&txtColor=0x' . $instance['color'] . '&itemLimit=' . $instance['itemlimit'] . '&initVolume=' . $instance['volume'];
return $instance;
}
function form($instance) {
echo $instance['debug'];
?>
Appearance
/>
Main Options
List the songs in a collection on AudioJungle. Make sure that only songs are listed in the collection.
Enter the Collection ID below, you can find this in the URL of the collection.
List the latest files that have been uploaded to AudioJungle. You are required to choose a category.
List a random list of newly uploaded files from AudioJungle.
List the popular files from AudioJungle.
/>