You are here

function addthis_page_build in AddThis 7.4

Implements hook_page_build().

File

./addthis.module, line 151

Code

function addthis_page_build(&$page) {

  // Include the addthis.js as a library on every page. Widget js will be loaded
  // according to the settings.
  $addthis_js_path = drupal_get_path('module', 'addthis') . '/addthis.js';
  $page['content']['#attached']['js'][$addthis_js_path] = array(
    'type' => 'file',
    'scope' => 'footer',
  );

  // Include the widget js when we include on all but admin pages.
  if (!path_is_admin(current_path()) && AddThis::getInstance()
    ->getWidgetJsInclude() == AddThis::WIDGET_JS_INCLUDE_PAGE) {
    $manager = AddThisScriptManager::getInstance();
    $manager
      ->attachJsToElement($page['content']);
  }
}