You are here

function add_to_head_page_bottom in Add To Head 8

Implements hook_page_bottom().

File

./add_to_head.module, line 82
Add To Head allows arbitrary insertion of code into the head of the page based on path selection.

Code

function add_to_head_page_bottom(array &$page_bottom) {

  // Inject code into the 'scripts' scope.
  $settings = add_to_head_get_settings('scripts');

  // If applicable, append each profile's code to the output.
  foreach ($settings as $profile) {
    if (_add_to_head_profile_visible($profile)) {

      // Add to output
      $page_bottom['add_to_head'][] = [
        [
          '#type' => 'markup',
          '#markup' => Markup::create($profile['code']),
          '#suffix' => "\n",
          '#cache' => [
            'keys' => [
              'add_to_head',
            ],
            'contexts' => [
              'user.permissions',
            ],
          ],
        ],
        'add-to-head--' . $profile['name'],
      ];
    }
  }
}