function amp_is_amp_request in Accelerated Mobile Pages (AMP) 7
Determines whether a request should return AMP HTML.
13 calls to amp_is_amp_request()
- amp_adsense_block_view_alter in modules/
amp_adsense/ amp_adsense.module - Implements hook_block_view_alter().
- amp_adsense_preprocess_amp_ad in modules/
amp_adsense/ amp_adsense.module - Implements hook_preprocess_amp_ad().
- amp_analytics_page_alter in modules/
amp_analytics/ amp_analytics.module - Implements hook_page_alter().
- amp_context_context_condition_is_amp_request::execute in modules/
amp_context/ plugins/ amp_context_context_condition_is_amp_request.inc - amp_context_context_load_alter in modules/
amp_context/ amp_context.module - Implements hook_context_load_alter().
File
- ./
amp.module, line 284
Code
function amp_is_amp_request() {
$result =& drupal_static(__FUNCTION__);
if (!isset($result)) {
$result = FALSE;
// The current request must have '?amp' in the query string.
if (isset($_GET['amp'])) {
// Ensure that there is a node loaded from the current request, and that
// it is a node type which has the AMP view mode enabled.
$node = menu_get_object();
if ($node && in_array($node->type, amp_get_enabled_types())) {
// Node level check.
if (amp_node_is_enabled($node->nid)) {
// Do an additional check to ensure the current path is actually the
// node's public URI. Without this check, this function would return
// TRUE on the node's edit form.
$uri = entity_uri('node', $node);
if ($uri['path'] == current_path()) {
// Only if all of the above conditions are true is this a valid AMP
// request.
$result = TRUE;
}
}
}
}
// Allow other modules to create a custom logic
// of amp request identification.
drupal_alter('is_amp_request', $result);
}
return $result;
}