You are here

function elf_filter in External Links Filter 5.2

Same name and namespace in other branches
  1. 5.3 elf.module \elf_filter()
  2. 5 elf.module \elf_filter()
  3. 6.3 elf.module \elf_filter()
  4. 6.2 elf.module \elf_filter()

Implementation of hook_filter().

File

./elf.module, line 65

Code

function elf_filter($op, $delta = 0, $format = -1, $text = '') {
  switch ($op) {
    case 'list':
      return array(
        0 => t('External links filter'),
      );
    case 'description':
      return t('Adds a CSS class to all external and mailto links.');
    case 'process':

      // find all <a> tags and match their href so we can test if the link is external or not
      $text = preg_replace_callback('!<a.*?href="([^"]+)".*?>!', elf_replace, $text);
      return $text;
    default:
      return $text;
  }
}