You are here

function shortcode_filter in Shortcode 7

Same name and namespace in other branches
  1. 6 shortcode.module \shortcode_filter()

Implementation of hook_filter().

File

./shortcode.module, line 52

Code

function shortcode_filter($op, $delta = 0, $format = -1, $text = '') {
  switch ($op) {
    case 'list':
      return array(
        0 => t('Shortcodes'),
        1 => t('Shortcodes - html corrector'),
      );
      break;
    case 'description':
      switch ($delta) {
        case 1:
          return t('Shortcodes html corrector');
          break;
        case 0:
        default:
          return t('Shortcodes like in WP');
          break;
      }
      break;
    case 'settings':
      switch ($delta) {
        case 1:
          return '';
          break;
        case 0:
        default:

          // list all shortcodes, enable/disable, and cache value.
          return _shortcode_settings_form($format);
          break;
      }
      break;
    case 'no cache':

      // Do not cache the output.
      // TODO: build a shortcode list with cache options
      return TRUE;
      break;
    case 'prepare':

      // We're a simple filter and have no preparatory needs.
      return $text;
      break;
    case 'process':
      switch ($delta) {
        case 1:

          // run shortcodes html corrector
          return _shortcode_postprocess_text($text);
          break;

        // runs shortcodes
        case 0:
        default:
          return _shortcode_process($text, $format);
          break;
      }
      break;
    default:
      return $text;
  }
}