Prepare callback for hook_filter_info().
Note: This is not really a hook. The function name is manually specified via 'prepare callback' in hook_filter_info(), with this recommended callback name pattern. It is called from check_markup().
See hook_filter_info() for a description of the filtering process. Filters should not use the 'prepare callback' step for anything other than escaping, because that would short-circuit the control the user has over the order in which filters are applied.
$text: The text string to be filtered.
$filter: The filter object containing settings for the given format.
$format: The text format object assigned to the text to be filtered.
$langcode: The language code of the text to be filtered.
$cache: A Boolean indicating whether the filtered text is going to be cached in {cache_filter}.
$cache_id: The ID of the filtered text in {cache_filter}, if $cache is TRUE.
The prepared, escaped text.
function hook_filter_FILTER_prepare($text, $filter, $format, $langcode, $cache, $cache_id) {
// Escape <code> and </code> tags.
$text = preg_replace('|<code>(.+?)</code>|se', "[codefilter_code]\$1[/codefilter_code]", $text);
return $text;
}