function _cookiebot_visible in Cookiebot - Cookie consent, Cookie monitoring and Cookie control 7
Helper function which returns true if cookiebot applies to the current page / session or false if true. Checks for visibulity settings, permissions and other relevant criteria.
Return value
void
2 calls to _cookiebot_visible()
- cookiebot_page_alter in ./
cookiebot.module - Implements hook_page_alter().
- cookiebot_preprocess_html in ./
cookiebot.module
File
- ./
cookiebot.module, line 148 - The Cookiebot main module file.
Code
function _cookiebot_visible() {
global $user;
$cbid = variable_get('cookiebot_cbid', '');
if (empty($cbid)) {
return FALSE;
}
// Check hide if user can use site without giving Cookiebot cookie consent.
if ($user->uid != 1 && user_access('skip cookiebot consent')) {
return FALSE;
}
// Check hide cookie for the superuser.
if ($user->uid == 1 && variable_get('cookiebot_exclude_uid_1', FALSE)) {
return FALSE;
}
// Check exclude paths.
$cookiebot_exclude_paths = variable_get('cookiebot_exclude_paths', '');
if (!empty($cookiebot_exclude_paths)) {
$path = drupal_strtolower(drupal_get_path_alias($_GET['q']));
// Compare the lowercase internal and lowercase path alias (if any).
$page_match = drupal_match_path($path, $cookiebot_exclude_paths);
if ($path != $_GET['q']) {
$page_match = $page_match || drupal_match_path($_GET['q'], $cookiebot_exclude_paths);
}
if ($page_match) {
return FALSE;
}
}
// Check hide cookie compliance on admin theme.
if (variable_get('cookiebot_exclude_admin_theme', FALSE) && path_is_admin(current_path())) {
return FALSE;
}
return TRUE;
}