You are here

function simplelogin_css_alter in SimpleLogin 8.6

Implements hook_css_alter().

File

./simplelogin.module, line 259
The module file for simplelogin pages module.

Code

function simplelogin_css_alter(&$css, \Drupal\Core\Asset\AttachedAssetsInterface $assets) {
  $path = \Drupal::service('path.current')
    ->getPath();
  $user_path = array(
    '/user',
    '/user/login',
    '/user/password',
    '/user/register',
  );
  $current_user = \Drupal::currentUser();

  // Whether the current user is anonymous or authenticated
  if (!$current_user
    ->id()) {
    if (in_array($path, $user_path)) {
      $unset_css = simple_login_settings('unset_css');
      $unset_css_array = explode("\n", $unset_css);
      foreach ($unset_css_array as $key => $value) {
        unset($css[trim($value)]);
      }

      // The active theme CSS files are removed from the simple login pages
      $unset_active_css = simple_login_settings('unset_active_css');
      if ($unset_active_css) {
        foreach ($css as $stylesheet => $value) {
          $theme = \Drupal::theme()
            ->getActiveTheme();
          if (strstr($stylesheet, $theme
            ->getPath())) {
            unset($css[trim($value['data'])]);
          }
        }
      }
    }
  }
}