You are here

function addtoany_footer in AddToAny Share Buttons 6.3

Same name and namespace in other branches
  1. 5.2 addtoany.module \addtoany_footer()
  2. 6.2 addtoany.module \addtoany_footer()

Implementation of hook_footer(). Add inline JavaScript before the closing body tag.

Return value

None. hook_footer is used for drupal_add_js, because hook_init is too early in the load process.

File

./addtoany.module, line 172
Standalone module file to handle AddToAny button integration

Code

function addtoany_footer() {
  global $_addtoany_init, $_addtoany_targets;

  // Only output script when AddToAny is used
  if (!$_addtoany_init) {
    return;
  }
  $javascript_footer = "da2a.targets=[" . implode(",", $_addtoany_targets) . "];\n" . "da2a.html_done=true;" . "if(da2a.script_ready&&!da2a.done)da2a.init();" . "da2a.script_load();";

  // Load external script if not already called with the first AddToAny button.  Fixes issues where first button code is processed internally but without actual code output
  drupal_add_js($javascript_footer, 'inline', 'footer');
}