You are here

slick.install in Slick Carousel 8

Same filename and directory in other branches
  1. 8.2 slick.install
  2. 7.3 slick.install
  3. 7.2 slick.install

Installation actions for Slick.

File

slick.install
View source
<?php

/**
 * @file
 * Installation actions for Slick.
 */

/**
 * Implements hook_requirements().
 */
function slick_requirements($phase) {
  if ($phase != 'runtime') {
    return [];
  }
  $path = DRUPAL_ROOT . '/libraries/slick/slick/slick.min.js';
  if (function_exists('libraries_get_path')) {
    $library_path = libraries_get_path('slick') ?: libraries_get_path('slick-carousel');
    if ($library_path) {
      $path = $library_path . '/slick/slick.min.js';
    }
  }
  $exists = is_file($path);
  return [
    'slick_library' => [
      'title' => t('Slick library'),
      'description' => $exists ? '' : t('The <a href=":url">Slick library</a> should be installed at <strong>/libraries/slick/slick/slick.min.js</strong>, or any path supported by libraries.module if installed.', [
        ':url' => 'https://github.com/kenwheeler/slick/',
      ]),
      'severity' => $exists ? REQUIREMENT_OK : REQUIREMENT_ERROR,
      'value' => $exists ? t('Installed') : t('Not installed'),
    ],
  ];
}

/**
 * Removed HTML tags from arrows due to translation issue as per #3075838.
 */
function slick_update_8101() {

  // Configuration translation disallowed HTML.
  // See https://drupal.org/node/3075838
  $config_factory = \Drupal::configFactory();
  foreach ($config_factory
    ->listAll('slick.optionset.') as $optionset_name) {
    $optionset = $config_factory
      ->getEditable($optionset_name);
    foreach ([
      'prevArrow',
      'nextArrow',
    ] as $key) {

      // Don't bother with Optimized ON, as arrows are removed already.
      if ($value = $optionset
        ->get('options.settings.' . $key)) {
        $optionset
          ->set('options.settings.' . $key, trim(strip_tags($value)));
      }
    }
    $optionset
      ->save(TRUE);
  }
}

Functions

Namesort descending Description
slick_requirements Implements hook_requirements().
slick_update_8101 Removed HTML tags from arrows due to translation issue as per #3075838.