function likebtn_filter_process in Like Button 7
Same name and namespace in other branches
- 8.2 likebtn.module \likebtn_filter_process()
Process callback for callback_filter_process.
1 string reference to 'likebtn_filter_process'
- likebtn_filter_info in ./
likebtn.module - Implements hook_filter_info().
File
- ./
likebtn.module, line 1697 - Implements the LikeBtn module.
Code
function likebtn_filter_process($text, $filter, $format, $langcode, $cache, $cache_id) {
$replacements = array();
$regex = '/(?<!\\<code\\>)\\[' . LIKEBTN_SHORTCODE . '([^}\\n]*?)\\](?!\\<\\/code\\>)/is';
preg_match_all($regex, $text, $matches);
// Found shortcodes.
if (!empty($matches[1])) {
// Parse options.
foreach ($matches[1] as $index => $params_str) {
$regex_list[$index] = $regex;
$replacements[$index] = '';
$regex_params = '/(\\w+)\\s*=\\s*\\"(.*?)\\"/si';
preg_match_all($regex_params, $params_str, $matches_params);
if (!count($matches_params)) {
continue;
}
$settings = array();
foreach ($matches_params[1] as $matches_params_index => $option) {
$settings[$option] = _likebtn_prepare_option($option, $matches_params[2][$matches_params_index]);
}
// Get button markup.
$markup = _likebtn_get_markup('', '', $settings, FALSE, FALSE);
$replacements[$index] = $markup;
}
$text = preg_replace($regex_list, $replacements, $text, 1);
}
return $text;
}