function cleantalk_page_attachments_alter in Anti Spam by CleanTalk 8.3
Same name and namespace in other branches
- 8.4 cleantalk.module \cleantalk_page_attachments_alter()
- 9.1.x cleantalk.module \cleantalk_page_attachments_alter()
Implements hook_page_attachments_alter()
File
- ./
cleantalk.module, line 22
Code
function cleantalk_page_attachments_alter(array &$page) {
if (\Drupal::request()->query
->get('search')) {
if (\Drupal::config('cleantalk.settings')
->get('cleantalk_search_noindex')) {
$skip_index_results = [
'#tag' => 'meta',
'#attributes' => [
'name' => 'robots',
'content' => 'noindex',
],
];
$page['#attached']['html_head'][] = [
$skip_index_results,
'skip_index_results',
];
}
}
if (!\Drupal::request()->query
->get('amp') && !\Drupal::service('router.admin_context')
->isAdminRoute()) {
$js_template = "var ct_check_js_val = '%s';";
$js_addon_body = sprintf($js_template, CleantalkFuncs::_cleantalk_get_checkjs_value());
$page['#attached']['html_head'][] = array(
array(
'#tag' => 'script',
'#value' => $js_addon_body,
),
'ga_scripts',
);
$page['#attached']['library'][] = 'cleantalk/apbct-public';
}
}