You are here

function _hotjar_should_be_added in Hotjar 7

Same name and namespace in other branches
  1. 6 hotjar.module \_hotjar_should_be_added()

Check Hotjar code should be added.

1 call to _hotjar_should_be_added()
_hotjar_access in ./hotjar.module
Determines whether we add tracking code to page.

File

./hotjar.module, line 150
Drupal Module: Hotjar.

Code

function _hotjar_should_be_added() {
  $page_match =& drupal_static(__FUNCTION__);
  if (isset($page_match)) {
    return $page_match;
  }
  $settings = hotjar_get_settings();
  $visibility = $settings['hotjar_visibility_pages'];
  $setting_pages = $settings['hotjar_pages'];
  if (empty($setting_pages)) {
    $page_match = TRUE;
    return $page_match;
  }
  $pages = drupal_strtolower($setting_pages);
  if ($visibility < 2) {
    $path = drupal_strtolower(drupal_get_path_alias($_GET['q']));
    $page_match = drupal_match_path($path, $pages);
    if ($path != $_GET['q']) {
      $page_match = $page_match || drupal_match_path($_GET['q'], $pages);
    }

    // When $visibility has a value of 0, the tracking code is displayed on
    // all pages except those listed in $pages. When set to 1, it
    // is displayed only on those pages listed in $pages.
    $page_match = !($visibility xor $page_match);
  }
  else {
    $page_match = FALSE;
  }
  return $page_match;
}