function _google_tag_path_check in GoogleTagManager 7
Determines whether to insert the snippet based on the path settings.
Return value
bool TRUE if the path conditions are met; FALSE otherwise.
1 call to _google_tag_path_check()
- google_tag_insert_snippet in ./
google_tag.module - Determines whether to insert the snippet on the response.
File
- ./
google_tag.module, line 335 - Provides primary Drupal hook implementations.
Code
function _google_tag_path_check() {
static $satisfied;
if (!isset($satisfied)) {
$debug = variable_get('google_tag_debug_output', 0);
$toggle = variable_get('google_tag_path_toggle', GOOGLE_TAG_EXCLUDE_LISTED);
$paths = variable_get('google_tag_path_list', GOOGLE_TAG_PATHS);
if (empty($paths)) {
$satisfied = $toggle == GOOGLE_TAG_EXCLUDE_LISTED;
}
else {
// @todo Are not some paths case sensitive???
// Convert the paths to lowercase before comparison.
$paths = drupal_strtolower($paths);
$path = drupal_strtolower(drupal_get_path_alias($_GET['q']));
$satisfied = drupal_match_path($path, $paths);
// @todo Lowercase $_GET['q'] before comparison? What is purpose of this check?
if ($path != $_GET['q']) {
$satisfied = $satisfied || drupal_match_path($_GET['q'], $paths);
}
$satisfied = $toggle == GOOGLE_TAG_EXCLUDE_LISTED ? !$satisfied : $satisfied;
}
$debug ? drupal_set_message(t('path check @satisfied', array(
'@satisfied' => $satisfied,
))) : '';
}
return $satisfied;
}