You are here

function hfs_process_html in Header and Footer Scripts 7

Same name and namespace in other branches
  1. 7.2 hfs.module \hfs_process_html()

Implements hook_process_html().

Add scripts on overall the site which are defined on the settings page.

File

./hfs.module, line 79
Enables Drupal to add scripts and styles from the frontend on all over the site.

Code

function hfs_process_html(&$variables) {
  $header_scripts = variable_get('hfs_header_scripts');
  $body_scripts = variable_get('hfs_body_scripts');
  $footer_scripts = variable_get('hfs_footer_scripts');
  if (isset($body_scripts) && !empty($body_scripts)) {
    if (!empty($body_scripts['styles'])) {
      $variables['page_top'] .= $body_scripts['styles'] . PHP_EOL;
    }
    if (!empty($body_scripts['scripts'])) {
      $variables['page_top'] .= $body_scripts['scripts'] . PHP_EOL;
    }
  }
  if (isset($header_scripts) && !empty($header_scripts)) {
    if (!empty($header_scripts['styles'])) {
      $variables['styles'] .= $header_scripts['styles'] . PHP_EOL;
    }
    if (!empty($header_scripts['scripts'])) {
      $variables['scripts'] .= $header_scripts['scripts'] . PHP_EOL;
    }
  }
  if (isset($footer_scripts) && !empty($footer_scripts)) {
    if (!empty($footer_scripts['styles'])) {
      $variables['page_bottom'] .= $footer_scripts['styles'] . PHP_EOL;
    }
    if (!empty($footer_scripts['scripts'])) {
      $variables['page_bottom'] .= $footer_scripts['scripts'] . PHP_EOL;
    }
  }
}