You are here

public function FilterElf::elf_url_external in External Links Filter 8

Parameters

string $url:

Return value

bool

1 call to FilterElf::elf_url_external()
FilterElf::process in src/Plugin/Filter/FilterElf.php
Performs the filter processing.

File

src/Plugin/Filter/FilterElf.php, line 108

Class

FilterElf
Adds a CSS class to all external and mailto links.

Namespace

Drupal\elf\Plugin\Filter

Code

public function elf_url_external($url) {
  global $base_url;
  if (empty($this->pattern)) {
    $domains = [];
    $elf_domains = \Drupal::config('elf.settings')
      ->get('elf_domains');
    $elf_domains = is_array($elf_domains) ? $elf_domains : [];
    foreach (array_merge($elf_domains, [
      $base_url,
    ]) as $domain) {
      $domains[] = preg_quote($domain, '#');
    }
    $this->pattern = '#^(' . str_replace('\\*', '.*', implode('|', $domains)) . ')#';
  }
  return preg_match($this->pattern, $url) ? FALSE : UrlHelper::isExternal($url);
}