function _royalslider_remove_default_optionset_options in RoyalSlider Integration 7
Strip options with default values from the Option Set options so that we don't add unecessary options.
Parameters
array: An array of Option Set options.
Return value
array An array of reduced Option Set options.
1 call to _royalslider_remove_default_optionset_options()
- royalslider_add in ./
royalslider.module - This function loads the required JavaScripts and settings for a RoyalSlider instance.
File
- ./
royalslider.module, line 887 - RoyalSlider module.
Code
function _royalslider_remove_default_optionset_options($options) {
$defaults = _royalslider_optionset_defaults();
foreach ($options as $key => $value) {
if (array_key_exists($key, $defaults)) {
if (is_array($value)) {
foreach ($value as $k => $v) {
// For nested option groups, if it has an "enabled" flag and it's set to
// FALSE, remove the entire sub-group.
if ($k === 'enabled' && $v === FALSE) {
unset($options[$key]);
if ($key === 'visibleNearby') {
// As false is not the default option for visibleNearby.
// Add the enabled key again.
$options[$key][$k] = $v;
}
}
else {
if ($key === 'visibleNearby' && $k === 'enabled' && $v === TRUE) {
// Exception for the visibleNearby option.
// This is the only nested option group that has TRUE as its default for enabled.
// "enabled" needs to be part of the optionset for it to work.
// Therefor it is not unset here.
}
else {
if ($v === $defaults[$key][$k]) {
unset($options[$key][$k]);
}
}
}
}
// "Thumbs" is the exception, because it doesn't have an "enabled"
// flag and, instead, is toggled on or off by the "controlNavigation"
// option.
if ($key === 'thumbs') {
if (!isset($options['controlNavigation']) || $options['controlNavigation'] !== 'thumbnails') {
unset($options[$key]);
}
}
}
else {
if ($value === $defaults[$key]) {
unset($options[$key]);
}
}
}
}
return $options;
}