function replace_google_analytics_counter_tags in Google Analytics Counter 7.2
Same name and namespace in other branches
- 6.2 google_analytics_counter.module \replace_google_analytics_counter_tags()
- 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()
Finds [gac|...] tags and replaces them by actual values.
1 call to replace_google_analytics_counter_tags()
- google_analytics_counter_filter_google_analytics_counter_process in ./
google_analytics_counter.module - Implements hook_filter_FILTER_process().
File
- ./
google_analytics_counter.module, line 189 - Basic functions for this module.
Code
function replace_google_analytics_counter_tags($str) {
// [gac|path/to/page]
$matchlink = '';
$orig_match = '';
$matches = '';
preg_match_all("/(\\[)gac[^\\]]*(\\])/s", $str, $matches);
// This allows more than one pipe sign (|) ... does not hurt and leaves room for possible extension.
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]));
/* 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;
}