function replace_google_analytics_counter_tags in Google Analytics Counter 6.2
Same name and namespace in other branches
- 6 google_analytics_counter.module \replace_google_analytics_counter_tags()
- 7.3 google_analytics_counter.module \replace_google_analytics_counter_tags()
- 7 google_analytics_counter.module \replace_google_analytics_counter_tags()
- 7.2 google_analytics_counter.module \replace_google_analytics_counter_tags()
1 call to replace_google_analytics_counter_tags()
File
- ./
google_analytics_counter.module, line 556
Code
function replace_google_analytics_counter_tags($str) {
// [gac|path/to/page|debugon_or_debugoff]
$matchlink = '';
$orig_match = '';
//preg_match_all("/(\[)gac(\|)[^\]]*(\])/s", $str, $matches);
preg_match_all("/(\\[)gac[^\\]]*(\\])/s", $str, $matches);
foreach ($matches[0] as $match) {
// Keep original value.
$orig_match[] = $match;
// Remove wrapping [].
$match = substr($match, 1, strlen($match) - 2);
// Create an array of parameter attributions.
$match = explode("|", $match);
$path = trim(check_plain(@$match[1]));
$google_analytics_counter_debug_override = strtolower(check_plain(@$match[2]));
if ($google_analytics_counter_debug_override == 'debugon') {
$GLOBALS['google_analytics_counter_debug_override'] = 1;
}
else {
if ($google_analytics_counter_debug_override == 'debugoff') {
$GLOBALS['google_analytics_counter_debug_override'] = 0;
}
}
// So now we can display the count based on the path. If no path was defined, the function will detect the current page's count.
$matchlink[] = google_analytics_counter_display($path);
}
$str = str_replace($orig_match, $matchlink, $str);
return $str;
}