function add_to_head_page_attachments_alter in Add To Head 8
Implements hook_page_attachments_alter().
File
- ./
add_to_head.module, line 58 - Add To Head allows arbitrary insertion of code into the head of the page based on path selection.
Code
function add_to_head_page_attachments_alter(array &$attachments) {
// Inject code into the 'head' scope.
$settings = add_to_head_get_settings('head');
// If applicable, append each profile's code to the output.
foreach ($settings as $profile) {
if (_add_to_head_profile_visible($profile)) {
// Add to output
$attachments['#attached']['html_head'][] = [
[
'#type' => 'markup',
'#markup' => \Drupal\Core\Render\Markup::create($profile['code']),
'#suffix' => "\n",
],
'add-to-head--' . $profile['name'],
];
}
}
}