You are here

function hfs_process_html in Header and Footer Scripts 7.2

Same name and namespace in other branches
  1. 7 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 111
Enables Drupal to add scripts and styles from frontend on all over the site.

Code

function hfs_process_html(&$variables) {
  $header_scripts = variable_get('header_and_footer_scripts_header_settings');
  $body_scripts = variable_get('header_and_footer_scripts_body_settings');
  $footer_scripts = variable_get('header_and_footer_scripts_footer_settings');
  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;
    }
  }
}