function _adsense_process_tags in Google AdSense integration 5
Same name and namespace in other branches
- 5.3 adsense.module \_adsense_process_tags()
- 5.2 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 1327
Code
function _adsense_process_tags($text) {
$patterns = array(
'flexi' => '/\\[adsense:flexiblock:(\\d+)\\]/x',
'block' => '/\\[adsense:block:(\\d+)\\]/x',
'tags' => '/\\[adsense:(\\w+):(\\d+):(\\d+)\\]/x',
);
foreach ($patterns as $mode => $pattern) {
if (preg_match_all($pattern, $text, $matches, PREG_SET_ORDER)) {
foreach ($matches as $match) {
switch ($mode) {
case 'flexi':
$ad = _adsense_tag_flexiblock($match[1]);
break;
case 'block':
$ad = _adsense_tag_block($match[1]);
break;
case 'tags':
// Tag is in [adsense:468x60:1:1] format
$ad = adsense_display($match[1], $match[2], $match[3]);
}
// Replace the first occurance of the tag, in case we have the same
// tag more than once.
$str = '/\\' . $match[0] . '/';
$text = preg_replace($str, $ad, $text, 1);
}
}
}
return $text;
}