function codefilter_filter in Code Filter 6
Same name and namespace in other branches
- 5 codefilter.module \codefilter_filter()
Implementation of hook_filter()
File
- ./
codefilter.module, line 126
Code
function codefilter_filter($op, $delta = 0, $format = -1, $text = '') {
switch ($op) {
case 'list':
return array(
0 => t('Code filter'),
);
case 'description':
return t('Allows users to post code verbatim using <code> and <?php ?> tags.');
case 'prepare':
/**
* We replace <code> </code>, <?php ?>, [?php ?], to prevent other filters
* from acting on them.
*/
$text = preg_replace_callback('@<code>(.+?)</code>@s', '_codefilter_escape_code_tag', $text);
$text = preg_replace_callback('@[\\[<](\\?php)(.+?)(\\?)[\\]>]@s', '_codefilter_escape_php_tag', $text);
return $text;
case 'process':
$text = preg_replace_callback('@\\[codefilter_code\\](.+?)\\[/codefilter_code\\]@s', 'codefilter_process_code', $text);
$text = preg_replace_callback('@\\[codefilter_php\\](.+?)\\[/codefilter_php\\]@s', 'codefilter_process_php', $text);
return $text;
default:
return $text;
}
}