You are here

function _slick_remove_default_optionset_options in Slick Carousel 7.2

Strips out options similar to default values from the optionset options.

1 call to _slick_remove_default_optionset_options()
template_preprocess_slick in templates/slick.theme.inc
Prepares variables for slick templates.

File

templates/slick.theme.inc, line 552
Hooks and preprocess functions for the Slick module.

Code

function _slick_remove_default_optionset_options($optionset, $js = array(), $context = array()) {
  $config = array();
  $options = $optionset->options;
  $defaults = slick_get_options();

  // Remove wasted dependent options if disabled, empty or not.
  slick_remove_wasted_dependent_options($js);
  $config = array_diff_assoc($js, $defaults);
  if (empty($config['lazyLoad'])) {
    unset($config['lazyLoad']);
  }
  unset($config['prevArrow'], $config['nextArrow']);

  // Clean up responsive options if similar to the defaults.
  $responses = array();
  if (isset($options['responsives']) && isset($options['responsives']['responsive'])) {
    $responsives = $options['responsives']['responsive'];
    foreach ($responsives as $key => $responsive) {
      if (empty($responsives[$key]['breakpoint'])) {
        unset($responsives[$key]);
      }
      if (isset($responsives[$key])) {
        $responses[$key] = $responsive;
      }
    }
    if ($responses) {
      $cleaned = array();
      foreach ($responses as $i => $response) {
        $cleaned[$i]['breakpoint'] = $responses[$i]['breakpoint'];
        if (isset($responses[$i]['unslick']) && $responses[$i]['unslick']) {
          $cleaned[$i]['settings'] = 'unslick';
          unset($responses[$i]['unslick']);
        }
        else {
          slick_remove_wasted_dependent_options($responses[$i]['settings']);
          $cleaned[$i]['settings'] = array_diff_assoc($responses[$i]['settings'], $defaults);
        }
      }
      $config['responsive'] = $cleaned;
    }
  }
  return $config;
}