function _google_tag_status_check in GoogleTagManager 7
Determines whether to insert the snippet based on status code settings.
Return value
bool TRUE if the status conditions are met; FALSE otherwise.
1 call to _google_tag_status_check()
- google_tag_insert_snippet in ./
google_tag.module - Determines whether to insert the snippet on the response.
File
- ./
google_tag.module, line 306 - Provides primary Drupal hook implementations.
Code
function _google_tag_status_check() {
static $satisfied;
if (!isset($satisfied)) {
$debug = variable_get('google_tag_debug_output', 0);
$toggle = variable_get('google_tag_status_toggle', GOOGLE_TAG_EXCLUDE_LISTED);
$statuses = variable_get('google_tag_status_list', GOOGLE_TAG_STATUSES);
if (empty($statuses)) {
$satisfied = $toggle == GOOGLE_TAG_EXCLUDE_LISTED;
}
else {
// Get the HTTP response status.
$status = drupal_get_http_header('status');
$satisfied = $status && strpos($statuses, $status) !== FALSE;
$satisfied = $toggle == GOOGLE_TAG_EXCLUDE_LISTED ? !$satisfied : $satisfied;
}
$debug ? drupal_set_message(t('google_tag')) : '';
$debug ? drupal_set_message(t('status check @satisfied', array(
'@satisfied' => $satisfied,
))) : '';
}
return $satisfied;
}