You are here

function sharethis_add_js in ShareThis 5

Same name and namespace in other branches
  1. 6 sharethis.module \sharethis_add_js()

Adds the ShareThis JavaScript header code.

Return value

Whether or not the code was added.

3 calls to sharethis_add_js()
sharethis_get_js in ./sharethis.module
Creates the complete script tag to create SHARETHIS elements.
sharethis_link in ./sharethis.module
Implementation of hook_link().
sharethis_nodeapi in ./sharethis.module
Implementation of hook_nodeapi().

File

./sharethis.module, line 186
Provides the ShareThis service.

Code

function sharethis_add_js() {
  static $added = FALSE;
  if ($added == FALSE) {
    $added = TRUE;
    $code = variable_get('sharethis_sharethis_this_code', '');
    if (empty($code)) {
      $code = 'http://w.sharethis.com/button/sharethis.js#publisher=00000000-0000-0000-0000-000000000000&type=website';
    }
    else {
      $code = str_replace(array(
        '<script type="text/javascript" src="',
        '"></script>',
      ), array(
        '',
        '',
      ), $code);
    }
    drupal_add_js(drupal_get_path('module', 'sharethis') . '/sharethis.js');
    drupal_set_html_head('<script type="text/javascript" src="' . $code . '&amp;button=false"></script>');
  }
  return $added;
}