function _adsense_process_tags in Google AdSense integration 5.2
Same name and namespace in other branches
- 5.3 adsense.module \_adsense_process_tags()
- 5 adsense.module \_adsense_process_tags()
- 6 adsense.module \_adsense_process_tags()
- 7 adsense.module \_adsense_process_tags()
1 call to _adsense_process_tags()
- adsense_filter in ./adsense.module
- Implementation of hook_filter().
File
- ./adsense.module, line 1310
Code
function _adsense_process_tags($text) {
$patterns = array(
'flexi' => '/\\[adsense:flexiblock:(\\d+)\\]/x',
'block' => '/\\[adsense:block:(\\d+)\\]/x',
'tags' => '/\\[adsense:([^:]+):(\\d*):(\\d*):?(\\w*)\\]/x',
);
foreach ($patterns as $mode => $pattern) {
if (preg_match_all($pattern, $text, $matches, PREG_SET_ORDER)) {
foreach ($matches as $match) {
if (empty($match[2])) {
$match[2] = 1;
}
if (empty($match[3])) {
$match[3] = 1;
}
switch ($mode) {
case 'flexi':
$ad = _adsense_tag_flexiblock($match[1]);
break;
case 'block':
$ad = _adsense_tag_block($match[1]);
break;
case 'tags':
$ad = adsense_display($match[1], $match[2], $match[3], $match[4]);
break;
}
$str = '/\\' . $match[0] . '/';
$text = preg_replace($str, $ad, $text, 1);
}
}
}
return $text;
}