You are here

function sharethis_service_links_callback in ShareThis 6.2

Callback function from Service Links.

1 string reference to 'sharethis_service_links_callback'
sharethis_service_links in ./sharethis.module
Implementation of hook_service_links().

File

./sharethis.module, line 75

Code

function sharethis_service_links_callback($service, $context) {
  static $added = FALSE;
  if ($added == FALSE) {
    $added = TRUE;
    $code = variable_get('sharethis_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_set_html_head('<script type="text/javascript" src="' . $code . '&amp;button=false"></script>');
  }
  $settings = array(
    $service['attributes']['id'] => array(
      'title' => $context['title'],
      'url' => $context['url'],
      'chicklet' => isset($service['attributes']['class']) ? $service['attributes']['class'] : FALSE,
    ),
  );
  drupal_add_js(array(
    'sharethis' => $settings,
  ), 'setting');
}