function yandex_metrics_show_counter in Yandex.Metrics 7.2
Same name and namespace in other branches
- 8.3 yandex_metrics.module \yandex_metrics_show_counter()
- 8.2 yandex_metrics.module \yandex_metrics_show_counter()
- 6.2 yandex_metrics.module \yandex_metrics_show_counter()
- 6 yandex_metrics.module \yandex_metrics_show_counter()
- 7.3 yandex_metrics.module \yandex_metrics_show_counter()
- 7 yandex_metrics.module \yandex_metrics_show_counter()
Returns FALSE if we need to disable counter on page.
Return value
bool
1 call to yandex_metrics_show_counter()
- yandex_metrics_page_build in ./
yandex_metrics.module - Implements hook_page_build(). Adds Yandex.Metrica counter code to the site footer.
File
- ./
yandex_metrics.module, line 176 - The main code of Yandex.Metrics Counter module.
Code
function yandex_metrics_show_counter() {
$pages = variable_get('yandex_metrics_pages', YANDEX_METRICS_PAGES);
$visibility = variable_get('yandex_metrics_visibility', 0);
$urls_equal = FALSE;
if (!empty($pages)) {
$pages_in_lowcase = drupal_strtolower($pages);
$current_path = drupal_strtolower(drupal_get_path_alias($_GET['q']));
// Compare internal and path alias.
$path_match = drupal_match_path($current_path, $pages_in_lowcase);
if ($path_match) {
$urls_equal = TRUE;
}
else {
// If path alias doesn't equal with $_GET['q'] then compare internal and $_GET['q'].
$path_match = drupal_match_path($_GET['q'], $pages_in_lowcase);
if ($current_path != $_GET['q'] && $path_match) {
$urls_equal = TRUE;
}
}
}
if (!$visibility && $urls_equal) {
return FALSE;
}
elseif (!$visibility && !$urls_equal) {
return TRUE;
}
elseif ($visibility && $urls_equal) {
return TRUE;
}
elseif ($visibility && !$urls_equal) {
return FALSE;
}
}