You are here

function noscript_tag_page_top in Noscript Tag 8

Implements hook_page_top().

File

./noscript_tag.module, line 55
Adds functionality to display noscript tag when javascript is disabled.

Code

function noscript_tag_page_top(array &$page_top) {

  // If the user has view permission, Append the noscript HTML to page Top.
  if (\Drupal::currentUser()
    ->hasPermission('view noscript tag')) {

    // Get config.
    $noscript_tag_config = \Drupal::config('noscript_tag.settings');

    // Get value from config.
    $noscript_tag_value = $noscript_tag_config
      ->get('noscript_tag_value');

    // Get format from config.
    $noscript_tag_format = $noscript_tag_config
      ->get('noscript_tag_format');

    // Format Markup.
    $markup = check_markup($noscript_tag_value, $noscript_tag_format);

    // Add html to page top.
    $page_top = [
      'noscript_tag' => [
        '#type' => 'html_tag',
        '#tag' => 'p',
        '#noscript' => TRUE,
        '#value' => $markup,
      ],
    ];
  }
}